From 14503e270c7efbee4c766d1e805865f1d415ec05 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Wed, 9 Mar 2016 14:01:24 -0800 Subject: [PATCH] Fix clobbered RemoteInputView when changing position Bug: 27357771 Change-Id: If6e5c943ce8939d343fd989bfed20b1b657c9c5d --- .../systemui/statusbar/ExpandableView.java | 9 +++++++++ .../statusbar/policy/RemoteInputView.java | 16 ++++++++++++++++ .../stack/NotificationStackScrollLayout.java | 2 ++ 3 files changed, 27 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java index c0e434046139c..91418ad312bfa 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java @@ -43,6 +43,7 @@ public abstract class ExpandableView extends FrameLayout { private boolean mWillBeGone; private int mMinClipTopAmount = 0; private boolean mClipToActualHeight = true; + private boolean mChangingPosition = false; public ExpandableView(Context context, AttributeSet attrs) { super(context, attrs); @@ -407,6 +408,14 @@ public abstract class ExpandableView extends FrameLayout { return 0; } + public void setChangingPosition(boolean changingPosition) { + mChangingPosition = changingPosition; + } + + public boolean isChangingPosition() { + return mChangingPosition; + } + /** * A listener notifying when {@link #getActualHeight} changes. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index d9e8bd91cace9..29b0f4b75876e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -154,9 +154,22 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene setVisibility(INVISIBLE); } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (mEntry.row.isChangingPosition()) { + if (getVisibility() == VISIBLE && mEditText.isFocusable()) { + mEditText.requestFocus(); + } + } + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); + if (mEntry.row.isChangingPosition()) { + return; + } mController.removeRemoteInput(mEntry); } @@ -229,6 +242,9 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } private void defocusIfNeeded() { + if (mDefocusListener.mEntry.row.isChangingPosition()) { + return; + } if (isFocusable() && isEnabled()) { setInnerFocusable(false); if (mDefocusListener != null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 2ea95076d99e1..9dfe36903f7f2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -2252,8 +2252,10 @@ public class NotificationStackScrollLayout extends ViewGroup int currentIndex = indexOfChild(child); if (child != null && child.getParent() == this && currentIndex != newIndex) { mChangePositionInProgress = true; + ((ExpandableView)child).setChangingPosition(true); removeView(child); addView(child, newIndex); + ((ExpandableView)child).setChangingPosition(false); mChangePositionInProgress = false; if (mIsExpanded && mAnimationsEnabled && child.getVisibility() != View.GONE) { mChildrenChangingPositions.add(child);