Update volume panel
Change-Id: I6f0887069598f8addc5c5af5aef9c07a69532424
This commit is contained in:
@@ -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;
|
||||
|
||||
BIN
core/res/res/drawable-hdpi/scrubber_track_qntm_alpha.9.png
Normal file
BIN
core/res/res/drawable-hdpi/scrubber_track_qntm_alpha.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 105 B |
BIN
core/res/res/drawable-mdpi/scrubber_track_qntm_alpha.9.png
Normal file
BIN
core/res/res/drawable-mdpi/scrubber_track_qntm_alpha.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 100 B |
BIN
core/res/res/drawable-xhdpi/scrubber_track_qntm_alpha.9.png
Normal file
BIN
core/res/res/drawable-xhdpi/scrubber_track_qntm_alpha.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 114 B |
BIN
core/res/res/drawable-xxhdpi/scrubber_track_qntm_alpha.9.png
Normal file
BIN
core/res/res/drawable-xxhdpi/scrubber_track_qntm_alpha.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 204 B |
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
<item>
|
||||
<bitmap android:src="@drawable/scrubber_primary_qntm_alpha"
|
||||
<item android:state_enabled="false">
|
||||
<bitmap android:src="@drawable/scrubber_track_qntm_alpha"
|
||||
android:tint="?attr/colorControlNormal" />
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
|
||||
@@ -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>
|
||||
@@ -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" />
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user