diff options
| -rw-r--r-- | core/java/android/view/VolumePanel.java | 181 | ||||
| -rw-r--r-- | core/res/res/layout/volume_adjust.xml | 62 | ||||
| -rw-r--r-- | core/res/res/layout/volume_adjust_item.xml | 3 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 2 | ||||
| -rw-r--r-- | core/res/res/values/themes.xml | 5 | ||||
| -rw-r--r-- | packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml | 3 | ||||
| -rw-r--r-- | packages/SystemUI/res/values/styles.xml | 3 |
7 files changed, 123 insertions, 136 deletions
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java index 8eae62967187..4730e595e347 100644 --- a/core/java/android/view/VolumePanel.java +++ b/core/java/android/view/VolumePanel.java @@ -27,8 +27,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Resources; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.media.AudioService; import android.media.AudioSystem; @@ -58,10 +56,8 @@ import java.util.HashMap; * * @hide */ -public class VolumePanel extends Handler implements OnSeekBarChangeListener, View.OnClickListener, - VolumeController -{ - private static final String TAG = "VolumePanel"; +public class VolumePanel extends Handler implements VolumeController { + private static final String TAG = VolumePanel.class.getSimpleName(); private static boolean LOGD = false; /** @@ -189,7 +185,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie this.iconMuteRes = iconMuteRes; this.show = show; } - }; + } // List of stream types and their order private static final StreamResources[] STREAMS = { @@ -256,14 +252,14 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } - public VolumePanel(final Context context, AudioService volumeService) { + public VolumePanel(Context context, AudioService volumeService) { mContext = context; mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mAudioService = volumeService; // For now, only show master volume if master volume is supported - final boolean useMasterVolume = context.getResources().getBoolean( - R.bool.config_useMasterVolume); + final Resources res = context.getResources(); + final boolean useMasterVolume = res.getBoolean(R.bool.config_useMasterVolume); if (useMasterVolume) { for (int i = 0; i < STREAMS.length; i++) { StreamResources streamRes = STREAMS[i]; @@ -271,29 +267,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } } - final TypedArray a = context.obtainStyledAttributes(null, - com.android.internal.R.styleable.AlertDialog, - com.android.internal.R.attr.alertDialogStyle, 0); - final Drawable background = a.getDrawable(R.styleable.AlertDialog_fullBright); - a.recycle(); - - final LayoutInflater inflater = (LayoutInflater) context.getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - mView = inflater.inflate(R.layout.volume_adjust, null); - mView.setBackground(background); - mView.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - resetTimeout(); - return false; - } - }); - mPanel = (ViewGroup) mView.findViewById(R.id.visible_panel); - mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group); - mMoreButton = mView.findViewById(R.id.expand_button); - mDivider = mView.findViewById(R.id.expand_button_divider); - - mDialog = new Dialog(context, R.style.Theme_Panel_Volume) { + mDialog = new Dialog(context) { @Override public boolean onTouchEvent(MotionEvent event) { if (isShowing() && event.getAction() == MotionEvent.ACTION_OUTSIDE && @@ -304,51 +278,65 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie return false; } }; - - mDialog.setTitle("Volume control"); // No need to localize - mDialog.setContentView(mView); - mDialog.setOnDismissListener(new OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - mActiveStreamType = -1; - mAudioManager.forceVolumeControlStream(mActiveStreamType); - } - }); // Change some window properties final Window window = mDialog.getWindow(); - window.setGravity(Gravity.TOP); - final LayoutParams lp = window.getAttributes(); lp.token = null; // Offset from the top - lp.y = mContext.getResources().getDimensionPixelOffset(R.dimen.volume_panel_top); + lp.y = res.getDimensionPixelOffset(R.dimen.volume_panel_top); lp.type = LayoutParams.TYPE_VOLUME_OVERLAY; - lp.width = LayoutParams.WRAP_CONTENT; - lp.height = LayoutParams.WRAP_CONTENT; + lp.windowAnimations = R.style.Animation_VolumePanel; window.setAttributes(lp); - window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCH_MODAL + window.setGravity(Gravity.TOP); + window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); + window.requestFeature(Window.FEATURE_NO_TITLE); + window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE + | LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH); - mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()]; - mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); + mDialog.setCanceledOnTouchOutside(true); + mDialog.setContentView(R.layout.volume_adjust); + mDialog.setOnDismissListener(new OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + mActiveStreamType = -1; + mAudioManager.forceVolumeControlStream(mActiveStreamType); + } + }); + + mDialog.create(); + mView = window.findViewById(R.id.content); + mView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + resetTimeout(); + return false; + } + }); + + mPanel = (ViewGroup) mView.findViewById(R.id.visible_panel); + mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group); + mMoreButton = mView.findViewById(R.id.expand_button); + mDivider = mView.findViewById(R.id.expand_button_divider); + + mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()]; + mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); mVoiceCapable = context.getResources().getBoolean(R.bool.config_voice_capable); + + // If we don't want to show multiple volumes, hide the settings button + // and divider. mShowCombinedVolumes = !mVoiceCapable && !useMasterVolume; - - // If we don't want to show multiple volumes, hide the settings button and divider if (!mShowCombinedVolumes) { mMoreButton.setVisibility(View.GONE); mDivider.setVisibility(View.GONE); } else { - mMoreButton.setOnClickListener(this); + mMoreButton.setOnClickListener(mClickListener); } - final boolean masterVolumeOnly = context.getResources().getBoolean( - R.bool.config_useMasterVolume); - final boolean masterVolumeKeySounds = mContext.getResources().getBoolean( - R.bool.config_useVolumeKeySounds); - + final boolean masterVolumeOnly = res.getBoolean(R.bool.config_useMasterVolume); + final boolean masterVolumeKeySounds = res.getBoolean(R.bool.config_useVolumeKeySounds); mPlayMasterStreamTones = masterVolumeOnly && masterVolumeKeySounds; listenToRingerMode(); @@ -444,7 +432,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie final int plusOne = (streamType == AudioSystem.STREAM_BLUETOOTH_SCO || streamType == AudioSystem.STREAM_VOICE_CALL) ? 1 : 0; sc.seekbarView.setMax(getStreamMaxVolume(streamType) + plusOne); - sc.seekbarView.setOnSeekBarChangeListener(this); + sc.seekbarView.setOnSeekBarChangeListener(mSeekListener); sc.seekbarView.setTag(sc); mStreamControls.put(streamType, sc); } @@ -506,10 +494,6 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } } - private boolean isExpanded() { - return mMoreButton.getVisibility() != View.VISIBLE; - } - private void expand() { final int count = mSliderGroup.getChildCount(); for (int i = 0; i < count; i++) { @@ -547,6 +531,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie obtainMessage(MSG_VOLUME_CHANGED, streamType, flags).sendToTarget(); } + @Override public void postRemoteVolumeChanged(int streamType, int flags) { if (hasMessages(MSG_REMOTE_VOLUME_CHANGED)) return; synchronized (this) { @@ -558,6 +543,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie obtainMessage(MSG_REMOTE_VOLUME_CHANGED, streamType, flags).sendToTarget(); } + @Override public void postRemoteSliderVisibility(boolean visible) { obtainMessage(MSG_SLIDER_VISIBILITY_CHANGED, AudioService.STREAM_REMOTE_MUSIC, visible ? 1 : 0).sendToTarget(); @@ -574,6 +560,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie * as a request to update the volume), the application will likely set a new volume. If the UI * is still up, we need to refresh the display to show this new value. */ + @Override public void postHasNewRemotePlaybackInfo() { if (hasMessages(MSG_REMOTE_VOLUME_UPDATE_IF_SHOWN)) return; // don't create or prevent resources to be freed, if they disappear, this update came too @@ -753,7 +740,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie int stream = (streamType == AudioService.STREAM_REMOTE_MUSIC) ? -1 : streamType; // when the stream is for remote playback, use -1 to reset the stream type evaluation mAudioManager.forceVolumeControlStream(stream); - mDialog.setContentView(mView); + // Showing dialog - use collapsed state if (mShowCombinedVolumes) { collapse(); @@ -885,6 +872,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie .setMessage(com.android.internal.R.string.safe_media_volume_warning) .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { + @Override public void onClick(DialogInterface dialog, int which) { mAudioService.disableSafeMediaVolume(); } @@ -1041,39 +1029,48 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie sendMessage(obtainMessage(MSG_TIMEOUT)); } - public void onProgressChanged(SeekBar seekBar, int progress, - boolean fromUser) { - final Object tag = seekBar.getTag(); - if (fromUser && tag instanceof StreamControl) { - StreamControl sc = (StreamControl) tag; - if (getStreamVolume(sc.streamType) != progress) { - setStreamVolume(sc.streamType, progress, 0); + private final OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + final Object tag = seekBar.getTag(); + if (fromUser && tag instanceof StreamControl) { + StreamControl sc = (StreamControl) tag; + if (getStreamVolume(sc.streamType) != progress) { + setStreamVolume(sc.streamType, progress, 0); + } } + resetTimeout(); } - resetTimeout(); - } - public void onStartTrackingTouch(SeekBar seekBar) { - } + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } - public void onStopTrackingTouch(SeekBar seekBar) { - final Object tag = seekBar.getTag(); - if (tag instanceof StreamControl) { - StreamControl sc = (StreamControl) tag; - // because remote volume updates are asynchronous, AudioService might have received - // a new remote volume value since the finger adjusted the slider. So when the - // progress of the slider isn't being tracked anymore, adjust the slider to the last - // "published" remote volume value, so the UI reflects the actual volume. - if (sc.streamType == AudioService.STREAM_REMOTE_MUSIC) { - seekBar.setProgress(getStreamVolume(AudioService.STREAM_REMOTE_MUSIC)); + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + final Object tag = seekBar.getTag(); + if (tag instanceof StreamControl) { + StreamControl sc = (StreamControl) tag; + // Because remote volume updates are asynchronous, AudioService + // might have received a new remote volume value since the + // finger adjusted the slider. So when the progress of the + // slider isn't being tracked anymore, adjust the slider to the + // last "published" remote volume value, so the UI reflects the + // actual volume. + if (sc.streamType == AudioService.STREAM_REMOTE_MUSIC) { + seekBar.setProgress(getStreamVolume(AudioService.STREAM_REMOTE_MUSIC)); + } } } - } + }; - public void onClick(View v) { - if (v == mMoreButton) { - expand(); + private final View.OnClickListener mClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + if (v == mMoreButton) { + expand(); + } + resetTimeout(); } - resetTimeout(); - } + }; } diff --git a/core/res/res/layout/volume_adjust.xml b/core/res/res/layout/volume_adjust.xml index 1cf7ca9bc441..3ad1f23575b8 100644 --- a/core/res/res/layout/volume_adjust.xml +++ b/core/res/res/layout/volume_adjust.xml @@ -14,42 +14,38 @@ limitations under the License. --> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="448dp" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/visible_panel" + android:orientation="horizontal" + android:layout_width="300dp" android:layout_height="wrap_content"> + <LinearLayout - android:id="@+id/visible_panel" - android:layout_width="match_parent" + android:id="@+id/slider_group" + android:layout_width="0dp" android:layout_height="wrap_content" - android:orientation="horizontal"> - - <LinearLayout - android:id="@+id/slider_group" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:orientation="vertical"> - <!-- Sliders go here --> - </LinearLayout> + android:layout_weight="1" + android:orientation="vertical"> + <!-- Sliders go here --> + </LinearLayout> - <ImageView - android:id="@+id/expand_button_divider" - android:src="?attr/dividerVertical" - android:layout_width="wrap_content" - android:layout_height="32dip" - android:scaleType="fitXY" - android:layout_gravity="top" - android:layout_marginTop="16dip" - android:layout_marginBottom="16dip" /> + <ImageView + android:id="@+id/expand_button_divider" + android:src="?attr/dividerVertical" + android:layout_width="wrap_content" + android:layout_height="32dip" + android:scaleType="fitXY" + android:layout_gravity="top" + android:layout_marginTop="16dip" + android:layout_marginBottom="16dip" /> - <ImageView - android:id="@+id/expand_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="top" - android:padding="16dip" - android:background="?attr/selectableItemBackground" - android:src="@drawable/ic_sysbar_quicksettings" /> + <ImageView + android:id="@+id/expand_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="top" + android:padding="16dip" + android:background="?attr/selectableItemBackground" + android:src="@drawable/ic_sysbar_quicksettings" /> - </LinearLayout> -</FrameLayout>
\ No newline at end of file +</LinearLayout> diff --git a/core/res/res/layout/volume_adjust_item.xml b/core/res/res/layout/volume_adjust_item.xml index 746cf913a897..57cecf479489 100644 --- a/core/res/res/layout/volume_adjust_item.xml +++ b/core/res/res/layout/volume_adjust_item.xml @@ -33,8 +33,9 @@ <SeekBar style="?android:attr/seekBarStyle" android:id="@+id/seekbar" - android:layout_width="252dp" + android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_weight="1" android:padding="16dip" android:layout_marginEnd="16dip" /> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index ac6c15da2926..7a11ce8eeb04 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1254,7 +1254,6 @@ <java-symbol type="style" name="TextAppearance.SlidingTabNormal" /> <java-symbol type="style" name="Theme.DeviceDefault.Dialog.NoFrame" /> <java-symbol type="style" name="Theme.IconMenu" /> - <java-symbol type="style" name="Theme.Panel.Volume" /> <java-symbol type="attr" name="mediaRouteButtonStyle" /> <java-symbol type="attr" name="externalRouteEnabledDrawable" /> @@ -1836,5 +1835,6 @@ <java-symbol type="attr" name="subtitleTextAppearance" /> <java-symbol type="drawable" name="ic_lock_bugreport" /> <java-symbol type="id" name="icon_frame" /> + <java-symbol type="style" name="Animation.VolumePanel" /> </resources> diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index 6f9e55baa736..7b3d5e3ab398 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -892,11 +892,6 @@ please see themes_device_defaults.xml. <item name="android:windowCloseOnTouchOutside">false</item> </style> - <style name="Theme.Panel.Volume"> - <item name="android:windowAnimationStyle">@android:style/Animation.VolumePanel</item> - <item name="android:windowCloseOnTouchOutside">true</item> - </style> - <!-- Default theme with an Action Bar. --> <style name="Theme.WithActionBar"> <item name="android:windowActionBar">true</item> diff --git a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml index 46fbaff6ab55..b7df51d3777b 100644 --- a/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml +++ b/packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml @@ -22,7 +22,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:paddingEnd="10dp" + android:layout_marginEnd="8dp" android:src="@drawable/ic_qs_brightness_auto_off" android:contentDescription="@null" /> @@ -31,7 +31,6 @@ android:layout_width="0dp" android:layout_height="40dp" android:layout_gravity="center_vertical" - android:layout_marginEnd="2dp" android:layout_weight="1" systemui:text="@string/status_bar_settings_auto_brightness_label" /> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 76cadd79bfa5..0ece8e04ed0d 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -137,10 +137,9 @@ <style name="BaseBrightnessDialogContainer"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> - <item name="android:layout_marginLeft">8dp</item> - <item name="android:layout_marginRight">8dp</item> <item name="android:padding">16dp</item> </style> + <style name="BrightnessDialogContainer" parent="@style/BaseBrightnessDialogContainer" /> <style name="Animation" /> |