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

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

Merge "Bug 5420741: exception when rotating device while suggestion popup is visible"

parents b9e78d96 26c8b3ae
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -8243,6 +8243,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            }

            hideControllers();
            if (mSuggestionsPopupWindow != null) {
                mSuggestionsPopupWindow.onParentLostFocus();
            }
        }

        startStopMarquee(hasWindowFocus);
@@ -9618,6 +9621,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        private SuggestionInfo[] mSuggestionInfos;
        private int mNumberOfSuggestions;
        private boolean mCursorWasVisibleBeforeSuggestions;
        private boolean mIsShowingUp = false;
        private SuggestionAdapter mSuggestionsAdapter;
        private final Comparator<SuggestionSpan> mSuggestionSpanComparator;
        private final HashMap<SuggestionSpan, Integer> mSpansLengths;
@@ -9673,6 +9677,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            }
        }

        public boolean isShowingUp() {
            return mIsShowingUp;
        }

        public void onParentLostFocus() {
            mIsShowingUp = false;
        }

        private class SuggestionInfo {
            int suggestionStart, suggestionEnd; // range of actual suggestion within text
            SuggestionSpan suggestionSpan; // the SuggestionSpan that this TextView represents
@@ -9776,6 +9788,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            updateSuggestions();
            mCursorWasVisibleBeforeSuggestions = mCursorVisible;
            setCursorVisible(false);
            mIsShowingUp = true;
            super.show();
        }

@@ -11188,6 +11201,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }

    private void hideCursorControllers() {
        if (mSuggestionsPopupWindow != null && !mSuggestionsPopupWindow.isShowingUp()) {
            // Should be done before hide insertion point controller since it triggers a show of it
            mSuggestionsPopupWindow.hide();
        }
        hideInsertionPointCursorController();
        stopSelectionActionMode();
    }