am c144299f: Merge "Remove compiler warnings from emoji related code"
* commit 'c144299f7015c89bdb0fe2d5ae06de9615edac36': Remove compiler warnings from emoji related codemain
commit
bb92d53e67
|
@ -31,17 +31,17 @@ public class EmojiCategoryPageIndicatorView extends LinearLayout {
|
||||||
private int mCurrentCategoryPageId = 0;
|
private int mCurrentCategoryPageId = 0;
|
||||||
private float mOffset = 0.0f;
|
private float mOffset = 0.0f;
|
||||||
|
|
||||||
public EmojiCategoryPageIndicatorView(Context context) {
|
public EmojiCategoryPageIndicatorView(final Context context) {
|
||||||
this(context, null /* attrs */);
|
this(context, null /* attrs */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmojiCategoryPageIndicatorView(Context context, AttributeSet attrs) {
|
public EmojiCategoryPageIndicatorView(final Context context, final AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mPaint.setColor(context.getResources().getColor(
|
mPaint.setColor(context.getResources().getColor(
|
||||||
R.color.emoji_category_page_id_view_foreground));
|
R.color.emoji_category_page_id_view_foreground));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategoryPageId(int size, int id, float offset) {
|
public void setCategoryPageId(final int size, final int id, final float offset) {
|
||||||
mCategoryPageSize = size;
|
mCategoryPageSize = size;
|
||||||
mCurrentCategoryPageId = id;
|
mCurrentCategoryPageId = id;
|
||||||
mOffset = offset;
|
mOffset = offset;
|
||||||
|
@ -49,7 +49,7 @@ public class EmojiCategoryPageIndicatorView extends LinearLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(final Canvas canvas) {
|
||||||
if (mCategoryPageSize <= 1) {
|
if (mCategoryPageSize <= 1) {
|
||||||
// If the category is not set yet or contains only one category,
|
// If the category is not set yet or contains only one category,
|
||||||
// just clear and return.
|
// just clear and return.
|
||||||
|
|
|
@ -44,6 +44,7 @@ import android.widget.TabHost.OnTabChangeListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.internal.DynamicGridKeyboard;
|
import com.android.inputmethod.keyboard.internal.DynamicGridKeyboard;
|
||||||
|
import com.android.inputmethod.keyboard.internal.EmojiLayoutParams;
|
||||||
import com.android.inputmethod.keyboard.internal.EmojiPageKeyboardView;
|
import com.android.inputmethod.keyboard.internal.EmojiPageKeyboardView;
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
@ -72,14 +73,14 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
public final class EmojiPalettesView extends LinearLayout implements OnTabChangeListener,
|
public final class EmojiPalettesView extends LinearLayout implements OnTabChangeListener,
|
||||||
ViewPager.OnPageChangeListener, View.OnClickListener,
|
ViewPager.OnPageChangeListener, View.OnClickListener,
|
||||||
EmojiPageKeyboardView.OnKeyClickListener {
|
EmojiPageKeyboardView.OnKeyClickListener {
|
||||||
private static final String TAG = EmojiPalettesView.class.getSimpleName();
|
static final String TAG = EmojiPalettesView.class.getSimpleName();
|
||||||
private static final boolean DEBUG_PAGER = false;
|
private static final boolean DEBUG_PAGER = false;
|
||||||
private final int mKeyBackgroundId;
|
private final int mKeyBackgroundId;
|
||||||
private final int mEmojiFunctionalKeyBackgroundId;
|
private final int mEmojiFunctionalKeyBackgroundId;
|
||||||
private final KeyboardLayoutSet mLayoutSet;
|
|
||||||
private final ColorStateList mTabLabelColor;
|
private final ColorStateList mTabLabelColor;
|
||||||
private final DeleteKeyOnTouchListener mDeleteKeyOnTouchListener;
|
private final DeleteKeyOnTouchListener mDeleteKeyOnTouchListener;
|
||||||
private EmojiPalettesAdapter mEmojiPalettesAdapter;
|
private EmojiPalettesAdapter mEmojiPalettesAdapter;
|
||||||
|
private final EmojiLayoutParams mEmojiLayoutParams;
|
||||||
|
|
||||||
private TabHost mTabHost;
|
private TabHost mTabHost;
|
||||||
private ViewPager mEmojiPager;
|
private ViewPager mEmojiPager;
|
||||||
|
@ -173,7 +174,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
.loadRecentKeys(mCategoryKeyboardMap.values());
|
.loadRecentKeys(mCategoryKeyboardMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addShownCategoryId(int categoryId) {
|
private void addShownCategoryId(final int categoryId) {
|
||||||
// Load a keyboard of categoryId
|
// Load a keyboard of categoryId
|
||||||
getKeyboard(categoryId, 0 /* cagetoryPageId */);
|
getKeyboard(categoryId, 0 /* cagetoryPageId */);
|
||||||
final CategoryProperties properties =
|
final CategoryProperties properties =
|
||||||
|
@ -181,20 +182,20 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
mShownCategories.add(properties);
|
mShownCategories.add(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCategoryName(int categoryId, int categoryPageId) {
|
public String getCategoryName(final int categoryId, final int categoryPageId) {
|
||||||
return sCategoryName[categoryId] + "-" + categoryPageId;
|
return sCategoryName[categoryId] + "-" + categoryPageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCategoryId(String name) {
|
public int getCategoryId(final String name) {
|
||||||
final String[] strings = name.split("-");
|
final String[] strings = name.split("-");
|
||||||
return mCategoryNameToIdMap.get(strings[0]);
|
return mCategoryNameToIdMap.get(strings[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCategoryIcon(int categoryId) {
|
public int getCategoryIcon(final int categoryId) {
|
||||||
return sCategoryIcon[categoryId];
|
return sCategoryIcon[categoryId];
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCategoryLabel(int categoryId) {
|
public String getCategoryLabel(final int categoryId) {
|
||||||
return sCategoryLabel[categoryId];
|
return sCategoryLabel[categoryId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +211,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
return getCategoryPageSize(mCurrentCategoryId);
|
return getCategoryPageSize(mCurrentCategoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCategoryPageSize(int categoryId) {
|
public int getCategoryPageSize(final int categoryId) {
|
||||||
for (final CategoryProperties prop : mShownCategories) {
|
for (final CategoryProperties prop : mShownCategories) {
|
||||||
if (prop.mCategoryId == categoryId) {
|
if (prop.mCategoryId == categoryId) {
|
||||||
return prop.mPageCount;
|
return prop.mPageCount;
|
||||||
|
@ -221,12 +222,12 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentCategoryId(int categoryId) {
|
public void setCurrentCategoryId(final int categoryId) {
|
||||||
mCurrentCategoryId = categoryId;
|
mCurrentCategoryId = categoryId;
|
||||||
Settings.writeLastShownEmojiCategoryId(mPrefs, categoryId);
|
Settings.writeLastShownEmojiCategoryId(mPrefs, categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentCategoryPageId(int id) {
|
public void setCurrentCategoryPageId(final int id) {
|
||||||
mCurrentCategoryPageId = id;
|
mCurrentCategoryPageId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +244,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
return mCurrentCategoryId == CATEGORY_ID_RECENTS;
|
return mCurrentCategoryId == CATEGORY_ID_RECENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTabIdFromCategoryId(int categoryId) {
|
public int getTabIdFromCategoryId(final int categoryId) {
|
||||||
for (int i = 0; i < mShownCategories.size(); ++i) {
|
for (int i = 0; i < mShownCategories.size(); ++i) {
|
||||||
if (mShownCategories.get(i).mCategoryId == categoryId) {
|
if (mShownCategories.get(i).mCategoryId == categoryId) {
|
||||||
return i;
|
return i;
|
||||||
|
@ -254,7 +255,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the view pager's page position for the categoryId
|
// Returns the view pager's page position for the categoryId
|
||||||
public int getPageIdFromCategoryId(int categoryId) {
|
public int getPageIdFromCategoryId(final int categoryId) {
|
||||||
final int lastSavedCategoryPageId =
|
final int lastSavedCategoryPageId =
|
||||||
Settings.readLastTypedEmojiCategoryPageId(mPrefs, categoryId);
|
Settings.readLastTypedEmojiCategoryPageId(mPrefs, categoryId);
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
@ -273,7 +274,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
return getTabIdFromCategoryId(CATEGORY_ID_RECENTS);
|
return getTabIdFromCategoryId(CATEGORY_ID_RECENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCategoryPageCount(int categoryId) {
|
private int getCategoryPageCount(final int categoryId) {
|
||||||
final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
|
final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
|
||||||
return (keyboard.getKeys().length - 1) / mMaxPageKeyCount + 1;
|
return (keyboard.getKeys().length - 1) / mMaxPageKeyCount + 1;
|
||||||
}
|
}
|
||||||
|
@ -282,9 +283,9 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
// position. The category page id is numbered in each category. And the view page position
|
// position. The category page id is numbered in each category. And the view page position
|
||||||
// is the position of the current shown page in the view pager which contains all pages of
|
// is the position of the current shown page in the view pager which contains all pages of
|
||||||
// all categories.
|
// all categories.
|
||||||
public Pair<Integer, Integer> getCategoryIdAndPageIdFromPagePosition(int position) {
|
public Pair<Integer, Integer> getCategoryIdAndPageIdFromPagePosition(final int position) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (CategoryProperties properties : mShownCategories) {
|
for (final CategoryProperties properties : mShownCategories) {
|
||||||
final int temp = sum;
|
final int temp = sum;
|
||||||
sum += properties.mPageCount;
|
sum += properties.mPageCount;
|
||||||
if (sum > position) {
|
if (sum > position) {
|
||||||
|
@ -295,7 +296,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a keyboard from the view pager's page position.
|
// Returns a keyboard from the view pager's page position.
|
||||||
public DynamicGridKeyboard getKeyboardFromPagePosition(int position) {
|
public DynamicGridKeyboard getKeyboardFromPagePosition(final int position) {
|
||||||
final Pair<Integer, Integer> categoryAndId =
|
final Pair<Integer, Integer> categoryAndId =
|
||||||
getCategoryIdAndPageIdFromPagePosition(position);
|
getCategoryIdAndPageIdFromPagePosition(position);
|
||||||
if (categoryAndId != null) {
|
if (categoryAndId != null) {
|
||||||
|
@ -304,39 +305,41 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DynamicGridKeyboard getKeyboard(int categoryId, int id) {
|
private static final Long getCategoryKeyboardMapKey(final int categoryId, final int id) {
|
||||||
synchronized(mCategoryKeyboardMap) {
|
return (((long) categoryId) << Constants.MAX_INT_BIT_COUNT) | id;
|
||||||
final long key = (((long) categoryId) << Constants.MAX_INT_BIT_COUNT) | id;
|
}
|
||||||
final DynamicGridKeyboard kbd;
|
|
||||||
if (!mCategoryKeyboardMap.containsKey(key)) {
|
public DynamicGridKeyboard getKeyboard(final int categoryId, final int id) {
|
||||||
if (categoryId != CATEGORY_ID_RECENTS) {
|
synchronized (mCategoryKeyboardMap) {
|
||||||
final Keyboard keyboard =
|
final Long categotyKeyboardMapKey = getCategoryKeyboardMapKey(categoryId, id);
|
||||||
mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
|
if (mCategoryKeyboardMap.containsKey(categotyKeyboardMapKey)) {
|
||||||
final Key[][] sortedKeys = sortKeys(keyboard.getKeys(), mMaxPageKeyCount);
|
return mCategoryKeyboardMap.get(categotyKeyboardMapKey);
|
||||||
for (int i = 0; i < sortedKeys.length; ++i) {
|
}
|
||||||
final DynamicGridKeyboard tempKbd = new DynamicGridKeyboard(mPrefs,
|
|
||||||
|
if (categoryId == CATEGORY_ID_RECENTS) {
|
||||||
|
final DynamicGridKeyboard kbd = new DynamicGridKeyboard(mPrefs,
|
||||||
mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
|
mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
|
||||||
mMaxPageKeyCount, categoryId, i /* categoryPageId */);
|
mMaxPageKeyCount, categoryId);
|
||||||
for (Key emojiKey : sortedKeys[i]) {
|
mCategoryKeyboardMap.put(categotyKeyboardMapKey, kbd);
|
||||||
|
return kbd;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Keyboard keyboard = mLayoutSet.getKeyboard(sCategoryElementId[categoryId]);
|
||||||
|
final Key[][] sortedKeys = sortKeysIntoPages(keyboard.getKeys(), mMaxPageKeyCount);
|
||||||
|
for (int pageId = 0; pageId < sortedKeys.length; ++pageId) {
|
||||||
|
final DynamicGridKeyboard tempKeyboard = new DynamicGridKeyboard(mPrefs,
|
||||||
|
mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
|
||||||
|
mMaxPageKeyCount, categoryId);
|
||||||
|
for (final Key emojiKey : sortedKeys[pageId]) {
|
||||||
if (emojiKey == null) {
|
if (emojiKey == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tempKbd.addKeyLast(emojiKey);
|
tempKeyboard.addKeyLast(emojiKey);
|
||||||
}
|
}
|
||||||
mCategoryKeyboardMap.put((((long) categoryId)
|
mCategoryKeyboardMap.put(
|
||||||
<< Constants.MAX_INT_BIT_COUNT) | i, tempKbd);
|
getCategoryKeyboardMapKey(categoryId, pageId), tempKeyboard);
|
||||||
}
|
}
|
||||||
kbd = mCategoryKeyboardMap.get(key);
|
return mCategoryKeyboardMap.get(categotyKeyboardMapKey);
|
||||||
} else {
|
|
||||||
kbd = new DynamicGridKeyboard(mPrefs,
|
|
||||||
mLayoutSet.getKeyboard(KeyboardId.ELEMENT_EMOJI_RECENTS),
|
|
||||||
mMaxPageKeyCount, categoryId, 0 /* categoryPageId */);
|
|
||||||
mCategoryKeyboardMap.put(key, kbd);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
kbd = mCategoryKeyboardMap.get(key);
|
|
||||||
}
|
|
||||||
return kbd;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,11 +351,9 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Key[][] sortKeys(Key[] inKeys, int maxPageCount) {
|
private static Comparator<Key> EMOJI_KEY_COMPARATOR = new Comparator<Key>() {
|
||||||
Key[] keys = Arrays.copyOf(inKeys, inKeys.length);
|
|
||||||
Arrays.sort(keys, 0, keys.length, new Comparator<Key>() {
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Key lhs, Key rhs) {
|
public int compare(final Key lhs, final Key rhs) {
|
||||||
final Rect lHitBox = lhs.getHitBox();
|
final Rect lHitBox = lhs.getHitBox();
|
||||||
final Rect rHitBox = rhs.getHitBox();
|
final Rect rHitBox = rhs.getHitBox();
|
||||||
if (lHitBox.top < rHitBox.top) {
|
if (lHitBox.top < rHitBox.top) {
|
||||||
|
@ -370,7 +371,11 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
}
|
}
|
||||||
return lhs.getCode() < rhs.getCode() ? -1 : 1;
|
return lhs.getCode() < rhs.getCode() ? -1 : 1;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
private static Key[][] sortKeysIntoPages(final Key[] inKeys, final int maxPageCount) {
|
||||||
|
final Key[] keys = Arrays.copyOf(inKeys, inKeys.length);
|
||||||
|
Arrays.sort(keys, 0, keys.length, EMOJI_KEY_COMPARATOR);
|
||||||
final int pageCount = (keys.length - 1) / maxPageCount + 1;
|
final int pageCount = (keys.length - 1) / maxPageCount + 1;
|
||||||
final Key[][] retval = new Key[pageCount][maxPageCount];
|
final Key[][] retval = new Key[pageCount][maxPageCount];
|
||||||
for (int i = 0; i < keys.length; ++i) {
|
for (int i = 0; i < keys.length; ++i) {
|
||||||
|
@ -403,12 +408,11 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
|
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
|
||||||
context, null /* editorInfo */);
|
context, null /* editorInfo */);
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
final EmojiLayoutParams emojiLp = new EmojiLayoutParams(res);
|
mEmojiLayoutParams = new EmojiLayoutParams(res);
|
||||||
builder.setSubtype(SubtypeSwitcher.getInstance().getEmojiSubtype());
|
builder.setSubtype(SubtypeSwitcher.getInstance().getEmojiSubtype());
|
||||||
builder.setKeyboardGeometry(ResourceUtils.getDefaultKeyboardWidth(res),
|
builder.setKeyboardGeometry(ResourceUtils.getDefaultKeyboardWidth(res),
|
||||||
emojiLp.mEmojiKeyboardHeight);
|
mEmojiLayoutParams.mEmojiKeyboardHeight);
|
||||||
builder.setOptions(false, false, false /* lanuageSwitchKeyEnabled */);
|
builder.setOptions(false, false, false /* lanuageSwitchKeyEnabled */);
|
||||||
mLayoutSet = builder.build();
|
|
||||||
mEmojiCategory = new EmojiCategory(PreferenceManager.getDefaultSharedPreferences(context),
|
mEmojiCategory = new EmojiCategory(PreferenceManager.getDefaultSharedPreferences(context),
|
||||||
context.getResources(), builder.build());
|
context.getResources(), builder.build());
|
||||||
mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener(context);
|
mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener(context);
|
||||||
|
@ -457,25 +461,23 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
mTabHost.setOnTabChangedListener(this);
|
mTabHost.setOnTabChangedListener(this);
|
||||||
mTabHost.getTabWidget().setStripEnabled(true);
|
mTabHost.getTabWidget().setStripEnabled(true);
|
||||||
|
|
||||||
mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, mLayoutSet, this);
|
mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this);
|
||||||
|
|
||||||
mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager);
|
mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager);
|
||||||
mEmojiPager.setAdapter(mEmojiPalettesAdapter);
|
mEmojiPager.setAdapter(mEmojiPalettesAdapter);
|
||||||
mEmojiPager.setOnPageChangeListener(this);
|
mEmojiPager.setOnPageChangeListener(this);
|
||||||
mEmojiPager.setOffscreenPageLimit(0);
|
mEmojiPager.setOffscreenPageLimit(0);
|
||||||
mEmojiPager.setPersistentDrawingCache(ViewPager.PERSISTENT_NO_CACHE);
|
mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE);
|
||||||
final Resources res = getResources();
|
mEmojiLayoutParams.setPagerProperties(mEmojiPager);
|
||||||
final EmojiLayoutParams emojiLp = new EmojiLayoutParams(res);
|
|
||||||
emojiLp.setPagerProperties(mEmojiPager);
|
|
||||||
|
|
||||||
mEmojiCategoryPageIndicatorView =
|
mEmojiCategoryPageIndicatorView =
|
||||||
(EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view);
|
(EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view);
|
||||||
emojiLp.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);
|
mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);
|
||||||
|
|
||||||
setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */);
|
setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */);
|
||||||
|
|
||||||
final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar);
|
final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar);
|
||||||
emojiLp.setActionBarProperties(actionBar);
|
mEmojiLayoutParams.setActionBarProperties(actionBar);
|
||||||
|
|
||||||
final ImageView deleteKey = (ImageView)findViewById(R.id.emoji_keyboard_delete);
|
final ImageView deleteKey = (ImageView)findViewById(R.id.emoji_keyboard_delete);
|
||||||
deleteKey.setTag(Constants.CODE_DELETE);
|
deleteKey.setTag(Constants.CODE_DELETE);
|
||||||
|
@ -488,7 +490,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
spaceKey.setBackgroundResource(mKeyBackgroundId);
|
spaceKey.setBackgroundResource(mKeyBackgroundId);
|
||||||
spaceKey.setTag(Constants.CODE_SPACE);
|
spaceKey.setTag(Constants.CODE_SPACE);
|
||||||
spaceKey.setOnClickListener(this);
|
spaceKey.setOnClickListener(this);
|
||||||
emojiLp.setKeyProperties(spaceKey);
|
mEmojiLayoutParams.setKeyProperties(spaceKey);
|
||||||
final ImageView alphabetKey2 = (ImageView)findViewById(R.id.emoji_keyboard_alphabet2);
|
final ImageView alphabetKey2 = (ImageView)findViewById(R.id.emoji_keyboard_alphabet2);
|
||||||
alphabetKey2.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
|
alphabetKey2.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
|
||||||
alphabetKey2.setTag(Constants.CODE_SWITCH_ALPHA_SYMBOL);
|
alphabetKey2.setTag(Constants.CODE_SWITCH_ALPHA_SYMBOL);
|
||||||
|
@ -635,7 +637,6 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
private int mActivePosition = 0;
|
private int mActivePosition = 0;
|
||||||
|
|
||||||
public EmojiPalettesAdapter(final EmojiCategory emojiCategory,
|
public EmojiPalettesAdapter(final EmojiCategory emojiCategory,
|
||||||
final KeyboardLayoutSet layoutSet,
|
|
||||||
final EmojiPageKeyboardView.OnKeyClickListener listener) {
|
final EmojiPageKeyboardView.OnKeyClickListener listener) {
|
||||||
mEmojiCategory = emojiCategory;
|
mEmojiCategory = emojiCategory;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
|
@ -670,7 +671,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPrimaryItem(final View container, final int position, final Object object) {
|
public void setPrimaryItem(final ViewGroup container, final int position,
|
||||||
|
final Object object) {
|
||||||
if (mActivePosition == position) {
|
if (mActivePosition == position) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -789,7 +791,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pressDelete(int repeatCount) {
|
public void pressDelete(final int repeatCount) {
|
||||||
mKeyboardActionListener.onPressKey(
|
mKeyboardActionListener.onPressKey(
|
||||||
Constants.CODE_DELETE, repeatCount, true /* isSinglePointer */);
|
Constants.CODE_DELETE, repeatCount, true /* isSinglePointer */);
|
||||||
mKeyboardActionListener.onCodeInput(
|
mKeyboardActionListener.onCodeInput(
|
||||||
|
@ -798,12 +800,12 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
Constants.CODE_DELETE, false /* withSliding */);
|
Constants.CODE_DELETE, false /* withSliding */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyboardActionListener(KeyboardActionListener listener) {
|
public void setKeyboardActionListener(final KeyboardActionListener listener) {
|
||||||
mKeyboardActionListener = listener;
|
mKeyboardActionListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(final View v, final MotionEvent event) {
|
||||||
switch(event.getAction()) {
|
switch(event.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
v.setBackgroundColor(mDeleteKeyPressedBackgroundColor);
|
v.setBackgroundColor(mDeleteKeyPressedBackgroundColor);
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
private Key[] mCachedGridKeys;
|
private Key[] mCachedGridKeys;
|
||||||
|
|
||||||
public DynamicGridKeyboard(final SharedPreferences prefs, final Keyboard templateKeyboard,
|
public DynamicGridKeyboard(final SharedPreferences prefs, final Keyboard templateKeyboard,
|
||||||
final int maxKeyCount, final int categoryId, final int categoryPageId) {
|
final int maxKeyCount, final int categoryId) {
|
||||||
super(templateKeyboard);
|
super(templateKeyboard);
|
||||||
final Key key0 = getTemplateKey(TEMPLATE_KEY_CODE_0);
|
final Key key0 = getTemplateKey(TEMPLATE_KEY_CODE_0);
|
||||||
final Key key1 = getTemplateKey(TEMPLATE_KEY_CODE_1);
|
final Key key1 = getTemplateKey(TEMPLATE_KEY_CODE_1);
|
||||||
|
@ -124,7 +124,7 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
final int keyY0 = getKeyY0(index);
|
final int keyY0 = getKeyY0(index);
|
||||||
final int keyX1 = getKeyX1(index);
|
final int keyX1 = getKeyX1(index);
|
||||||
final int keyY1 = getKeyY1(index);
|
final int keyY1 = getKeyY1(index);
|
||||||
gridKey.updateCorrdinates(keyX0, keyY0, keyX1, keyY1);
|
gridKey.updateCoordinates(keyX0, keyY0, keyX1, keyY1);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,32 +143,44 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
Settings.writeEmojiRecentKeys(mPrefs, jsonStr);
|
Settings.writeEmojiRecentKeys(mPrefs, jsonStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Key getKey(final Collection<DynamicGridKeyboard> keyboards, final Object o) {
|
private static Key getKeyByCode(final Collection<DynamicGridKeyboard> keyboards,
|
||||||
for (final DynamicGridKeyboard kbd : keyboards) {
|
final int code) {
|
||||||
if (o instanceof Integer) {
|
for (final DynamicGridKeyboard keyboard : keyboards) {
|
||||||
final int code = (Integer) o;
|
final Key key = keyboard.getKey(code);
|
||||||
final Key key = kbd.getKey(code);
|
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
} else if (o instanceof String) {
|
|
||||||
final String outputText = (String) o;
|
|
||||||
final Key key = kbd.getKeyFromOutputText(outputText);
|
|
||||||
if (key != null) {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "Invalid object: " + o);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadRecentKeys(Collection<DynamicGridKeyboard> keyboards) {
|
private static Key getKeyByOutputText(final Collection<DynamicGridKeyboard> keyboards,
|
||||||
|
final String outputText) {
|
||||||
|
for (final DynamicGridKeyboard kbd : keyboards) {
|
||||||
|
final Key key = kbd.getKeyFromOutputText(outputText);
|
||||||
|
if (key != null) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadRecentKeys(final Collection<DynamicGridKeyboard> keyboards) {
|
||||||
final String str = Settings.readEmojiRecentKeys(mPrefs);
|
final String str = Settings.readEmojiRecentKeys(mPrefs);
|
||||||
final List<Object> keys = StringUtils.jsonStrToList(str);
|
final List<Object> keys = StringUtils.jsonStrToList(str);
|
||||||
for (final Object o : keys) {
|
for (final Object o : keys) {
|
||||||
addKeyLast(getKey(keyboards, o));
|
final Key key;
|
||||||
|
if (o instanceof Integer) {
|
||||||
|
final int code = (Integer)o;
|
||||||
|
key = getKeyByCode(keyboards, code);
|
||||||
|
} else if (o instanceof String) {
|
||||||
|
final String outputText = (String)o;
|
||||||
|
key = getKeyByOutputText(keyboards, outputText);
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "Invalid object: " + o);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
addKeyLast(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +229,7 @@ public class DynamicGridKeyboard extends Keyboard {
|
||||||
super(originalKey);
|
super(originalKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCorrdinates(final int x0, final int y0, final int x1, final int y1) {
|
public void updateCoordinates(final int x0, final int y0, final int x1, final int y1) {
|
||||||
mCurrentX = x0;
|
mCurrentX = x0;
|
||||||
mCurrentY = y0;
|
mCurrentY = y0;
|
||||||
getHitBox().set(x0, y0, x1, y1);
|
getHitBox().set(x0, y0, x1, y1);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.utils.ResourceUtils;
|
import com.android.inputmethod.latin.utils.ResourceUtils;
|
||||||
|
@ -37,22 +37,22 @@ public class EmojiLayoutParams {
|
||||||
private final int mBottomPadding;
|
private final int mBottomPadding;
|
||||||
private final int mTopPadding;
|
private final int mTopPadding;
|
||||||
|
|
||||||
public EmojiLayoutParams(Resources res) {
|
public EmojiLayoutParams(final Resources res) {
|
||||||
final int defaultKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
final int defaultKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
||||||
final int defaultKeyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
final int defaultKeyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
||||||
mKeyVerticalGap = (int) res.getFraction(R.fraction.key_bottom_gap_holo,
|
mKeyVerticalGap = (int) res.getFraction(R.fraction.key_bottom_gap_holo,
|
||||||
(int) defaultKeyboardHeight, (int) defaultKeyboardHeight);
|
defaultKeyboardHeight, defaultKeyboardHeight);
|
||||||
mBottomPadding = (int) res.getFraction(R.fraction.keyboard_bottom_padding_holo,
|
mBottomPadding = (int) res.getFraction(R.fraction.keyboard_bottom_padding_holo,
|
||||||
(int) defaultKeyboardHeight, (int) defaultKeyboardHeight);
|
defaultKeyboardHeight, defaultKeyboardHeight);
|
||||||
mTopPadding = (int) res.getFraction(R.fraction.keyboard_top_padding_holo,
|
mTopPadding = (int) res.getFraction(R.fraction.keyboard_top_padding_holo,
|
||||||
(int) defaultKeyboardHeight, (int) defaultKeyboardHeight);
|
defaultKeyboardHeight, defaultKeyboardHeight);
|
||||||
mKeyHorizontalGap = (int) (res.getFraction(R.fraction.key_horizontal_gap_holo,
|
mKeyHorizontalGap = (int) (res.getFraction(R.fraction.key_horizontal_gap_holo,
|
||||||
defaultKeyboardWidth, defaultKeyboardWidth));
|
defaultKeyboardWidth, defaultKeyboardWidth));
|
||||||
mEmojiCategoryPageIdViewHeight =
|
mEmojiCategoryPageIdViewHeight =
|
||||||
(int) (res.getDimension(R.dimen.emoji_category_page_id_height));
|
(int) (res.getDimension(R.dimen.emoji_category_page_id_height));
|
||||||
final int baseheight = defaultKeyboardHeight - mBottomPadding - mTopPadding
|
final int baseheight = defaultKeyboardHeight - mBottomPadding - mTopPadding
|
||||||
+ mKeyVerticalGap;
|
+ mKeyVerticalGap;
|
||||||
mEmojiActionBarHeight = ((int) baseheight) / DEFAULT_KEYBOARD_ROWS
|
mEmojiActionBarHeight = baseheight / DEFAULT_KEYBOARD_ROWS
|
||||||
- (mKeyVerticalGap - mBottomPadding) / 2;
|
- (mKeyVerticalGap - mBottomPadding) / 2;
|
||||||
mEmojiPagerHeight = defaultKeyboardHeight - mEmojiActionBarHeight
|
mEmojiPagerHeight = defaultKeyboardHeight - mEmojiActionBarHeight
|
||||||
- mEmojiCategoryPageIdViewHeight;
|
- mEmojiCategoryPageIdViewHeight;
|
||||||
|
@ -60,26 +60,26 @@ public class EmojiLayoutParams {
|
||||||
mEmojiKeyboardHeight = mEmojiPagerHeight - mEmojiPagerBottomMargin - 1;
|
mEmojiKeyboardHeight = mEmojiPagerHeight - mEmojiPagerBottomMargin - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPagerProperties(ViewPager vp) {
|
public void setPagerProperties(final ViewPager vp) {
|
||||||
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) vp.getLayoutParams();
|
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) vp.getLayoutParams();
|
||||||
lp.height = mEmojiKeyboardHeight;
|
lp.height = mEmojiKeyboardHeight;
|
||||||
lp.bottomMargin = mEmojiPagerBottomMargin;
|
lp.bottomMargin = mEmojiPagerBottomMargin;
|
||||||
vp.setLayoutParams(lp);
|
vp.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategoryPageIdViewProperties(LinearLayout ll) {
|
public void setCategoryPageIdViewProperties(final LinearLayout ll) {
|
||||||
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
|
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
|
||||||
lp.height = mEmojiCategoryPageIdViewHeight;
|
lp.height = mEmojiCategoryPageIdViewHeight;
|
||||||
ll.setLayoutParams(lp);
|
ll.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActionBarProperties(LinearLayout ll) {
|
public void setActionBarProperties(final LinearLayout ll) {
|
||||||
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
|
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
|
||||||
lp.height = mEmojiActionBarHeight - mBottomPadding;
|
lp.height = mEmojiActionBarHeight - mBottomPadding;
|
||||||
ll.setLayoutParams(lp);
|
ll.setLayoutParams(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyProperties(ImageView ib) {
|
public void setKeyProperties(final ImageView ib) {
|
||||||
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ib.getLayoutParams();
|
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ib.getLayoutParams();
|
||||||
lp.leftMargin = mKeyHorizontalGap / 2;
|
lp.leftMargin = mKeyHorizontalGap / 2;
|
||||||
lp.rightMargin = mKeyHorizontalGap / 2;
|
lp.rightMargin = mKeyHorizontalGap / 2;
|
|
@ -16,15 +16,16 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.utils;
|
package com.android.inputmethod.latin.utils;
|
||||||
|
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
|
||||||
import com.android.inputmethod.latin.Constants;
|
|
||||||
import com.android.inputmethod.latin.settings.SettingsValues;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.JsonReader;
|
import android.util.JsonReader;
|
||||||
import android.util.JsonWriter;
|
import android.util.JsonWriter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
@ -383,7 +384,7 @@ public final class StringUtils {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEmptyStringOrWhiteSpaces(String s) {
|
public static boolean isEmptyStringOrWhiteSpaces(final String s) {
|
||||||
final int N = codePointCount(s);
|
final int N = codePointCount(s);
|
||||||
for (int i = 0; i < N; ++i) {
|
for (int i = 0; i < N; ++i) {
|
||||||
if (!Character.isWhitespace(s.codePointAt(i))) {
|
if (!Character.isWhitespace(s.codePointAt(i))) {
|
||||||
|
@ -394,7 +395,7 @@ public final class StringUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
public static String byteArrayToHexString(byte[] bytes) {
|
public static String byteArrayToHexString(final byte[] bytes) {
|
||||||
if (bytes == null || bytes.length == 0) {
|
if (bytes == null || bytes.length == 0) {
|
||||||
return EMPTY_STRING;
|
return EMPTY_STRING;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +410,7 @@ public final class StringUtils {
|
||||||
* Convert hex string to byte array. The string length must be an even number.
|
* Convert hex string to byte array. The string length must be an even number.
|
||||||
*/
|
*/
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
public static byte[] hexStringToByteArray(String hexString) {
|
public static byte[] hexStringToByteArray(final String hexString) {
|
||||||
if (TextUtils.isEmpty(hexString)) {
|
if (TextUtils.isEmpty(hexString)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -426,19 +427,22 @@ public final class StringUtils {
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Object> jsonStrToList(String s) {
|
private static final String INTEGER_CLASS_NAME = Integer.class.getSimpleName();
|
||||||
final ArrayList<Object> retval = CollectionUtils.newArrayList();
|
private static final String STRING_CLASS_NAME = String.class.getSimpleName();
|
||||||
|
|
||||||
|
public static List<Object> jsonStrToList(final String s) {
|
||||||
|
final ArrayList<Object> list = CollectionUtils.newArrayList();
|
||||||
final JsonReader reader = new JsonReader(new StringReader(s));
|
final JsonReader reader = new JsonReader(new StringReader(s));
|
||||||
try {
|
try {
|
||||||
reader.beginArray();
|
reader.beginArray();
|
||||||
while(reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
final String name = reader.nextName();
|
final String name = reader.nextName();
|
||||||
if (name.equals(Integer.class.getSimpleName())) {
|
if (name.equals(INTEGER_CLASS_NAME)) {
|
||||||
retval.add(reader.nextInt());
|
list.add(reader.nextInt());
|
||||||
} else if (name.equals(String.class.getSimpleName())) {
|
} else if (name.equals(STRING_CLASS_NAME)) {
|
||||||
retval.add(reader.nextString());
|
list.add(reader.nextString());
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Invalid name: " + name);
|
Log.w(TAG, "Invalid name: " + name);
|
||||||
reader.skipValue();
|
reader.skipValue();
|
||||||
|
@ -447,18 +451,15 @@ public final class StringUtils {
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
}
|
}
|
||||||
reader.endArray();
|
reader.endArray();
|
||||||
return retval;
|
return list;
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
close(reader);
|
||||||
reader.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Collections.<Object>emptyList();
|
return Collections.<Object>emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String listToJsonStr(List<Object> list) {
|
public static String listToJsonStr(final List<Object> list) {
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
return EMPTY_STRING;
|
return EMPTY_STRING;
|
||||||
}
|
}
|
||||||
|
@ -469,23 +470,28 @@ public final class StringUtils {
|
||||||
for (final Object o : list) {
|
for (final Object o : list) {
|
||||||
writer.beginObject();
|
writer.beginObject();
|
||||||
if (o instanceof Integer) {
|
if (o instanceof Integer) {
|
||||||
writer.name(Integer.class.getSimpleName()).value((Integer)o);
|
writer.name(INTEGER_CLASS_NAME).value((Integer)o);
|
||||||
} else if (o instanceof String) {
|
} else if (o instanceof String) {
|
||||||
writer.name(String.class.getSimpleName()).value((String)o);
|
writer.name(STRING_CLASS_NAME).value((String)o);
|
||||||
}
|
}
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
}
|
}
|
||||||
writer.endArray();
|
writer.endArray();
|
||||||
return sw.toString();
|
return sw.toString();
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
close(writer);
|
||||||
if (writer != null) {
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return EMPTY_STRING;
|
return EMPTY_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void close(final Closeable closeable) {
|
||||||
|
try {
|
||||||
|
if (closeable != null) {
|
||||||
|
closeable.close();
|
||||||
|
}
|
||||||
|
} catch (final IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue