Merge "Move Key class out of internal package"

main
Tadashi G. Takaoka 2011-06-23 07:22:58 -07:00 committed by Android (Google) Code Review
commit 35bda743ed
18 changed files with 36 additions and 34 deletions

View File

@ -27,10 +27,10 @@ import android.view.accessibility.AccessibilityEvent;
import com.android.inputmethod.compat.AccessibilityEventCompatUtils; import com.android.inputmethod.compat.AccessibilityEventCompatUtils;
import com.android.inputmethod.compat.MotionEventCompatUtils; import com.android.inputmethod.compat.MotionEventCompatUtils;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.PointerTracker; import com.android.inputmethod.keyboard.PointerTracker;
import com.android.inputmethod.keyboard.internal.Key;
public class AccessibleKeyboardViewProxy { public class AccessibleKeyboardViewProxy {
private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName(); private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName();

View File

@ -20,9 +20,9 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import java.util.HashMap; import java.util.HashMap;

View File

@ -14,7 +14,7 @@
* the License. * the License.
*/ */
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
@ -23,7 +23,11 @@ import android.graphics.drawable.Drawable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Xml; import android.util.Xml;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.internal.KeyStyles;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParser;
import com.android.inputmethod.keyboard.internal.PopupCharactersParser;
import com.android.inputmethod.keyboard.internal.Row;
import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle; import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle;
import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException; import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
@ -97,11 +101,11 @@ public class Key {
private final Keyboard mKeyboard; private final Keyboard mKeyboard;
/** The current pressed state of this key */ /** The current pressed state of this key */
public boolean mPressed; private boolean mPressed;
/** If this is a sticky key, is its highlight on? */ /** If this is a sticky key, is its highlight on? */
public boolean mHighlightOn; private boolean mHighlightOn;
/** Key is enabled and responds on press */ /** Key is enabled and responds on press */
public boolean mEnabled = true; private boolean mEnabled = true;
// keyWidth constants // keyWidth constants
private static final int KEYWIDTH_FILL_RIGHT = 0; private static final int KEYWIDTH_FILL_RIGHT = 0;
@ -377,6 +381,18 @@ public class Key {
mPressed = false; mPressed = false;
} }
public void setHighlightOn(boolean highlightOn) {
mHighlightOn = highlightOn;
}
public boolean isEnabled() {
return mEnabled;
}
public void setEnabled(boolean enabled) {
mEnabled = enabled;
}
/** /**
* Detects if a point falls on this key. * Detects if a point falls on this key.
* @param x the x-coordinate of the point * @param x the x-coordinate of the point

View File

@ -18,8 +18,6 @@ package com.android.inputmethod.keyboard;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.keyboard.internal.Key;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View File

@ -21,7 +21,6 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParser; import com.android.inputmethod.keyboard.internal.KeyboardParser;
import com.android.inputmethod.keyboard.internal.KeyboardShiftState; import com.android.inputmethod.keyboard.internal.KeyboardShiftState;
@ -297,7 +296,7 @@ public class Keyboard {
public boolean setShiftLocked(boolean newShiftLockState) { public boolean setShiftLocked(boolean newShiftLockState) {
final Map<Key, Drawable> shiftedIcons = getShiftedIcons(); final Map<Key, Drawable> shiftedIcons = getShiftedIcons();
for (final Key key : getShiftKeys()) { for (final Key key : getShiftKeys()) {
key.mHighlightOn = newShiftLockState; key.setHighlightOn(newShiftLockState);
key.setIcon(newShiftLockState ? shiftedIcons.get(key) : mNormalShiftIcons.get(key)); key.setIcon(newShiftLockState ? shiftedIcons.get(key) : mNormalShiftIcons.get(key));
} }
mShiftState.setShiftLocked(newShiftLockState); mShiftState.setShiftLocked(newShiftLockState);

View File

@ -28,7 +28,6 @@ import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.ModifierKeyState; import com.android.inputmethod.keyboard.internal.ModifierKeyState;
import com.android.inputmethod.keyboard.internal.ShiftKeyState; import com.android.inputmethod.keyboard.internal.ShiftKeyState;
import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinIME;

View File

@ -49,7 +49,6 @@ import android.widget.TextView;
import com.android.inputmethod.accessibility.AccessibilityUtils; import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.compat.FrameLayoutCompatUtils; import com.android.inputmethod.compat.FrameLayoutCompatUtils;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.MiniKeyboardBuilder; import com.android.inputmethod.keyboard.internal.MiniKeyboardBuilder;
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.keyboard.internal.SwipeTracker; import com.android.inputmethod.keyboard.internal.SwipeTracker;
@ -744,7 +743,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
} else { } else {
paint.setColor(mKeyTextColor); paint.setColor(mKeyTextColor);
} }
if (key.mEnabled) { if (key.isEnabled()) {
// Set a drop shadow for the text // Set a drop shadow for the text
paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor); paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
} else { } else {

View File

@ -33,7 +33,6 @@ import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.SlidingLocaleDrawable; import com.android.inputmethod.keyboard.internal.SlidingLocaleDrawable;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
@ -175,7 +174,7 @@ public class LatinKeyboard extends Keyboard {
public void updateShortcutKey(boolean available, LatinKeyboardView view) { public void updateShortcutKey(boolean available, LatinKeyboardView view) {
if (mShortcutKey == null) if (mShortcutKey == null)
return; return;
mShortcutKey.mEnabled = available; mShortcutKey.setEnabled(available);
mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon); mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon);
if (view != null) if (view != null)
view.invalidateKey(mShortcutKey); view.invalidateKey(mShortcutKey);

View File

@ -24,7 +24,6 @@ import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import com.android.inputmethod.deprecated.VoiceProxy; import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils;

View File

@ -18,8 +18,6 @@ package com.android.inputmethod.keyboard;
import android.content.Context; import android.content.Context;
import com.android.inputmethod.keyboard.internal.Key;
import java.util.List; import java.util.List;
public class MiniKeyboard extends Keyboard { public class MiniKeyboard extends Keyboard {

View File

@ -16,8 +16,6 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import com.android.inputmethod.keyboard.internal.Key;
import java.util.List; import java.util.List;
public class MiniKeyboardKeyDetector extends KeyDetector { public class MiniKeyboardKeyDetector extends KeyDetector {

View File

@ -22,7 +22,6 @@ import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import com.android.inputmethod.keyboard.KeyboardView.UIHandler; import com.android.inputmethod.keyboard.KeyboardView.UIHandler;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.PointerTrackerKeyState; import com.android.inputmethod.keyboard.internal.PointerTrackerKeyState;
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
@ -150,7 +149,7 @@ public class PointerTracker {
+ " ignoreModifier=" + ignoreModifierKey); + " ignoreModifier=" + ignoreModifierKey);
if (ignoreModifierKey) if (ignoreModifierKey)
return false; return false;
if (key.mEnabled) { if (key.isEnabled()) {
mListener.onPress(key.mCode, withSliding); mListener.onPress(key.mCode, withSliding);
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged; final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
mKeyboardLayoutHasBeenChanged = false; mKeyboardLayoutHasBeenChanged = false;
@ -169,14 +168,14 @@ public class PointerTracker {
+ " ignoreModifier=" + ignoreModifierKey); + " ignoreModifier=" + ignoreModifierKey);
if (ignoreModifierKey) if (ignoreModifierKey)
return; return;
if (key.mEnabled) if (key.isEnabled())
mListener.onCodeInput(primaryCode, keyCodes, x, y); mListener.onCodeInput(primaryCode, keyCodes, x, y);
} }
private void callListenerOnTextInput(Key key) { private void callListenerOnTextInput(Key key) {
if (DEBUG_LISTENER) if (DEBUG_LISTENER)
Log.d(TAG, "onTextInput: text=" + key.mOutputText); Log.d(TAG, "onTextInput: text=" + key.mOutputText);
if (key.mEnabled) if (key.isEnabled())
mListener.onTextInput(key.mOutputText); mListener.onTextInput(key.mOutputText);
} }
@ -189,7 +188,7 @@ public class PointerTracker {
+ withSliding + " ignoreModifier=" + ignoreModifierKey); + withSliding + " ignoreModifier=" + ignoreModifierKey);
if (ignoreModifierKey) if (ignoreModifierKey)
return; return;
if (key.mEnabled) if (key.isEnabled())
mListener.onRelease(primaryCode, withSliding); mListener.onRelease(primaryCode, withSliding);
} }
@ -269,7 +268,7 @@ public class PointerTracker {
private void setPressedKeyGraphics(int keyIndex) { private void setPressedKeyGraphics(int keyIndex) {
final Key key = getKey(keyIndex); final Key key = getKey(keyIndex);
if (key != null && key.mEnabled) { if (key != null && key.isEnabled()) {
key.onPressed(); key.onPressed();
mProxy.invalidateKey(key); mProxy.invalidateKey(key);
} }
@ -618,7 +617,7 @@ public class PointerTracker {
// The modifier key, such as shift key, should not show its key preview. // The modifier key, such as shift key, should not show its key preview.
private boolean isKeyPreviewNotRequired(int keyIndex) { private boolean isKeyPreviewNotRequired(int keyIndex) {
final Key key = getKey(keyIndex); final Key key = getKey(keyIndex);
if (key == null || !key.mEnabled) if (key == null || !key.isEnabled())
return true; return true;
// Such as spacebar sliding language switch. // Such as spacebar sliding language switch.
if (mKeyboard.needSpacebarPreview(keyIndex)) if (mKeyboard.needSpacebarPreview(keyIndex))

View File

@ -25,7 +25,6 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
/** /**

View File

@ -19,8 +19,6 @@ package com.android.inputmethod.keyboard;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import com.android.inputmethod.keyboard.internal.Key;
public interface PopupPanel { public interface PopupPanel {
/** /**
* Show popup panel. * Show popup panel.

View File

@ -16,7 +16,6 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils;
import java.util.Arrays; import java.util.Arrays;

View File

@ -26,6 +26,7 @@ import android.util.Xml;
import android.view.InflateException; import android.view.InflateException;
import com.android.inputmethod.compat.EditorInfoCompatUtils; import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
@ -331,7 +332,7 @@ public class KeyboardParser {
} else { } else {
Key key = new Key(mResources, row, mCurrentX, mCurrentY, parser, mKeyStyles); Key key = new Key(mResources, row, mCurrentX, mCurrentY, parser, mKeyStyles);
if (DEBUG) Log.d(TAG, String.format("<%s%s keyLabel=%s code=%d popupCharacters=%s />", if (DEBUG) Log.d(TAG, String.format("<%s%s keyLabel=%s code=%d popupCharacters=%s />",
TAG_KEY, (key.mEnabled ? "" : " disabled"), key.mLabel, key.mCode, TAG_KEY, (key.isEnabled() ? "" : " disabled"), key.mLabel, key.mCode,
Arrays.toString(key.mPopupCharacters))); Arrays.toString(key.mPopupCharacters)));
checkEndTag(TAG_KEY, parser); checkEndTag(TAG_KEY, parser);
keys.add(key); keys.add(key);

View File

@ -21,6 +21,7 @@ import android.content.res.Resources;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.MiniKeyboard; import com.android.inputmethod.keyboard.MiniKeyboard;

View File

@ -16,10 +16,10 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.LatinKeyboard; import com.android.inputmethod.keyboard.LatinKeyboard;
import com.android.inputmethod.keyboard.internal.Key;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;