aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-12-18 08:00:07 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-12-18 18:25:29 +0900
commit7bd714c086a78e2058543b0971ac92f5a30b2362 (patch)
tree40cc639e59950a4744de3383239a429e7036c823 /java/src
parent1ebedd7a15a8fd94e68fb43eb089ed87c4c5a480 (diff)
downloadlatinime-7bd714c086a78e2058543b0971ac92f5a30b2362.tar.gz
latinime-7bd714c086a78e2058543b0971ac92f5a30b2362.tar.xz
latinime-7bd714c086a78e2058543b0971ac92f5a30b2362.zip
Add extra key icons to KeyboardIconsSet
* Get rid of Key.keyIconShifted attribute. Add Keyboard.iconShiftKeyShifted to KeyboardIconsSet. * Get rid of LatinKeyboardView.disabledShortcutIcon attribute. Add Keyboard.iconShortcurKeyDisabled to KeyboardIconsSet. * Add Keyboard.iconSpaceKeyForNumber to KeyboardIconsSet. * Fix misplaced autoCorrectionSpacebarLedIcon resources. Change-Id: I381bff3789254977ab3cb18f58f95b3c433b1e1a
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java13
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java32
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java30
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java11
6 files changed, 35 insertions, 59 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 8330c3127..5dc02c4a7 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -280,8 +280,6 @@ public class Key {
R.styleable.Keyboard_Key_keyIconPreview, KeyboardIconsSet.ICON_UNDEFINED));
mIcon = iconsSet.getIcon(style.getInt(keyAttr, R.styleable.Keyboard_Key_keyIcon,
KeyboardIconsSet.ICON_UNDEFINED));
- final int shiftedIconId = style.getInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted,
- KeyboardIconsSet.ICON_UNDEFINED);
mHintLabel = style.getText(keyAttr, R.styleable.Keyboard_Key_keyHintLabel);
mLabel = style.getText(keyAttr, R.styleable.Keyboard_Key_keyLabel);
@@ -308,11 +306,6 @@ public class Key {
mHashCode = hashCode(this);
keyAttr.recycle();
-
- if (shiftedIconId != KeyboardIconsSet.ICON_UNDEFINED) {
- final Drawable shiftedIcon = iconsSet.getIcon(shiftedIconId);
- params.addShiftedIcon(this, shiftedIcon);
- }
}
private static int hashCode(Key key) {
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index b7dd302b7..8a4bb8ce1 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -16,7 +16,6 @@
package com.android.inputmethod.keyboard;
-import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
@@ -108,8 +107,6 @@ public class Keyboard {
public final Set<Key> mKeys;
public final Set<Key> mShiftKeys;
public final Set<Key> mShiftLockKeys;
- public final Map<Key, Drawable> mShiftedIcons;
- public final Map<Key, Drawable> mUnshiftedIcons;
public final KeyboardIconsSet mIconsSet;
private final Map<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
@@ -136,8 +133,6 @@ public class Keyboard {
mKeys = Collections.unmodifiableSet(params.mKeys);
mShiftKeys = Collections.unmodifiableSet(params.mShiftKeys);
mShiftLockKeys = Collections.unmodifiableSet(params.mShiftLockKeys);
- mShiftedIcons = Collections.unmodifiableMap(params.mShiftedIcons);
- mUnshiftedIcons = Collections.unmodifiableMap(params.mUnshiftedIcons);
mIconsSet = params.mIconsSet;
mProximityInfo = new ProximityInfo(
@@ -179,7 +174,9 @@ public class Keyboard {
// To represent "shift locked" state. The highlight is handled by background image that
// might be a StateListDrawable.
key.setHighlightOn(newShiftLockState);
- key.setIcon(newShiftLockState ? mShiftedIcons.get(key) : mUnshiftedIcons.get(key));
+ final int iconId = newShiftLockState ? KeyboardIconsSet.ICON_SHIFT_KEY_SHIFTED
+ : KeyboardIconsSet.ICON_SHIFT_KEY;
+ key.setIcon(mIconsSet.getIcon(iconId));
}
mShiftState.setShiftLocked(newShiftLockState);
}
@@ -193,7 +190,9 @@ public class Keyboard {
void setShifted(boolean newShiftState) {
if (!mShiftState.isShiftLocked()) {
for (final Key key : mShiftKeys) {
- key.setIcon(newShiftState ? mShiftedIcons.get(key) : mUnshiftedIcons.get(key));
+ final int iconId = newShiftState ? KeyboardIconsSet.ICON_SHIFT_KEY_SHIFTED
+ : KeyboardIconsSet.ICON_SHIFT_KEY;
+ key.setIcon(mIconsSet.getIcon(iconId));
}
}
mShiftState.setShifted(newShiftState);
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 81f8640e9..ccea00f43 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -19,10 +19,8 @@ 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;
@@ -41,6 +39,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
+import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
@@ -67,14 +66,6 @@ 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
@@ -266,11 +257,6 @@ 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() {
@@ -325,9 +311,6 @@ 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;
}
/**
@@ -714,10 +697,15 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
}
public void updateShortcutKey(boolean available) {
- if (mShortcutKey == null) return;
- mShortcutKey.setEnabled(available);
- mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon);
- invalidateKey(mShortcutKey);
+ final Keyboard keyboard = getKeyboard();
+ if (keyboard == null) return;
+ final Key shortcutKey = keyboard.getKey(Keyboard.CODE_SHORTCUT);
+ if (shortcutKey == null) return;
+ shortcutKey.setEnabled(available);
+ final int iconId = available ? KeyboardIconsSet.ICON_SHORTCUT_KEY
+ : KeyboardIconsSet.ICON_SHORTCUT_KEY_DISABLED;
+ shortcutKey.setIcon(keyboard.mIconsSet.getIcon(iconId));
+ invalidateKey(shortcutKey);
}
public void updateSpacebar() {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
index 3324fa6af..4e15ecf64 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
@@ -160,7 +160,6 @@ public class KeyStyles {
readFlag(keyAttr, R.styleable.Keyboard_Key_keyLabelFlags);
readInt(keyAttr, R.styleable.Keyboard_Key_keyIcon);
readInt(keyAttr, R.styleable.Keyboard_Key_keyIconPreview);
- readInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted);
readInt(keyAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn);
readInt(keyAttr, R.styleable.Keyboard_Key_backgroundType);
readFlag(keyAttr, R.styleable.Keyboard_Key_keyActionFlags);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
index faa5f86f2..c8a75a92a 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -28,22 +28,26 @@ public class KeyboardIconsSet {
public static final int ICON_UNDEFINED = 0;
+ // TODO: Make all enums private
// This should be aligned with Keyboard.keyIcon enum.
- private static final int ICON_SHIFT_KEY = 1;
+ public static final int ICON_SHIFT_KEY = 1;
private static final int ICON_DELETE_KEY = 2;
- private static final int ICON_SETTINGS_KEY = 3; // This is also represented as "@icon/3" in XML.
- private static final int ICON_SPACE_KEY = 4;
+ // This is also represented as "@icon/3" in keyboard layout XML.
+ private static final int ICON_SETTINGS_KEY = 3;
+ public static final int ICON_SPACE_KEY = 4;
private static final int ICON_RETURN_KEY = 5;
private static final int ICON_SEARCH_KEY = 6;
- private static final int ICON_TAB_KEY = 7; // This is also represented as "@icon/7" in XML.
- private static final int ICON_SHORTCUT_KEY = 8;
+ // This is also represented as "@icon/7" in keyboard layout XML.
+ private static final int ICON_TAB_KEY = 7;
+ public static final int ICON_SHORTCUT_KEY = 8;
private static final int ICON_SHORTCUT_FOR_LABEL = 9;
- // This should be aligned with Keyboard.keyIconShifted enum.
- private static final int ICON_SHIFTED_SHIFT_KEY = 10;
+ public static final int ICON_SHORTCUT_KEY_DISABLED = 10;
+ private static final int ICON_SPACE_KEY_FOR_NUMBER_LAYOUT = 11;
+ public static final int ICON_SHIFT_KEY_SHIFTED = 12;
// This should be aligned with Keyboard.keyIconPreview enum.
- private static final int ICON_PREVIEW_TAB_KEY = 11;
+ private static final int ICON_PREVIEW_TAB_KEY = 13;
- private static final int ICON_LAST = 11;
+ private static final int ICON_LAST = 13;
private final Drawable mIcons[] = new Drawable[ICON_LAST + 1];
@@ -67,8 +71,12 @@ public class KeyboardIconsSet {
return ICON_SHORTCUT_KEY;
case R.styleable.Keyboard_iconShortcutForLabel:
return ICON_SHORTCUT_FOR_LABEL;
- case R.styleable.Keyboard_iconShiftedShiftKey:
- return ICON_SHIFTED_SHIFT_KEY;
+ case R.styleable.Keyboard_iconShortcutKeyDisabled:
+ return ICON_SHORTCUT_KEY_DISABLED;
+ case R.styleable.Keyboard_iconSpaceKeyForNumberLayout:
+ return ICON_SPACE_KEY_FOR_NUMBER_LAYOUT;
+ case R.styleable.Keyboard_iconShiftKeyShifted:
+ return ICON_SHIFT_KEY_SHIFTED;
case R.styleable.Keyboard_iconPreviewTabKey:
return ICON_PREVIEW_TAB_KEY;
default:
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
index 5248016f1..3e345c42a 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
@@ -16,8 +16,6 @@
package com.android.inputmethod.keyboard.internal;
-import android.graphics.drawable.Drawable;
-
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
@@ -60,8 +58,6 @@ public class KeyboardParams {
public final Set<Key> mKeys = new HashSet<Key>();
public final Set<Key> mShiftKeys = new HashSet<Key>();
public final Set<Key> mShiftLockKeys = new HashSet<Key>();
- public final Map<Key, Drawable> mShiftedIcons = new HashMap<Key, Drawable>();
- public final Map<Key, Drawable> mUnshiftedIcons = new HashMap<Key, Drawable>();
public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
public int mMostCommonKeyHeight = 0;
@@ -128,8 +124,6 @@ public class KeyboardParams {
mKeys.clear();
mShiftKeys.clear();
mShiftLockKeys.clear();
- mShiftedIcons.clear();
- mUnshiftedIcons.clear();
clearHistogram();
}
@@ -144,11 +138,6 @@ public class KeyboardParams {
}
}
- public void addShiftedIcon(Key key, Drawable icon) {
- mUnshiftedIcons.put(key, key.getIcon());
- mShiftedIcons.put(key, icon);
- }
-
private int mMaxHeightCount = 0;
private int mMaxWidthCount = 0;
private final Map<Integer, Integer> mHeightHistogram = new HashMap<Integer, Integer>();