Consolidate attributes to EmojiPaletteView to control indicators

This CL consolidates attributes of EmojiTabWidget and
EmojiCategoryPageIndicatorView with EmojiPaletteView.

Bug: 15151483
Change-Id: I6eca10b60e894d945080ef3f88523d539a4992fa
main
Tadashi G. Takaoka 2014-05-23 16:04:39 +09:00
parent c1442aa282
commit 2782f97927
16 changed files with 53 additions and 60 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 B

View File

@ -41,9 +41,7 @@
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:tabStripEnabled="true"
style="?attr/emojiTabWidgetStyle" />
android:divider="@null" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dip"
@ -77,8 +75,7 @@
<com.android.inputmethod.keyboard.emoji.EmojiCategoryPageIndicatorView
android:id="@+id/emoji_category_page_id_view"
android:layout_width="match_parent"
android:layout_height="2dip"
style="?attr/emojiCategoryPageIndicatorViewStyle" />
android:layout_height="2dip" />
<LinearLayout
android:id="@+id/emoji_action_bar"
android:orientation="horizontal"

View File

@ -30,10 +30,6 @@
<attr name="keyPreviewTextViewStyle" format="reference"/>
<!-- EmojiPalettesView style -->
<attr name="emojiPalettesViewStyle" format="reference" />
<!-- TabWidget of EmojiPlettesView style -->
<attr name="emojiTabWidgetStyle" format="reference" />
<!-- EmojiCategoryPageIndicatorView style -->
<attr name="emojiCategoryPageIndicatorViewStyle" format="reference" />
<!-- MoreKeysKeyboard style -->
<attr name="moreKeysKeyboardStyle" format="reference" />
<!-- MoreKeysKeyboardView style -->
@ -176,6 +172,11 @@
</declare-styleable>
<declare-styleable name="EmojiPalettesView">
<attr name="categoryIndicatorEnabled" format="boolean" />
<attr name="categoryIndicatorDrawable" format="reference" />
<attr name="categoryIndicatorBackground" format="reference" />
<attr name="categoryPageIndicatorColor" format="color" />
<attr name="categoryPageIndicatorBackground" format="color" />
<attr name="iconEmojiRecentsTab" format="reference" />
<attr name="iconEmojiCategory1Tab" format="reference" />
<attr name="iconEmojiCategory2Tab" format="reference" />
@ -185,10 +186,6 @@
<attr name="iconEmojiCategory6Tab" format="reference" />
</declare-styleable>
<declare-styleable name="EmojiCategoryPageIndicatorView">
<attr name="emojiCategoryPageIndicatorColor" format="color" />
</declare-styleable>
<declare-styleable name="SuggestionStripView">
<attr name="suggestionStripOptions" format="integer">
<!-- This should be aligned with SuggestionStripLayoutHelper.AUTO_CORRECT_* and etc. -->

View File

@ -110,8 +110,6 @@
<!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
for instance delete button, need themed {@link KeyboardView} attributes. -->
<style name="EmojiPalettesView" />
<style name="EmojiTabWidget" />
<style name="EmojiCategoryPageIndicatorView" />
<style name="MoreKeysKeyboard" />
<style
name="MoreKeysKeyboardView"

View File

@ -25,8 +25,6 @@
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.ICS</item>
<item name="keyPreviewTextViewStyle">@style/KeyPreviewTextView.ICS</item>
<item name="emojiPalettesViewStyle">@style/EmojiPalettesView.ICS</item>
<item name="emojiTabWidgetStyle">@style/EmojiTabWidget.ICS</item>
<item name="emojiCategoryPageIndicatorViewStyle">@style/EmojiCategoryPageIndicatorView.ICS</item>
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.ICS</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.ICS</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripView.ICS</item>
@ -89,6 +87,11 @@
name="EmojiPalettesView.ICS"
parent="MainKeyboardView.ICS"
>
<item name="categoryIndicatorEnabled">true</item>
<item name="categoryIndicatorDrawable">@drawable/emoji_category_tab_selected_ics</item>
<item name="categoryIndicatorBackground">@drawable/emoji_category_tab_unselected_holo_dark</item>
<item name="categoryPageIndicatorColor">@color/highlight_color_ics</item>
<item name="categoryPageIndicatorBackground">@color/emoji_tab_page_indicator_background_holo</item>
<item name="iconEmojiRecentsTab">@drawable/ic_emoji_recents_holo_dark</item>
<item name="iconEmojiCategory1Tab">@drawable/ic_emoji_people_holo_dark</item>
<item name="iconEmojiCategory2Tab">@drawable/ic_emoji_objects_holo_dark</item>
@ -97,15 +100,6 @@
<item name="iconEmojiCategory5Tab">@drawable/ic_emoji_symbols_holo_dark</item>
<item name="iconEmojiCategory6Tab">@drawable/ic_emoji_emoticons_holo_dark</item>
</style>
<style name="EmojiCategoryPageIndicatorView.ICS">
<item name="android:background">@color/emoji_tab_page_indicator_background_holo</item>
<item name="emojiCategoryPageIndicatorColor">@color/highlight_color_ics</item>
</style>
<style name="EmojiTabWidget.ICS">
<item name="android:background">@drawable/emoji_category_tab_selected_ics</item>
<item name="android:tabStripLeft">@drawable/emoji_category_tab_unselected_holo_dark</item>
<item name="android:tabStripRight">@drawable/emoji_category_tab_unselected_holo_dark</item>
</style>
<style
name="MoreKeysKeyboard.ICS"
parent="Keyboard.ICS"

View File

@ -25,8 +25,6 @@
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.KLP</item>
<item name="keyPreviewTextViewStyle">@style/KeyPreviewTextView.KLP</item>
<item name="emojiPalettesViewStyle">@style/EmojiPalettesView.KLP</item>
<item name="emojiTabWidgetStyle">@style/EmojiTabWidget.KLP</item>
<item name="emojiCategoryPageIndicatorViewStyle">@style/EmojiCategoryPageIndicatorView.KLP</item>
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.KLP</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.KLP</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripView.KLP</item>
@ -89,6 +87,11 @@
name="EmojiPalettesView.KLP"
parent="MainKeyboardView.KLP"
>
<item name="categoryIndicatorEnabled">true</item>
<item name="categoryIndicatorDrawable">@drawable/emoji_category_tab_selected_klp</item>
<item name="categoryIndicatorBackground">@drawable/emoji_category_tab_unselected_holo_dark</item>
<item name="categoryPageIndicatorColor">@color/highlight_color_klp</item>
<item name="categoryPageIndicatorBackground">@color/emoji_tab_page_indicator_background_holo</item>
<item name="iconEmojiRecentsTab">@drawable/ic_emoji_recents_holo_dark</item>
<item name="iconEmojiCategory1Tab">@drawable/ic_emoji_people_holo_dark</item>
<item name="iconEmojiCategory2Tab">@drawable/ic_emoji_objects_holo_dark</item>
@ -97,15 +100,6 @@
<item name="iconEmojiCategory5Tab">@drawable/ic_emoji_symbols_holo_dark</item>
<item name="iconEmojiCategory6Tab">@drawable/ic_emoji_emoticons_holo_dark</item>
</style>
<style name="EmojiCategoryPageIndicatorView.KLP">
<item name="android:background">@color/emoji_tab_page_indicator_background_holo</item>
<item name="emojiCategoryPageIndicatorColor">@color/highlight_color_klp</item>
</style>
<style name="EmojiTabWidget.KLP">
<item name="android:background">@drawable/emoji_category_tab_selected_klp</item>
<item name="android:tabStripLeft">@drawable/emoji_category_tab_unselected_holo_dark</item>
<item name="android:tabStripRight">@drawable/emoji_category_tab_unselected_holo_dark</item>
</style>
<style
name="MoreKeysKeyboard.KLP"
parent="Keyboard.KLP"

View File

@ -25,8 +25,6 @@
<item name="mainKeyboardViewStyle">@style/MainKeyboardView.LXX_Dark</item>
<item name="keyPreviewTextViewStyle">@style/KeyPreviewTextView.LXX_Dark</item>
<item name="emojiPalettesViewStyle">@style/EmojiPalettesView.LXX_Dark</item>
<item name="emojiTabWidgetStyle">@style/EmojiTabWidget.LXX_Dark</item>
<item name="emojiCategoryPageIndicatorViewStyle">@style/EmojiCategoryPageIndicatorView.LXX_Dark</item>
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.LXX_Dark</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.LXX_Dark</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripView.LXX_Dark</item>
@ -90,6 +88,9 @@
name="EmojiPalettesView.LXX_Dark"
parent="MainKeyboardView.LXX_Dark"
>
<item name="categoryIndicatorEnabled">false</item>
<item name="categoryPageIndicatorColor">@color/highlight_color_lxx_dark</item>
<item name="categoryPageIndicatorBackground">@color/emoji_tab_page_indicator_background_lxx_dark</item>
<!-- TODO: Update those icons to LXX_Dark theme. -->
<item name="iconEmojiRecentsTab">@drawable/ic_emoji_recents_holo_dark</item>
<item name="iconEmojiCategory1Tab">@drawable/ic_emoji_people_holo_dark</item>
@ -99,15 +100,6 @@
<item name="iconEmojiCategory5Tab">@drawable/ic_emoji_symbols_holo_dark</item>
<item name="iconEmojiCategory6Tab">@drawable/ic_emoji_emoticons_holo_dark</item>
</style>
<style name="EmojiCategoryPageIndicatorView.LXX_Dark">
<item name="android:background">@color/emoji_tab_page_indicator_background_lxx_dark</item>
<item name="emojiCategoryPageIndicatorColor">@color/highlight_color_lxx_dark</item>
</style>
<style name="EmojiTabWidget.LXX_Dark">
<item name="android:background">@drawable/emoji_category_tab_selected_lxx_dark</item>
<item name="android:tabStripLeft">@drawable/emoji_category_tab_unselected_lxx_dark</item>
<item name="android:tabStripRight">@drawable/emoji_category_tab_unselected_lxx_dark</item>
</style>
<style
name="MoreKeysKeyboard.LXX_Dark"
parent="Keyboard.LXX_Dark"

View File

@ -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) {

View File

@ -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 */);