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

Commit c5328681 authored by Alexander Toresson's avatar Alexander Toresson Committed by Danesh M
Browse files

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
parent 15b3922a
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -130,6 +130,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) {
@@ -275,10 +276,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);