am 5afc3ae2: Add LatinKeyboardView style

* commit '5afc3ae2d9df0c2c93f2c66af13b128889ac3b5d':
  Add LatinKeyboardView style
main
Tadashi G. Takaoka 2011-12-18 00:04:48 -08:00 committed by Android Git Automerger
commit dbd811789f
11 changed files with 82 additions and 29 deletions

View File

@ -18,10 +18,13 @@
<declare-styleable name="KeyboardTheme"> <declare-styleable name="KeyboardTheme">
<!-- Keyboard style --> <!-- Keyboard style -->
<attr name="keyboardStyle" format="reference" /> <attr name="keyboardStyle" format="reference" />
<!-- TODO: Get rid of latinKeyboardStyle -->
<!-- LatinKeyboard style --> <!-- LatinKeyboard style -->
<attr name="latinKeyboardStyle" format="reference" /> <attr name="latinKeyboardStyle" format="reference" />
<!-- KeyboardView style --> <!-- KeyboardView style -->
<attr name="keyboardViewStyle" format="reference" /> <attr name="keyboardViewStyle" format="reference" />
<!-- LatinKeyboardView style -->
<attr name="latinKeyboardViewStyle" format="reference" />
<!-- MiniKeyboard style --> <!-- MiniKeyboard style -->
<attr name="miniKeyboardStyle" format="reference" /> <attr name="miniKeyboardStyle" format="reference" />
<!-- MiniKeyboardView style --> <!-- MiniKeyboardView style -->
@ -120,6 +123,10 @@
</attr> </attr>
</declare-styleable> </declare-styleable>
<declare-styleable name="LatinKeyboardView">
<attr name="disabledShortcutIcon" format="reference" />
</declare-styleable>
<declare-styleable name="SuggestionsView"> <declare-styleable name="SuggestionsView">
<attr name="suggestionStripOption" format="integer"> <attr name="suggestionStripOption" format="integer">
<!-- This should be aligned with SuggestionsViewParams.AUTO_CORRECT_* and etc. --> <!-- This should be aligned with SuggestionsViewParams.AUTO_CORRECT_* and etc. -->
@ -321,11 +328,10 @@
<attr name="parentStyle" format="string" /> <attr name="parentStyle" format="string" />
</declare-styleable> </declare-styleable>
<!-- Move these attributes to LatinKeyboardView --> <!-- TODO: Move these attributes to LatinKeyboardView -->
<declare-styleable name="LatinKeyboard"> <declare-styleable name="LatinKeyboard">
<attr name="autoCorrectionSpacebarLedEnabled" format="boolean" /> <attr name="autoCorrectionSpacebarLedEnabled" format="boolean" />
<attr name="autoCorrectionSpacebarLedIcon" format="reference" /> <attr name="autoCorrectionSpacebarLedIcon" format="reference" />
<attr name="disabledShortcutIcon" format="reference" />
<!-- Size of the text for spacebar language label, in the proportion of key height. --> <!-- Size of the text for spacebar language label, in the proportion of key height. -->
<attr name="spacebarTextRatio" format="fraction" /> <attr name="spacebarTextRatio" format="fraction" />
<attr name="spacebarTextColor" format="color" /> <attr name="spacebarTextColor" format="color" />

View File

@ -71,6 +71,12 @@
<item name="shadowRadius">2.75</item> <item name="shadowRadius">2.75</item>
<item name="backgroundDimAmount">0.5</item> <item name="backgroundDimAmount">0.5</item>
</style> </style>
<style
name="LatinKeyboardView"
parent="KeyboardView">
<!-- TODO: Needs non-holo disabled shortcut icon drawable -->
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
<style <style
name="MiniKeyboard" name="MiniKeyboard"
parent="Keyboard" parent="Keyboard"
@ -134,6 +140,13 @@
<item name="android:background">@android:color/black</item> <item name="android:background">@android:color/black</item>
<item name="keyBackground">@drawable/btn_keyboard_key3</item> <item name="keyBackground">@drawable/btn_keyboard_key3</item>
</style> </style>
<style
name="LatinKeyboardView.HighContrast"
parent="KeyboardView.HighContrast"
>
<!-- TODO: Needs non-holo disabled shortcut icon drawable -->
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
<!-- Theme "Stone" --> <!-- Theme "Stone" -->
<style <style
name="Keyboard.Stone" name="Keyboard.Stone"
@ -166,6 +179,12 @@
<item name="keyUppercaseLetterActivatedColor">#CC000000</item> <item name="keyUppercaseLetterActivatedColor">#CC000000</item>
<item name="shadowColor">#FFFFFFFF</item> <item name="shadowColor">#FFFFFFFF</item>
</style> </style>
<style
name="LatinKeyboardView.Stone"
parent="KeyboardView.Stone"
>
<item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item>
</style>
<style <style
name="MiniKeyboard.Stone" name="MiniKeyboard.Stone"
parent="Keyboard.Stone" parent="Keyboard.Stone"
@ -195,6 +214,12 @@
> >
<item name="keyTextStyle">bold</item> <item name="keyTextStyle">bold</item>
</style> </style>
<style
name="LatinKeyboardView.Stone.Bold"
parent="KeyboardView.Stone.Bold"
>
<item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item>
</style>
<!-- Theme "Gingerbread" --> <!-- Theme "Gingerbread" -->
<style <style
name="Keyboard.Gingerbread" name="Keyboard.Gingerbread"
@ -213,6 +238,13 @@
<item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item> <item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item>
<item name="keyTextStyle">bold</item> <item name="keyTextStyle">bold</item>
</style> </style>
<style
name="LatinKeyboardView.Gingerbread"
parent="KeyboardView.Gingerbread"
>
<!-- TODO: Needs non-holo disabled shortcut icon drawable -->
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
<style <style
name="MiniKeyboard.Gingerbread" name="MiniKeyboard.Gingerbread"
parent="Keyboard.Gingerbread" parent="Keyboard.Gingerbread"
@ -244,7 +276,6 @@
parent="LatinKeyboard" parent="LatinKeyboard"
> >
<item name="autoCorrectionSpacebarLedEnabled">false</item> <item name="autoCorrectionSpacebarLedEnabled">false</item>
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style> </style>
<style <style
name="KeyboardView.IceCreamSandwich" name="KeyboardView.IceCreamSandwich"
@ -269,6 +300,12 @@
<item name="shadowColor">#00000000</item> <item name="shadowColor">#00000000</item>
<item name="shadowRadius">0.0</item> <item name="shadowRadius">0.0</item>
</style> </style>
<style
name="LatinKeyboardView.IceCreamSandwich"
parent="KeyboardView.IceCreamSandwich"
>
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
<style <style
name="MiniKeyboard.IceCreamSandwich" name="MiniKeyboard.IceCreamSandwich"
parent="Keyboard.IceCreamSandwich" parent="Keyboard.IceCreamSandwich"

View File

@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.HighContrast</item> <item name="keyboardStyle">@style/Keyboard.HighContrast</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item>
<item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item> <item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item>
<item name="latinKeyboardViewStyle">@style/LatinKeyboardView.HighContrast</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard</item> <item name="miniKeyboardStyle">@style/MiniKeyboard</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView</item> <item name="miniKeyboardViewStyle">@style/MiniKeyboardView</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item> <item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>

View File

@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard</item> <item name="keyboardStyle">@style/Keyboard</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item>
<item name="keyboardViewStyle">@style/KeyboardView</item> <item name="keyboardViewStyle">@style/KeyboardView</item>
<item name="latinKeyboardViewStyle">@style/LatinKeyboardView</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard</item> <item name="miniKeyboardStyle">@style/MiniKeyboard</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView</item> <item name="miniKeyboardViewStyle">@style/MiniKeyboardView</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item> <item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>

View File

@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.Gingerbread</item> <item name="keyboardStyle">@style/Keyboard.Gingerbread</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard</item> <item name="latinKeyboardStyle">@style/LatinKeyboard</item>
<item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item> <item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item>
<item name="latinKeyboardViewStyle">@style/LatinKeyboardView.Gingerbread</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard.Gingerbread</item> <item name="miniKeyboardStyle">@style/MiniKeyboard.Gingerbread</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView.Gingerbread</item> <item name="miniKeyboardViewStyle">@style/MiniKeyboardView.Gingerbread</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item> <item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>

View File

@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.IceCreamSandwich</item> <item name="keyboardStyle">@style/Keyboard.IceCreamSandwich</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard.IceCreamSandwich</item> <item name="latinKeyboardStyle">@style/LatinKeyboard.IceCreamSandwich</item>
<item name="keyboardViewStyle">@style/KeyboardView.IceCreamSandwich</item> <item name="keyboardViewStyle">@style/KeyboardView.IceCreamSandwich</item>
<item name="latinKeyboardViewStyle">@style/LatinKeyboardView.IceCreamSandwich</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard.IceCreamSandwich</item> <item name="miniKeyboardStyle">@style/MiniKeyboard.IceCreamSandwich</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView.IceCreamSandwich</item> <item name="miniKeyboardViewStyle">@style/MiniKeyboardView.IceCreamSandwich</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle.IceCreamSandwich</item> <item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle.IceCreamSandwich</item>

View File

@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.Stone.Bold</item> <item name="keyboardStyle">@style/Keyboard.Stone.Bold</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</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="latinKeyboardViewStyle">@style/LatinKeyboardView.Stone.Bold</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard.Stone</item> <item name="miniKeyboardStyle">@style/MiniKeyboard.Stone</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView.Stone</item> <item name="miniKeyboardViewStyle">@style/MiniKeyboardView.Stone</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item> <item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>

View File

@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.Stone</item> <item name="keyboardStyle">@style/Keyboard.Stone</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item> <item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</item>
<item name="keyboardViewStyle">@style/KeyboardView.Stone</item> <item name="keyboardViewStyle">@style/KeyboardView.Stone</item>
<item name="latinKeyboardViewStyle">@style/LatinKeyboardView.Stone</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard.Stone</item> <item name="miniKeyboardStyle">@style/MiniKeyboard.Stone</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView.Stone</item> <item name="miniKeyboardViewStyle">@style/MiniKeyboardView.Stone</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item> <item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>

View File

@ -157,6 +157,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mKeyboardView.setKeyPreviewPopupEnabled( mKeyboardView.setKeyPreviewPopupEnabled(
SettingsValues.isKeyPreviewPopupEnabled(mPrefs, mResources), SettingsValues.isKeyPreviewPopupEnabled(mPrefs, mResources),
SettingsValues.getKeyPreviewPopupDismissDelay(mPrefs, mResources)); SettingsValues.getKeyPreviewPopupDismissDelay(mPrefs, mResources));
mKeyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
final boolean localeChanged = (oldKeyboard == null) final boolean localeChanged = (oldKeyboard == null)
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale); || !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
if (keyboard instanceof LatinKeyboard) { if (keyboard instanceof LatinKeyboard) {
@ -168,7 +169,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mKeyboardView.updateSpacebar(); mKeyboardView.updateSpacebar();
latinKeyboard.updateSpacebarLanguage(0.0f, latinKeyboard.updateSpacebarLanguage(0.0f,
mSubtypeSwitcher.needsToDisplayLanguage(latinKeyboard.mId.mLocale)); mSubtypeSwitcher.needsToDisplayLanguage(latinKeyboard.mId.mLocale));
latinKeyboard.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
} }
updateShiftState(); updateShiftState();
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged); mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
@ -411,12 +411,8 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
} }
public void onNetworkStateChanged() { public void onNetworkStateChanged() {
final LatinKeyboard keyboard = getLatinKeyboard(); if (mKeyboardView != null) {
if (keyboard == null) return; mKeyboardView.updateShortcutKey(SubtypeSwitcher.getInstance().isShortcutImeReady());
final Key updatedKey = keyboard.updateShortcutKey(
SubtypeSwitcher.getInstance().isShortcutImeReady());
if (updatedKey != null && mKeyboardView != null) {
mKeyboardView.invalidateKey(updatedKey);
} }
} }

View File

@ -60,11 +60,6 @@ public class LatinKeyboard extends Keyboard {
private boolean mNeedsToDisplayLanguage; private boolean mNeedsToDisplayLanguage;
private float mSpacebarTextFadeFactor = 0.0f; private float mSpacebarTextFadeFactor = 0.0f;
/* Shortcut key and its icons if available */
private final Key mShortcutKey;
private final Drawable mEnabledShortcutIcon;
private final Drawable mDisabledShortcutIcon;
// Height in space key the language name will be drawn. (proportional to space key height) // Height in space key the language name will be drawn. (proportional to space key height)
public static final float SPACEBAR_LANGUAGE_BASELINE = 0.6f; public static final float SPACEBAR_LANGUAGE_BASELINE = 0.6f;
// If the full language name needs to be smaller than this value to be drawn on space key, // If the full language name needs to be smaller than this value to be drawn on space key,
@ -79,16 +74,13 @@ public class LatinKeyboard extends Keyboard {
mSpaceKey = getKey(CODE_SPACE); mSpaceKey = getKey(CODE_SPACE);
mSpaceIcon = (mSpaceKey != null) ? mSpaceKey.getIcon() : null; mSpaceIcon = (mSpaceKey != null) ? mSpaceKey.getIcon() : null;
mShortcutKey = getKey(CODE_SHORTCUT); // TODO: Move these to LatinKeyboardView attributes.
mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
final TypedArray a = context.obtainStyledAttributes( final TypedArray a = context.obtainStyledAttributes(
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard); null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
mAutoCorrectionSpacebarLedEnabled = a.getBoolean( mAutoCorrectionSpacebarLedEnabled = a.getBoolean(
R.styleable.LatinKeyboard_autoCorrectionSpacebarLedEnabled, false); R.styleable.LatinKeyboard_autoCorrectionSpacebarLedEnabled, false);
mAutoCorrectionSpacebarLedIcon = a.getDrawable( mAutoCorrectionSpacebarLedIcon = a.getDrawable(
R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon); R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon);
mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboard_disabledShortcutIcon);
final float spacebarTextRatio = a.getFraction(R.styleable.LatinKeyboard_spacebarTextRatio, final float spacebarTextRatio = a.getFraction(R.styleable.LatinKeyboard_spacebarTextRatio,
1000, 1000, 1) / 1000.0f; 1000, 1000, 1) / 1000.0f;
final int keyHeight = mMostCommonKeyHeight - mVerticalGap; final int keyHeight = mMostCommonKeyHeight - mVerticalGap;
@ -131,15 +123,6 @@ public class LatinKeyboard extends Keyboard {
return newColor; return newColor;
} }
// TODO: Move this drawing method to LatinKeyboardView.
public Key updateShortcutKey(boolean available) {
if (mShortcutKey == null)
return null;
mShortcutKey.setEnabled(available);
mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon);
return mShortcutKey;
}
// TODO: Get rid of this method // TODO: Get rid of this method
public boolean needsAutoCorrectionSpacebarLed() { public boolean needsAutoCorrectionSpacebarLed() {
return mAutoCorrectionSpacebarLedEnabled; return mAutoCorrectionSpacebarLedEnabled;

View File

@ -19,8 +19,10 @@ package com.android.inputmethod.keyboard;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.os.Message; import android.os.Message;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
@ -65,6 +67,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
private final boolean mIsSpacebarTriggeringPopupByLongPress; private final boolean mIsSpacebarTriggeringPopupByLongPress;
private boolean mMultipleEnabledIMEsOrSubtypes; private boolean mMultipleEnabledIMEsOrSubtypes;
/* Shortcut key and its icons if available */
private Key mShortcutKey;
// TODO: Remove this variable, use KeyboardIconsSet instead.
private Drawable mEnabledShortcutIcon;
// TODO: Remove this variable and LatinKeyboardView.disabledShortcutIcon attribute.
// This should be moved to KeyboardIconsSet.
private final Drawable mDisabledShortcutIcon;
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator; private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
// Timing constants // Timing constants
@ -228,7 +238,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
} }
public LatinKeyboardView(Context context, AttributeSet attrs) { public LatinKeyboardView(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.keyboardViewStyle); this(context, attrs, R.attr.latinKeyboardViewStyle);
} }
public LatinKeyboardView(Context context, AttributeSet attrs, int defStyle) { public LatinKeyboardView(Context context, AttributeSet attrs, int defStyle) {
@ -256,6 +266,11 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
final int longPressSpaceKeyTimeout = final int longPressSpaceKeyTimeout =
res.getInteger(R.integer.config_long_press_space_key_timeout); res.getInteger(R.integer.config_long_press_space_key_timeout);
mIsSpacebarTriggeringPopupByLongPress = (longPressSpaceKeyTimeout > 0); mIsSpacebarTriggeringPopupByLongPress = (longPressSpaceKeyTimeout > 0);
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView);
mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboardView_disabledShortcutIcon);
a.recycle();
} }
public void startIgnoringDoubleTap() { public void startIgnoringDoubleTap() {
@ -310,6 +325,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
PointerTracker.setKeyDetector(mKeyDetector); PointerTracker.setKeyDetector(mKeyDetector);
mTouchScreenRegulator.setKeyboard(keyboard); mTouchScreenRegulator.setKeyboard(keyboard);
mMoreKeysPanelCache.clear(); mMoreKeysPanelCache.clear();
mShortcutKey = keyboard.getKey(Keyboard.CODE_SHORTCUT);
mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
} }
/** /**
@ -695,6 +713,13 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
return false; return false;
} }
public void updateShortcutKey(boolean available) {
if (mShortcutKey == null) return;
mShortcutKey.setEnabled(available);
mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon);
invalidateKey(mShortcutKey);
}
public void updateSpacebar() { public void updateSpacebar() {
mMultipleEnabledIMEsOrSubtypes = Utils.hasMultipleEnabledIMEsOrSubtypes( mMultipleEnabledIMEsOrSubtypes = Utils.hasMultipleEnabledIMEsOrSubtypes(
true /* include aux subtypes */); true /* include aux subtypes */);