Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5504ba1 authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "Visual glitches when starting extracted text" into ics-mr1

parents b5dbf66c 61ddbbae
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.ExtractEditText;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -101,7 +100,6 @@ import android.util.Log;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ActionMode.Callback;
import android.view.ContextMenu;
import android.view.DragEvent;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
@@ -8357,12 +8355,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        // When the cursor moves, the word that was typed may need spell check
                        mSpellChecker.onSelectionChanged();
                    }
                    if (!extractedTextModeWillBeStarted()) {
                        if (isCursorInsideEasyCorrectionSpan()) {
                            showSuggestions();
                        } else if (hasInsertionController()) {
                            getInsertionController().show();
                        }
                    }
                }

                handled = true;
            }
@@ -10112,27 +10112,35 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            }
        }

        final InputMethodManager imm = InputMethodManager.peekInstance();
        boolean extractedTextModeWillBeStartedFullScreen = !(this instanceof ExtractEditText) &&
                imm != null && imm.isFullscreenMode();
        boolean willExtract = extractedTextModeWillBeStarted();

        // 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) {
        if (!willExtract) {
            ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
            mSelectionActionMode = startActionMode(actionModeCallback);
        }
        final boolean selectionStarted = mSelectionActionMode != null ||
                extractedTextModeWillBeStartedFullScreen;

        if (selectionStarted && !mTextIsSelectable && imm != null && mSoftInputShownOnFocus) {
        final boolean selectionStarted = mSelectionActionMode != null || willExtract;
        if (selectionStarted && !mTextIsSelectable && mSoftInputShownOnFocus) {
            // Show the IME to be able to replace text, except when selecting non editable text.
            final InputMethodManager imm = InputMethodManager.peekInstance();
            if (imm != null) {
                imm.showSoftInput(this, 0, null);
            }
        }

        return selectionStarted;
    }

    private boolean extractedTextModeWillBeStarted() {
        if (!(this instanceof ExtractEditText)) {
            final InputMethodManager imm = InputMethodManager.peekInstance();
            return  imm != null && imm.isFullscreenMode();
        }
        return false;
    }

    private void stopSelectionActionMode() {
        if (mSelectionActionMode != null) {
            // This will hide the mSelectionModifierCursorController