Loading core/java/android/inputmethodservice/InputMethodService.java +28 −9 Original line number Diff line number Diff line Loading @@ -1820,6 +1820,17 @@ public class InputMethodService extends AbstractInputMethodService { return false; } /** * @return {#link ExtractEditText} if it is considered to be visible and active. Otherwise * {@code null} is returned. */ private ExtractEditText getExtractEditTextIfVisible() { if (!isExtractViewShown() || !isInputViewShown()) { return null; } return mExtractEditText; } /** * Override this to intercept key down events before they are processed by the * application. If you return true, the application will not Loading @@ -1835,6 +1846,10 @@ public class InputMethodService extends AbstractInputMethodService { */ public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { final ExtractEditText eet = getExtractEditTextIfVisible(); if (eet != null && eet.handleBackInTextActionModeIfNeeded(event)) { return true; } if (handleBack(false)) { event.startTracking(); return true; Loading Loading @@ -1882,11 +1897,15 @@ public class InputMethodService extends AbstractInputMethodService { * them to perform navigation in the underlying application. */ public boolean onKeyUp(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.isTracking() && !event.isCanceled()) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { final ExtractEditText eet = getExtractEditTextIfVisible(); if (eet != null && eet.handleBackInTextActionModeIfNeeded(event)) { return true; } if (event.isTracking() && !event.isCanceled()) { return handleBack(true); } } return doMovementKey(keyCode, event, MOVEMENT_UP); } Loading Loading @@ -1954,8 +1973,8 @@ public class InputMethodService extends AbstractInputMethodService { } boolean doMovementKey(int keyCode, KeyEvent event, int count) { final ExtractEditText eet = mExtractEditText; if (isExtractViewShown() && isInputViewShown() && eet != null) { final ExtractEditText eet = getExtractEditTextIfVisible(); if (eet != null) { // If we are in fullscreen mode, the cursor will move around // the extract edit text, but should NOT cause focus to move // to other fields. Loading core/java/android/widget/TextView.java +33 −21 Original line number Diff line number Diff line Loading @@ -5849,10 +5849,24 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @Override public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { boolean isInSelectionMode = mEditor != null && mEditor.mTextActionMode != null; // Note: If the IME is in fullscreen mode and IMS#mExtractEditText is in text action mode, // InputMethodService#onKeyDown and InputMethodService#onKeyUp are responsible to call // InputMethodService#mExtractEditText.maybeHandleBackInTextActionMode(event). if (keyCode == KeyEvent.KEYCODE_BACK && handleBackInTextActionModeIfNeeded(event)) { return true; } return super.onKeyPreIme(keyCode, event); } /** * @hide */ public boolean handleBackInTextActionModeIfNeeded(KeyEvent event) { // Do nothing unless mEditor is in text action mode. if (mEditor == null || mEditor.mTextActionMode == null) { return false; } if (isInSelectionMode) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { KeyEvent.DispatcherState state = getKeyDispatcherState(); if (state != null) { Loading @@ -5869,9 +5883,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return true; } } } } return super.onKeyPreIme(keyCode, event); return false; } @Override Loading Loading
core/java/android/inputmethodservice/InputMethodService.java +28 −9 Original line number Diff line number Diff line Loading @@ -1820,6 +1820,17 @@ public class InputMethodService extends AbstractInputMethodService { return false; } /** * @return {#link ExtractEditText} if it is considered to be visible and active. Otherwise * {@code null} is returned. */ private ExtractEditText getExtractEditTextIfVisible() { if (!isExtractViewShown() || !isInputViewShown()) { return null; } return mExtractEditText; } /** * Override this to intercept key down events before they are processed by the * application. If you return true, the application will not Loading @@ -1835,6 +1846,10 @@ public class InputMethodService extends AbstractInputMethodService { */ public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { final ExtractEditText eet = getExtractEditTextIfVisible(); if (eet != null && eet.handleBackInTextActionModeIfNeeded(event)) { return true; } if (handleBack(false)) { event.startTracking(); return true; Loading Loading @@ -1882,11 +1897,15 @@ public class InputMethodService extends AbstractInputMethodService { * them to perform navigation in the underlying application. */ public boolean onKeyUp(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.isTracking() && !event.isCanceled()) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { final ExtractEditText eet = getExtractEditTextIfVisible(); if (eet != null && eet.handleBackInTextActionModeIfNeeded(event)) { return true; } if (event.isTracking() && !event.isCanceled()) { return handleBack(true); } } return doMovementKey(keyCode, event, MOVEMENT_UP); } Loading Loading @@ -1954,8 +1973,8 @@ public class InputMethodService extends AbstractInputMethodService { } boolean doMovementKey(int keyCode, KeyEvent event, int count) { final ExtractEditText eet = mExtractEditText; if (isExtractViewShown() && isInputViewShown() && eet != null) { final ExtractEditText eet = getExtractEditTextIfVisible(); if (eet != null) { // If we are in fullscreen mode, the cursor will move around // the extract edit text, but should NOT cause focus to move // to other fields. Loading
core/java/android/widget/TextView.java +33 −21 Original line number Diff line number Diff line Loading @@ -5849,10 +5849,24 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener @Override public boolean onKeyPreIme(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { boolean isInSelectionMode = mEditor != null && mEditor.mTextActionMode != null; // Note: If the IME is in fullscreen mode and IMS#mExtractEditText is in text action mode, // InputMethodService#onKeyDown and InputMethodService#onKeyUp are responsible to call // InputMethodService#mExtractEditText.maybeHandleBackInTextActionMode(event). if (keyCode == KeyEvent.KEYCODE_BACK && handleBackInTextActionModeIfNeeded(event)) { return true; } return super.onKeyPreIme(keyCode, event); } /** * @hide */ public boolean handleBackInTextActionModeIfNeeded(KeyEvent event) { // Do nothing unless mEditor is in text action mode. if (mEditor == null || mEditor.mTextActionMode == null) { return false; } if (isInSelectionMode) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { KeyEvent.DispatcherState state = getKeyDispatcherState(); if (state != null) { Loading @@ -5869,9 +5883,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return true; } } } } return super.onKeyPreIme(keyCode, event); return false; } @Override Loading