Make LatinKeyboard aware of theme
Bug: 4436327 Change-Id: Idecdd470cbb0720b96958039eb11f6978d39629emain
parent
08a6f2aea7
commit
a61967330e
|
@ -18,6 +18,8 @@
|
||||||
<declare-styleable name="KeyboardTheme">
|
<declare-styleable name="KeyboardTheme">
|
||||||
<!-- Keyboard style -->
|
<!-- Keyboard style -->
|
||||||
<attr name="keyboardStyle" format="reference" />
|
<attr name="keyboardStyle" format="reference" />
|
||||||
|
<!-- LatinKeyboard style -->
|
||||||
|
<attr name="latinKeyboardStyle" format="reference" />
|
||||||
<!-- KeyboardView style -->
|
<!-- KeyboardView style -->
|
||||||
<attr name="keyboardViewStyle" format="reference" />
|
<attr name="keyboardViewStyle" format="reference" />
|
||||||
<attr name="keyPreviewStyle" format="reference" />
|
<attr name="keyPreviewStyle" format="reference" />
|
||||||
|
@ -94,7 +96,6 @@
|
||||||
<flag name="autoCorrectBold" value="0x01" />
|
<flag name="autoCorrectBold" value="0x01" />
|
||||||
<flag name="autoCorrectUnderline" value="0x02" />
|
<flag name="autoCorrectUnderline" value="0x02" />
|
||||||
<flag name="autoCorrectInvert" value="0x04" />
|
<flag name="autoCorrectInvert" value="0x04" />
|
||||||
<flag name="autoCorrectSpacebarLed" value="0x08" />
|
|
||||||
</attr>
|
</attr>
|
||||||
<attr name="colorTypedWord" format="color" />
|
<attr name="colorTypedWord" format="color" />
|
||||||
<attr name="colorAutoCorrect" format="color" />
|
<attr name="colorAutoCorrect" format="color" />
|
||||||
|
@ -243,4 +244,15 @@
|
||||||
<attr name="styleName" format="string" />
|
<attr name="styleName" format="string" />
|
||||||
<attr name="parentStyle" format="string" />
|
<attr name="parentStyle" format="string" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="LatinKeyboard">
|
||||||
|
<attr name="autoCorrectionSpacebarLedIcon" format="reference" />
|
||||||
|
<attr name="disabledShortcutIcon" format="reference" />
|
||||||
|
<attr name="spacebarTextColor" format="color" />
|
||||||
|
<attr name="spacebarTextShadowColor" format="color" />
|
||||||
|
<attr name="spacebarArrowLeftIcon" format="reference" />
|
||||||
|
<attr name="spacebarArrowRightIcon" format="reference" />
|
||||||
|
<attr name="spacebarArrowPreviewLeftIcon" format="reference" />
|
||||||
|
<attr name="spacebarArrowPreviewRightIcon" format="reference" />
|
||||||
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -16,9 +16,19 @@
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Theme "Basic" -->
|
<!-- Theme "Basic" -->
|
||||||
<style name="Keyboard" >
|
<style name="Keyboard">
|
||||||
<item name="popupHintIcon">@drawable/hint_popup</item>
|
<item name="popupHintIcon">@drawable/hint_popup</item>
|
||||||
</style>
|
</style>
|
||||||
|
<style name="LatinKeyboard">
|
||||||
|
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item>
|
||||||
|
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
|
||||||
|
<item name="spacebarTextColor">@color/latinkeyboard_bar_language_text</item>
|
||||||
|
<item name="spacebarTextShadowColor">@color/latinkeyboard_bar_language_shadow_white</item>
|
||||||
|
<item name="spacebarArrowLeftIcon">@drawable/sym_keyboard_language_arrows_left</item>
|
||||||
|
<item name="spacebarArrowRightIcon">@drawable/sym_keyboard_language_arrows_right</item>
|
||||||
|
<item name="spacebarArrowPreviewLeftIcon">@drawable/sym_keyboard_feedback_language_arrows_left</item>
|
||||||
|
<item name="spacebarArrowPreviewRightIcon">@drawable/sym_keyboard_feedback_language_arrows_right</item>
|
||||||
|
</style>
|
||||||
<style name="KeyboardView">
|
<style name="KeyboardView">
|
||||||
<item name="android:background">@drawable/keyboard_background</item>
|
<item name="android:background">@drawable/keyboard_background</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key</item>
|
||||||
|
@ -61,8 +71,6 @@
|
||||||
<item name="android:background">@drawable/candidate_feedback_background</item>
|
<item name="android:background">@drawable/candidate_feedback_background</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="CandidateViewStyle" parent="SuggestionsStripBackgroundStyle">
|
<style name="CandidateViewStyle" parent="SuggestionsStripBackgroundStyle">
|
||||||
<!-- TODO: autoCorrectSpacebarLed should be in style for LatinKeyboard. -->
|
|
||||||
<item name="autoCorrectHighlight">autoCorrectBold|autoCorrectSpacebarLed</item>
|
|
||||||
<item name="colorTypedWord">#FFFFFFFF</item>
|
<item name="colorTypedWord">#FFFFFFFF</item>
|
||||||
<item name="colorAutoCorrect">#FFFCAE00</item>
|
<item name="colorAutoCorrect">#FFFCAE00</item>
|
||||||
<item name="colorSuggested">#FFFCAE00</item>
|
<item name="colorSuggested">#FFFCAE00</item>
|
||||||
|
@ -75,6 +83,11 @@
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key3</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key3</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Theme "Stone" -->
|
<!-- Theme "Stone" -->
|
||||||
|
<style name="LatinKeyboard.Stone" patent="LatinKeyboard">
|
||||||
|
<item name="spacebarTextColor">#FF444444</item>
|
||||||
|
<item name="spacebarTextShadowColor">@color/latinkeyboard_bar_language_shadow_black</item>
|
||||||
|
<item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item>
|
||||||
|
</style>
|
||||||
<style name="KeyboardView.Stone" parent="KeyboardView">
|
<style name="KeyboardView.Stone" parent="KeyboardView">
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
|
||||||
<item name="keyTextColor">@color/latinkeyboard_key_color_black</item>
|
<item name="keyTextColor">@color/latinkeyboard_key_color_black</item>
|
||||||
|
@ -104,6 +117,10 @@
|
||||||
<style name="Keyboard.Honeycomb" parent="Keyboard" >
|
<style name="Keyboard.Honeycomb" parent="Keyboard" >
|
||||||
<item name="popupHintIcon">@drawable/hint_popup_holo</item>
|
<item name="popupHintIcon">@drawable/hint_popup_holo</item>
|
||||||
</style>
|
</style>
|
||||||
|
<style name="LatinKeyboard.Honeycomb" parent="LatinKeyboard">
|
||||||
|
<item name="autoCorrectionSpacebarLedIcon">@null</item>
|
||||||
|
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
|
||||||
|
</style>
|
||||||
<style name="KeyboardView.Honeycomb" parent="KeyboardView">
|
<style name="KeyboardView.Honeycomb" parent="KeyboardView">
|
||||||
<item name="android:background">@drawable/keyboard_background_holo</item>
|
<item name="android:background">@drawable/keyboard_background_holo</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_honeycomb</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_honeycomb</item>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
<style name="KeyboardTheme" parent="android:Theme">
|
<style name="KeyboardTheme" parent="android:Theme">
|
||||||
<item name="keyboardStyle">@style/Keyboard</item>
|
<item name="keyboardStyle">@style/Keyboard</item>
|
||||||
|
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView</item>
|
<item name="keyboardViewStyle">@style/KeyboardView</item>
|
||||||
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
||||||
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item>
|
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item>
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
</style>
|
</style>
|
||||||
<style name="KeyboardTheme.HighContrast" parent="android:Theme">
|
<style name="KeyboardTheme.HighContrast" parent="android:Theme">
|
||||||
<item name="keyboardStyle">@style/Keyboard</item>
|
<item name="keyboardStyle">@style/Keyboard</item>
|
||||||
|
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item>
|
||||||
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
||||||
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item>
|
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView</item>
|
||||||
|
@ -38,6 +40,7 @@
|
||||||
</style>
|
</style>
|
||||||
<style name="KeyboardTheme.Stone" parent="android:Theme.Light">
|
<style name="KeyboardTheme.Stone" parent="android:Theme.Light">
|
||||||
<item name="keyboardStyle">@style/Keyboard</item>
|
<item name="keyboardStyle">@style/Keyboard</item>
|
||||||
|
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.Stone</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.Stone</item>
|
||||||
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
||||||
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item>
|
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item>
|
||||||
|
@ -48,6 +51,7 @@
|
||||||
</style>
|
</style>
|
||||||
<style name="KeyboardTheme.Stone.Bold" parent="android:Theme.Light">
|
<style name="KeyboardTheme.Stone.Bold" parent="android:Theme.Light">
|
||||||
<item name="keyboardStyle">@style/Keyboard</item>
|
<item name="keyboardStyle">@style/Keyboard</item>
|
||||||
|
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.Stone.Bold</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.Stone.Bold</item>
|
||||||
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
||||||
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item>
|
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Stone</item>
|
||||||
|
@ -58,6 +62,7 @@
|
||||||
</style>
|
</style>
|
||||||
<style name="KeyboardTheme.Gingerbread" parent="android:Theme.Black">
|
<style name="KeyboardTheme.Gingerbread" parent="android:Theme.Black">
|
||||||
<item name="keyboardStyle">@style/Keyboard</item>
|
<item name="keyboardStyle">@style/Keyboard</item>
|
||||||
|
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item>
|
||||||
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
<item name="keyPreviewStyle">@style/KeyPreviewStyle</item>
|
||||||
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Gingerbread</item>
|
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Gingerbread</item>
|
||||||
|
@ -68,6 +73,7 @@
|
||||||
</style>
|
</style>
|
||||||
<style name="KeyboardTheme.Honeycomb" parent="android:Theme.Holo">
|
<style name="KeyboardTheme.Honeycomb" parent="android:Theme.Holo">
|
||||||
<item name="keyboardStyle">@style/Keyboard.Honeycomb</item>
|
<item name="keyboardStyle">@style/Keyboard.Honeycomb</item>
|
||||||
|
<item name="latinKeyboardStyle">@style/LatinKeyboard.Honeycomb</item>
|
||||||
<item name="keyboardViewStyle">@style/KeyboardView.Honeycomb</item>
|
<item name="keyboardViewStyle">@style/KeyboardView.Honeycomb</item>
|
||||||
<item name="keyPreviewStyle">@style/KeyPreviewStyle.Honeycomb</item>
|
<item name="keyPreviewStyle">@style/KeyPreviewStyle.Honeycomb</item>
|
||||||
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Honeycomb</item>
|
<item name="popupMiniKeyboardViewStyle">@style/PopupMiniKeyboardView.Honeycomb</item>
|
||||||
|
|
|
@ -57,9 +57,9 @@ public class LatinKeyboard extends Keyboard {
|
||||||
private final Drawable mSpaceIcon;
|
private final Drawable mSpaceIcon;
|
||||||
private final Drawable mSpacePreviewIcon;
|
private final Drawable mSpacePreviewIcon;
|
||||||
private final int mSpaceKeyIndex;
|
private final int mSpaceKeyIndex;
|
||||||
private final Drawable mSpaceAutoCorrectionIndicator;
|
private final Drawable mAutoCorrectionSpacebarLedIcon;
|
||||||
private final Drawable mButtonArrowLeftIcon;
|
private final Drawable mSpacebarArrowLeftIcon;
|
||||||
private final Drawable mButtonArrowRightIcon;
|
private final Drawable mSpacebarArrowRightIcon;
|
||||||
private final int mSpacebarTextColor;
|
private final int mSpacebarTextColor;
|
||||||
private final int mSpacebarTextShadowColor;
|
private final int mSpacebarTextShadowColor;
|
||||||
private float mSpacebarTextFadeFactor = 0.0f;
|
private float mSpacebarTextFadeFactor = 0.0f;
|
||||||
|
@ -90,7 +90,6 @@ public class LatinKeyboard extends Keyboard {
|
||||||
|
|
||||||
public LatinKeyboard(Context context, KeyboardId id, int width) {
|
public LatinKeyboard(Context context, KeyboardId id, int width) {
|
||||||
super(context, id.getXmlId(), id, width);
|
super(context, id.getXmlId(), id, width);
|
||||||
final Resources res = context.getResources();
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
final List<Key> keys = getKeys();
|
final List<Key> keys = getKeys();
|
||||||
|
@ -118,19 +117,20 @@ public class LatinKeyboard extends Keyboard {
|
||||||
mShortcutKey = (shortcutKeyIndex >= 0) ? keys.get(shortcutKeyIndex) : null;
|
mShortcutKey = (shortcutKeyIndex >= 0) ? keys.get(shortcutKeyIndex) : null;
|
||||||
mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
|
mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
|
||||||
|
|
||||||
mSpacebarTextColor = res.getColor(R.color.latinkeyboard_bar_language_text);
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
if (id.mColorScheme == KeyboardView.COLOR_SCHEME_BLACK) {
|
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
|
||||||
mSpacebarTextShadowColor = res.getColor(
|
mAutoCorrectionSpacebarLedIcon = a.getDrawable(
|
||||||
R.color.latinkeyboard_bar_language_shadow_black);
|
R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon);
|
||||||
mDisabledShortcutIcon = res.getDrawable(R.drawable.sym_bkeyboard_voice_off);
|
mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboard_disabledShortcutIcon);
|
||||||
} else { // default color scheme is KeyboardView.COLOR_SCHEME_WHITE
|
mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0);
|
||||||
mSpacebarTextShadowColor = res.getColor(
|
mSpacebarTextShadowColor = a.getColor(
|
||||||
R.color.latinkeyboard_bar_language_shadow_white);
|
R.styleable.LatinKeyboard_spacebarTextShadowColor, 0);
|
||||||
mDisabledShortcutIcon = res.getDrawable(R.drawable.sym_keyboard_voice_off_holo);
|
mSpacebarArrowLeftIcon = a.getDrawable(
|
||||||
}
|
R.styleable.LatinKeyboard_spacebarArrowLeftIcon);
|
||||||
mSpaceAutoCorrectionIndicator = res.getDrawable(R.drawable.sym_keyboard_space_led);
|
mSpacebarArrowRightIcon = a.getDrawable(
|
||||||
mButtonArrowLeftIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_left);
|
R.styleable.LatinKeyboard_spacebarArrowRightIcon);
|
||||||
mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right);
|
a.recycle();
|
||||||
|
|
||||||
// The threshold is "key width" x 1.25
|
// The threshold is "key width" x 1.25
|
||||||
mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4;
|
mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4;
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,10 @@ public class LatinKeyboard extends Keyboard {
|
||||||
view.invalidateKey(mShortcutKey);
|
view.invalidateKey(mShortcutKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean needsAutoCorrectionSpacebarLed() {
|
||||||
|
return mAutoCorrectionSpacebarLedIcon != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a key which should be invalidated.
|
* @return a key which should be invalidated.
|
||||||
*/
|
*/
|
||||||
|
@ -282,7 +286,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String language = layoutSpacebar(paint, inputLocale,
|
final String language = layoutSpacebar(paint, inputLocale,
|
||||||
mButtonArrowLeftIcon, mButtonArrowRightIcon, width, height,
|
mSpacebarArrowLeftIcon, mSpacebarArrowRightIcon, width, height,
|
||||||
getTextSizeFromTheme(mContext.getTheme(), textStyle, defaultTextSize));
|
getTextSizeFromTheme(mContext.getTheme(), textStyle, defaultTextSize));
|
||||||
|
|
||||||
// Draw language text with shadow
|
// Draw language text with shadow
|
||||||
|
@ -303,21 +307,21 @@ public class LatinKeyboard extends Keyboard {
|
||||||
if (mSubtypeSwitcher.useSpacebarLanguageSwitcher()
|
if (mSubtypeSwitcher.useSpacebarLanguageSwitcher()
|
||||||
&& mSubtypeSwitcher.getEnabledKeyboardLocaleCount() > 1
|
&& mSubtypeSwitcher.getEnabledKeyboardLocaleCount() > 1
|
||||||
&& !(isPhoneKeyboard() || isNumberKeyboard())) {
|
&& !(isPhoneKeyboard() || isNumberKeyboard())) {
|
||||||
mButtonArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor));
|
mSpacebarArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor));
|
||||||
mButtonArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor));
|
mSpacebarArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor));
|
||||||
mButtonArrowLeftIcon.draw(canvas);
|
mSpacebarArrowLeftIcon.draw(canvas);
|
||||||
mButtonArrowRightIcon.draw(canvas);
|
mSpacebarArrowRightIcon.draw(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the spacebar icon at the bottom
|
// Draw the spacebar icon at the bottom
|
||||||
if (isAutoCorrection) {
|
if (isAutoCorrection) {
|
||||||
final int iconWidth = width * SPACE_LED_LENGTH_PERCENT / 100;
|
final int iconWidth = width * SPACE_LED_LENGTH_PERCENT / 100;
|
||||||
final int iconHeight = mSpaceAutoCorrectionIndicator.getIntrinsicHeight();
|
final int iconHeight = mAutoCorrectionSpacebarLedIcon.getIntrinsicHeight();
|
||||||
int x = (width - iconWidth) / 2;
|
int x = (width - iconWidth) / 2;
|
||||||
int y = height - iconHeight;
|
int y = height - iconHeight;
|
||||||
mSpaceAutoCorrectionIndicator.setBounds(x, y, x + iconWidth, y + iconHeight);
|
mAutoCorrectionSpacebarLedIcon.setBounds(x, y, x + iconWidth, y + iconHeight);
|
||||||
mSpaceAutoCorrectionIndicator.draw(canvas);
|
mAutoCorrectionSpacebarLedIcon.draw(canvas);
|
||||||
} else if (mSpaceIcon != null) {
|
} else if (mSpaceIcon != null) {
|
||||||
final int iconWidth = mSpaceIcon.getIntrinsicWidth();
|
final int iconWidth = mSpaceIcon.getIntrinsicWidth();
|
||||||
final int iconHeight = mSpaceIcon.getIntrinsicHeight();
|
final int iconHeight = mSpaceIcon.getIntrinsicHeight();
|
||||||
|
|
|
@ -16,22 +16,21 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.R;
|
|
||||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PixelFormat;
|
|
||||||
import android.graphics.Paint.Align;
|
import android.graphics.Paint.Align;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.R;
|
||||||
|
import com.android.inputmethod.latin.SubtypeSwitcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animation to be displayed on the spacebar preview popup when switching languages by swiping the
|
* Animation to be displayed on the spacebar preview popup when switching languages by swiping the
|
||||||
* spacebar. It draws the current, previous and next languages and moves them by the delta of touch
|
* spacebar. It draws the current, previous and next languages and moves them by the delta of touch
|
||||||
|
@ -39,16 +38,16 @@ import android.view.ViewConfiguration;
|
||||||
*/
|
*/
|
||||||
public class SlidingLocaleDrawable extends Drawable {
|
public class SlidingLocaleDrawable extends Drawable {
|
||||||
private static final int SLIDE_SPEED_MULTIPLIER_RATIO = 150;
|
private static final int SLIDE_SPEED_MULTIPLIER_RATIO = 150;
|
||||||
private final Context mContext;
|
|
||||||
private final Resources mRes;
|
|
||||||
private final int mWidth;
|
private final int mWidth;
|
||||||
private final int mHeight;
|
private final int mHeight;
|
||||||
private final Drawable mBackground;
|
private final Drawable mBackground;
|
||||||
|
private final int mSpacebarTextColor;
|
||||||
private final TextPaint mTextPaint;
|
private final TextPaint mTextPaint;
|
||||||
private final int mMiddleX;
|
private final int mMiddleX;
|
||||||
private final Drawable mLeftDrawable;
|
private final Drawable mLeftDrawable;
|
||||||
private final Drawable mRightDrawable;
|
private final Drawable mRightDrawable;
|
||||||
private final int mThreshold;
|
private final int mThreshold;
|
||||||
|
|
||||||
private int mDiff;
|
private int mDiff;
|
||||||
private boolean mHitThreshold;
|
private boolean mHitThreshold;
|
||||||
private String mCurrentLanguage;
|
private String mCurrentLanguage;
|
||||||
|
@ -56,29 +55,31 @@ public class SlidingLocaleDrawable extends Drawable {
|
||||||
private String mPrevLanguage;
|
private String mPrevLanguage;
|
||||||
|
|
||||||
public SlidingLocaleDrawable(Context context, Drawable background, int width, int height) {
|
public SlidingLocaleDrawable(Context context, Drawable background, int width, int height) {
|
||||||
mContext = context;
|
|
||||||
mRes = context.getResources();
|
|
||||||
mBackground = background;
|
mBackground = background;
|
||||||
Keyboard.setDefaultBounds(mBackground);
|
Keyboard.setDefaultBounds(mBackground);
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
final TextPaint textPaint = new TextPaint();
|
final TextPaint textPaint = new TextPaint();
|
||||||
textPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18));
|
textPaint.setTextSize(getTextSizeFromTheme(
|
||||||
|
context, android.R.style.TextAppearance_Medium, 18));
|
||||||
textPaint.setColor(Color.TRANSPARENT);
|
textPaint.setColor(Color.TRANSPARENT);
|
||||||
textPaint.setTextAlign(Align.CENTER);
|
textPaint.setTextAlign(Align.CENTER);
|
||||||
textPaint.setAntiAlias(true);
|
textPaint.setAntiAlias(true);
|
||||||
mTextPaint = textPaint;
|
mTextPaint = textPaint;
|
||||||
mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2;
|
mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2;
|
||||||
final Resources res = mRes;
|
|
||||||
mLeftDrawable = res.getDrawable(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
R.drawable.sym_keyboard_feedback_language_arrows_left);
|
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
|
||||||
mRightDrawable = res.getDrawable(
|
mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0);
|
||||||
R.drawable.sym_keyboard_feedback_language_arrows_right);
|
mLeftDrawable = a.getDrawable(R.styleable.LatinKeyboard_spacebarArrowPreviewLeftIcon);
|
||||||
mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop();
|
mRightDrawable = a.getDrawable(R.styleable.LatinKeyboard_spacebarArrowPreviewRightIcon);
|
||||||
|
a.recycle();
|
||||||
|
|
||||||
|
mThreshold = ViewConfiguration.get(context).getScaledTouchSlop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getTextSizeFromTheme(int style, int defValue) {
|
private static int getTextSizeFromTheme(Context context, int style, int defValue) {
|
||||||
TypedArray array = mContext.getTheme().obtainStyledAttributes(
|
TypedArray array = context.getTheme().obtainStyledAttributes(
|
||||||
style, new int[] { android.R.attr.textSize });
|
style, new int[] { android.R.attr.textSize });
|
||||||
int textSize = array.getDimensionPixelSize(array.getResourceId(0, 0), defValue);
|
int textSize = array.getDimensionPixelSize(array.getResourceId(0, 0), defValue);
|
||||||
return textSize;
|
return textSize;
|
||||||
|
@ -118,7 +119,7 @@ public class SlidingLocaleDrawable extends Drawable {
|
||||||
// Draw language text with shadow
|
// Draw language text with shadow
|
||||||
final float baseline = mHeight * LatinKeyboard.SPACEBAR_LANGUAGE_BASELINE
|
final float baseline = mHeight * LatinKeyboard.SPACEBAR_LANGUAGE_BASELINE
|
||||||
- paint.descent();
|
- paint.descent();
|
||||||
paint.setColor(mRes.getColor(R.color.latinkeyboard_feedback_language_text));
|
paint.setColor(mSpacebarTextColor);
|
||||||
canvas.drawText(mCurrentLanguage, width / 2 + diff, baseline, paint);
|
canvas.drawText(mCurrentLanguage, width / 2 + diff, baseline, paint);
|
||||||
canvas.drawText(mNextLanguage, diff - width / 2, baseline, paint);
|
canvas.drawText(mNextLanguage, diff - width / 2, baseline, paint);
|
||||||
canvas.drawText(mPrevLanguage, diff + width + width / 2, baseline, paint);
|
canvas.drawText(mPrevLanguage, diff + width + width / 2, baseline, paint);
|
||||||
|
|
|
@ -81,7 +81,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
private static final int AUTO_CORRECT_BOLD = 0x01;
|
private static final int AUTO_CORRECT_BOLD = 0x01;
|
||||||
private static final int AUTO_CORRECT_UNDERLINE = 0x02;
|
private static final int AUTO_CORRECT_UNDERLINE = 0x02;
|
||||||
private static final int AUTO_CORRECT_INVERT = 0x04;
|
private static final int AUTO_CORRECT_INVERT = 0x04;
|
||||||
private static final int AUTO_CORRECT_SPACEBAR_LED = 0x08;
|
|
||||||
private final int mColorTypedWord;
|
private final int mColorTypedWord;
|
||||||
private final int mColorAutoCorrect;
|
private final int mColorAutoCorrect;
|
||||||
private final int mColorSuggestedCandidate;
|
private final int mColorSuggestedCandidate;
|
||||||
|
@ -420,10 +419,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
mShowingAutoCorrectionInverted = true;
|
mShowingAutoCorrectionInverted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsAutoCorrectionSpacebarLed() {
|
|
||||||
return (mAutoCorrectHighlight & AUTO_CORRECT_SPACEBAR_LED) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShowingAddToDictionaryHint() {
|
public boolean isShowingAddToDictionaryHint() {
|
||||||
return mShowingAddToDictionary;
|
return mShowingAddToDictionary;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1464,7 +1464,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|
|
||||||
if (mCandidateView != null) {
|
if (mCandidateView != null) {
|
||||||
mCandidateView.setSuggestions(words);
|
mCandidateView.setSuggestions(words);
|
||||||
if (mCandidateView.needsAutoCorrectionSpacebarLed()) {
|
if (mKeyboardSwitcher.getLatinKeyboard().needsAutoCorrectionSpacebarLed()) {
|
||||||
mKeyboardSwitcher.onAutoCorrectionStateChanged(
|
mKeyboardSwitcher.onAutoCorrectionStateChanged(
|
||||||
words.hasWordAboveAutoCorrectionScoreThreshold());
|
words.hasWordAboveAutoCorrectionScoreThreshold());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue