am 00005385: Merge "Use ringer assets for notification volume since the two volumes are tied." into ics-mr0
* commit '000053859290d322625dfcbdb0467fc34d5e55f4': Use ringer assets for notification volume since the two volumes are tied.
This commit is contained in:
@@ -97,6 +97,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
protected AudioService mAudioService;
|
protected AudioService mAudioService;
|
||||||
private boolean mRingIsSilent;
|
private boolean mRingIsSilent;
|
||||||
private boolean mShowCombinedVolumes;
|
private boolean mShowCombinedVolumes;
|
||||||
|
private boolean mVoiceCapable;
|
||||||
|
|
||||||
/** Dialog containing all the sliders */
|
/** Dialog containing all the sliders */
|
||||||
private final Dialog mDialog;
|
private final Dialog mDialog;
|
||||||
@@ -117,40 +118,56 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
/** All the slider controls mapped by stream type */
|
/** All the slider controls mapped by stream type */
|
||||||
private HashMap<Integer,StreamControl> mStreamControls;
|
private HashMap<Integer,StreamControl> mStreamControls;
|
||||||
|
|
||||||
|
private enum StreamResources {
|
||||||
|
BluetoothSCOStream(AudioManager.STREAM_BLUETOOTH_SCO,
|
||||||
|
R.string.volume_icon_description_bluetooth,
|
||||||
|
R.drawable.ic_audio_bt,
|
||||||
|
R.drawable.ic_audio_bt,
|
||||||
|
false),
|
||||||
|
RingerStream(AudioManager.STREAM_RING,
|
||||||
|
R.string.volume_icon_description_ringer,
|
||||||
|
R.drawable.ic_audio_ring_notif,
|
||||||
|
R.drawable.ic_audio_ring_notif_mute,
|
||||||
|
false),
|
||||||
|
VoiceStream(AudioManager.STREAM_VOICE_CALL,
|
||||||
|
R.string.volume_icon_description_incall,
|
||||||
|
R.drawable.ic_audio_phone,
|
||||||
|
R.drawable.ic_audio_phone,
|
||||||
|
false),
|
||||||
|
MediaStream(AudioManager.STREAM_MUSIC,
|
||||||
|
R.string.volume_icon_description_media,
|
||||||
|
R.drawable.ic_audio_vol,
|
||||||
|
R.drawable.ic_audio_vol_mute,
|
||||||
|
true),
|
||||||
|
NotificationStream(AudioManager.STREAM_NOTIFICATION,
|
||||||
|
R.string.volume_icon_description_notification,
|
||||||
|
R.drawable.ic_audio_notification,
|
||||||
|
R.drawable.ic_audio_notification_mute,
|
||||||
|
true);
|
||||||
|
|
||||||
|
int streamType;
|
||||||
|
int descRes;
|
||||||
|
int iconRes;
|
||||||
|
int iconMuteRes;
|
||||||
|
// RING, VOICE_CALL & BLUETOOTH_SCO are hidden unless explicitly requested
|
||||||
|
boolean show;
|
||||||
|
|
||||||
|
StreamResources(int streamType, int descRes, int iconRes, int iconMuteRes, boolean show) {
|
||||||
|
this.streamType = streamType;
|
||||||
|
this.descRes = descRes;
|
||||||
|
this.iconRes = iconRes;
|
||||||
|
this.iconMuteRes = iconMuteRes;
|
||||||
|
this.show = show;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// List of stream types and their order
|
// List of stream types and their order
|
||||||
// RING, VOICE_CALL & BLUETOOTH_SCO are hidden unless explicitly requested
|
private static final StreamResources[] STREAMS = {
|
||||||
private static final int [] STREAM_TYPES = {
|
StreamResources.BluetoothSCOStream,
|
||||||
AudioManager.STREAM_BLUETOOTH_SCO,
|
StreamResources.RingerStream,
|
||||||
AudioManager.STREAM_RING,
|
StreamResources.VoiceStream,
|
||||||
AudioManager.STREAM_VOICE_CALL,
|
StreamResources.MediaStream,
|
||||||
AudioManager.STREAM_MUSIC,
|
StreamResources.NotificationStream
|
||||||
AudioManager.STREAM_NOTIFICATION
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final int [] CONTENT_DESCRIPTIONS = {
|
|
||||||
R.string.volume_icon_description_bluetooth,
|
|
||||||
R.string.volume_icon_description_ringer,
|
|
||||||
R.string.volume_icon_description_incall,
|
|
||||||
R.string.volume_icon_description_media,
|
|
||||||
R.string.volume_icon_description_notification
|
|
||||||
};
|
|
||||||
|
|
||||||
// These icons need to correspond to the ones above.
|
|
||||||
private static final int [] STREAM_ICONS_NORMAL = {
|
|
||||||
R.drawable.ic_audio_bt,
|
|
||||||
R.drawable.ic_audio_ring_notif,
|
|
||||||
R.drawable.ic_audio_phone,
|
|
||||||
R.drawable.ic_audio_vol,
|
|
||||||
R.drawable.ic_audio_notification,
|
|
||||||
};
|
|
||||||
|
|
||||||
// These icons need to correspond to the ones above.
|
|
||||||
private static final int [] STREAM_ICONS_MUTED = {
|
|
||||||
R.drawable.ic_audio_bt,
|
|
||||||
R.drawable.ic_audio_ring_notif_mute,
|
|
||||||
R.drawable.ic_audio_phone,
|
|
||||||
R.drawable.ic_audio_vol_mute,
|
|
||||||
R.drawable.ic_audio_notification_mute,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Object that contains data for each slider */
|
/** Object that contains data for each slider */
|
||||||
@@ -221,7 +238,8 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()];
|
mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()];
|
||||||
mVibrator = new Vibrator();
|
mVibrator = new Vibrator();
|
||||||
|
|
||||||
mShowCombinedVolumes = !context.getResources().getBoolean(R.bool.config_voice_capable);
|
mVoiceCapable = context.getResources().getBoolean(R.bool.config_voice_capable);
|
||||||
|
mShowCombinedVolumes = !mVoiceCapable;
|
||||||
// If we don't want to show multiple volumes, hide the settings button and divider
|
// If we don't want to show multiple volumes, hide the settings button and divider
|
||||||
if (!mShowCombinedVolumes) {
|
if (!mShowCombinedVolumes) {
|
||||||
mMoreButton.setVisibility(View.GONE);
|
mMoreButton.setVisibility(View.GONE);
|
||||||
@@ -260,10 +278,14 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) mContext
|
LayoutInflater inflater = (LayoutInflater) mContext
|
||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mStreamControls = new HashMap<Integer,StreamControl>(STREAM_TYPES.length);
|
mStreamControls = new HashMap<Integer, StreamControl>(STREAMS.length);
|
||||||
Resources res = mContext.getResources();
|
Resources res = mContext.getResources();
|
||||||
for (int i = 0; i < STREAM_TYPES.length; i++) {
|
for (int i = 0; i < STREAMS.length; i++) {
|
||||||
final int streamType = STREAM_TYPES[i];
|
StreamResources streamRes = STREAMS[i];
|
||||||
|
int streamType = streamRes.streamType;
|
||||||
|
if (mVoiceCapable && streamRes == StreamResources.NotificationStream) {
|
||||||
|
streamRes = StreamResources.RingerStream;
|
||||||
|
}
|
||||||
StreamControl sc = new StreamControl();
|
StreamControl sc = new StreamControl();
|
||||||
sc.streamType = streamType;
|
sc.streamType = streamType;
|
||||||
sc.group = (ViewGroup) inflater.inflate(R.layout.volume_adjust_item, null);
|
sc.group = (ViewGroup) inflater.inflate(R.layout.volume_adjust_item, null);
|
||||||
@@ -273,9 +295,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
sc.icon.setOnClickListener(this);
|
sc.icon.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
sc.icon.setTag(sc);
|
sc.icon.setTag(sc);
|
||||||
sc.icon.setContentDescription(res.getString(CONTENT_DESCRIPTIONS[i]));
|
sc.icon.setContentDescription(res.getString(streamRes.descRes));
|
||||||
sc.iconRes = STREAM_ICONS_NORMAL[i];
|
sc.iconRes = streamRes.iconRes;
|
||||||
sc.iconMuteRes = STREAM_ICONS_MUTED[i];
|
sc.iconMuteRes = streamRes.iconMuteRes;
|
||||||
sc.icon.setImageResource(sc.iconRes);
|
sc.icon.setImageResource(sc.iconRes);
|
||||||
sc.seekbarView = (SeekBar) sc.group.findViewById(R.id.seekbar);
|
sc.seekbarView = (SeekBar) sc.group.findViewById(R.id.seekbar);
|
||||||
int plusOne = (streamType == AudioSystem.STREAM_BLUETOOTH_SCO ||
|
int plusOne = (streamType == AudioSystem.STREAM_BLUETOOTH_SCO ||
|
||||||
@@ -307,13 +329,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
private void addOtherVolumes() {
|
private void addOtherVolumes() {
|
||||||
if (!mShowCombinedVolumes) return;
|
if (!mShowCombinedVolumes) return;
|
||||||
|
|
||||||
for (int i = 0; i < STREAM_TYPES.length; i++) {
|
for (int i = 0; i < STREAMS.length; i++) {
|
||||||
// Skip the phone specific ones and the active one
|
// Skip the phone specific ones and the active one
|
||||||
final int streamType = STREAM_TYPES[i];
|
final int streamType = STREAMS[i].streamType;
|
||||||
if (streamType == AudioManager.STREAM_RING
|
if (!STREAMS[i].show || streamType == mActiveStreamType) {
|
||||||
|| streamType == AudioManager.STREAM_VOICE_CALL
|
|
||||||
|| streamType == AudioManager.STREAM_BLUETOOTH_SCO
|
|
||||||
|| streamType == mActiveStreamType) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
StreamControl sc = mStreamControls.get(streamType);
|
StreamControl sc = mStreamControls.get(streamType);
|
||||||
|
|||||||
Reference in New Issue
Block a user