aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2013-01-21 14:41:33 +0900
committerTadashi G. Takaoka <takaoka@google.com>2013-01-21 15:28:17 +0900
commitd9449ccf3ce9e5eabb022aed6a45bba680bce115 (patch)
treeb1edcdc42e2005611f4cf7d9d262fd0dd09ac143 /java/src
parent00f8474c734d796faeea12f240e492983691222a (diff)
downloadlatinime-d9449ccf3ce9e5eabb022aed6a45bba680bce115.tar.gz
latinime-d9449ccf3ce9e5eabb022aed6a45bba680bce115.tar.xz
latinime-d9449ccf3ce9e5eabb022aed6a45bba680bce115.zip
Move MoreKeysPanel.Controller implementation to MainKeyboardView
Change-Id: Iffa298d51ca21a7dcd1e77c633217532d96d2cf5
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java46
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java96
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java14
3 files changed, 72 insertions, 84 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 7fc68e061..5f62be827 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -60,7 +60,6 @@ import java.util.HashSet;
* A view that renders a virtual {@link Keyboard}.
*
* @attr ref R.styleable#KeyboardView_keyBackground
- * @attr ref R.styleable#KeyboardView_moreKeysLayout
* @attr ref R.styleable#KeyboardView_keyPreviewLayout
* @attr ref R.styleable#KeyboardView_keyPreviewOffset
* @attr ref R.styleable#KeyboardView_keyPreviewHeight
@@ -103,8 +102,8 @@ import java.util.HashSet;
* @attr ref R.styleable#Keyboard_Key_keyShiftedLetterHintActivatedColor
* @attr ref R.styleable#Keyboard_Key_keyPreviewTextColor
*/
-public class KeyboardView extends View implements PointerTracker.DrawingProxy,
- MoreKeysPanel.Controller {
+// TODO: Move PointerTracker.DrawingProxy to MainKeyboardView
+public class KeyboardView extends View implements PointerTracker.DrawingProxy {
private static final String TAG = KeyboardView.class.getSimpleName();
// XML attributes
@@ -115,7 +114,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
private final float mKeyShiftedLetterHintPadding;
private final float mKeyTextShadowRadius;
protected final float mVerticalCorrection;
- protected final int mMoreKeysLayout;
protected final Drawable mKeyBackground;
protected final Rect mKeyBackgroundPadding = new Rect();
private final int mBackgroundDimAlpha;
@@ -136,13 +134,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
protected final KeyDrawParams mKeyDrawParams = new KeyDrawParams();
// Preview placer view
- private final PreviewPlacerView mPreviewPlacerView;
+ // TODO: Move PreviewPlacerView to MainKeyboardView
+ protected final PreviewPlacerView mPreviewPlacerView;
private final int[] mOriginCoords = CoordinateUtils.newInstance();
- // More keys panel (used by both more keys keyboard and more suggestions view)
- // TODO: Consider extending to support multiple more keys panels
- protected MoreKeysPanel mMoreKeysPanel;
-
// Key preview
private static final int PREVIEW_ALPHA = 240;
private final int mKeyPreviewLayoutId;
@@ -287,8 +282,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
}
mVerticalCorrection = keyboardViewAttr.getDimension(
R.styleable.KeyboardView_verticalCorrection, 0);
- mMoreKeysLayout = keyboardViewAttr.getResourceId(
- R.styleable.KeyboardView_moreKeysLayout, 0);
mBackgroundDimAlpha = keyboardViewAttr.getInt(
R.styleable.KeyboardView_backgroundDimAlpha, 0);
mGestureFloatingPreviewTextLingerTimeout = keyboardViewAttr.getInt(
@@ -1027,43 +1020,12 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy,
public void closing() {
dismissAllKeyPreviews();
cancelAllMessages();
- onCancelMoreKeysPanel();
mInvalidateAllKeys = true;
mKeyboard = null;
requestLayout();
}
@Override
- public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
- if (isShowingMoreKeysPanel()) {
- onDismissMoreKeysPanel();
- }
- mMoreKeysPanel = panel;
- mPreviewPlacerView.addView(mMoreKeysPanel.getContainerView());
- }
-
- public boolean isShowingMoreKeysPanel() {
- return (mMoreKeysPanel != null);
- }
-
- @Override
- public void onCancelMoreKeysPanel() {
- if (isShowingMoreKeysPanel()) {
- mMoreKeysPanel.dismissMoreKeysPanel();
- }
- }
-
- @Override
- public boolean onDismissMoreKeysPanel() {
- if (isShowingMoreKeysPanel()) {
- mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView());
- mMoreKeysPanel = null;
- return true;
- }
- return false;
- }
-
- @Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
closing();
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 625575d53..f8a5ea600 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -85,6 +85,7 @@ import java.util.WeakHashMap;
* @attr ref R.styleable#MainKeyboardView_longPressKeyTimeout
* @attr ref R.styleable#MainKeyboardView_longPressShiftKeyTimeout
* @attr ref R.styleable#MainKeyboardView_ignoreAltCodeKeyTimeout
+ * @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardLayout
* @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint
* @attr ref R.styleable#MainKeyboardView_gestureStaticTimeThresholdAfterFastTyping
* @attr ref R.styleable#MainKeyboardView_gestureDetectFastMoveSpeedThreshold
@@ -99,7 +100,7 @@ import java.util.WeakHashMap;
* @attr ref R.styleable#MainKeyboardView_suppressKeyPreviewAfterBatchInputDuration
*/
public final class MainKeyboardView extends KeyboardView implements PointerTracker.KeyEventHandler,
- TouchScreenRegulator.ProcessMotionEvent {
+ MoreKeysPanel.Controller, TouchScreenRegulator.ProcessMotionEvent {
private static final String TAG = MainKeyboardView.class.getSimpleName();
// TODO: Kill process when the usability study mode was changed.
@@ -137,11 +138,15 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
// More keys keyboard
private final WeakHashMap<Key, MoreKeysPanel> mMoreKeysPanelCache =
new WeakHashMap<Key, MoreKeysPanel>();
+ private final int mMoreKeysLayout;
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
+ // More keys panel (used by both more keys keyboard and more suggestions view)
+ // TODO: Consider extending to support multiple more keys panels
+ private MoreKeysPanel mMoreKeysPanel;
private final TouchScreenRegulator mTouchScreenRegulator;
- protected KeyDetector mKeyDetector;
+ private KeyDetector mKeyDetector;
private final boolean mHasDistinctMultitouch;
private int mOldPointerCount = 1;
private Key mOldKey;
@@ -402,38 +407,41 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
res, R.array.phantom_sudden_move_event_device_list));
PointerTracker.init(needsPhantomSuddenMoveEventHack);
- final TypedArray a = context.obtainStyledAttributes(
+ final TypedArray mainKeyboardViewAttr = context.obtainStyledAttributes(
attrs, R.styleable.MainKeyboardView, defStyle, R.style.MainKeyboardView);
- mAutoCorrectionSpacebarLedEnabled = a.getBoolean(
+ mAutoCorrectionSpacebarLedEnabled = mainKeyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_autoCorrectionSpacebarLedEnabled, false);
- mAutoCorrectionSpacebarLedIcon = a.getDrawable(
+ mAutoCorrectionSpacebarLedIcon = mainKeyboardViewAttr.getDrawable(
R.styleable.MainKeyboardView_autoCorrectionSpacebarLedIcon);
- mSpacebarTextRatio = a.getFraction(
+ mSpacebarTextRatio = mainKeyboardViewAttr.getFraction(
R.styleable.MainKeyboardView_spacebarTextRatio, 1, 1, 1.0f);
- mSpacebarTextColor = a.getColor(R.styleable.MainKeyboardView_spacebarTextColor, 0);
- mSpacebarTextShadowColor = a.getColor(
+ mSpacebarTextColor = mainKeyboardViewAttr.getColor(
+ R.styleable.MainKeyboardView_spacebarTextColor, 0);
+ mSpacebarTextShadowColor = mainKeyboardViewAttr.getColor(
R.styleable.MainKeyboardView_spacebarTextShadowColor, 0);
- mLanguageOnSpacebarFinalAlpha = a.getInt(
+ mLanguageOnSpacebarFinalAlpha = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_languageOnSpacebarFinalAlpha,
Constants.Color.ALPHA_OPAQUE);
- final int languageOnSpacebarFadeoutAnimatorResId = a.getResourceId(
+ final int languageOnSpacebarFadeoutAnimatorResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_languageOnSpacebarFadeoutAnimator, 0);
- final int altCodeKeyWhileTypingFadeoutAnimatorResId = a.getResourceId(
+ final int altCodeKeyWhileTypingFadeoutAnimatorResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeoutAnimator, 0);
- final int altCodeKeyWhileTypingFadeinAnimatorResId = a.getResourceId(
+ final int altCodeKeyWhileTypingFadeinAnimatorResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
- final float keyHysteresisDistance = a.getDimension(
+ final float keyHysteresisDistance = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_keyHysteresisDistance, 0);
- final float keyHysteresisDistanceForSlidingModifier = a.getDimension(
+ final float keyHysteresisDistanceForSlidingModifier = mainKeyboardViewAttr.getDimension(
R.styleable.MainKeyboardView_keyHysteresisDistanceForSlidingModifier, 0);
mKeyDetector = new KeyDetector(
keyHysteresisDistance, keyHysteresisDistanceForSlidingModifier);
- mKeyTimerHandler = new KeyTimerHandler(this, a);
- mConfigShowMoreKeysKeyboardAtTouchedPoint = a.getBoolean(
+ mKeyTimerHandler = new KeyTimerHandler(this, mainKeyboardViewAttr);
+ mMoreKeysLayout = mainKeyboardViewAttr.getResourceId(
+ R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
+ mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
- PointerTracker.setParameters(a);
- a.recycle();
+ PointerTracker.setParameters(mainKeyboardViewAttr);
+ mainKeyboardViewAttr.recycle();
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(
languageOnSpacebarFadeoutAnimatorResId, this);
@@ -591,8 +599,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
return onLongPress(parentKey, tracker);
}
- // This default implementation returns a more keys panel.
- protected MoreKeysPanel onCreateMoreKeysPanel(final Key parentKey) {
+ private MoreKeysPanel onCreateMoreKeysPanel(final Key parentKey) {
if (parentKey.mMoreKeys == null) {
return null;
}
@@ -613,14 +620,13 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
/**
- * Called when a key is long pressed. By default this will open more keys keyboard associated
- * with this key.
+ * Called when a key is long pressed.
* @param parentKey the key that was long pressed
* @param tracker the pointer tracker which pressed the parent key
* @return true if the long press is handled, false otherwise. Subclasses should call the
* method on the base class if the subclass doesn't wish to handle the call.
*/
- protected boolean onLongPress(final Key parentKey, final PointerTracker tracker) {
+ private boolean onLongPress(final Key parentKey, final PointerTracker tracker) {
if (ProductionFlag.IS_EXPERIMENTAL) {
ResearchLogger.mainKeyboardView_onLongPress();
}
@@ -697,6 +703,38 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
return PointerTracker.isAnyInSlidingKeyInput();
}
+ @Override
+ public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
+ if (isShowingMoreKeysPanel()) {
+ onDismissMoreKeysPanel();
+ }
+ mMoreKeysPanel = panel;
+ mPreviewPlacerView.addView(mMoreKeysPanel.getContainerView());
+ }
+
+ public boolean isShowingMoreKeysPanel() {
+ return (mMoreKeysPanel != null);
+ }
+
+ @Override
+ public void onCancelMoreKeysPanel() {
+ if (isShowingMoreKeysPanel()) {
+ mMoreKeysPanel.dismissMoreKeysPanel();
+ }
+ PointerTracker.dismissAllMoreKeysPanels();
+ }
+
+ @Override
+ public boolean onDismissMoreKeysPanel() {
+ dimEntireKeyboard(false /* dimmed */);
+ if (isShowingMoreKeysPanel()) {
+ mPreviewPlacerView.removeView(mMoreKeysPanel.getContainerView());
+ mMoreKeysPanel = null;
+ return true;
+ }
+ return false;
+ }
+
public int getPointerCount() {
return mOldPointerCount;
}
@@ -853,18 +891,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mMoreKeysPanelCache.clear();
}
- @Override
- public void onCancelMoreKeysPanel() {
- super.onCancelMoreKeysPanel();
- PointerTracker.dismissAllMoreKeysPanels();
- }
-
- @Override
- public boolean onDismissMoreKeysPanel() {
- dimEntireKeyboard(false /* dimmed */);
- return super.onDismissMoreKeysPanel();
- }
-
/**
* Receives hover events from the input framework.
*
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index 14bb95b3c..5b440c368 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -52,7 +52,7 @@ import android.widget.TextView;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
-import com.android.inputmethod.keyboard.KeyboardView;
+import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.keyboard.MoreKeysPanel;
import com.android.inputmethod.keyboard.ViewLayoutUtils;
import com.android.inputmethod.latin.AutoCorrection;
@@ -81,7 +81,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
static final boolean DBG = LatinImeLogger.sDBG;
private final ViewGroup mSuggestionsStrip;
- KeyboardView mKeyboardView;
+ MainKeyboardView mMainKeyboardView;
private final View mMoreSuggestionsContainer;
private final MoreSuggestionsView mMoreSuggestionsView;
@@ -610,7 +610,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
*/
public void setListener(final Listener listener, final View inputView) {
mListener = listener;
- mKeyboardView = (KeyboardView)inputView.findViewById(R.id.keyboard_view);
+ mMainKeyboardView = (MainKeyboardView)inputView.findViewById(R.id.keyboard_view);
}
public void setSuggestions(final SuggestedWords suggestedWords) {
@@ -676,13 +676,13 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
new MoreKeysPanel.Controller() {
@Override
public boolean onDismissMoreKeysPanel() {
- mKeyboardView.dimEntireKeyboard(false /* dimmed */);
- return mKeyboardView.onDismissMoreKeysPanel();
+ mMainKeyboardView.dimEntireKeyboard(false /* dimmed */);
+ return mMainKeyboardView.onDismissMoreKeysPanel();
}
@Override
public void onShowMoreKeysPanel(MoreKeysPanel panel) {
- mKeyboardView.onShowMoreKeysPanel(panel);
+ mMainKeyboardView.onShowMoreKeysPanel(panel);
}
@Override
@@ -728,7 +728,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
mOriginX = mLastX;
mOriginY = mLastY;
- mKeyboardView.dimEntireKeyboard(true /* dimmed */);
+ mMainKeyboardView.dimEntireKeyboard(true /* dimmed */);
for (int i = 0; i < params.mSuggestionsCountInStrip; i++) {
mWords.get(i).setPressed(false);
}