The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 19 | import com.android.internal.R; |
| 20 | |
| 21 | import android.app.Dialog; |
| 22 | import android.content.DialogInterface.OnDismissListener; |
| 23 | import android.content.BroadcastReceiver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.content.Context; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 25 | import android.content.DialogInterface; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.Intent; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 27 | import android.content.IntentFilter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.content.res.Resources; |
| 29 | import android.media.AudioManager; |
| 30 | import android.media.AudioService; |
| 31 | import android.media.AudioSystem; |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 32 | import android.media.RingtoneManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | import android.media.ToneGenerator; |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 34 | import android.net.Uri; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | import android.os.Handler; |
| 36 | import android.os.Message; |
Amith Yamasani | 284e630 | 2011-09-16 18:24:47 -0700 | [diff] [blame] | 37 | import android.os.RemoteException; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | import android.os.Vibrator; |
Amith Yamasani | 9b8e848 | 2011-08-10 15:55:36 -0700 | [diff] [blame] | 39 | import android.provider.Settings; |
| 40 | import android.provider.Settings.System; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | import android.util.Log; |
Amith Yamasani | 284e630 | 2011-09-16 18:24:47 -0700 | [diff] [blame] | 42 | import android.view.WindowManager.LayoutParams; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | import android.widget.ImageView; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 44 | import android.widget.SeekBar; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 45 | import android.widget.SeekBar.OnSeekBarChangeListener; |
| 46 | |
| 47 | import java.util.HashMap; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Handle the volume up and down keys. |
| 51 | * |
| 52 | * This code really should be moved elsewhere. |
| 53 | * |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 54 | * Seriously, it really really should be moved elsewhere. This is used by |
| 55 | * android.media.AudioService, which actually runs in the system process, to |
| 56 | * show the volume dialog when the user changes the volume. What a mess. |
| 57 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | * @hide |
| 59 | */ |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 60 | public class VolumePanel extends Handler implements OnSeekBarChangeListener, View.OnClickListener |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | { |
| 62 | private static final String TAG = "VolumePanel"; |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 63 | private static boolean LOGD = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * The delay before playing a sound. This small period exists so the user |
| 67 | * can press another key (non-volume keys, too) to have it NOT be audible. |
| 68 | * <p> |
| 69 | * PhoneWindow will implement this part. |
| 70 | */ |
| 71 | public static final int PLAY_SOUND_DELAY = 300; |
| 72 | |
| 73 | /** |
| 74 | * The delay before vibrating. This small period exists so if the user is |
| 75 | * moving to silent mode, it will not emit a short vibrate (it normally |
| 76 | * would since vibrate is between normal mode and silent mode using hardware |
| 77 | * keys). |
| 78 | */ |
| 79 | public static final int VIBRATE_DELAY = 300; |
| 80 | |
| 81 | private static final int VIBRATE_DURATION = 300; |
| 82 | private static final int BEEP_DURATION = 150; |
| 83 | private static final int MAX_VOLUME = 100; |
| 84 | private static final int FREE_DELAY = 10000; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 85 | private static final int TIMEOUT_DELAY = 3000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | |
| 87 | private static final int MSG_VOLUME_CHANGED = 0; |
| 88 | private static final int MSG_FREE_RESOURCES = 1; |
| 89 | private static final int MSG_PLAY_SOUND = 2; |
| 90 | private static final int MSG_STOP_SOUNDS = 3; |
| 91 | private static final int MSG_VIBRATE = 4; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 92 | private static final int MSG_TIMEOUT = 5; |
| 93 | private static final int MSG_RINGER_MODE_CHANGED = 6; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | protected Context mContext; |
| 96 | private AudioManager mAudioManager; |
| 97 | protected AudioService mAudioService; |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 98 | private boolean mRingIsSilent; |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 99 | private boolean mShowCombinedVolumes; |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 100 | private boolean mVoiceCapable; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 101 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 102 | /** Dialog containing all the sliders */ |
| 103 | private final Dialog mDialog; |
| 104 | /** Dialog's content view */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | private final View mView; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 106 | |
Amith Yamasani | baf6dbf | 2011-08-18 17:40:29 -0700 | [diff] [blame] | 107 | /** The visible portion of the volume overlay */ |
| 108 | private final ViewGroup mPanel; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 109 | /** Contains the sliders and their touchable icons */ |
| 110 | private final ViewGroup mSliderGroup; |
| 111 | /** The button that expands the dialog to show all sliders */ |
| 112 | private final View mMoreButton; |
| 113 | /** Dummy divider icon that needs to vanish with the more button */ |
| 114 | private final View mDivider; |
| 115 | |
| 116 | /** Currently active stream that shows up at the top of the list of sliders */ |
| 117 | private int mActiveStreamType = -1; |
| 118 | /** All the slider controls mapped by stream type */ |
| 119 | private HashMap<Integer,StreamControl> mStreamControls; |
| 120 | |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 121 | private enum StreamResources { |
| 122 | BluetoothSCOStream(AudioManager.STREAM_BLUETOOTH_SCO, |
| 123 | R.string.volume_icon_description_bluetooth, |
| 124 | R.drawable.ic_audio_bt, |
| 125 | R.drawable.ic_audio_bt, |
| 126 | false), |
| 127 | RingerStream(AudioManager.STREAM_RING, |
| 128 | R.string.volume_icon_description_ringer, |
| 129 | R.drawable.ic_audio_ring_notif, |
| 130 | R.drawable.ic_audio_ring_notif_mute, |
| 131 | false), |
| 132 | VoiceStream(AudioManager.STREAM_VOICE_CALL, |
| 133 | R.string.volume_icon_description_incall, |
| 134 | R.drawable.ic_audio_phone, |
| 135 | R.drawable.ic_audio_phone, |
| 136 | false), |
Amith Yamasani | 92e1b2d | 2011-10-14 17:24:47 -0700 | [diff] [blame^] | 137 | AlarmStream(AudioManager.STREAM_ALARM, |
| 138 | R.string.volume_alarm, |
| 139 | R.drawable.ic_audio_alarm, |
| 140 | R.drawable.ic_audio_alarm_mute, |
| 141 | false), |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 142 | MediaStream(AudioManager.STREAM_MUSIC, |
| 143 | R.string.volume_icon_description_media, |
| 144 | R.drawable.ic_audio_vol, |
| 145 | R.drawable.ic_audio_vol_mute, |
| 146 | true), |
| 147 | NotificationStream(AudioManager.STREAM_NOTIFICATION, |
| 148 | R.string.volume_icon_description_notification, |
| 149 | R.drawable.ic_audio_notification, |
| 150 | R.drawable.ic_audio_notification_mute, |
| 151 | true); |
| 152 | |
| 153 | int streamType; |
| 154 | int descRes; |
| 155 | int iconRes; |
| 156 | int iconMuteRes; |
| 157 | // RING, VOICE_CALL & BLUETOOTH_SCO are hidden unless explicitly requested |
| 158 | boolean show; |
| 159 | |
| 160 | StreamResources(int streamType, int descRes, int iconRes, int iconMuteRes, boolean show) { |
| 161 | this.streamType = streamType; |
| 162 | this.descRes = descRes; |
| 163 | this.iconRes = iconRes; |
| 164 | this.iconMuteRes = iconMuteRes; |
| 165 | this.show = show; |
| 166 | } |
| 167 | }; |
| 168 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 169 | // List of stream types and their order |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 170 | private static final StreamResources[] STREAMS = { |
| 171 | StreamResources.BluetoothSCOStream, |
| 172 | StreamResources.RingerStream, |
| 173 | StreamResources.VoiceStream, |
| 174 | StreamResources.MediaStream, |
Amith Yamasani | 92e1b2d | 2011-10-14 17:24:47 -0700 | [diff] [blame^] | 175 | StreamResources.NotificationStream, |
| 176 | StreamResources.AlarmStream |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | /** Object that contains data for each slider */ |
| 180 | private class StreamControl { |
| 181 | int streamType; |
| 182 | ViewGroup group; |
| 183 | ImageView icon; |
| 184 | SeekBar seekbarView; |
| 185 | int iconRes; |
| 186 | int iconMuteRes; |
| 187 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 188 | |
| 189 | // Synchronize when accessing this |
| 190 | private ToneGenerator mToneGenerators[]; |
| 191 | private Vibrator mVibrator; |
| 192 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 193 | public VolumePanel(final Context context, AudioService volumeService) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | mContext = context; |
| 195 | mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); |
| 196 | mAudioService = volumeService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 197 | |
| 198 | LayoutInflater inflater = (LayoutInflater) context |
| 199 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 200 | View view = mView = inflater.inflate(R.layout.volume_adjust, null); |
| 201 | mView.setOnTouchListener(new View.OnTouchListener() { |
| 202 | public boolean onTouch(View v, MotionEvent event) { |
| 203 | resetTimeout(); |
Amith Yamasani | 284e630 | 2011-09-16 18:24:47 -0700 | [diff] [blame] | 204 | return false; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 205 | } |
| 206 | }); |
Amith Yamasani | baf6dbf | 2011-08-18 17:40:29 -0700 | [diff] [blame] | 207 | mPanel = (ViewGroup) mView.findViewById(R.id.visible_panel); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 208 | mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group); |
| 209 | mMoreButton = (ImageView) mView.findViewById(R.id.expand_button); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 210 | mDivider = (ImageView) mView.findViewById(R.id.expand_button_divider); |
| 211 | |
Amith Yamasani | 284e630 | 2011-09-16 18:24:47 -0700 | [diff] [blame] | 212 | mDialog = new Dialog(context, R.style.Theme_Panel_Volume) { |
| 213 | public boolean onTouchEvent(MotionEvent event) { |
| 214 | if (isShowing() && event.getAction() == MotionEvent.ACTION_OUTSIDE) { |
| 215 | forceTimeout(); |
| 216 | return true; |
| 217 | } |
| 218 | return false; |
| 219 | } |
| 220 | }; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 221 | mDialog.setTitle("Volume control"); // No need to localize |
| 222 | mDialog.setContentView(mView); |
| 223 | mDialog.setOnDismissListener(new OnDismissListener() { |
| 224 | public void onDismiss(DialogInterface dialog) { |
| 225 | mActiveStreamType = -1; |
Eric Laurent | 402f7f2 | 2011-02-04 12:30:32 -0800 | [diff] [blame] | 226 | mAudioManager.forceVolumeControlStream(mActiveStreamType); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 227 | } |
| 228 | }); |
| 229 | // Change some window properties |
| 230 | Window window = mDialog.getWindow(); |
| 231 | window.setGravity(Gravity.TOP); |
Amith Yamasani | 284e630 | 2011-09-16 18:24:47 -0700 | [diff] [blame] | 232 | LayoutParams lp = window.getAttributes(); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 233 | lp.token = null; |
Amith Yamasani | 284e630 | 2011-09-16 18:24:47 -0700 | [diff] [blame] | 234 | // Offset from the top |
| 235 | lp.y = mContext.getResources().getDimensionPixelOffset( |
| 236 | com.android.internal.R.dimen.volume_panel_top); |
| 237 | lp.type = LayoutParams.TYPE_VOLUME_OVERLAY; |
| 238 | lp.width = LayoutParams.WRAP_CONTENT; |
| 239 | lp.height = LayoutParams.WRAP_CONTENT; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 240 | window.setAttributes(lp); |
Amith Yamasani | 284e630 | 2011-09-16 18:24:47 -0700 | [diff] [blame] | 241 | window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 242 | | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 243 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 244 | mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()]; |
| 245 | mVibrator = new Vibrator(); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 246 | |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 247 | mVoiceCapable = context.getResources().getBoolean(R.bool.config_voice_capable); |
| 248 | mShowCombinedVolumes = !mVoiceCapable; |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 249 | // If we don't want to show multiple volumes, hide the settings button and divider |
| 250 | if (!mShowCombinedVolumes) { |
| 251 | mMoreButton.setVisibility(View.GONE); |
| 252 | mDivider.setVisibility(View.GONE); |
| 253 | } else { |
| 254 | mMoreButton.setOnClickListener(this); |
| 255 | } |
| 256 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 257 | listenToRingerMode(); |
| 258 | } |
| 259 | |
| 260 | private void listenToRingerMode() { |
| 261 | final IntentFilter filter = new IntentFilter(); |
| 262 | filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); |
| 263 | mContext.registerReceiver(new BroadcastReceiver() { |
| 264 | |
| 265 | public void onReceive(Context context, Intent intent) { |
| 266 | final String action = intent.getAction(); |
| 267 | |
| 268 | if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) { |
| 269 | removeMessages(MSG_RINGER_MODE_CHANGED); |
| 270 | sendMessage(obtainMessage(MSG_RINGER_MODE_CHANGED)); |
| 271 | } |
| 272 | } |
| 273 | }, filter); |
| 274 | } |
| 275 | |
| 276 | private boolean isMuted(int streamType) { |
| 277 | return mAudioManager.isStreamMute(streamType); |
| 278 | } |
| 279 | |
| 280 | private void createSliders() { |
Amith Yamasani | 9b8e848 | 2011-08-10 15:55:36 -0700 | [diff] [blame] | 281 | final int silentableStreams = System.getInt(mContext.getContentResolver(), |
| 282 | System.MODE_RINGER_STREAMS_AFFECTED, |
| 283 | ((1 << AudioSystem.STREAM_NOTIFICATION) | (1 << AudioSystem.STREAM_RING))); |
| 284 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 285 | LayoutInflater inflater = (LayoutInflater) mContext |
| 286 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 287 | mStreamControls = new HashMap<Integer, StreamControl>(STREAMS.length); |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 288 | Resources res = mContext.getResources(); |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 289 | for (int i = 0; i < STREAMS.length; i++) { |
| 290 | StreamResources streamRes = STREAMS[i]; |
| 291 | int streamType = streamRes.streamType; |
| 292 | if (mVoiceCapable && streamRes == StreamResources.NotificationStream) { |
| 293 | streamRes = StreamResources.RingerStream; |
| 294 | } |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 295 | StreamControl sc = new StreamControl(); |
Amith Yamasani | d47a3aee | 2011-08-23 11:11:35 -0700 | [diff] [blame] | 296 | sc.streamType = streamType; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 297 | sc.group = (ViewGroup) inflater.inflate(R.layout.volume_adjust_item, null); |
| 298 | sc.group.setTag(sc); |
| 299 | sc.icon = (ImageView) sc.group.findViewById(R.id.stream_icon); |
Amith Yamasani | 9b8e848 | 2011-08-10 15:55:36 -0700 | [diff] [blame] | 300 | if ((silentableStreams & (1 << sc.streamType)) != 0) { |
| 301 | sc.icon.setOnClickListener(this); |
| 302 | } |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 303 | sc.icon.setTag(sc); |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 304 | sc.icon.setContentDescription(res.getString(streamRes.descRes)); |
| 305 | sc.iconRes = streamRes.iconRes; |
| 306 | sc.iconMuteRes = streamRes.iconMuteRes; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 307 | sc.icon.setImageResource(sc.iconRes); |
| 308 | sc.seekbarView = (SeekBar) sc.group.findViewById(R.id.seekbar); |
Amith Yamasani | d47a3aee | 2011-08-23 11:11:35 -0700 | [diff] [blame] | 309 | int plusOne = (streamType == AudioSystem.STREAM_BLUETOOTH_SCO || |
| 310 | streamType == AudioSystem.STREAM_VOICE_CALL) ? 1 : 0; |
| 311 | sc.seekbarView.setMax(mAudioManager.getStreamMaxVolume(streamType) + plusOne); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 312 | sc.seekbarView.setOnSeekBarChangeListener(this); |
| 313 | sc.seekbarView.setTag(sc); |
Amith Yamasani | d47a3aee | 2011-08-23 11:11:35 -0700 | [diff] [blame] | 314 | mStreamControls.put(streamType, sc); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | |
| 318 | private void reorderSliders(int activeStreamType) { |
| 319 | mSliderGroup.removeAllViews(); |
| 320 | |
| 321 | StreamControl active = mStreamControls.get(activeStreamType); |
| 322 | if (active == null) { |
| 323 | Log.e("VolumePanel", "Missing stream type! - " + activeStreamType); |
| 324 | mActiveStreamType = -1; |
| 325 | } else { |
| 326 | mSliderGroup.addView(active.group); |
| 327 | mActiveStreamType = activeStreamType; |
| 328 | active.group.setVisibility(View.VISIBLE); |
| 329 | updateSlider(active); |
| 330 | } |
| 331 | |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 332 | addOtherVolumes(); |
| 333 | } |
| 334 | |
| 335 | private void addOtherVolumes() { |
| 336 | if (!mShowCombinedVolumes) return; |
| 337 | |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 338 | for (int i = 0; i < STREAMS.length; i++) { |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 339 | // Skip the phone specific ones and the active one |
Amith Yamasani | 71def77 | 2011-10-12 12:25:24 -0700 | [diff] [blame] | 340 | final int streamType = STREAMS[i].streamType; |
| 341 | if (!STREAMS[i].show || streamType == mActiveStreamType) { |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 342 | continue; |
| 343 | } |
| 344 | StreamControl sc = mStreamControls.get(streamType); |
| 345 | mSliderGroup.addView(sc.group); |
| 346 | updateSlider(sc); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | /** Update the mute and progress state of a slider */ |
| 351 | private void updateSlider(StreamControl sc) { |
| 352 | sc.seekbarView.setProgress(mAudioManager.getLastAudibleStreamVolume(sc.streamType)); |
| 353 | final boolean muted = isMuted(sc.streamType); |
| 354 | sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes); |
| 355 | sc.seekbarView.setEnabled(!muted); |
| 356 | } |
| 357 | |
| 358 | private boolean isExpanded() { |
| 359 | return mMoreButton.getVisibility() != View.VISIBLE; |
| 360 | } |
| 361 | |
| 362 | private void expand() { |
| 363 | final int count = mSliderGroup.getChildCount(); |
| 364 | for (int i = 0; i < count; i++) { |
| 365 | mSliderGroup.getChildAt(i).setVisibility(View.VISIBLE); |
| 366 | } |
| 367 | mMoreButton.setVisibility(View.INVISIBLE); |
| 368 | mDivider.setVisibility(View.INVISIBLE); |
| 369 | } |
| 370 | |
| 371 | private void collapse() { |
| 372 | mMoreButton.setVisibility(View.VISIBLE); |
| 373 | mDivider.setVisibility(View.VISIBLE); |
| 374 | final int count = mSliderGroup.getChildCount(); |
| 375 | for (int i = 1; i < count; i++) { |
| 376 | mSliderGroup.getChildAt(i).setVisibility(View.GONE); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | private void updateStates() { |
| 381 | final int count = mSliderGroup.getChildCount(); |
| 382 | for (int i = 0; i < count; i++) { |
| 383 | StreamControl sc = (StreamControl) mSliderGroup.getChildAt(i).getTag(); |
| 384 | updateSlider(sc); |
| 385 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | public void postVolumeChanged(int streamType, int flags) { |
| 389 | if (hasMessages(MSG_VOLUME_CHANGED)) return; |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 390 | if (mStreamControls == null) { |
| 391 | createSliders(); |
| 392 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 393 | removeMessages(MSG_FREE_RESOURCES); |
| 394 | obtainMessage(MSG_VOLUME_CHANGED, streamType, flags).sendToTarget(); |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * Override this if you have other work to do when the volume changes (for |
| 399 | * example, vibrating, playing a sound, etc.). Make sure to call through to |
| 400 | * the superclass implementation. |
| 401 | */ |
| 402 | protected void onVolumeChanged(int streamType, int flags) { |
| 403 | |
| 404 | if (LOGD) Log.d(TAG, "onVolumeChanged(streamType: " + streamType + ", flags: " + flags + ")"); |
| 405 | |
| 406 | if ((flags & AudioManager.FLAG_SHOW_UI) != 0) { |
Amith Yamasani | e3361b8 | 2011-02-10 18:20:50 -0800 | [diff] [blame] | 407 | if (mActiveStreamType == -1) { |
| 408 | reorderSliders(streamType); |
| 409 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 410 | onShowVolumeChanged(streamType, flags); |
| 411 | } |
| 412 | |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 413 | if ((flags & AudioManager.FLAG_PLAY_SOUND) != 0 && ! mRingIsSilent) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 414 | removeMessages(MSG_PLAY_SOUND); |
| 415 | sendMessageDelayed(obtainMessage(MSG_PLAY_SOUND, streamType, flags), PLAY_SOUND_DELAY); |
| 416 | } |
| 417 | |
| 418 | if ((flags & AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE) != 0) { |
| 419 | removeMessages(MSG_PLAY_SOUND); |
| 420 | removeMessages(MSG_VIBRATE); |
| 421 | onStopSounds(); |
| 422 | } |
| 423 | |
| 424 | removeMessages(MSG_FREE_RESOURCES); |
| 425 | sendMessageDelayed(obtainMessage(MSG_FREE_RESOURCES), FREE_DELAY); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 426 | |
| 427 | resetTimeout(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | protected void onShowVolumeChanged(int streamType, int flags) { |
Eric Laurent | d72d51c | 2011-02-03 18:47:47 -0800 | [diff] [blame] | 431 | int index = mAudioService.isStreamMute(streamType) ? |
| 432 | mAudioService.getLastAudibleStreamVolume(streamType) |
| 433 | : mAudioService.getStreamVolume(streamType); |
| 434 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 435 | // int message = UNKNOWN_VOLUME_TEXT; |
| 436 | // int additionalMessage = 0; |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 437 | mRingIsSilent = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 438 | |
| 439 | if (LOGD) { |
| 440 | Log.d(TAG, "onShowVolumeChanged(streamType: " + streamType |
| 441 | + ", flags: " + flags + "), index: " + index); |
| 442 | } |
| 443 | |
| 444 | // get max volume for progress bar |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 445 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 446 | int max = mAudioService.getStreamMaxVolume(streamType); |
| 447 | |
| 448 | switch (streamType) { |
| 449 | |
| 450 | case AudioManager.STREAM_RING: { |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 451 | // setRingerIcon(); |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 452 | Uri ringuri = RingtoneManager.getActualDefaultRingtoneUri( |
| 453 | mContext, RingtoneManager.TYPE_RINGTONE); |
| 454 | if (ringuri == null) { |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 455 | mRingIsSilent = true; |
| 456 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 457 | break; |
| 458 | } |
| 459 | |
| 460 | case AudioManager.STREAM_MUSIC: { |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 461 | // Special case for when Bluetooth is active for music |
Glenn Kasten | 8b4b97a | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 462 | if ((mAudioManager.getDevicesForStream(AudioManager.STREAM_MUSIC) & |
| 463 | (AudioManager.DEVICE_OUT_BLUETOOTH_A2DP | |
| 464 | AudioManager.DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | |
| 465 | AudioManager.DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)) != 0) { |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 466 | setMusicIcon(R.drawable.ic_audio_bt, R.drawable.ic_audio_bt_mute); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 467 | } else { |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 468 | setMusicIcon(R.drawable.ic_audio_vol, R.drawable.ic_audio_vol_mute); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 469 | } |
| 470 | break; |
| 471 | } |
| 472 | |
| 473 | case AudioManager.STREAM_VOICE_CALL: { |
| 474 | /* |
| 475 | * For in-call voice call volume, there is no inaudible volume. |
| 476 | * Rescale the UI control so the progress bar doesn't go all |
| 477 | * the way to zero and don't show the mute icon. |
| 478 | */ |
| 479 | index++; |
| 480 | max++; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 481 | break; |
| 482 | } |
| 483 | |
| 484 | case AudioManager.STREAM_ALARM: { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 485 | break; |
| 486 | } |
| 487 | |
| 488 | case AudioManager.STREAM_NOTIFICATION: { |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 489 | Uri ringuri = RingtoneManager.getActualDefaultRingtoneUri( |
| 490 | mContext, RingtoneManager.TYPE_NOTIFICATION); |
| 491 | if (ringuri == null) { |
Marco Nelissen | 69f593c | 2009-07-28 09:55:04 -0700 | [diff] [blame] | 492 | mRingIsSilent = true; |
| 493 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 494 | break; |
| 495 | } |
| 496 | |
| 497 | case AudioManager.STREAM_BLUETOOTH_SCO: { |
| 498 | /* |
| 499 | * For in-call voice call volume, there is no inaudible volume. |
| 500 | * Rescale the UI control so the progress bar doesn't go all |
| 501 | * the way to zero and don't show the mute icon. |
| 502 | */ |
| 503 | index++; |
| 504 | max++; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 505 | break; |
| 506 | } |
| 507 | } |
| 508 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 509 | StreamControl sc = mStreamControls.get(streamType); |
| 510 | if (sc != null) { |
Amith Yamasani | d47a3aee | 2011-08-23 11:11:35 -0700 | [diff] [blame] | 511 | if (sc.seekbarView.getMax() != max) { |
| 512 | sc.seekbarView.setMax(max); |
| 513 | } |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 514 | sc.seekbarView.setProgress(index); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | } |
| 516 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 517 | if (!mDialog.isShowing()) { |
Eric Laurent | 402f7f2 | 2011-02-04 12:30:32 -0800 | [diff] [blame] | 518 | mAudioManager.forceVolumeControlStream(streamType); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 519 | mDialog.setContentView(mView); |
| 520 | // Showing dialog - use collapsed state |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 521 | if (mShowCombinedVolumes) { |
| 522 | collapse(); |
| 523 | } |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 524 | mDialog.show(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 525 | } |
| 526 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 527 | // Do a little vibrate if applicable (only when going into vibrate mode) |
| 528 | if ((flags & AudioManager.FLAG_VIBRATE) != 0 && |
| 529 | mAudioService.isStreamAffectedByRingerMode(streamType) && |
| 530 | mAudioService.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE && |
| 531 | mAudioService.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) { |
| 532 | sendMessageDelayed(obtainMessage(MSG_VIBRATE), VIBRATE_DELAY); |
| 533 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | protected void onPlaySound(int streamType, int flags) { |
| 537 | |
| 538 | if (hasMessages(MSG_STOP_SOUNDS)) { |
| 539 | removeMessages(MSG_STOP_SOUNDS); |
| 540 | // Force stop right now |
| 541 | onStopSounds(); |
| 542 | } |
| 543 | |
| 544 | synchronized (this) { |
| 545 | ToneGenerator toneGen = getOrCreateToneGenerator(streamType); |
Eric Laurent | 733a42b | 2011-01-19 10:41:57 -0800 | [diff] [blame] | 546 | if (toneGen != null) { |
| 547 | toneGen.startTone(ToneGenerator.TONE_PROP_BEEP); |
| 548 | sendMessageDelayed(obtainMessage(MSG_STOP_SOUNDS), BEEP_DURATION); |
| 549 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | protected void onStopSounds() { |
| 554 | |
| 555 | synchronized (this) { |
| 556 | int numStreamTypes = AudioSystem.getNumStreamTypes(); |
| 557 | for (int i = numStreamTypes - 1; i >= 0; i--) { |
| 558 | ToneGenerator toneGen = mToneGenerators[i]; |
| 559 | if (toneGen != null) { |
| 560 | toneGen.stopTone(); |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | protected void onVibrate() { |
| 567 | |
| 568 | // Make sure we ended up in vibrate ringer mode |
| 569 | if (mAudioService.getRingerMode() != AudioManager.RINGER_MODE_VIBRATE) { |
| 570 | return; |
| 571 | } |
| 572 | |
| 573 | mVibrator.vibrate(VIBRATE_DURATION); |
| 574 | } |
| 575 | |
| 576 | /** |
| 577 | * Lock on this VolumePanel instance as long as you use the returned ToneGenerator. |
| 578 | */ |
| 579 | private ToneGenerator getOrCreateToneGenerator(int streamType) { |
| 580 | synchronized (this) { |
| 581 | if (mToneGenerators[streamType] == null) { |
Eric Laurent | 733a42b | 2011-01-19 10:41:57 -0800 | [diff] [blame] | 582 | try { |
| 583 | mToneGenerators[streamType] = new ToneGenerator(streamType, MAX_VOLUME); |
| 584 | } catch (RuntimeException e) { |
| 585 | if (LOGD) { |
| 586 | Log.d(TAG, "ToneGenerator constructor failed with " |
| 587 | + "RuntimeException: " + e); |
| 588 | } |
| 589 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 590 | } |
Eric Laurent | 733a42b | 2011-01-19 10:41:57 -0800 | [diff] [blame] | 591 | return mToneGenerators[streamType]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 592 | } |
| 593 | } |
| 594 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 595 | |
| 596 | /** |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 597 | * Switch between icons because Bluetooth music is same as music volume, but with |
| 598 | * different icons. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 599 | */ |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 600 | private void setMusicIcon(int resId, int resMuteId) { |
| 601 | StreamControl sc = mStreamControls.get(AudioManager.STREAM_MUSIC); |
| 602 | if (sc != null) { |
| 603 | sc.iconRes = resId; |
| 604 | sc.iconMuteRes = resMuteId; |
| 605 | sc.icon.setImageResource(isMuted(sc.streamType) ? sc.iconMuteRes : sc.iconRes); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 606 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | protected void onFreeResources() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 610 | synchronized (this) { |
| 611 | for (int i = mToneGenerators.length - 1; i >= 0; i--) { |
| 612 | if (mToneGenerators[i] != null) { |
| 613 | mToneGenerators[i].release(); |
| 614 | } |
| 615 | mToneGenerators[i] = null; |
| 616 | } |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | @Override |
| 621 | public void handleMessage(Message msg) { |
| 622 | switch (msg.what) { |
| 623 | |
| 624 | case MSG_VOLUME_CHANGED: { |
| 625 | onVolumeChanged(msg.arg1, msg.arg2); |
| 626 | break; |
| 627 | } |
| 628 | |
| 629 | case MSG_FREE_RESOURCES: { |
| 630 | onFreeResources(); |
| 631 | break; |
| 632 | } |
| 633 | |
| 634 | case MSG_STOP_SOUNDS: { |
| 635 | onStopSounds(); |
| 636 | break; |
| 637 | } |
| 638 | |
| 639 | case MSG_PLAY_SOUND: { |
| 640 | onPlaySound(msg.arg1, msg.arg2); |
| 641 | break; |
| 642 | } |
| 643 | |
| 644 | case MSG_VIBRATE: { |
| 645 | onVibrate(); |
| 646 | break; |
| 647 | } |
| 648 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 649 | case MSG_TIMEOUT: { |
| 650 | if (mDialog.isShowing()) { |
| 651 | mDialog.dismiss(); |
| 652 | mActiveStreamType = -1; |
| 653 | } |
| 654 | break; |
| 655 | } |
| 656 | case MSG_RINGER_MODE_CHANGED: { |
| 657 | if (mDialog.isShowing()) { |
| 658 | updateStates(); |
| 659 | } |
| 660 | break; |
| 661 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 662 | } |
| 663 | } |
| 664 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 665 | private void resetTimeout() { |
| 666 | removeMessages(MSG_TIMEOUT); |
| 667 | sendMessageDelayed(obtainMessage(MSG_TIMEOUT), TIMEOUT_DELAY); |
| 668 | } |
| 669 | |
Amith Yamasani | baf6dbf | 2011-08-18 17:40:29 -0700 | [diff] [blame] | 670 | private void forceTimeout() { |
| 671 | removeMessages(MSG_TIMEOUT); |
| 672 | sendMessage(obtainMessage(MSG_TIMEOUT)); |
| 673 | } |
| 674 | |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 675 | public void onProgressChanged(SeekBar seekBar, int progress, |
| 676 | boolean fromUser) { |
| 677 | final Object tag = seekBar.getTag(); |
| 678 | if (fromUser && tag instanceof StreamControl) { |
| 679 | StreamControl sc = (StreamControl) tag; |
| 680 | if (mAudioManager.getStreamVolume(sc.streamType) != progress) { |
| 681 | mAudioManager.setStreamVolume(sc.streamType, progress, 0); |
| 682 | } |
| 683 | } |
| 684 | resetTimeout(); |
| 685 | } |
| 686 | |
| 687 | public void onStartTrackingTouch(SeekBar seekBar) { |
| 688 | } |
| 689 | |
| 690 | public void onStopTrackingTouch(SeekBar seekBar) { |
| 691 | } |
| 692 | |
| 693 | public void onClick(View v) { |
| 694 | if (v == mMoreButton) { |
| 695 | expand(); |
| 696 | } else if (v.getTag() instanceof StreamControl) { |
| 697 | StreamControl sc = (StreamControl) v.getTag(); |
| 698 | mAudioManager.setRingerMode(mAudioManager.isSilentMode() |
| 699 | ? AudioManager.RINGER_MODE_NORMAL : AudioManager.RINGER_MODE_SILENT); |
| 700 | // Expand the dialog if it hasn't been expanded yet. |
Amith Yamasani | 42722bf | 2011-07-22 10:34:27 -0700 | [diff] [blame] | 701 | if (mShowCombinedVolumes && !isExpanded()) expand(); |
Amith Yamasani | 2bbdd77 | 2011-02-02 18:54:13 -0800 | [diff] [blame] | 702 | } |
| 703 | resetTimeout(); |
| 704 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 705 | } |