diff options
author | Alan Viverette <alanv@google.com> | 2014-04-10 18:12:56 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-04-10 18:13:08 -0700 |
commit | 494fb7b58a21a7a9a8eba3bacecffe115edcb8c6 (patch) | |
tree | 95dee8ae8b306ffa6816387cdee1f8fc0707857a /core | |
parent | c095ca1cb8877121f768b5b6940e4025e810d4ba (diff) | |
download | frameworks_base-494fb7b58a21a7a9a8eba3bacecffe115edcb8c6.zip frameworks_base-494fb7b58a21a7a9a8eba3bacecffe115edcb8c6.tar.gz frameworks_base-494fb7b58a21a7a9a8eba3bacecffe115edcb8c6.tar.bz2 |
Update volume panel
Change-Id: I6f0887069598f8addc5c5af5aef9c07a69532424
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/VolumePanel.java | 66 | ||||
-rw-r--r-- | core/res/res/drawable-hdpi/scrubber_track_qntm_alpha.9.png | bin | 0 -> 105 bytes | |||
-rw-r--r-- | core/res/res/drawable-mdpi/scrubber_track_qntm_alpha.9.png | bin | 0 -> 100 bytes | |||
-rw-r--r-- | core/res/res/drawable-xhdpi/scrubber_track_qntm_alpha.9.png | bin | 0 -> 114 bytes | |||
-rw-r--r-- | core/res/res/drawable-xxhdpi/scrubber_track_qntm_alpha.9.png | bin | 0 -> 204 bytes | |||
-rw-r--r-- | core/res/res/drawable/scrubber_control_selector_quantum.xml | 8 | ||||
-rw-r--r-- | core/res/res/drawable/scrubber_progress_horizontal_quantum.xml | 22 | ||||
-rw-r--r-- | core/res/res/layout/volume_adjust.xml | 15 | ||||
-rw-r--r-- | core/res/res/layout/volume_adjust_item.xml | 7 | ||||
-rw-r--r-- | core/res/res/values/dimens.xml | 2 |
10 files changed, 75 insertions, 45 deletions
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java index b05225b..8eae629 100644 --- a/core/java/android/view/VolumePanel.java +++ b/core/java/android/view/VolumePanel.java @@ -27,6 +27,8 @@ 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; @@ -238,6 +240,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie cleanUp(); } + @Override public void onDismiss(DialogInterface unused) { mContext.unregisterReceiver(this); cleanUp(); @@ -259,8 +262,8 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mAudioService = volumeService; // For now, only show master volume if master volume is supported - boolean useMasterVolume = context.getResources().getBoolean( - com.android.internal.R.bool.config_useMasterVolume); + final boolean useMasterVolume = context.getResources().getBoolean( + R.bool.config_useMasterVolume); if (useMasterVolume) { for (int i = 0; i < STREAMS.length; i++) { StreamResources streamRes = STREAMS[i]; @@ -268,10 +271,18 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } } - LayoutInflater inflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View view = mView = inflater.inflate(R.layout.volume_adjust, null); + 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; @@ -279,10 +290,11 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie }); 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); + mMoreButton = mView.findViewById(R.id.expand_button); + mDivider = mView.findViewById(R.id.expand_button_divider); mDialog = new Dialog(context, R.style.Theme_Panel_Volume) { + @Override public boolean onTouchEvent(MotionEvent event) { if (isShowing() && event.getAction() == MotionEvent.ACTION_OUTSIDE && sConfirmSafeVolumeDialog == null) { @@ -292,22 +304,25 @@ 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 - Window window = mDialog.getWindow(); + final Window window = mDialog.getWindow(); window.setGravity(Gravity.TOP); - LayoutParams lp = window.getAttributes(); + + final LayoutParams lp = window.getAttributes(); lp.token = null; // Offset from the top - lp.y = mContext.getResources().getDimensionPixelOffset( - com.android.internal.R.dimen.volume_panel_top); + lp.y = mContext.getResources().getDimensionPixelOffset(R.dimen.volume_panel_top); lp.type = LayoutParams.TYPE_VOLUME_OVERLAY; lp.width = LayoutParams.WRAP_CONTENT; lp.height = LayoutParams.WRAP_CONTENT; @@ -320,6 +335,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mVoiceCapable = context.getResources().getBoolean(R.bool.config_voice_capable); mShowCombinedVolumes = !mVoiceCapable && !useMasterVolume; + // If we don't want to show multiple volumes, hide the settings button and divider if (!mShowCombinedVolumes) { mMoreButton.setVisibility(View.GONE); @@ -328,10 +344,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mMoreButton.setOnClickListener(this); } - boolean masterVolumeOnly = context.getResources().getBoolean( - com.android.internal.R.bool.config_useMasterVolume); - boolean masterVolumeKeySounds = mContext.getResources().getBoolean( - com.android.internal.R.bool.config_useVolumeKeySounds); + final boolean masterVolumeOnly = context.getResources().getBoolean( + R.bool.config_useMasterVolume); + final boolean masterVolumeKeySounds = mContext.getResources().getBoolean( + R.bool.config_useVolumeKeySounds); mPlayMasterStreamTones = masterVolumeOnly && masterVolumeKeySounds; @@ -347,7 +363,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie final IntentFilter filter = new IntentFilter(); filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); mContext.registerReceiver(new BroadcastReceiver() { - + @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); @@ -400,17 +416,21 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } private void createSliders() { - LayoutInflater inflater = (LayoutInflater) mContext - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + final Resources res = mContext.getResources(); + final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + mStreamControls = new HashMap<Integer, StreamControl>(STREAMS.length); - Resources res = mContext.getResources(); + for (int i = 0; i < STREAMS.length; i++) { StreamResources streamRes = STREAMS[i]; - int streamType = streamRes.streamType; + + final int streamType = streamRes.streamType; if (mVoiceCapable && streamRes == StreamResources.NotificationStream) { streamRes = StreamResources.RingerStream; } - StreamControl sc = new StreamControl(); + + final StreamControl sc = new StreamControl(); sc.streamType = streamType; sc.group = (ViewGroup) inflater.inflate(R.layout.volume_adjust_item, null); sc.group.setTag(sc); @@ -421,7 +441,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie sc.iconMuteRes = streamRes.iconMuteRes; sc.icon.setImageResource(sc.iconRes); sc.seekbarView = (SeekBar) sc.group.findViewById(R.id.seekbar); - int plusOne = (streamType == AudioSystem.STREAM_BLUETOOTH_SCO || + 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); @@ -433,7 +453,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie private void reorderSliders(int activeStreamType) { mSliderGroup.removeAllViews(); - StreamControl active = mStreamControls.get(activeStreamType); + final StreamControl active = mStreamControls.get(activeStreamType); if (active == null) { Log.e("VolumePanel", "Missing stream type! - " + activeStreamType); mActiveStreamType = -1; diff --git a/core/res/res/drawable-hdpi/scrubber_track_qntm_alpha.9.png b/core/res/res/drawable-hdpi/scrubber_track_qntm_alpha.9.png Binary files differnew file mode 100644 index 0000000..32ddf7a --- /dev/null +++ b/core/res/res/drawable-hdpi/scrubber_track_qntm_alpha.9.png diff --git a/core/res/res/drawable-mdpi/scrubber_track_qntm_alpha.9.png b/core/res/res/drawable-mdpi/scrubber_track_qntm_alpha.9.png Binary files differnew file mode 100644 index 0000000..db9e172 --- /dev/null +++ b/core/res/res/drawable-mdpi/scrubber_track_qntm_alpha.9.png diff --git a/core/res/res/drawable-xhdpi/scrubber_track_qntm_alpha.9.png b/core/res/res/drawable-xhdpi/scrubber_track_qntm_alpha.9.png Binary files differnew file mode 100644 index 0000000..805cb29 --- /dev/null +++ b/core/res/res/drawable-xhdpi/scrubber_track_qntm_alpha.9.png diff --git a/core/res/res/drawable-xxhdpi/scrubber_track_qntm_alpha.9.png b/core/res/res/drawable-xxhdpi/scrubber_track_qntm_alpha.9.png Binary files differnew file mode 100644 index 0000000..c3791fc --- /dev/null +++ b/core/res/res/drawable-xxhdpi/scrubber_track_qntm_alpha.9.png diff --git a/core/res/res/drawable/scrubber_control_selector_quantum.xml b/core/res/res/drawable/scrubber_control_selector_quantum.xml index e31c2c1..e34f64a 100644 --- a/core/res/res/drawable/scrubber_control_selector_quantum.xml +++ b/core/res/res/drawable/scrubber_control_selector_quantum.xml @@ -15,12 +15,16 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_enabled="true" android:state_pressed="true"> + <item android:state_enabled="false"> + <bitmap android:src="@drawable/scrubber_control_off_qntm_alpha" + android:tint="?attr/colorControlNormal" /> + </item> + <item android:state_pressed="true"> <bitmap android:src="@drawable/scrubber_control_on_pressed_qntm_alpha" android:tint="?attr/colorControlActivated" /> </item> <item> <bitmap android:src="@drawable/scrubber_control_on_qntm_alpha" - android:tint="?attr/colorControlNormal" /> + android:tint="?attr/colorControlActivated" /> </item> </selector> diff --git a/core/res/res/drawable/scrubber_progress_horizontal_quantum.xml b/core/res/res/drawable/scrubber_progress_horizontal_quantum.xml index 7b124ac..d172b05 100644 --- a/core/res/res/drawable/scrubber_progress_horizontal_quantum.xml +++ b/core/res/res/drawable/scrubber_progress_horizontal_quantum.xml @@ -15,12 +15,24 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_pressed="true"> - <bitmap android:src="@drawable/scrubber_primary_qntm_alpha" - android:tint="?attr/colorControlActivated" /> + <item android:state_enabled="false"> + <bitmap android:src="@drawable/scrubber_track_qntm_alpha" + android:tint="?attr/colorControlNormal" /> </item> <item> - <bitmap android:src="@drawable/scrubber_primary_qntm_alpha" - android:tint="?attr/colorControlNormal" /> + <layer-list> + <item android:id="@id/background"> + <bitmap android:src="@drawable/scrubber_track_qntm_alpha" + android:tint="?attr/colorControlNormal" /> + </item> + <item android:id="@id/secondaryProgress"> + <bitmap android:src="@drawable/scrubber_primary_qntm_alpha" + android:tint="?attr/colorControlNormal" /> + </item> + <item android:id="@id/progress"> + <bitmap android:src="@drawable/scrubber_primary_qntm_alpha" + android:tint="?attr/colorControlActivated" /> + </item> + </layer-list> </item> </selector> diff --git a/core/res/res/layout/volume_adjust.xml b/core/res/res/layout/volume_adjust.xml index c16a12c..1cf7ca9 100644 --- a/core/res/res/layout/volume_adjust.xml +++ b/core/res/res/layout/volume_adjust.xml @@ -15,23 +15,20 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="480dp" + android:layout_width="448dp" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/visible_panel" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@android:drawable/dialog_full_holo_dark" - android:orientation="horizontal" - > + 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" - > + android:orientation="vertical"> <!-- Sliders go here --> </LinearLayout> @@ -43,8 +40,7 @@ android:scaleType="fitXY" android:layout_gravity="top" android:layout_marginTop="16dip" - android:layout_marginBottom="16dip" - /> + android:layout_marginBottom="16dip" /> <ImageView android:id="@+id/expand_button" @@ -53,8 +49,7 @@ android:layout_gravity="top" android:padding="16dip" android:background="?attr/selectableItemBackground" - android:src="@drawable/ic_sysbar_quicksettings" - /> + android:src="@drawable/ic_sysbar_quicksettings" /> </LinearLayout> </FrameLayout>
\ No newline at end of file diff --git a/core/res/res/layout/volume_adjust_item.xml b/core/res/res/layout/volume_adjust_item.xml index 4a0fbaf..746cf91 100644 --- a/core/res/res/layout/volume_adjust_item.xml +++ b/core/res/res/layout/volume_adjust_item.xml @@ -26,16 +26,15 @@ android:id="@+id/stream_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="16dip" + android:paddingLeft="16dip" android:background="?attr/selectableItemBackground" - /> + android:contentDescription="@null" /> <SeekBar style="?android:attr/seekBarStyle" android:id="@+id/seekbar" - android:layout_width="300dp" + android:layout_width="252dp" android:layout_height="wrap_content" - android:layout_weight="1" android:padding="16dip" android:layout_marginEnd="16dip" /> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 94123a2..6b2c788 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -201,7 +201,7 @@ <dimen name="textview_error_popup_default_width">240dip</dimen> <!-- Volume panel y offset --> - <dimen name="volume_panel_top">80dp</dimen> + <dimen name="volume_panel_top">16dp</dimen> <!-- Default padding to apply to AppWidgetHostViews containing widgets targeting API level 14 and up. --> <dimen name="default_app_widget_padding_left">8dp</dimen> |