diff options
| author | 2011-09-19 10:03:14 -0700 | |
|---|---|---|
| committer | 2011-09-19 10:03:14 -0700 | |
| commit | 4943b3aa360033c0eae9e5b67c7491b25ea9ae07 (patch) | |
| tree | 32481a5a861250198d5dfbed87649b069cb6841c | |
| parent | b3e6eab16153c28a30525a7c26fb7a153a5548f4 (diff) | |
| parent | 284e630a9b7f126ffb83cee4a1c4fe5134190cab (diff) | |
Merge "Make Volume control non-modal and allow touches underneath to take effect."
| -rw-r--r-- | core/java/android/view/VolumePanel.java | 38 | ||||
| -rw-r--r-- | core/res/res/layout/volume_adjust.xml | 1 | ||||
| -rw-r--r-- | core/res/res/values/dimens.xml | 2 |
3 files changed, 23 insertions, 18 deletions
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java index fb87e23a4d9e..122865e1e4cf 100644 --- a/core/java/android/view/VolumePanel.java +++ b/core/java/android/view/VolumePanel.java @@ -34,10 +34,12 @@ import android.media.ToneGenerator; import android.net.Uri; import android.os.Handler; import android.os.Message; +import android.os.RemoteException; import android.os.Vibrator; import android.provider.Settings; import android.provider.Settings.System; import android.util.Log; +import android.view.WindowManager.LayoutParams; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; @@ -175,20 +177,8 @@ 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; + return false; } }); mPanel = (ViewGroup) mView.findViewById(R.id.visible_panel); @@ -196,7 +186,15 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mMoreButton = (ImageView) mView.findViewById(R.id.expand_button); mDivider = (ImageView) mView.findViewById(R.id.expand_button_divider); - mDialog = new Dialog(context, R.style.Theme_Panel_Volume); + mDialog = new Dialog(context, R.style.Theme_Panel_Volume) { + public boolean onTouchEvent(MotionEvent event) { + if (isShowing() && event.getAction() == MotionEvent.ACTION_OUTSIDE) { + forceTimeout(); + return true; + } + return false; + } + }; mDialog.setTitle("Volume control"); // No need to localize mDialog.setContentView(mView); mDialog.setOnDismissListener(new OnDismissListener() { @@ -208,11 +206,17 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie // Change some window properties Window window = mDialog.getWindow(); window.setGravity(Gravity.TOP); - WindowManager.LayoutParams lp = window.getAttributes(); + LayoutParams lp = window.getAttributes(); lp.token = null; - lp.type = WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY; + // Offset from the top + lp.y = mContext.getResources().getDimensionPixelOffset( + com.android.internal.R.dimen.volume_panel_top); + lp.type = LayoutParams.TYPE_VOLUME_OVERLAY; + lp.width = LayoutParams.WRAP_CONTENT; + lp.height = LayoutParams.WRAP_CONTENT; window.setAttributes(lp); - window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); + window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCH_MODAL + | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH); mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()]; mVibrator = new Vibrator(); diff --git a/core/res/res/layout/volume_adjust.xml b/core/res/res/layout/volume_adjust.xml index ea4e1f9a6036..c16a12cec025 100644 --- a/core/res/res/layout/volume_adjust.xml +++ b/core/res/res/layout/volume_adjust.xml @@ -21,7 +21,6 @@ android:id="@+id/visible_panel" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="80dp" android:background="@android:drawable/dialog_full_holo_dark" android:orientation="horizontal" > diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index f1fc42c60db9..0d153888df82 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -178,4 +178,6 @@ <!-- Default width for a textview error popup --> <dimen name="textview_error_popup_default_width">240dip</dimen> + <!-- Volume panel y offset --> + <dimen name="volume_panel_top">80dp</dimen> </resources> |