Merge "Longpressing in landscape correctly starts selection mode."

This commit is contained in:
Gilles Debunne
2011-09-08 11:18:36 -07:00
committed by Android (Google) Code Review

View File

@@ -5746,7 +5746,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
MetaKeyKeyListener.stopSelecting(this, sp); MetaKeyKeyListener.stopSelecting(this, sp);
} }
} }
/** /**
* @hide * @hide
*/ */
@@ -5754,10 +5754,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (mInputMethodState != null) { if (mInputMethodState != null) {
mInputMethodState.mExtracting = req; mInputMethodState.mExtracting = req;
} }
// This stops a possible text selection mode. Maybe not intended. // This would stop a possible selection mode, but no such mode is started in case
// extracted mode will start. Some text is selected though, and will trigger an action mode
// in the extracted view.
hideControllers(); hideControllers();
} }
/** /**
* Called by the framework in response to a text completion from * Called by the framework in response to a text completion from
* the current input method, provided by it calling * the current input method, provided by it calling
@@ -10013,14 +10015,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
} }
} }
ActionMode.Callback actionModeCallback = new SelectionActionModeCallback(); final InputMethodManager imm = InputMethodManager.peekInstance();
mSelectionActionMode = startActionMode(actionModeCallback); boolean extractedTextModeWillBeStartedFullScreen = !(this instanceof ExtractEditText) &&
final boolean selectionStarted = mSelectionActionMode != null; imm != null && imm.isFullscreenMode();
if (selectionStarted && !mTextIsSelectable) { // Do not start the action mode when extracted text will show up full screen, thus
// immediately hiding the newly created action bar, which would be visually distracting.
if (!extractedTextModeWillBeStartedFullScreen) {
ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
mSelectionActionMode = startActionMode(actionModeCallback);
}
final boolean selectionStarted = mSelectionActionMode != null ||
extractedTextModeWillBeStartedFullScreen;
if (selectionStarted && !mTextIsSelectable && imm != null) {
// Show the IME to be able to replace text, except when selecting non editable text. // Show the IME to be able to replace text, except when selecting non editable text.
final InputMethodManager imm = InputMethodManager.peekInstance(); imm.showSoftInput(this, 0, null);
if (imm != null) imm.showSoftInput(this, 0, null);
} }
return selectionStarted; return selectionStarted;