Skip to content

Commit

Permalink
Bugfix : Expanded volume overlay
Browse files Browse the repository at this point in the history
If you switch to the Expanded volume overlay
(Settings > Sound > Volume panel)
from any of the other settings that are not expanded
then the Expanded overlay appears collapsed.

The only way to make it appear expanded is to restart the framework
or
In the Expandable view - expand the volumes - then immediately change.

This patch fixes this and also has a slight improvement in the
case where a user selects the same choice they have already.

Change-Id: I9264ce62e239f497e0a2924c6769f066f196ebeb
  • Loading branch information
StevenHarperUK committed Apr 13, 2012
1 parent d628aa0 commit 9b06af9
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions core/java/android/view/VolumePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
private boolean mRingIsSilent;
private boolean mShowCombinedVolumes;
private boolean mVoiceCapable;
private int mCurrentOverlayStyle;
private int mCurrentOverlayStyle = -1;

/** Dialog containing all the sliders */
private final Dialog mDialog;
Expand Down Expand Up @@ -250,16 +250,16 @@ public void onDismiss(DialogInterface dialog) {
mVoiceCapable = context.getResources().getBoolean(R.bool.config_voice_capable);

// get the users preference
mCurrentOverlayStyle = Settings.System.getInt(context.getContentResolver(),Settings.System.MODE_VOLUME_OVERLAY, Settings.System.VOLUME_OVERLAY_SINGLE);
int choosenStyle = Settings.System.getInt(context.getContentResolver(),Settings.System.MODE_VOLUME_OVERLAY, Settings.System.VOLUME_OVERLAY_SINGLE);
// by default -1 is expected - deal with choosing the right default
if (mCurrentOverlayStyle == -1) {
if (choosenStyle == -1) {
if (mVoiceCapable) {
mCurrentOverlayStyle = Settings.System.VOLUME_OVERLAY_SINGLE;
choosenStyle = Settings.System.VOLUME_OVERLAY_SINGLE;
} else {
mCurrentOverlayStyle = Settings.System.VOLUME_OVERLAY_EXPANDABLE;
choosenStyle = Settings.System.VOLUME_OVERLAY_EXPANDABLE;
}
}
changeOverlayStyle(mCurrentOverlayStyle);
changeOverlayStyle(choosenStyle);
mMoreButton.setOnClickListener(this);

listenToRingerModeAndConfigChanges();
Expand Down Expand Up @@ -287,6 +287,8 @@ public void onReceive(Context context, Intent intent) {

private void changeOverlayStyle(int newStyle) {
Log.i("VolumePanel", "changeOverlayStyle : " + newStyle);
// Don't change to the same style
if (newStyle == mCurrentOverlayStyle) return;
switch (newStyle) {
case Settings.System.VOLUME_OVERLAY_SINGLE :
mMoreButton.setVisibility(View.GONE);
Expand Down Expand Up @@ -403,7 +405,9 @@ private void expand() {
final int count = mSliderGroup.getChildCount();

for (int i = 0; i < count; i++) {
mSliderGroup.getChildAt(i).setVisibility(View.VISIBLE);
if (mSliderGroup.getChildAt(i).getVisibility() != View.VISIBLE) {
mSliderGroup.getChildAt(i).setVisibility(View.VISIBLE);
}
}
mMoreButton.setVisibility(View.GONE);
mDivider.setVisibility(View.GONE);
Expand Down Expand Up @@ -585,6 +589,10 @@ protected void onShowVolumeChanged(int streamType, int flags) {
if (mShowCombinedVolumes && mCurrentOverlayStyle != Settings.System.VOLUME_OVERLAY_EXPANDED) {
collapse();
}
// If just changed the style and we need to expand
if (mCurrentOverlayStyle == Settings.System.VOLUME_OVERLAY_EXPANDED) {
expand();
}
mDialog.show();
}

Expand Down

0 comments on commit 9b06af9

Please sign in to comment.