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

Commit 8c8293bc authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 3064135 - do not allow text handles on TextViews in sub windows.

Change-Id: I35db64d0a5c92c8ad184b36d243e45c91d4ac46e
parent 844a6b3c
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.view.ViewRoot;
@@ -6852,8 +6853,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    private void prepareCursorControllers() {
        boolean windowSupportsHandles = false;

        ViewGroup.LayoutParams params = getRootView().getLayoutParams();
        if (params instanceof WindowManager.LayoutParams) {
            WindowManager.LayoutParams windowParams = (WindowManager.LayoutParams) params;
            windowSupportsHandles = windowParams.type < WindowManager.LayoutParams.FIRST_SUB_WINDOW
                    || windowParams.type > WindowManager.LayoutParams.LAST_SUB_WINDOW;
        }

        // TODO Add an extra android:cursorController flag to disable the controller?
        if (mCursorVisible && mLayout != null) {
        if (windowSupportsHandles && mCursorVisible && mLayout != null) {
            if (mInsertionPointCursorController == null) {
                mInsertionPointCursorController = new InsertionPointCursorController();
            }
@@ -6861,7 +6871,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            mInsertionPointCursorController = null;
        }

        if (textCanBeSelected() && mLayout != null) {
        if (windowSupportsHandles && textCanBeSelected() && mLayout != null) {
            if (mSelectionModifierCursorController == null) {
                mSelectionModifierCursorController = new SelectionModifierCursorController();
            }