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

Commit 26c8b3ae authored by Gilles Debunne's avatar Gilles Debunne
Browse files

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

The suggestion popup window was not dismissed on orientation change.
This is triggered by onDetachedFromWindow.
However, this method is also called when the suggestion popup window
pops up. A new flag detects that case to dismiss the popup unless it
has expressly been asked to show up.

Still errors in the log after that change, I assume related to the window manager.

Change-Id: Ia515fc576ddf2127b2f9863cc2652aeb619fff6e
parent b10d396f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -8205,6 +8205,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            }

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

        startStopMarquee(hasWindowFocus);
@@ -9545,6 +9548,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;
@@ -9600,6 +9604,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
@@ -9703,6 +9715,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            updateSuggestions();
            mCursorWasVisibleBeforeSuggestions = mCursorVisible;
            setCursorVisible(false);
            mIsShowingUp = true;
            super.show();
        }

@@ -11113,6 +11126,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();
    }