aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/InputView.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2013-12-16 18:02:58 +0900
committerTadashi G. Takaoka <takaoka@google.com>2013-12-17 12:59:37 +0900
commit19dd753c0ccaea8dee71eeae7edc724c58c6f024 (patch)
tree3b53bea2589a0dec6eb0bfe65c08285b5325a816 /java/src/com/android/inputmethod/latin/InputView.java
parentdd4937848a314ab18f665299cf32084bcc55d166 (diff)
downloadlatinime-19dd753c0ccaea8dee71eeae7edc724c58c6f024.tar.gz
latinime-19dd753c0ccaea8dee71eeae7edc724c58c6f024.tar.xz
latinime-19dd753c0ccaea8dee71eeae7edc724c58c6f024.zip
Cancel more suggestions panel when touching keyboard
Bug: 10010128 Change-Id: I2ff0870c69f407d943caf8b9cec90b7ed89de5f1
Diffstat (limited to 'java/src/com/android/inputmethod/latin/InputView.java')
-rw-r--r--java/src/com/android/inputmethod/latin/InputView.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/InputView.java b/java/src/com/android/inputmethod/latin/InputView.java
index e711a3f9d..76b0912f6 100644
--- a/java/src/com/android/inputmethod/latin/InputView.java
+++ b/java/src/com/android/inputmethod/latin/InputView.java
@@ -24,11 +24,13 @@ import android.view.View;
import android.widget.LinearLayout;
import com.android.inputmethod.keyboard.MainKeyboardView;
+import com.android.inputmethod.latin.suggestions.MoreSuggestionsView;
import com.android.inputmethod.latin.suggestions.SuggestionStripView;
public final class InputView extends LinearLayout {
private final Rect mInputViewRect = new Rect();
private KeyboardTopPaddingForwarder mKeyboardTopPaddingForwarder;
+ private MoreSuggestionsViewCanceler mMoreSuggestionsViewCanceler;
public InputView(final Context context, final AttributeSet attrs) {
super(context, attrs, 0);
@@ -42,6 +44,8 @@ public final class InputView extends LinearLayout {
(MainKeyboardView)findViewById(R.id.keyboard_view);
mKeyboardTopPaddingForwarder = new KeyboardTopPaddingForwarder(
mainKeyboardView, suggestionStripView);
+ mMoreSuggestionsViewCanceler = new MoreSuggestionsViewCanceler(
+ mainKeyboardView, suggestionStripView);
}
public void setKeyboardTopPadding(final int keyboardTopPadding) {
@@ -60,6 +64,11 @@ public final class InputView extends LinearLayout {
if (mKeyboardTopPaddingForwarder.dispatchTouchEvent(x, y, me)) {
return true;
}
+ // To cancel {@link MoreSuggestionsView}, we should intercept a touch event to
+ // {@link MainKeyboardView} and dismiss the {@link MoreSuggestionsView}.
+ if (mMoreSuggestionsViewCanceler.dispatchTouchEvent(x, y, me)) {
+ return true;
+ }
return super.dispatchTouchEvent(me);
}
@@ -97,6 +106,9 @@ public final class InputView extends LinearLayout {
return y - mEventReceivingRect.top;
}
+ // Callback when a {@link MotionEvent} is forwarded.
+ protected void onForwardingEvent(final MotionEvent me) {}
+
// Dispatches a {@link MotioneEvent} to <code>Receiver</code> if needed and returns true.
// Otherwise returns false.
public boolean dispatchTouchEvent(final int x, final int y, final MotionEvent me) {
@@ -142,6 +154,7 @@ public final class InputView extends LinearLayout {
// Translate global coordinates to <code>Receiver</code> local coordinates.
me.setLocation(translateX(x), translateY(y));
mReceiverView.dispatchTouchEvent(me);
+ onForwardingEvent(me);
return true;
}
}
@@ -183,4 +196,30 @@ public final class InputView extends LinearLayout {
return translatedY;
}
}
+
+ /**
+ * This class forwards {@link MotionEvent}s happened in the {@link MainKeyboardView} to
+ * {@link SuggestionStripView} when the {@link MoreSuggestionsView} is showing.
+ * {@link SuggestionStripView} dismisses {@link MoreSuggestionsView} when it receives those
+ * events.
+ */
+ private static class MoreSuggestionsViewCanceler
+ extends MotionEventForwarder<MainKeyboardView, SuggestionStripView> {
+ public MoreSuggestionsViewCanceler(final MainKeyboardView mainKeyboardView,
+ final SuggestionStripView suggestionStripView) {
+ super(mainKeyboardView, suggestionStripView);
+ }
+
+ @Override
+ protected boolean needsToForward(final int x, final int y) {
+ return mReceiverView.isShowingMoreSuggestionPanel() && mEventSendingRect.contains(x, y);
+ }
+
+ @Override
+ protected void onForwardingEvent(final MotionEvent me) {
+ if (me.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ mReceiverView.dismissMoreSuggestionsPanel();
+ }
+ }
+ }
}