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
main
Tadashi G. Takaoka 2011-12-18 08:00:07 +09:00
parent 1ebedd7a15
commit 7bd714c086
15 changed files with 56 additions and 93 deletions

View File

@ -124,7 +124,6 @@
</declare-styleable>
<declare-styleable name="LatinKeyboardView">
<attr name="disabledShortcutIcon" format="reference" />
</declare-styleable>
<declare-styleable name="SuggestionsView">
@ -185,7 +184,9 @@
<attr name="iconTabKey" format="reference" />
<attr name="iconShortcutKey" format="reference" />
<attr name="iconShortcutForLabel" format="reference" />
<attr name="iconShiftedShiftKey" format="reference" />
<attr name="iconSpaceKeyForNumberLayout" format="reference" />
<attr name="iconShortcutKeyDisabled" format="reference" />
<attr name="iconShiftKeyShifted" format="reference" />
<attr name="iconPreviewTabKey" format="reference" />
</declare-styleable>
@ -248,16 +249,14 @@
<enum name="iconTabKey" value="7" />
<enum name="iconShortcutKey" value="8" />
<enum name="iconShortcutForLabel" value="9" />
</attr>
<!-- Shift key icon for shifted state -->
<attr name="keyIconShifted" format="enum">
<!-- This should be aligned with KeyboardIcons.ICON_SHIFTED_* -->
<enum name="iconShiftedShiftKey" value="10" />
<enum name="iconShortcutKeyDisabled" value="10" />
<enum name="iconSpaceKeyForNumberLayout" value="11" />
<enum name="iconShiftKeyShifted" value="12" />
</attr>
<!-- The icon to show in the popup preview. -->
<attr name="keyIconPreview" format="enum">
<!-- This should be aligned with KeyboardIcons.ICON_PREVIEW_* -->
<enum name="iconPreviewTabKey" value="11" />
<enum name="iconPreviewTabKey" value="13" />
</attr>
<!-- The key style to specify a set of key attributes defined by <key_style/> -->
<attr name="keyStyle" format="string" />

View File

@ -30,10 +30,9 @@
<item name="iconTabKey">@drawable/sym_bkeyboard_tab</item>
<item name="iconShortcutKey">@drawable/sym_bkeyboard_mic</item>
<item name="iconShortcutForLabel">@drawable/sym_bkeyboard_label_mic</item>
<item name="iconShiftedShiftKey">@drawable/sym_bkeyboard_shift_locked</item>
<item name="iconShortcutKeyDisabled">@drawable/sym_bkeyboard_voice_off</item>
<item name="iconSpaceKeyForNumberLayout">@drawable/sym_bkeyboard_space</item>
<item name="iconShiftKeyShifted">@drawable/sym_bkeyboard_shift_locked</item>
<item name="iconPreviewTabKey">@drawable/sym_keyboard_feedback_tab</item>
<!-- LatinKeyboard icons -->
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item>
<item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item>
</style>
</resources>

View File

@ -23,16 +23,15 @@
<item name="iconShiftKey">@drawable/sym_keyboard_shift_holo</item>
<item name="iconDeleteKey">@drawable/sym_keyboard_delete_holo</item>
<item name="iconSettingsKey">@drawable/sym_keyboard_settings_holo</item>
<item name="iconSpaceKey">@drawable/sym_keyboard_space_holo</item>
<item name="iconSpaceKey">@null</item>
<item name="iconReturnKey">@drawable/sym_keyboard_return_holo</item>
<item name="iconSearchKey">@drawable/sym_keyboard_search_holo</item>
<item name="iconTabKey">@drawable/sym_keyboard_tab_holo</item>
<item name="iconShortcutKey">@drawable/sym_keyboard_voice_holo</item>
<item name="iconShortcutForLabel">@drawable/sym_keyboard_label_mic_holo</item>
<item name="iconShiftedShiftKey">@drawable/sym_keyboard_shift_locked_holo</item>
<item name="iconShortcutKeyDisabled">@drawable/sym_keyboard_voice_off_holo</item>
<item name="iconSpaceKeyForNumberLayout">@drawable/sym_keyboard_space_holo</item>
<item name="iconShiftKeyShifted">@drawable/sym_keyboard_shift_locked_holo</item>
<item name="iconPreviewTabKey">@drawable/sym_keyboard_feedback_tab</item>
<!-- LatinKeyboard icons -->
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
</resources>

View File

@ -26,10 +26,10 @@
<item name="iconTabKey">@drawable/sym_keyboard_tab</item>
<item name="iconShortcutKey">@drawable/sym_keyboard_mic</item>
<item name="iconShortcutForLabel">@drawable/sym_keyboard_label_mic</item>
<item name="iconShiftedShiftKey">@drawable/sym_keyboard_shift_locked</item>
<!-- TODO: Needs non-holo disabled shortcut icon drawable -->
<item name="iconShortcutKeyDisabled">@drawable/sym_keyboard_voice_off_holo</item>
<item name="iconSpaceKeyForNumberLayout">@drawable/sym_keyboard_space</item>
<item name="iconShiftKeyShifted">@drawable/sym_keyboard_shift_locked</item>
<item name="iconPreviewTabKey">@drawable/sym_keyboard_feedback_tab</item>
<!-- LatinKeyboard icons -->
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item>
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
</resources>

View File

@ -33,6 +33,7 @@
</style>
<style name="LatinKeyboard">
<item name="autoCorrectionSpacebarLedEnabled">true</item>
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item>
<item name="spacebarTextRatio">@fraction/spacebar_text_ratio</item>
<item name="spacebarTextColor">#FFC0C0C0</item>
<item name="spacebarTextShadowColor">#80000000</item>
@ -74,8 +75,6 @@
<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"
@ -144,8 +143,6 @@
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
@ -183,7 +180,6 @@
name="LatinKeyboardView.Stone"
parent="KeyboardView.Stone"
>
<item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item>
</style>
<style
name="MiniKeyboard.Stone"
@ -218,7 +214,6 @@
name="LatinKeyboardView.Stone.Bold"
parent="KeyboardView.Stone.Bold"
>
<item name="disabledShortcutIcon">@drawable/sym_bkeyboard_voice_off</item>
</style>
<!-- Theme "Gingerbread" -->
<style
@ -242,8 +237,6 @@
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"
@ -276,6 +269,7 @@
parent="LatinKeyboard"
>
<item name="autoCorrectionSpacebarLedEnabled">false</item>
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
</style>
<style
name="KeyboardView.IceCreamSandwich"
@ -304,7 +298,6 @@
name="LatinKeyboardView.IceCreamSandwich"
parent="KeyboardView.IceCreamSandwich"
>
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
<style
name="MiniKeyboard.IceCreamSandwich"

View File

@ -43,7 +43,6 @@
latin:styleName="shiftKeyStyle"
latin:code="@integer/key_shift"
latin:keyIcon="iconShiftKey"
latin:keyIconShifted="iconShiftedShiftKey"
latin:keyActionFlags="noKeyPreview"
latin:backgroundType="sticky" />
<key-style

View File

@ -25,7 +25,6 @@
latin:styleName="shiftKeyStyle"
latin:code="@integer/key_shift"
latin:keyIcon="iconShiftKey"
latin:keyIconShifted="iconShiftedShiftKey"
latin:keyActionFlags="noKeyPreview"
latin:backgroundType="sticky" />
<key-style

View File

@ -66,7 +66,6 @@
latin:styleName="shiftKeyStyle"
latin:code="@integer/key_shift"
latin:keyIcon="iconShiftKey"
latin:keyIconShifted="iconShiftedShiftKey"
latin:keyActionFlags="noKeyPreview"
latin:backgroundType="sticky" />
<key-style

View File

@ -124,6 +124,6 @@
<key-style
latin:styleName="numSpaceKeyStyle"
latin:code="@integer/key_space"
latin:keyIcon="iconSpaceKey"
latin:keyIcon="iconSpaceKeyForNumberLayout"
latin:parentStyle="numKeyBaseStyle" />
</merge>

View File

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

View File

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

View File

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

View File

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

View File

@ -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:

View File

@ -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>();