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

Commit baf6dbfa authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Dismiss the volume overlay dialog when user touches above the dialog as well.

Bug: 5165168
Change-Id: Ib343c3b88371cb93f8241b1085d1a2f36a77b1ac
parent 3d01812f
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -101,6 +101,8 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
    /** Dialog's content view */
    /** Dialog's content view */
    private final View mView;
    private final View mView;


    /** The visible portion of the volume overlay */
    private final ViewGroup mPanel;
    /** Contains the sliders and their touchable icons */
    /** Contains the sliders and their touchable icons */
    private final ViewGroup mSliderGroup;
    private final ViewGroup mSliderGroup;
    /** The button that expands the dialog to show all sliders */
    /** The button that expands the dialog to show all sliders */
@@ -173,10 +175,23 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
        View view = mView = inflater.inflate(R.layout.volume_adjust, null);
        View view = mView = inflater.inflate(R.layout.volume_adjust, null);
        mView.setOnTouchListener(new View.OnTouchListener() {
        mView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
            public boolean onTouch(View v, MotionEvent event) {
                // Dismiss the dialog if the user touches outside the visible area. This is not
                // handled by the usual dialog dismissing code because there is a region above
                // the panel (marginTop) that is still within the dialog.
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    int x = (int) event.getX();
                    int y = (int) event.getY();
                    if (x < mPanel.getLeft() || x > mPanel.getRight() || y < mPanel.getTop()
                            || y > mPanel.getBottom()) {
                        forceTimeout();
                        return true;
                    }
                }
                resetTimeout();
                resetTimeout();
                return true;
                return true;
            }
            }
        });
        });
        mPanel = (ViewGroup) mView.findViewById(R.id.visible_panel);
        mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group);
        mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group);
        mMoreButton = (ImageView) mView.findViewById(R.id.expand_button);
        mMoreButton = (ImageView) mView.findViewById(R.id.expand_button);
        mDivider = (ImageView) mView.findViewById(R.id.expand_button_divider);
        mDivider = (ImageView) mView.findViewById(R.id.expand_button_divider);
@@ -639,6 +654,11 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
        sendMessageDelayed(obtainMessage(MSG_TIMEOUT), TIMEOUT_DELAY);
        sendMessageDelayed(obtainMessage(MSG_TIMEOUT), TIMEOUT_DELAY);
    }
    }


    private void forceTimeout() {
        removeMessages(MSG_TIMEOUT);
        sendMessage(obtainMessage(MSG_TIMEOUT));
    }

    public void onProgressChanged(SeekBar seekBar, int progress,
    public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {
            boolean fromUser) {
        final Object tag = seekBar.getTag();
        final Object tag = seekBar.getTag();
+1 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@
    android:layout_width="480dp"
    android:layout_width="480dp"
    android:layout_height="wrap_content">
    android:layout_height="wrap_content">
    <LinearLayout
    <LinearLayout
        android:id="@+id/visible_panel"
        android:layout_width="match_parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="80dp"
        android:layout_marginTop="80dp"