aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com')
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java33
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java27
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java13
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java41
-rw-r--r--java/src/com/android/inputmethod/latin/InputAttributes.java5
5 files changed, 53 insertions, 66 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/EmojiCategoryPageIndicatorView.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java
index f5aa1079e..a6b089169 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java
@@ -16,29 +16,36 @@
package com.android.inputmethod.keyboard.emoji;
-import com.android.inputmethod.latin.R;
-
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
-import android.widget.LinearLayout;
+import android.view.View;
+
+import com.android.inputmethod.latin.R;
-public final class EmojiCategoryPageIndicatorView extends LinearLayout {
+public final class EmojiCategoryPageIndicatorView extends View {
private static final float BOTTOM_MARGIN_RATIO = 1.0f;
private final Paint mPaint = new Paint();
private int mCategoryPageSize = 0;
private int mCurrentCategoryPageId = 0;
private float mOffset = 0.0f;
- public EmojiCategoryPageIndicatorView(final Context context) {
- this(context, null /* attrs */);
+ public EmojiCategoryPageIndicatorView(final Context context, final AttributeSet attrs) {
+ this(context, attrs, R.attr.emojiCategoryPageIndicatorViewStyle);
}
- public EmojiCategoryPageIndicatorView(final Context context, final AttributeSet attrs) {
- super(context, attrs);
- mPaint.setColor(context.getResources().getColor(
- R.color.emoji_category_page_id_foreground_holo));
+ public EmojiCategoryPageIndicatorView(final Context context, final AttributeSet attrs,
+ final int defStyle) {
+ super(context, attrs, defStyle);
+ final TypedArray indicatorViewAttr = context.obtainStyledAttributes(attrs,
+ R.styleable.EmojiCategoryPageIndicatorView, defStyle,
+ R.style.EmojiCategoryPageIndicatorView);
+ final int indicatorColor = indicatorViewAttr.getColor(
+ R.styleable.EmojiCategoryPageIndicatorView_emojiCategoryPageIndicatorColor, 0);
+ indicatorViewAttr.recycle();
+ mPaint.setColor(indicatorColor);
}
public void setCategoryPageId(final int size, final int id, final float offset) {
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
index 77c183a99..fbc12829f 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
@@ -16,14 +16,15 @@
package com.android.inputmethod.keyboard.emoji;
-import com.android.inputmethod.latin.R;
-import com.android.inputmethod.latin.utils.ResourceUtils;
-
import android.content.res.Resources;
import android.support.v4.view.ViewPager;
+import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.utils.ResourceUtils;
+
final class EmojiLayoutParams {
private static final int DEFAULT_KEYBOARD_ROWS = 4;
@@ -67,10 +68,10 @@ final class EmojiLayoutParams {
vp.setLayoutParams(lp);
}
- public void setCategoryPageIdViewProperties(final LinearLayout ll) {
- final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
+ public void setCategoryPageIdViewProperties(final View v) {
+ final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) v.getLayoutParams();
lp.height = mEmojiCategoryPageIdViewHeight;
- ll.setLayoutParams(lp);
+ v.setLayoutParams(lp);
}
public int getActionBarHeight() {
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);
}
diff --git a/java/src/com/android/inputmethod/latin/InputAttributes.java b/java/src/com/android/inputmethod/latin/InputAttributes.java
index 726b3d141..df4948322 100644
--- a/java/src/com/android/inputmethod/latin/InputAttributes.java
+++ b/java/src/com/android/inputmethod/latin/InputAttributes.java
@@ -46,6 +46,8 @@ public final class InputAttributes {
final int inputType = null != editorInfo ? editorInfo.inputType : 0;
final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
mInputType = inputType;
+ mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
+ || InputTypeUtils.isVisiblePasswordInputType(inputType);
if (inputClass != InputType.TYPE_CLASS_TEXT) {
// If we are not looking at a TYPE_CLASS_TEXT field, the following strange
// cases may arise, so we do a couple sanity checks for them. If it's a
@@ -61,7 +63,6 @@ public final class InputAttributes {
Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
+ " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
}
- mIsPasswordField = false;
mIsSettingsSuggestionStripOn = false;
mInputTypeNoAutoCorrect = false;
mApplicationSpecifiedCompletionOn = false;
@@ -79,8 +80,6 @@ public final class InputAttributes {
final boolean flagAutoComplete =
0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
- mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
- || InputTypeUtils.isVisiblePasswordInputType(inputType);
// TODO: Have a helper method in InputTypeUtils
// Make sure that passwords are not displayed in {@link SuggestionStripView}.
final boolean noSuggestionStrip = mIsPasswordField