From 5bb6dcef3f903a45e1e852a145d703dd71b993ed Mon Sep 17 00:00:00 2001 From: Alexander Toresson Date: Mon, 14 Dec 2015 16:10:04 +0100 Subject: Fix volume expand arrow to be displayed correctly Sometimes, the volume control expand arrow would be displayed incorrectly. When different apps use different volume controls and force different orientations, the position of the arrow (expand button) will not be updated correctly. When this happens the arrow cannot be pressed and the volume settings cannot be expanded. The underlying reason is that onLayoutChange only compares the old dimensions of a view with the new dimensions, which doesn't take into account that the last time onLayoutChange was run it may have been run for a different view (a different volume control), in which case the dimensions of the new view may not have changed, but the arrow needs to be repositioned anyway as it needs to be positioned in relation to another view. Fix this problem by storing the last stream (volume control) that the arrow was positioned in relation to, and checking if we're positioning in relation to the same stream the next time the position of the arrow is updated. Change-Id: Id23e7605d50857292e09c1909b3e27f01bdf5e22 --- .../SystemUI/src/com/android/systemui/volume/VolumeDialog.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java index e9f1095c0a60..16ea0e40aca4 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java @@ -128,6 +128,7 @@ public class VolumeDialog { private boolean mPendingStateChanged; private boolean mPendingRecheckAll; private long mCollapseTime; + private int mLastActiveStream; public VolumeDialog(Context context, int windowType, VolumeDialogController controller, ZenModeController zenModeController, Callback callback) { @@ -273,10 +274,14 @@ public class VolumeDialog { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - final boolean moved = oldLeft != left || oldTop != top; + final boolean moved = mLastActiveStream != mActiveStream || + oldLeft != left || oldTop != top; if (D.BUG) Log.d(TAG, "onLayoutChange moved=" + moved + " old=" + new Rect(oldLeft, oldTop, oldRight, oldBottom).toShortString() - + " new=" + new Rect(left,top,right,bottom).toShortString()); + + "," + mLastActiveStream + + " new=" + new Rect(left,top,right,bottom).toShortString() + + "," + mActiveStream); + mLastActiveStream = mActiveStream; if (moved) { for (int i = 0; i < mDialogContentView.getChildCount(); i++) { final View c = mDialogContentView.getChildAt(i); -- cgit v1.2.3-59-g8ed1b