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

This commit is contained in:
Amith Yamasani
2011-08-19 11:17:48 -07:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 0 deletions

View File

@@ -101,6 +101,8 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
/** Dialog's content view */
private final View mView;
/** The visible portion of the volume overlay */
private final ViewGroup mPanel;
/** Contains the sliders and their touchable icons */
private final ViewGroup mSliderGroup;
/** 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);
mView.setOnTouchListener(new View.OnTouchListener() {
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();
return true;
}
});
mPanel = (ViewGroup) mView.findViewById(R.id.visible_panel);
mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group);
mMoreButton = (ImageView) mView.findViewById(R.id.expand_button);
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);
}
private void forceTimeout() {
removeMessages(MSG_TIMEOUT);
sendMessage(obtainMessage(MSG_TIMEOUT));
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
final Object tag = seekBar.getTag();

View File

@@ -18,6 +18,7 @@
android:layout_width="480dp"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/visible_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"