aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-12-18 04:55:17 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-12-18 16:42:23 +0900
commit5afc3ae2d9df0c2c93f2c66af13b128889ac3b5d (patch)
treefe393b02ffdbd3d82124f35a3830859d1bdb69d9 /java
parent22b48de11ce6f31a0edf90e1308073e67a7a2adb (diff)
downloadlatinime-5afc3ae2d9df0c2c93f2c66af13b128889ac3b5d.tar.gz
latinime-5afc3ae2d9df0c2c93f2c66af13b128889ac3b5d.tar.xz
latinime-5afc3ae2d9df0c2c93f2c66af13b128889ac3b5d.zip
Add LatinKeyboardView style
As a result, this change moves shortcut related update code to LatinKeyboardView from LatinKeyboard. Change-Id: I1882672577f61e73c90d6c018b7dbb61f3fe21e4
Diffstat (limited to 'java')
-rw-r--r--java/res/values/attrs.xml10
-rw-r--r--java/res/values/styles.xml39
-rw-r--r--java/res/values/themes-basic-highcontrast.xml1
-rw-r--r--java/res/values/themes-basic.xml1
-rw-r--r--java/res/values/themes-gingerbread.xml1
-rw-r--r--java/res/values/themes-ics.xml1
-rw-r--r--java/res/values/themes-stone-bold.xml1
-rw-r--r--java/res/values/themes-stone.xml1
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java10
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboard.java19
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java27
11 files changed, 82 insertions, 29 deletions
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 2e8a0030e..62d667878 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -18,10 +18,13 @@
<declare-styleable name="KeyboardTheme">
<!-- Keyboard style -->
<attr name="keyboardStyle" format="reference" />
+ <!-- TODO: Get rid of latinKeyboardStyle -->
<!-- LatinKeyboard style -->
<attr name="latinKeyboardStyle" format="reference" />
<!-- KeyboardView style -->
<attr name="keyboardViewStyle" format="reference" />
+ <!-- LatinKeyboardView style -->
+ <attr name="latinKeyboardViewStyle" format="reference" />
<!-- MiniKeyboard style -->
<attr name="miniKeyboardStyle" format="reference" />
<!-- MiniKeyboardView style -->
@@ -120,6 +123,10 @@
</attr>
</declare-styleable>
+ <declare-styleable name="LatinKeyboardView">
+ <attr name="disabledShortcutIcon" format="reference" />
+ </declare-styleable>
+
<declare-styleable name="SuggestionsView">
<attr name="suggestionStripOption" format="integer">
<!-- This should be aligned with SuggestionsViewParams.AUTO_CORRECT_* and etc. -->
@@ -321,11 +328,10 @@
<attr name="parentStyle" format="string" />
</declare-styleable>
- <!-- Move these attributes to LatinKeyboardView -->
+ <!-- TODO: Move these attributes to LatinKeyboardView -->
<declare-styleable name="LatinKeyboard">
<attr name="autoCorrectionSpacebarLedEnabled" format="boolean" />
<attr name="autoCorrectionSpacebarLedIcon" format="reference" />
- <attr name="disabledShortcutIcon" format="reference" />
<!-- Size of the text for spacebar language label, in the proportion of key height. -->
<attr name="spacebarTextRatio" format="fraction" />
<attr name="spacebarTextColor" format="color" />
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index ed8795ade..b1b39088f 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -72,6 +72,12 @@
<item name="backgroundDimAmount">0.5</item>
</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
name="MiniKeyboard"
parent="Keyboard"
>
@@ -134,6 +140,13 @@
<item name="android:background">@android:color/black</item>
<item name="keyBackground">@drawable/btn_keyboard_key3</item>
</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" -->
<style
name="Keyboard.Stone"
@@ -167,6 +180,12 @@
<item name="shadowColor">#FFFFFFFF</item>
</style>
<style
+ name="LatinKeyboardView.Stone"
+ parent="KeyboardView.Stone"
+ >
+ <item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item>
+ </style>
+ <style
name="MiniKeyboard.Stone"
parent="Keyboard.Stone"
>
@@ -195,6 +214,12 @@
>
<item name="keyTextStyle">bold</item>
</style>
+ <style
+ name="LatinKeyboardView.Stone.Bold"
+ parent="KeyboardView.Stone.Bold"
+ >
+ <item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item>
+ </style>
<!-- Theme "Gingerbread" -->
<style
name="Keyboard.Gingerbread"
@@ -214,6 +239,13 @@
<item name="keyTextStyle">bold</item>
</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
name="MiniKeyboard.Gingerbread"
parent="Keyboard.Gingerbread"
>
@@ -244,7 +276,6 @@
parent="LatinKeyboard"
>
<item name="autoCorrectionSpacebarLedEnabled">false</item>
- <item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
<style
name="KeyboardView.IceCreamSandwich"
@@ -270,6 +301,12 @@
<item name="shadowRadius">0.0</item>
</style>
<style
+ name="LatinKeyboardView.IceCreamSandwich"
+ parent="KeyboardView.IceCreamSandwich"
+ >
+ <item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
+ </style>
+ <style
name="MiniKeyboard.IceCreamSandwich"
parent="Keyboard.IceCreamSandwich"
>
diff --git a/java/res/values/themes-basic-highcontrast.xml b/java/res/values/themes-basic-highcontrast.xml
index abb7c8057..a1b917057 100644
--- a/java/res/values/themes-basic-highcontrast.xml
+++ b/java/res/values/themes-basic-highcontrast.xml
@@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.HighContrast</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
<item name="keyboardViewStyle">@style/KeyboardView.HighContrast</item>
+ <item name="latinKeyboardViewStyle">@style/LatinKeyboardView.HighContrast</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>
diff --git a/java/res/values/themes-basic.xml b/java/res/values/themes-basic.xml
index ff9fed55f..1c2db1648 100644
--- a/java/res/values/themes-basic.xml
+++ b/java/res/values/themes-basic.xml
@@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
<item name="keyboardViewStyle">@style/KeyboardView</item>
+ <item name="latinKeyboardViewStyle">@style/LatinKeyboardView</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>
diff --git a/java/res/values/themes-gingerbread.xml b/java/res/values/themes-gingerbread.xml
index be853eb0f..2af3da12e 100644
--- a/java/res/values/themes-gingerbread.xml
+++ b/java/res/values/themes-gingerbread.xml
@@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.Gingerbread</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard</item>
<item name="keyboardViewStyle">@style/KeyboardView.Gingerbread</item>
+ <item name="latinKeyboardViewStyle">@style/LatinKeyboardView.Gingerbread</item>
<item name="miniKeyboardStyle">@style/MiniKeyboard.Gingerbread</item>
<item name="miniKeyboardViewStyle">@style/MiniKeyboardView.Gingerbread</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>
diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml
index 618aaed79..b7898414e 100644
--- a/java/res/values/themes-ics.xml
+++ b/java/res/values/themes-ics.xml
@@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.IceCreamSandwich</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard.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="miniKeyboardViewStyle">@style/MiniKeyboardView.IceCreamSandwich</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle.IceCreamSandwich</item>
diff --git a/java/res/values/themes-stone-bold.xml b/java/res/values/themes-stone-bold.xml
index 532a2985e..cf2cb9100 100644
--- a/java/res/values/themes-stone-bold.xml
+++ b/java/res/values/themes-stone-bold.xml
@@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.Stone.Bold</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard.Stone</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="miniKeyboardViewStyle">@style/MiniKeyboardView.Stone</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>
diff --git a/java/res/values/themes-stone.xml b/java/res/values/themes-stone.xml
index cb3edc58f..be0755f9a 100644
--- a/java/res/values/themes-stone.xml
+++ b/java/res/values/themes-stone.xml
@@ -19,6 +19,7 @@
<item name="keyboardStyle">@style/Keyboard.Stone</item>
<item name="latinKeyboardStyle">@style/LatinKeyboard.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="miniKeyboardViewStyle">@style/MiniKeyboardView.Stone</item>
<item name="miniKeyboardPanelStyle">@style/MiniKeyboardPanelStyle</item>
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 16f27b499..35734fb87 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -157,6 +157,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mKeyboardView.setKeyPreviewPopupEnabled(
SettingsValues.isKeyPreviewPopupEnabled(mPrefs, mResources),
SettingsValues.getKeyPreviewPopupDismissDelay(mPrefs, mResources));
+ mKeyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
final boolean localeChanged = (oldKeyboard == null)
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
if (keyboard instanceof LatinKeyboard) {
@@ -168,7 +169,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mKeyboardView.updateSpacebar();
latinKeyboard.updateSpacebarLanguage(0.0f,
mSubtypeSwitcher.needsToDisplayLanguage(latinKeyboard.mId.mLocale));
- latinKeyboard.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
}
updateShiftState();
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
@@ -411,12 +411,8 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
}
public void onNetworkStateChanged() {
- final LatinKeyboard keyboard = getLatinKeyboard();
- if (keyboard == null) return;
- final Key updatedKey = keyboard.updateShortcutKey(
- SubtypeSwitcher.getInstance().isShortcutImeReady());
- if (updatedKey != null && mKeyboardView != null) {
- mKeyboardView.invalidateKey(updatedKey);
+ if (mKeyboardView != null) {
+ mKeyboardView.updateShortcutKey(SubtypeSwitcher.getInstance().isShortcutImeReady());
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
index 29791108d..50a8d64ce 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
@@ -60,11 +60,6 @@ public class LatinKeyboard extends Keyboard {
private boolean mNeedsToDisplayLanguage;
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)
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,
@@ -79,16 +74,13 @@ public class LatinKeyboard extends Keyboard {
mSpaceKey = getKey(CODE_SPACE);
mSpaceIcon = (mSpaceKey != null) ? mSpaceKey.getIcon() : null;
- mShortcutKey = getKey(CODE_SHORTCUT);
- mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
-
+ // TODO: Move these to LatinKeyboardView attributes.
final TypedArray a = context.obtainStyledAttributes(
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
mAutoCorrectionSpacebarLedEnabled = a.getBoolean(
R.styleable.LatinKeyboard_autoCorrectionSpacebarLedEnabled, false);
mAutoCorrectionSpacebarLedIcon = a.getDrawable(
R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon);
- mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboard_disabledShortcutIcon);
final float spacebarTextRatio = a.getFraction(R.styleable.LatinKeyboard_spacebarTextRatio,
1000, 1000, 1) / 1000.0f;
final int keyHeight = mMostCommonKeyHeight - mVerticalGap;
@@ -131,15 +123,6 @@ public class LatinKeyboard extends Keyboard {
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
public boolean needsAutoCorrectionSpacebarLed() {
return mAutoCorrectionSpacebarLedEnabled;
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 55fc5f92a..81f8640e9 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -19,8 +19,10 @@ package com.android.inputmethod.keyboard;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -65,6 +67,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
private final boolean mIsSpacebarTriggeringPopupByLongPress;
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;
// Timing constants
@@ -228,7 +238,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
}
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) {
@@ -256,6 +266,11 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
final int longPressSpaceKeyTimeout =
res.getInteger(R.integer.config_long_press_space_key_timeout);
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() {
@@ -310,6 +325,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
PointerTracker.setKeyDetector(mKeyDetector);
mTouchScreenRegulator.setKeyboard(keyboard);
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;
}
+ public void updateShortcutKey(boolean available) {
+ if (mShortcutKey == null) return;
+ mShortcutKey.setEnabled(available);
+ mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon);
+ invalidateKey(mShortcutKey);
+ }
+
public void updateSpacebar() {
mMultipleEnabledIMEsOrSubtypes = Utils.hasMultipleEnabledIMEsOrSubtypes(
true /* include aux subtypes */);