diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java | 17 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java | 28 |
2 files changed, 33 insertions, 12 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java index a6b089169..43d62c71a 100644 --- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java +++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategoryPageIndicatorView.java @@ -17,14 +17,11 @@ package com.android.inputmethod.keyboard.emoji; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Paint; import android.util.AttributeSet; import android.view.View; -import com.android.inputmethod.latin.R; - public final class EmojiCategoryPageIndicatorView extends View { private static final float BOTTOM_MARGIN_RATIO = 1.0f; private final Paint mPaint = new Paint(); @@ -33,19 +30,17 @@ public final class EmojiCategoryPageIndicatorView extends View { private float mOffset = 0.0f; public EmojiCategoryPageIndicatorView(final Context context, final AttributeSet attrs) { - this(context, attrs, R.attr.emojiCategoryPageIndicatorViewStyle); + this(context, attrs, 0); } 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 setColors(final int foregroundColor, final int backgroundColor) { + mPaint.setColor(foregroundColor); + setBackgroundColor(backgroundColor); } public void setCategoryPageId(final int size, final int id, final float offset) { diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java index 6b9e880b9..7368f3c72 100644 --- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java +++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java @@ -36,6 +36,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TabHost; import android.widget.TabHost.OnTabChangeListener; +import android.widget.TabWidget; import android.widget.TextView; import com.android.inputmethod.keyboard.Key; @@ -68,6 +69,11 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange EmojiPageKeyboardView.OnKeyEventListener { private final int mFunctionalKeyBackgroundId; private final int mSpacebarBackgroundId; + private final boolean mCategoryIndicatorEnabled; + private final int mCategoryIndicatorDrawableResId; + private final int mCategoryIndicatorBackgroundResId; + private final int mCategoryPageIndicatorColor; + private final int mCategoryPageIndicatorBackground; private final DeleteKeyOnTouchListener mDeleteKeyOnTouchListener; private EmojiPalettesAdapter mEmojiPalettesAdapter; private final EmojiLayoutParams mEmojiLayoutParams; @@ -114,6 +120,16 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView); mEmojiCategory = new EmojiCategory(PreferenceManager.getDefaultSharedPreferences(context), res, layoutSet, emojiPalettesViewAttr); + mCategoryIndicatorEnabled = emojiPalettesViewAttr.getBoolean( + R.styleable.EmojiPalettesView_categoryIndicatorEnabled, false); + mCategoryIndicatorDrawableResId = emojiPalettesViewAttr.getResourceId( + R.styleable.EmojiPalettesView_categoryIndicatorDrawable, 0); + mCategoryIndicatorBackgroundResId = emojiPalettesViewAttr.getResourceId( + R.styleable.EmojiPalettesView_categoryIndicatorBackground, 0); + mCategoryPageIndicatorColor = emojiPalettesViewAttr.getColor( + R.styleable.EmojiPalettesView_categoryPageIndicatorColor, 0); + mCategoryPageIndicatorBackground = emojiPalettesViewAttr.getColor( + R.styleable.EmojiPalettesView_categoryPageIndicatorBackground, 0); emojiPalettesViewAttr.recycle(); mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener(context); } @@ -152,7 +168,15 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange addTab(mTabHost, properties.mCategoryId); } mTabHost.setOnTabChangedListener(this); - mTabHost.getTabWidget().setStripEnabled(true); + final TabWidget tabWidget = mTabHost.getTabWidget(); + tabWidget.setStripEnabled(mCategoryIndicatorEnabled); + if (mCategoryIndicatorEnabled) { + // On TabWidget's strip, what looks like an indicator is actually a background. + // And what looks like a background are actually left and right drawables. + tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId); + tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId); + tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId); + } mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this); @@ -165,6 +189,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view); + mEmojiCategoryPageIndicatorView.setColors( + mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground); mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView); setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */); |