diff options
Diffstat (limited to 'java/src/com/android/inputmethod')
3 files changed, 38 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 843185181..b467a32a2 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -35,7 +35,6 @@ import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.text.InputType; import android.text.TextUtils; -import android.util.DisplayMetrics; import android.util.Log; import android.util.PrintWriterPrinter; import android.util.Printer; @@ -1011,8 +1010,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: - if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getKeyboardView() != null) { - if (mKeyboardSwitcher.getKeyboardView().handleBack()) { + if (event.getRepeatCount() == 0) { + if (mSuggestionsView != null && mSuggestionsView.handleBack()) { + return true; + } + final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView(); + if (keyboardView != null && keyboardView.handleBack()) { return true; } } diff --git a/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java index f595510a3..695e60ffd 100644 --- a/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java @@ -67,7 +67,10 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel { @Override public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) { - mListener.onCustomRequest(primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE); + final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE; + if (index >= 0 && index < SuggestionsView.MAX_SUGGESTIONS) { + mListener.onCustomRequest(index); + } } @Override @@ -142,6 +145,13 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel { // Nothing to do with. } + private final View.OnTouchListener mMotionEventDelegate = new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent me) { + return MoreSuggestionsView.this.dispatchTouchEvent(me); + } + }; + @Override public void showMoreKeysPanel(View parentView, Controller controller, int pointX, int pointY, PopupWindow window, KeyboardActionListener listener) { @@ -160,6 +170,10 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel { - (container.getMeasuredHeight() - container.getPaddingBottom()) + parentView.getPaddingTop() + mCoordinates[1]; + container.setOnTouchListener(mMotionEventDelegate); + window.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); + window.setFocusable(true); + window.setOutsideTouchable(true); window.setContentView(container); window.setWidth(container.getMeasuredWidth()); window.setHeight(container.getMeasuredHeight()); @@ -215,6 +229,19 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel { }; @Override + public boolean dispatchTouchEvent(MotionEvent me) { + final int x = (int)me.getX(); + final int y = (int)me.getY(); + final boolean inside = (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()); + if (inside) { + return super.dispatchTouchEvent(me); + } else { + dismissMoreKeysPanel(); + return true; + } + } + + @Override public boolean onTouchEvent(MotionEvent me) { final int action = me.getAction(); final long eventTime = me.getEventTime(); diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java index 6879f7660..380e73bc0 100644 --- a/java/src/com/android/inputmethod/latin/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java @@ -728,6 +728,10 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, return false; } + public boolean handleBack() { + return dismissMoreSuggestions(); + } + @Override public boolean onLongClick(View view) { final SuggestionsViewParams params = mParams; |