Do not show selection action mode when the TextView is not shown.

OnPreDraw is called even if the View is not visible.
So need to check isShown() and hasWindowFocus() before calling
starting selection action mode.

This hack is originally introduced for keeping selection on device rotation.
I manually verified this issue does not revive with this CL.

Bug: 22036870
Change-Id: I814db6165e2345fcacedcbd399c1a3985501c8fd
This commit is contained in:
Seigo Nonaka
2015-06-25 22:27:12 +09:00
parent d4d802be39
commit 145252f840

View File

@@ -5231,7 +5231,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// ExtractEditText does not call onFocus when it is displayed, and mHasSelectionOnFocus can
// not be set. Do the test here instead.
if (isInExtractedMode() && hasSelection() && mEditor != null
&& mEditor.mTextActionMode == null) {
&& mEditor.mTextActionMode == null && isShown() && hasWindowFocus()) {
mEditor.startSelectionActionMode();
}