aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android')
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java33
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java41
2 files changed, 27 insertions, 47 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java
index 495fa554b..859099110 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard.emoji;
import android.content.SharedPreferences;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
@@ -69,17 +70,14 @@ final class EmojiCategory {
"symbols",
"emoticons" };
- private static final int[] sCategoryIcon = {
- R.drawable.ic_emoji_recent_holo_dark,
- R.drawable.ic_emoji_people_holo_dark,
- R.drawable.ic_emoji_objects_holo_dark,
- R.drawable.ic_emoji_nature_holo_dark,
- R.drawable.ic_emoji_places_holo_dark,
- R.drawable.ic_emoji_symbols_holo_dark,
- 0 };
-
- private static final String[] sCategoryLabel =
- { null, null, null, null, null, null, ":-)" };
+ private static final int[] sCategoryTabIconAttr = {
+ R.styleable.EmojiPalettesView_iconEmojiRecentsTab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory1Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory2Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory3Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory4Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory5Tab,
+ R.styleable.EmojiPalettesView_iconEmojiCategory6Tab };
private static final int[] sAccessibilityDescriptionResourceIdsForCategories = {
R.string.spoken_descrption_emoji_category_recents,
@@ -104,6 +102,7 @@ final class EmojiCategory {
private final int mMaxPageKeyCount;
private final KeyboardLayoutSet mLayoutSet;
private final HashMap<String, Integer> mCategoryNameToIdMap = CollectionUtils.newHashMap();
+ private final int[] mCategoryTabIconId = new int[sCategoryName.length];
private final ArrayList<CategoryProperties> mShownCategories =
CollectionUtils.newArrayList();
private final ConcurrentHashMap<Long, DynamicGridKeyboard>
@@ -113,13 +112,15 @@ final class EmojiCategory {
private int mCurrentCategoryPageId = 0;
public EmojiCategory(final SharedPreferences prefs, final Resources res,
- final KeyboardLayoutSet layoutSet) {
+ final KeyboardLayoutSet layoutSet, final TypedArray emojiPaletteViewAttr) {
mPrefs = prefs;
mRes = res;
mMaxPageKeyCount = res.getInteger(R.integer.config_emoji_keyboard_max_page_key_count);
mLayoutSet = layoutSet;
for (int i = 0; i < sCategoryName.length; ++i) {
mCategoryNameToIdMap.put(sCategoryName[i], i);
+ mCategoryTabIconId[i] = emojiPaletteViewAttr.getResourceId(
+ sCategoryTabIconAttr[i], 0);
}
addShownCategoryId(EmojiCategory.ID_RECENTS);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2
@@ -158,12 +159,8 @@ final class EmojiCategory {
return mCategoryNameToIdMap.get(strings[0]);
}
- public int getCategoryIcon(final int categoryId) {
- return sCategoryIcon[categoryId];
- }
-
- public String getCategoryLabel(final int categoryId) {
- return sCategoryLabel[categoryId];
+ public int getCategoryTabIcon(final int categoryId) {
+ return mCategoryTabIconId[categoryId];
}
public String getAccessibilityDescription(final int categoryId) {
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
index 8e4595703..6b9e880b9 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
@@ -19,11 +19,9 @@ package com.android.inputmethod.keyboard.emoji;
import static com.android.inputmethod.latin.Constants.NOT_A_COORDINATE;
import android.content.Context;
-import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
-import android.graphics.Typeface;
import android.os.CountDownTimer;
import android.preference.PreferenceManager;
import android.support.v4.view.ViewPager;
@@ -56,7 +54,7 @@ import java.util.concurrent.TimeUnit;
/**
* View class to implement Emoji palettes.
- * The Emoji keyboard consists of group of views {@link R.layout#emoji_palettes_view}.
+ * The Emoji keyboard consists of group of views layout/emoji_palettes_view.
* <ol>
* <li> Emoji category tabs.
* <li> Delete button.
@@ -70,7 +68,6 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
EmojiPageKeyboardView.OnKeyEventListener {
private final int mFunctionalKeyBackgroundId;
private final int mSpacebarBackgroundId;
- private final ColorStateList mTabLabelColor;
private final DeleteKeyOnTouchListener mDeleteKeyOnTouchListener;
private EmojiPalettesAdapter mEmojiPalettesAdapter;
private final EmojiLayoutParams mEmojiLayoutParams;
@@ -103,11 +100,6 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
mSpacebarBackgroundId = keyboardViewAttr.getResourceId(
R.styleable.KeyboardView_spacebarBackground, keyBackgroundId);
keyboardViewAttr.recycle();
- final TypedArray emojiPalettesViewAttr = context.obtainStyledAttributes(attrs,
- R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView);
- mTabLabelColor = emojiPalettesViewAttr.getColorStateList(
- R.styleable.EmojiPalettesView_emojiTabLabelColor);
- emojiPalettesViewAttr.recycle();
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
context, null /* editorInfo */);
final Resources res = context.getResources();
@@ -117,8 +109,12 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
mEmojiLayoutParams.mEmojiKeyboardHeight);
builder.setOptions(false /* shortcutImeEnabled */, false /* showsVoiceInputKey */,
false /* languageSwitchKeyEnabled */);
+ final KeyboardLayoutSet layoutSet = builder.build();
+ final TypedArray emojiPalettesViewAttr = context.obtainStyledAttributes(attrs,
+ R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView);
mEmojiCategory = new EmojiCategory(PreferenceManager.getDefaultSharedPreferences(context),
- context.getResources(), builder.build());
+ res, layoutSet, emojiPalettesViewAttr);
+ emojiPalettesViewAttr.recycle();
mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener(context);
}
@@ -139,24 +135,11 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
final String tabId = mEmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */);
final TabHost.TabSpec tspec = host.newTabSpec(tabId);
tspec.setContent(R.id.emoji_keyboard_dummy);
- if (mEmojiCategory.getCategoryIcon(categoryId) != 0) {
- final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate(
- R.layout.emoji_keyboard_tab_icon, null);
- iconView.setImageResource(mEmojiCategory.getCategoryIcon(categoryId));
- iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
- tspec.setIndicator(iconView);
- }
- if (mEmojiCategory.getCategoryLabel(categoryId) != null) {
- final TextView textView = (TextView)LayoutInflater.from(getContext()).inflate(
- R.layout.emoji_keyboard_tab_label, null);
- textView.setText(mEmojiCategory.getCategoryLabel(categoryId));
- textView.setTypeface(Typeface.DEFAULT_BOLD);
- textView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
- if (mTabLabelColor != null) {
- textView.setTextColor(mTabLabelColor);
- }
- tspec.setIndicator(textView);
- }
+ final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate(
+ R.layout.emoji_keyboard_tab_icon, null);
+ iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
+ iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
+ tspec.setIndicator(iconView);
host.addTab(tspec);
}
@@ -353,7 +336,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
private static void setupAlphabetKey(final TextView alphabetKey, final String label,
final KeyDrawParams params) {
alphabetKey.setText(label);
- alphabetKey.setTextColor(params.mTextColor);
+ alphabetKey.setTextColor(params.mFunctionalTextColor);
alphabetKey.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize);
alphabetKey.setTypeface(params.mTypeface);
}