John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 com.android.systemui.volume; |
| 18 | |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 19 | import android.accessibilityservice.AccessibilityServiceInfo; |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 20 | import android.animation.ObjectAnimator; |
Julia Reynolds | 2feab16 | 2016-04-21 14:58:52 -0400 | [diff] [blame] | 21 | import android.annotation.NonNull; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 22 | import android.annotation.SuppressLint; |
| 23 | import android.app.Dialog; |
| 24 | import android.app.KeyguardManager; |
| 25 | import android.content.Context; |
Takayuki Hoshi | bb0ec55 | 2015-12-17 20:50:25 +0900 | [diff] [blame] | 26 | import android.content.pm.PackageManager; |
John Spurlock | 77bb25af | 2015-05-11 12:12:07 -0400 | [diff] [blame] | 27 | import android.content.res.ColorStateList; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 28 | import android.content.res.Configuration; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 29 | import android.content.res.Resources; |
| 30 | import android.graphics.Color; |
| 31 | import android.graphics.PixelFormat; |
| 32 | import android.graphics.Rect; |
| 33 | import android.graphics.drawable.AnimatedVectorDrawable; |
| 34 | import android.graphics.drawable.ColorDrawable; |
| 35 | import android.graphics.drawable.Drawable; |
| 36 | import android.media.AudioManager; |
| 37 | import android.media.AudioSystem; |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 38 | import android.os.Debug; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 39 | import android.os.Handler; |
| 40 | import android.os.Looper; |
| 41 | import android.os.Message; |
| 42 | import android.os.SystemClock; |
| 43 | import android.provider.Settings.Global; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 44 | import android.transition.AutoTransition; |
| 45 | import android.transition.Transition; |
| 46 | import android.transition.TransitionManager; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 47 | import android.util.DisplayMetrics; |
| 48 | import android.util.Log; |
| 49 | import android.util.SparseBooleanArray; |
| 50 | import android.view.Gravity; |
| 51 | import android.view.MotionEvent; |
| 52 | import android.view.View; |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 53 | import android.view.View.AccessibilityDelegate; |
| 54 | import android.view.View.OnAttachStateChangeListener; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 55 | import android.view.View.OnClickListener; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 56 | import android.view.View.OnTouchListener; |
| 57 | import android.view.ViewGroup; |
| 58 | import android.view.ViewGroup.MarginLayoutParams; |
| 59 | import android.view.Window; |
| 60 | import android.view.WindowManager; |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 61 | import android.view.accessibility.AccessibilityEvent; |
| 62 | import android.view.accessibility.AccessibilityManager; |
| 63 | import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener; |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 64 | import android.view.animation.DecelerateInterpolator; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 65 | import android.widget.ImageButton; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 66 | import android.widget.SeekBar; |
| 67 | import android.widget.SeekBar.OnSeekBarChangeListener; |
| 68 | import android.widget.TextView; |
| 69 | |
Andrew Sapperstein | 5c37344 | 2016-06-12 13:17:16 -0700 | [diff] [blame] | 70 | import com.android.settingslib.Utils; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 71 | import com.android.systemui.Interpolators; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 72 | import com.android.systemui.R; |
| 73 | import com.android.systemui.statusbar.policy.ZenModeController; |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 74 | import com.android.systemui.tuner.TunerService; |
Jason Monk | aa911b3 | 2016-02-10 21:01:30 -0500 | [diff] [blame] | 75 | import com.android.systemui.tuner.TunerZenModePanel; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 76 | import com.android.systemui.volume.VolumeDialogController.State; |
| 77 | import com.android.systemui.volume.VolumeDialogController.StreamState; |
| 78 | |
| 79 | import java.io.PrintWriter; |
| 80 | import java.util.ArrayList; |
| 81 | import java.util.List; |
| 82 | |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 83 | import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_ALL_MASK; |
| 84 | import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_GENERIC; |
| 85 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 86 | /** |
| 87 | * Visual presentation of the volume dialog. |
| 88 | * |
| 89 | * A client of VolumeDialogController and its state model. |
| 90 | * |
| 91 | * Methods ending in "H" must be called on the (ui) handler. |
| 92 | */ |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 93 | public class VolumeDialog implements TunerService.Tunable { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 94 | private static final String TAG = Util.logTag(VolumeDialog.class); |
| 95 | |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 96 | public static final String SHOW_FULL_ZEN = "sysui_show_full_zen"; |
| 97 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 98 | private static final long USER_ATTEMPT_GRACE_PERIOD = 1000; |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 99 | private static final int UPDATE_ANIMATION_DURATION = 80; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 100 | |
| 101 | private final Context mContext; |
| 102 | private final H mHandler = new H(); |
| 103 | private final VolumeDialogController mController; |
| 104 | |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 105 | private Window mWindow; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 106 | private CustomDialog mDialog; |
| 107 | private ViewGroup mDialogView; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 108 | private ViewGroup mDialogRowsView; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 109 | private ViewGroup mDialogContentView; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 110 | private ImageButton mExpandButton; |
| 111 | private final List<VolumeRow> mRows = new ArrayList<>(); |
Julia Reynolds | f4d803d | 2016-06-02 10:57:02 -0400 | [diff] [blame] | 112 | private SpTexts mSpTexts; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 113 | private final SparseBooleanArray mDynamic = new SparseBooleanArray(); |
| 114 | private final KeyguardManager mKeyguard; |
Julia Reynolds | 6aa83b4 | 2015-09-08 13:41:45 -0400 | [diff] [blame] | 115 | private final AudioManager mAudioManager; |
Julia Reynolds | 2feab16 | 2016-04-21 14:58:52 -0400 | [diff] [blame] | 116 | private final AccessibilityManager mAccessibilityMgr; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 117 | private int mExpandButtonAnimationDuration; |
| 118 | private ZenFooter mZenFooter; |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 119 | private final Object mSafetyWarningLock = new Object(); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 120 | private final Accessibility mAccessibility = new Accessibility(); |
John Spurlock | 77bb25af | 2015-05-11 12:12:07 -0400 | [diff] [blame] | 121 | private final ColorStateList mActiveSliderTint; |
| 122 | private final ColorStateList mInactiveSliderTint; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 123 | private VolumeDialogMotion mMotion; |
| 124 | private final int mWindowType; |
| 125 | private final ZenModeController mZenModeController; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 126 | |
| 127 | private boolean mShowing; |
| 128 | private boolean mExpanded; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 129 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 130 | private int mActiveStream; |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 131 | private boolean mShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 132 | private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE; |
| 133 | private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 134 | private State mState; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 135 | private boolean mExpandButtonAnimationRunning; |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 136 | private SafetyWarningDialog mSafetyWarning; |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 137 | private Callback mCallback; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 138 | private boolean mPendingStateChanged; |
| 139 | private boolean mPendingRecheckAll; |
| 140 | private long mCollapseTime; |
Jun Mukai | 3f5d713 | 2015-07-21 14:10:09 -0700 | [diff] [blame] | 141 | private boolean mHovering = false; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 142 | private int mDensity; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 143 | |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 144 | private boolean mShowFullZen; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 145 | private TunerZenModePanel mZenPanel; |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 146 | |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 147 | public VolumeDialog(Context context, int windowType, VolumeDialogController controller, |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 148 | ZenModeController zenModeController, Callback callback) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 149 | mContext = context; |
| 150 | mController = controller; |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 151 | mCallback = callback; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 152 | mWindowType = windowType; |
| 153 | mZenModeController = zenModeController; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 154 | mKeyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); |
Julia Reynolds | 6aa83b4 | 2015-09-08 13:41:45 -0400 | [diff] [blame] | 155 | mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 156 | mAccessibilityMgr = |
| 157 | (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); |
Andrew Sapperstein | 5c37344 | 2016-06-12 13:17:16 -0700 | [diff] [blame] | 158 | mActiveSliderTint = ColorStateList.valueOf(Utils.getColorAccent(mContext)); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 159 | mInactiveSliderTint = loadColorStateList(R.color.volume_slider_inactive); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 160 | |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 161 | initDialog(); |
| 162 | |
| 163 | mAccessibility.init(); |
| 164 | |
| 165 | controller.addCallback(mControllerCallbackH, mHandler); |
| 166 | controller.getState(); |
| 167 | TunerService.get(mContext).addTunable(this, SHOW_FULL_ZEN); |
| 168 | |
| 169 | final Configuration currentConfig = mContext.getResources().getConfiguration(); |
| 170 | mDensity = currentConfig.densityDpi; |
| 171 | } |
| 172 | |
| 173 | private void initDialog() { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 174 | mDialog = new CustomDialog(mContext); |
| 175 | |
Julia Reynolds | f4d803d | 2016-06-02 10:57:02 -0400 | [diff] [blame] | 176 | mSpTexts = new SpTexts(mContext); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 177 | mHovering = false; |
| 178 | mShowing = false; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 179 | mWindow = mDialog.getWindow(); |
| 180 | mWindow.requestFeature(Window.FEATURE_NO_TITLE); |
| 181 | mWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); |
| 182 | mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
| 183 | mWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 184 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 185 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 186 | | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
| 187 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 188 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); |
| 189 | mDialog.setCanceledOnTouchOutside(true); |
| 190 | final Resources res = mContext.getResources(); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 191 | final WindowManager.LayoutParams lp = mWindow.getAttributes(); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 192 | lp.type = mWindowType; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 193 | lp.format = PixelFormat.TRANSLUCENT; |
| 194 | lp.setTitle(VolumeDialog.class.getSimpleName()); |
| 195 | lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 196 | lp.y = res.getDimensionPixelSize(R.dimen.volume_offset_top); |
| 197 | lp.gravity = Gravity.TOP; |
Jorim Jaggi | 6d712e0 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 198 | lp.windowAnimations = -1; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 199 | mWindow.setAttributes(lp); |
| 200 | mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 201 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 202 | mDialog.setContentView(R.layout.volume_dialog); |
| 203 | mDialogView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog); |
Jun Mukai | 3f5d713 | 2015-07-21 14:10:09 -0700 | [diff] [blame] | 204 | mDialogView.setOnHoverListener(new View.OnHoverListener() { |
| 205 | @Override |
| 206 | public boolean onHover(View v, MotionEvent event) { |
| 207 | int action = event.getActionMasked(); |
| 208 | mHovering = (action == MotionEvent.ACTION_HOVER_ENTER) |
| 209 | || (action == MotionEvent.ACTION_HOVER_MOVE); |
| 210 | rescheduleTimeoutH(); |
| 211 | return true; |
| 212 | } |
| 213 | }); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 214 | mDialogContentView = (ViewGroup) mDialog.findViewById(R.id.volume_dialog_content); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 215 | mDialogRowsView = (ViewGroup) mDialogContentView.findViewById(R.id.volume_dialog_rows); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 216 | mExpanded = false; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 217 | mExpandButton = (ImageButton) mDialogView.findViewById(R.id.volume_expand_button); |
| 218 | mExpandButton.setOnClickListener(mClickExpand); |
Muyuan Li | 36007d2 | 2016-06-21 14:21:48 -0700 | [diff] [blame] | 219 | |
| 220 | mExpandButton.setVisibility( |
| 221 | AudioSystem.isSingleVolume(mContext) ? View.GONE : View.VISIBLE); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 222 | updateWindowWidthH(); |
| 223 | updateExpandButtonH(); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 224 | |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 225 | mMotion = new VolumeDialogMotion(mDialog, mDialogView, mDialogContentView, mExpandButton, |
| 226 | new VolumeDialogMotion.Callback() { |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 227 | @Override |
| 228 | public void onAnimatingChanged(boolean animating) { |
| 229 | if (animating) return; |
| 230 | if (mPendingStateChanged) { |
| 231 | mHandler.sendEmptyMessage(H.STATE_CHANGED); |
| 232 | mPendingStateChanged = false; |
| 233 | } |
| 234 | if (mPendingRecheckAll) { |
| 235 | mHandler.sendEmptyMessage(H.RECHECK_ALL); |
| 236 | mPendingRecheckAll = false; |
| 237 | } |
| 238 | } |
| 239 | }); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 240 | |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 241 | if (mRows.isEmpty()) { |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 242 | addRow(AudioManager.STREAM_MUSIC, |
| 243 | R.drawable.ic_volume_media, R.drawable.ic_volume_media_mute, true); |
Muyuan Li | 36007d2 | 2016-06-21 14:21:48 -0700 | [diff] [blame] | 244 | if (!AudioSystem.isSingleVolume(mContext)) { |
| 245 | addRow(AudioManager.STREAM_RING, |
| 246 | R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true); |
| 247 | |
| 248 | addRow(AudioManager.STREAM_ALARM, |
| 249 | R.drawable.ic_volume_alarm, R.drawable.ic_volume_alarm_mute, false); |
| 250 | addRow(AudioManager.STREAM_VOICE_CALL, |
| 251 | R.drawable.ic_volume_voice, R.drawable.ic_volume_voice, false); |
| 252 | addRow(AudioManager.STREAM_BLUETOOTH_SCO, |
| 253 | R.drawable.ic_volume_bt_sco, R.drawable.ic_volume_bt_sco, false); |
| 254 | addRow(AudioManager.STREAM_SYSTEM, |
| 255 | R.drawable.ic_volume_system, R.drawable.ic_volume_system_mute, false); |
| 256 | } |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 257 | } else { |
| 258 | addExistingRows(); |
| 259 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 260 | mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration); |
| 261 | mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 262 | mZenFooter.init(mZenModeController); |
Jason Monk | aa911b3 | 2016-02-10 21:01:30 -0500 | [diff] [blame] | 263 | mZenPanel = (TunerZenModePanel) mDialog.findViewById(R.id.tuner_zen_mode_panel); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 264 | mZenPanel.init(mZenModeController); |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 265 | mZenPanel.setCallback(mZenPanelCallback); |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | @Override |
| 269 | public void onTuningChanged(String key, String newValue) { |
| 270 | if (SHOW_FULL_ZEN.equals(key)) { |
| 271 | mShowFullZen = newValue != null && Integer.parseInt(newValue) != 0; |
| 272 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 273 | } |
| 274 | |
John Spurlock | 77bb25af | 2015-05-11 12:12:07 -0400 | [diff] [blame] | 275 | private ColorStateList loadColorStateList(int colorResId) { |
| 276 | return ColorStateList.valueOf(mContext.getColor(colorResId)); |
| 277 | } |
| 278 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 279 | private void updateWindowWidthH() { |
| 280 | final ViewGroup.LayoutParams lp = mDialogView.getLayoutParams(); |
| 281 | final DisplayMetrics dm = mContext.getResources().getDisplayMetrics(); |
| 282 | if (D.BUG) Log.d(TAG, "updateWindowWidth dm.w=" + dm.widthPixels); |
| 283 | int w = dm.widthPixels; |
| 284 | final int max = mContext.getResources() |
Anthony Chen | 2f60d11 | 2016-01-26 15:34:12 -0800 | [diff] [blame] | 285 | .getDimensionPixelSize(R.dimen.volume_dialog_panel_width); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 286 | if (w > max) { |
| 287 | w = max; |
| 288 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 289 | lp.width = w; |
| 290 | mDialogView.setLayoutParams(lp); |
| 291 | } |
| 292 | |
| 293 | public void setStreamImportant(int stream, boolean important) { |
| 294 | mHandler.obtainMessage(H.SET_STREAM_IMPORTANT, stream, important ? 1 : 0).sendToTarget(); |
| 295 | } |
| 296 | |
| 297 | public void setShowHeaders(boolean showHeaders) { |
| 298 | if (showHeaders == mShowHeaders) return; |
| 299 | mShowHeaders = showHeaders; |
| 300 | mHandler.sendEmptyMessage(H.RECHECK_ALL); |
| 301 | } |
| 302 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 303 | public void setAutomute(boolean automute) { |
| 304 | if (mAutomute == automute) return; |
| 305 | mAutomute = automute; |
| 306 | mHandler.sendEmptyMessage(H.RECHECK_ALL); |
| 307 | } |
| 308 | |
| 309 | public void setSilentMode(boolean silentMode) { |
| 310 | if (mSilentMode == silentMode) return; |
| 311 | mSilentMode = silentMode; |
| 312 | mHandler.sendEmptyMessage(H.RECHECK_ALL); |
| 313 | } |
| 314 | |
| 315 | private void addRow(int stream, int iconRes, int iconMuteRes, boolean important) { |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 316 | VolumeRow row = new VolumeRow(); |
| 317 | initRow(row, stream, iconRes, iconMuteRes, important); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 318 | mDialogRowsView.addView(row.view); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 319 | mRows.add(row); |
| 320 | } |
| 321 | |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 322 | private void addExistingRows() { |
| 323 | int N = mRows.size(); |
| 324 | for (int i = 0; i < N; i++) { |
| 325 | final VolumeRow row = mRows.get(i); |
| 326 | initRow(row, row.stream, row.iconRes, row.iconMuteRes, row.important); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 327 | mDialogRowsView.addView(row.view); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 328 | } |
| 329 | } |
| 330 | |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 331 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 332 | private boolean isAttached() { |
| 333 | return mDialogContentView != null && mDialogContentView.isAttachedToWindow(); |
| 334 | } |
| 335 | |
| 336 | private VolumeRow getActiveRow() { |
| 337 | for (VolumeRow row : mRows) { |
| 338 | if (row.stream == mActiveStream) { |
| 339 | return row; |
| 340 | } |
| 341 | } |
| 342 | return mRows.get(0); |
| 343 | } |
| 344 | |
| 345 | private VolumeRow findRow(int stream) { |
| 346 | for (VolumeRow row : mRows) { |
| 347 | if (row.stream == stream) return row; |
| 348 | } |
| 349 | return null; |
| 350 | } |
| 351 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 352 | public void dump(PrintWriter writer) { |
| 353 | writer.println(VolumeDialog.class.getSimpleName() + " state:"); |
| 354 | writer.print(" mShowing: "); writer.println(mShowing); |
| 355 | writer.print(" mExpanded: "); writer.println(mExpanded); |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 356 | writer.print(" mExpandButtonAnimationRunning: "); |
| 357 | writer.println(mExpandButtonAnimationRunning); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 358 | writer.print(" mActiveStream: "); writer.println(mActiveStream); |
| 359 | writer.print(" mDynamic: "); writer.println(mDynamic); |
| 360 | writer.print(" mShowHeaders: "); writer.println(mShowHeaders); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 361 | writer.print(" mAutomute: "); writer.println(mAutomute); |
| 362 | writer.print(" mSilentMode: "); writer.println(mSilentMode); |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 363 | writer.print(" mCollapseTime: "); writer.println(mCollapseTime); |
John Spurlock | 84ee67c | 2015-05-20 23:33:43 -0400 | [diff] [blame] | 364 | writer.print(" mAccessibility.mFeedbackEnabled: "); |
| 365 | writer.println(mAccessibility.mFeedbackEnabled); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 366 | } |
| 367 | |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 368 | private static int getImpliedLevel(SeekBar seekBar, int progress) { |
| 369 | final int m = seekBar.getMax(); |
| 370 | final int n = m / 100 - 1; |
| 371 | final int level = progress == 0 ? 0 |
| 372 | : progress == m ? (m / 100) : (1 + (int)((progress / (float) m) * n)); |
| 373 | return level; |
| 374 | } |
| 375 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 376 | @SuppressLint("InflateParams") |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 377 | private void initRow(final VolumeRow row, final int stream, int iconRes, int iconMuteRes, |
| 378 | boolean important) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 379 | row.stream = stream; |
| 380 | row.iconRes = iconRes; |
| 381 | row.iconMuteRes = iconMuteRes; |
| 382 | row.important = important; |
| 383 | row.view = mDialog.getLayoutInflater().inflate(R.layout.volume_dialog_row, null); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 384 | row.view.setId(row.stream); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 385 | row.view.setTag(row); |
| 386 | row.header = (TextView) row.view.findViewById(R.id.volume_row_header); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 387 | row.header.setId(20 * row.stream); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 388 | mSpTexts.add(row.header); |
| 389 | row.slider = (SeekBar) row.view.findViewById(R.id.volume_row_slider); |
| 390 | row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row)); |
Julia Reynolds | 5774cf0 | 2016-05-26 13:43:38 -0400 | [diff] [blame] | 391 | row.anim = null; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 392 | row.cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 393 | |
| 394 | // forward events above the slider into the slider |
| 395 | row.view.setOnTouchListener(new OnTouchListener() { |
| 396 | private final Rect mSliderHitRect = new Rect(); |
| 397 | private boolean mDragging; |
| 398 | |
| 399 | @SuppressLint("ClickableViewAccessibility") |
| 400 | @Override |
| 401 | public boolean onTouch(View v, MotionEvent event) { |
| 402 | row.slider.getHitRect(mSliderHitRect); |
| 403 | if (!mDragging && event.getActionMasked() == MotionEvent.ACTION_DOWN |
| 404 | && event.getY() < mSliderHitRect.top) { |
| 405 | mDragging = true; |
| 406 | } |
| 407 | if (mDragging) { |
| 408 | event.offsetLocation(-mSliderHitRect.left, -mSliderHitRect.top); |
| 409 | row.slider.dispatchTouchEvent(event); |
| 410 | if (event.getActionMasked() == MotionEvent.ACTION_UP |
| 411 | || event.getActionMasked() == MotionEvent.ACTION_CANCEL) { |
| 412 | mDragging = false; |
| 413 | } |
| 414 | return true; |
| 415 | } |
| 416 | return false; |
| 417 | } |
| 418 | }); |
| 419 | row.icon = (ImageButton) row.view.findViewById(R.id.volume_row_icon); |
| 420 | row.icon.setImageResource(iconRes); |
| 421 | row.icon.setOnClickListener(new OnClickListener() { |
| 422 | @Override |
| 423 | public void onClick(View v) { |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 424 | Events.writeEvent(mContext, Events.EVENT_ICON_CLICK, row.stream, row.iconState); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 425 | mController.setActiveStream(row.stream); |
| 426 | if (row.stream == AudioManager.STREAM_RING) { |
| 427 | final boolean hasVibrator = mController.hasVibrator(); |
| 428 | if (mState.ringerModeInternal == AudioManager.RINGER_MODE_NORMAL) { |
| 429 | if (hasVibrator) { |
| 430 | mController.setRingerMode(AudioManager.RINGER_MODE_VIBRATE, false); |
| 431 | } else { |
| 432 | final boolean wasZero = row.ss.level == 0; |
| 433 | mController.setStreamVolume(stream, wasZero ? row.lastAudibleLevel : 0); |
| 434 | } |
| 435 | } else { |
| 436 | mController.setRingerMode(AudioManager.RINGER_MODE_NORMAL, false); |
| 437 | if (row.ss.level == 0) { |
| 438 | mController.setStreamVolume(stream, 1); |
| 439 | } |
| 440 | } |
| 441 | } else { |
Julia Reynolds | 798b0c3 | 2015-09-01 14:35:53 -0400 | [diff] [blame] | 442 | final boolean vmute = row.ss.level == row.ss.levelMin; |
| 443 | mController.setStreamVolume(stream, |
| 444 | vmute ? row.lastAudibleLevel : row.ss.levelMin); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 445 | } |
| 446 | row.userAttempt = 0; // reset the grace period, slider should update immediately |
| 447 | } |
| 448 | }); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | public void destroy() { |
| 452 | mController.removeCallback(mControllerCallbackH); |
| 453 | } |
| 454 | |
| 455 | public void show(int reason) { |
| 456 | mHandler.obtainMessage(H.SHOW, reason, 0).sendToTarget(); |
| 457 | } |
| 458 | |
| 459 | public void dismiss(int reason) { |
| 460 | mHandler.obtainMessage(H.DISMISS, reason, 0).sendToTarget(); |
| 461 | } |
| 462 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 463 | private void showH(int reason) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 464 | if (D.BUG) Log.d(TAG, "showH r=" + Events.DISMISS_REASONS[reason]); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 465 | mHandler.removeMessages(H.SHOW); |
| 466 | mHandler.removeMessages(H.DISMISS); |
| 467 | rescheduleTimeoutH(); |
| 468 | if (mShowing) return; |
| 469 | mShowing = true; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 470 | mMotion.startShow(); |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 471 | Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked()); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 472 | mController.notifyVisible(true); |
| 473 | } |
| 474 | |
| 475 | protected void rescheduleTimeoutH() { |
| 476 | mHandler.removeMessages(H.DISMISS); |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 477 | final int timeout = computeTimeoutH(); |
| 478 | mHandler.sendMessageDelayed(mHandler |
| 479 | .obtainMessage(H.DISMISS, Events.DISMISS_REASON_TIMEOUT, 0), timeout); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 480 | if (D.BUG) Log.d(TAG, "rescheduleTimeout " + timeout + " " + Debug.getCaller()); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 481 | mController.userActivity(); |
| 482 | } |
| 483 | |
| 484 | private int computeTimeoutH() { |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 485 | if (mAccessibility.mFeedbackEnabled) return 20000; |
Jun Mukai | 3f5d713 | 2015-07-21 14:10:09 -0700 | [diff] [blame] | 486 | if (mHovering) return 16000; |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 487 | if (mSafetyWarning != null) return 5000; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 488 | if (mExpanded || mExpandButtonAnimationRunning) return 5000; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 489 | if (mActiveStream == AudioManager.STREAM_MUSIC) return 1500; |
| 490 | return 3000; |
| 491 | } |
| 492 | |
| 493 | protected void dismissH(int reason) { |
Jason Monk | 305e0ba | 2015-07-06 15:53:59 -0400 | [diff] [blame] | 494 | if (mMotion.isAnimating()) { |
| 495 | return; |
| 496 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 497 | mHandler.removeMessages(H.DISMISS); |
| 498 | mHandler.removeMessages(H.SHOW); |
| 499 | if (!mShowing) return; |
| 500 | mShowing = false; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 501 | mMotion.startDismiss(new Runnable() { |
| 502 | @Override |
| 503 | public void run() { |
Julia Reynolds | 48242f0 | 2016-08-10 11:42:56 -0400 | [diff] [blame] | 504 | updateExpandedH(false /* expanding */, true /* dismissing */); |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 505 | } |
| 506 | }); |
Julia Reynolds | 2feab16 | 2016-04-21 14:58:52 -0400 | [diff] [blame] | 507 | if (mAccessibilityMgr.isEnabled()) { |
| 508 | AccessibilityEvent event = |
| 509 | AccessibilityEvent.obtain(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); |
| 510 | event.setPackageName(mContext.getPackageName()); |
| 511 | event.setClassName(CustomDialog.class.getSuperclass().getName()); |
| 512 | event.getText().add(mContext.getString( |
| 513 | R.string.volume_dialog_accessibility_dismissed_message)); |
| 514 | mAccessibilityMgr.sendAccessibilityEvent(event); |
| 515 | } |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 516 | Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 517 | mController.notifyVisible(false); |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 518 | synchronized (mSafetyWarningLock) { |
| 519 | if (mSafetyWarning != null) { |
| 520 | if (D.BUG) Log.d(TAG, "SafetyWarning dismissed"); |
| 521 | mSafetyWarning.dismiss(); |
| 522 | } |
| 523 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 524 | } |
| 525 | |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 526 | private void updateDialogBottomMarginH() { |
| 527 | final long diff = System.currentTimeMillis() - mCollapseTime; |
| 528 | final boolean collapsing = mCollapseTime != 0 && diff < getConservativeCollapseDuration(); |
| 529 | final ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) mDialogView.getLayoutParams(); |
| 530 | final int bottomMargin = collapsing ? mDialogContentView.getHeight() : |
| 531 | mContext.getResources().getDimensionPixelSize(R.dimen.volume_dialog_margin_bottom); |
| 532 | if (bottomMargin != mlp.bottomMargin) { |
| 533 | if (D.BUG) Log.d(TAG, "bottomMargin " + mlp.bottomMargin + " -> " + bottomMargin); |
| 534 | mlp.bottomMargin = bottomMargin; |
| 535 | mDialogView.setLayoutParams(mlp); |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | private long getConservativeCollapseDuration() { |
| 540 | return mExpandButtonAnimationDuration * 3; |
| 541 | } |
| 542 | |
| 543 | private void prepareForCollapse() { |
| 544 | mHandler.removeMessages(H.UPDATE_BOTTOM_MARGIN); |
| 545 | mCollapseTime = System.currentTimeMillis(); |
| 546 | updateDialogBottomMarginH(); |
| 547 | mHandler.sendEmptyMessageDelayed(H.UPDATE_BOTTOM_MARGIN, getConservativeCollapseDuration()); |
| 548 | } |
| 549 | |
Julia Reynolds | 48242f0 | 2016-08-10 11:42:56 -0400 | [diff] [blame] | 550 | private void updateExpandedH(final boolean expanded, final boolean dismissing) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 551 | if (mExpanded == expanded) return; |
| 552 | mExpanded = expanded; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 553 | mExpandButtonAnimationRunning = isAttached(); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 554 | if (D.BUG) Log.d(TAG, "updateExpandedH " + expanded); |
| 555 | updateExpandButtonH(); |
| 556 | updateFooterH(); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 557 | TransitionManager.endTransitions(mDialogView); |
Julia Reynolds | 48242f0 | 2016-08-10 11:42:56 -0400 | [diff] [blame] | 558 | final VolumeRow activeRow = getActiveRow(); |
| 559 | if (!dismissing) { |
| 560 | mWindow.setLayout(mWindow.getAttributes().width, ViewGroup.LayoutParams.MATCH_PARENT); |
Julia Reynolds | 24f411d | 2016-08-11 15:57:10 -0400 | [diff] [blame] | 561 | TransitionManager.beginDelayedTransition(mDialogView, getTransistion()); |
Julia Reynolds | 48242f0 | 2016-08-10 11:42:56 -0400 | [diff] [blame] | 562 | } |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 563 | updateRowsH(activeRow); |
| 564 | rescheduleTimeoutH(); |
| 565 | } |
| 566 | |
| 567 | private void updateExpandButtonH() { |
| 568 | if (D.BUG) Log.d(TAG, "updateExpandButtonH"); |
| 569 | mExpandButton.setClickable(!mExpandButtonAnimationRunning); |
| 570 | if (!(mExpandButtonAnimationRunning && isAttached())) { |
| 571 | final int res = mExpanded ? R.drawable.ic_volume_collapse_animation |
| 572 | : R.drawable.ic_volume_expand_animation; |
| 573 | if (hasTouchFeature()) { |
| 574 | mExpandButton.setImageResource(res); |
| 575 | } else { |
| 576 | // if there is no touch feature, show the volume ringer instead |
| 577 | mExpandButton.setImageResource(R.drawable.ic_volume_ringer); |
| 578 | mExpandButton.setBackgroundResource(0); // remove gray background emphasis |
| 579 | } |
| 580 | mExpandButton.setContentDescription(mContext.getString(mExpanded ? |
| 581 | R.string.accessibility_volume_collapse : R.string.accessibility_volume_expand)); |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 582 | } |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 583 | if (mExpandButtonAnimationRunning) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 584 | final Drawable d = mExpandButton.getDrawable(); |
| 585 | if (d instanceof AnimatedVectorDrawable) { |
| 586 | // workaround to reset drawable |
| 587 | final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) d.getConstantState() |
| 588 | .newDrawable(); |
| 589 | mExpandButton.setImageDrawable(avd); |
| 590 | avd.start(); |
| 591 | mHandler.postDelayed(new Runnable() { |
| 592 | @Override |
| 593 | public void run() { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 594 | mExpandButtonAnimationRunning = false; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 595 | updateExpandButtonH(); |
| 596 | rescheduleTimeoutH(); |
| 597 | } |
| 598 | }, mExpandButtonAnimationDuration); |
| 599 | } |
| 600 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 601 | } |
| 602 | |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 603 | private boolean shouldBeVisibleH(VolumeRow row, boolean isActive) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 604 | return mExpanded && row.view.getVisibility() == View.VISIBLE |
| 605 | || (mExpanded && (row.important || isActive)) |
| 606 | || !mExpanded && isActive; |
| 607 | } |
| 608 | |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 609 | private void updateRowsH(final VolumeRow activeRow) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 610 | if (D.BUG) Log.d(TAG, "updateRowsH"); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 611 | if (!mShowing) { |
| 612 | trimObsoleteH(); |
| 613 | } |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 614 | Util.setVisOrGone(mDialogRowsView.findViewById(R.id.spacer), mExpanded); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 615 | // apply changes to all rows |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 616 | for (final VolumeRow row : mRows) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 617 | final boolean isActive = row == activeRow; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 618 | final boolean shouldBeVisible = shouldBeVisibleH(row, isActive); |
| 619 | Util.setVisOrGone(row.view, shouldBeVisible); |
| 620 | if (row.view.isShown()) { |
| 621 | updateVolumeRowHeaderVisibleH(row); |
| 622 | updateVolumeRowSliderTintH(row, isActive); |
| 623 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 624 | } |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 625 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | private void trimObsoleteH() { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 629 | if (D.BUG) Log.d(TAG, "trimObsoleteH"); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 630 | for (int i = mRows.size() - 1; i >= 0; i--) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 631 | final VolumeRow row = mRows.get(i); |
| 632 | if (row.ss == null || !row.ss.dynamic) continue; |
| 633 | if (!mDynamic.get(row.stream)) { |
| 634 | mRows.remove(i); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 635 | mDialogRowsView.removeView(row.view); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 636 | } |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | private void onStateChangedH(State state) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 641 | final boolean animating = mMotion.isAnimating(); |
| 642 | if (D.BUG) Log.d(TAG, "onStateChangedH animating=" + animating); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 643 | mState = state; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 644 | if (animating) { |
| 645 | mPendingStateChanged = true; |
| 646 | return; |
| 647 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 648 | mDynamic.clear(); |
| 649 | // add any new dynamic rows |
| 650 | for (int i = 0; i < state.states.size(); i++) { |
| 651 | final int stream = state.states.keyAt(i); |
| 652 | final StreamState ss = state.states.valueAt(i); |
| 653 | if (!ss.dynamic) continue; |
| 654 | mDynamic.put(stream, true); |
| 655 | if (findRow(stream) == null) { |
| 656 | addRow(stream, R.drawable.ic_volume_remote, R.drawable.ic_volume_remote_mute, true); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | if (mActiveStream != state.activeStream) { |
| 661 | mActiveStream = state.activeStream; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 662 | updateRowsH(getActiveRow()); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 663 | rescheduleTimeoutH(); |
| 664 | } |
| 665 | for (VolumeRow row : mRows) { |
| 666 | updateVolumeRowH(row); |
| 667 | } |
| 668 | updateFooterH(); |
| 669 | } |
| 670 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 671 | private void updateFooterH() { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 672 | if (D.BUG) Log.d(TAG, "updateFooterH"); |
| 673 | final boolean wasVisible = mZenFooter.getVisibility() == View.VISIBLE; |
Julia Reynolds | 6aa83b4 | 2015-09-08 13:41:45 -0400 | [diff] [blame] | 674 | final boolean visible = mState.zenMode != Global.ZEN_MODE_OFF |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 675 | && (mAudioManager.isStreamAffectedByRingerMode(mActiveStream) || mExpanded) |
Jason Monk | aa911b3 | 2016-02-10 21:01:30 -0500 | [diff] [blame] | 676 | && !mZenPanel.isEditing(); |
Julia Reynolds | 24f411d | 2016-08-11 15:57:10 -0400 | [diff] [blame] | 677 | TransitionManager.beginDelayedTransition(mDialogView, getTransistion()); |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 678 | if (wasVisible != visible && !visible) { |
| 679 | prepareForCollapse(); |
| 680 | } |
| 681 | Util.setVisOrGone(mZenFooter, visible); |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 682 | mZenFooter.update(); |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 683 | |
| 684 | final boolean fullWasVisible = mZenPanel.getVisibility() == View.VISIBLE; |
Jason Monk | aa911b3 | 2016-02-10 21:01:30 -0500 | [diff] [blame] | 685 | final boolean fullVisible = mShowFullZen && !visible; |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 686 | if (fullWasVisible != fullVisible && !fullVisible) { |
| 687 | prepareForCollapse(); |
| 688 | } |
| 689 | Util.setVisOrGone(mZenPanel, fullVisible); |
Jason Monk | aa911b3 | 2016-02-10 21:01:30 -0500 | [diff] [blame] | 690 | if (fullVisible) { |
| 691 | mZenPanel.setZenState(mState.zenMode); |
| 692 | mZenPanel.setDoneListener(new OnClickListener() { |
| 693 | @Override |
| 694 | public void onClick(View v) { |
| 695 | prepareForCollapse(); |
| 696 | mHandler.sendEmptyMessage(H.UPDATE_FOOTER); |
| 697 | } |
| 698 | }); |
| 699 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | private void updateVolumeRowH(VolumeRow row) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 703 | if (D.BUG) Log.d(TAG, "updateVolumeRowH s=" + row.stream); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 704 | if (mState == null) return; |
| 705 | final StreamState ss = mState.states.get(row.stream); |
| 706 | if (ss == null) return; |
| 707 | row.ss = ss; |
| 708 | if (ss.level > 0) { |
| 709 | row.lastAudibleLevel = ss.level; |
| 710 | } |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 711 | if (ss.level == row.requestedLevel) { |
| 712 | row.requestedLevel = -1; |
| 713 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 714 | final boolean isRingStream = row.stream == AudioManager.STREAM_RING; |
| 715 | final boolean isSystemStream = row.stream == AudioManager.STREAM_SYSTEM; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 716 | final boolean isAlarmStream = row.stream == AudioManager.STREAM_ALARM; |
| 717 | final boolean isMusicStream = row.stream == AudioManager.STREAM_MUSIC; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 718 | final boolean isRingVibrate = isRingStream |
| 719 | && mState.ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 720 | final boolean isRingSilent = isRingStream |
| 721 | && mState.ringerModeInternal == AudioManager.RINGER_MODE_SILENT; |
| 722 | final boolean isZenAlarms = mState.zenMode == Global.ZEN_MODE_ALARMS; |
| 723 | final boolean isZenNone = mState.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 724 | final boolean zenMuted = isZenAlarms ? (isRingStream || isSystemStream) |
| 725 | : isZenNone ? (isRingStream || isSystemStream || isAlarmStream || isMusicStream) |
| 726 | : false; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 727 | |
| 728 | // update slider max |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 729 | final int max = ss.levelMax * 100; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 730 | if (max != row.slider.getMax()) { |
| 731 | row.slider.setMax(max); |
| 732 | } |
| 733 | |
| 734 | // update header visible |
John Spurlock | 0265657 | 2015-06-10 09:33:34 -0400 | [diff] [blame] | 735 | updateVolumeRowHeaderVisibleH(row); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 736 | |
| 737 | // update header text |
Julia Reynolds | 5f83c85 | 2016-06-15 12:53:31 -0400 | [diff] [blame] | 738 | Util.setText(row.header, ss.name); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 739 | |
| 740 | // update icon |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 741 | final boolean iconEnabled = (mAutomute || ss.muteSupported) && !zenMuted; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 742 | row.icon.setEnabled(iconEnabled); |
| 743 | row.icon.setAlpha(iconEnabled ? 1 : 0.5f); |
| 744 | final int iconRes = |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 745 | isRingVibrate ? R.drawable.ic_volume_ringer_vibrate |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 746 | : isRingSilent || zenMuted ? row.cachedIconRes |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 747 | : ss.routedToBluetooth ? |
John Spurlock | f15ef11 | 2015-04-09 22:04:14 -0400 | [diff] [blame] | 748 | (ss.muted ? R.drawable.ic_volume_media_bt_mute |
| 749 | : R.drawable.ic_volume_media_bt) |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 750 | : mAutomute && ss.level == 0 ? row.iconMuteRes |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 751 | : (ss.muted ? row.iconMuteRes : row.iconRes); |
| 752 | if (iconRes != row.cachedIconRes) { |
| 753 | if (row.cachedIconRes != 0 && isRingVibrate) { |
| 754 | mController.vibrate(); |
| 755 | } |
| 756 | row.cachedIconRes = iconRes; |
| 757 | row.icon.setImageResource(iconRes); |
| 758 | } |
| 759 | row.iconState = |
| 760 | iconRes == R.drawable.ic_volume_ringer_vibrate ? Events.ICON_STATE_VIBRATE |
John Spurlock | f15ef11 | 2015-04-09 22:04:14 -0400 | [diff] [blame] | 761 | : (iconRes == R.drawable.ic_volume_media_bt_mute || iconRes == row.iconMuteRes) |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 762 | ? Events.ICON_STATE_MUTE |
John Spurlock | f15ef11 | 2015-04-09 22:04:14 -0400 | [diff] [blame] | 763 | : (iconRes == R.drawable.ic_volume_media_bt || iconRes == row.iconRes) |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 764 | ? Events.ICON_STATE_UNMUTE |
| 765 | : Events.ICON_STATE_UNKNOWN; |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 766 | if (iconEnabled) { |
| 767 | if (isRingStream) { |
| 768 | if (isRingVibrate) { |
| 769 | row.icon.setContentDescription(mContext.getString( |
| 770 | R.string.volume_stream_content_description_unmute, |
| 771 | ss.name)); |
| 772 | } else { |
| 773 | if (mController.hasVibrator()) { |
| 774 | row.icon.setContentDescription(mContext.getString( |
| 775 | R.string.volume_stream_content_description_vibrate, |
| 776 | ss.name)); |
| 777 | } else { |
| 778 | row.icon.setContentDescription(mContext.getString( |
| 779 | R.string.volume_stream_content_description_mute, |
| 780 | ss.name)); |
| 781 | } |
| 782 | } |
| 783 | } else { |
| 784 | if (ss.muted || mAutomute && ss.level == 0) { |
| 785 | row.icon.setContentDescription(mContext.getString( |
| 786 | R.string.volume_stream_content_description_unmute, |
| 787 | ss.name)); |
| 788 | } else { |
| 789 | row.icon.setContentDescription(mContext.getString( |
| 790 | R.string.volume_stream_content_description_mute, |
| 791 | ss.name)); |
| 792 | } |
| 793 | } |
| 794 | } else { |
| 795 | row.icon.setContentDescription(ss.name); |
| 796 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 797 | |
| 798 | // update slider |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 799 | final boolean enableSlider = !zenMuted; |
| 800 | final int vlevel = row.ss.muted && (isRingVibrate || !isRingStream && !zenMuted) ? 0 |
| 801 | : row.ss.level; |
| 802 | updateVolumeRowSliderH(row, enableSlider, vlevel); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 803 | } |
| 804 | |
John Spurlock | 0265657 | 2015-06-10 09:33:34 -0400 | [diff] [blame] | 805 | private void updateVolumeRowHeaderVisibleH(VolumeRow row) { |
| 806 | final boolean dynamic = row.ss != null && row.ss.dynamic; |
Julia Reynolds | 5f83c85 | 2016-06-15 12:53:31 -0400 | [diff] [blame] | 807 | final boolean showHeaders = mExpanded && (mShowHeaders || dynamic); |
John Spurlock | 0265657 | 2015-06-10 09:33:34 -0400 | [diff] [blame] | 808 | if (row.cachedShowHeaders != showHeaders) { |
| 809 | row.cachedShowHeaders = showHeaders; |
| 810 | Util.setVisOrGone(row.header, showHeaders); |
| 811 | } |
| 812 | } |
| 813 | |
John Spurlock | ecc8058 | 2015-05-13 16:23:14 -0400 | [diff] [blame] | 814 | private void updateVolumeRowSliderTintH(VolumeRow row, boolean isActive) { |
John Spurlock | 67a0f85 | 2015-06-15 15:35:47 -0400 | [diff] [blame] | 815 | if (isActive && mExpanded) { |
John Spurlock | 67a0f85 | 2015-06-15 15:35:47 -0400 | [diff] [blame] | 816 | row.slider.requestFocus(); |
John Spurlock | 67a0f85 | 2015-06-15 15:35:47 -0400 | [diff] [blame] | 817 | } |
John Spurlock | ecc8058 | 2015-05-13 16:23:14 -0400 | [diff] [blame] | 818 | final ColorStateList tint = isActive && row.slider.isEnabled() ? mActiveSliderTint |
| 819 | : mInactiveSliderTint; |
| 820 | if (tint == row.cachedSliderTint) return; |
| 821 | row.cachedSliderTint = tint; |
| 822 | row.slider.setProgressTintList(tint); |
| 823 | row.slider.setThumbTintList(tint); |
| 824 | } |
| 825 | |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 826 | private void updateVolumeRowSliderH(VolumeRow row, boolean enable, int vlevel) { |
| 827 | row.slider.setEnabled(enable); |
John Spurlock | ecc8058 | 2015-05-13 16:23:14 -0400 | [diff] [blame] | 828 | updateVolumeRowSliderTintH(row, row.stream == mActiveStream); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 829 | if (row.tracking) { |
| 830 | return; // don't update if user is sliding |
| 831 | } |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 832 | final int progress = row.slider.getProgress(); |
| 833 | final int level = getImpliedLevel(row.slider, progress); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 834 | final boolean rowVisible = row.view.getVisibility() == View.VISIBLE; |
| 835 | final boolean inGracePeriod = (SystemClock.uptimeMillis() - row.userAttempt) |
| 836 | < USER_ATTEMPT_GRACE_PERIOD; |
| 837 | mHandler.removeMessages(H.RECHECK, row); |
| 838 | if (mShowing && rowVisible && inGracePeriod) { |
| 839 | if (D.BUG) Log.d(TAG, "inGracePeriod"); |
| 840 | mHandler.sendMessageAtTime(mHandler.obtainMessage(H.RECHECK, row), |
| 841 | row.userAttempt + USER_ATTEMPT_GRACE_PERIOD); |
| 842 | return; // don't update if visible and in grace period |
| 843 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 844 | if (vlevel == level) { |
| 845 | if (mShowing && rowVisible) { |
| 846 | return; // don't clamp if visible |
| 847 | } |
| 848 | } |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 849 | final int newProgress = vlevel * 100; |
| 850 | if (progress != newProgress) { |
| 851 | if (mShowing && rowVisible) { |
| 852 | // animate! |
| 853 | if (row.anim != null && row.anim.isRunning() |
| 854 | && row.animTargetProgress == newProgress) { |
| 855 | return; // already animating to the target progress |
| 856 | } |
| 857 | // start/update animation |
| 858 | if (row.anim == null) { |
| 859 | row.anim = ObjectAnimator.ofInt(row.slider, "progress", progress, newProgress); |
| 860 | row.anim.setInterpolator(new DecelerateInterpolator()); |
| 861 | } else { |
| 862 | row.anim.cancel(); |
| 863 | row.anim.setIntValues(progress, newProgress); |
| 864 | } |
| 865 | row.animTargetProgress = newProgress; |
| 866 | row.anim.setDuration(UPDATE_ANIMATION_DURATION); |
| 867 | row.anim.start(); |
| 868 | } else { |
| 869 | // update slider directly to clamped value |
| 870 | if (row.anim != null) { |
| 871 | row.anim.cancel(); |
| 872 | } |
Julia Reynolds | 88dabde | 2016-08-09 13:59:44 -0400 | [diff] [blame^] | 873 | row.slider.setProgress(newProgress, true); |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 874 | } |
| 875 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | private void recheckH(VolumeRow row) { |
| 879 | if (row == null) { |
| 880 | if (D.BUG) Log.d(TAG, "recheckH ALL"); |
| 881 | trimObsoleteH(); |
| 882 | for (VolumeRow r : mRows) { |
| 883 | updateVolumeRowH(r); |
| 884 | } |
| 885 | } else { |
| 886 | if (D.BUG) Log.d(TAG, "recheckH " + row.stream); |
| 887 | updateVolumeRowH(row); |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | private void setStreamImportantH(int stream, boolean important) { |
| 892 | for (VolumeRow row : mRows) { |
| 893 | if (row.stream == stream) { |
| 894 | row.important = important; |
| 895 | return; |
| 896 | } |
| 897 | } |
| 898 | } |
| 899 | |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 900 | private void showSafetyWarningH(int flags) { |
| 901 | if ((flags & (AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_SHOW_UI_WARNINGS)) != 0 |
| 902 | || mShowing) { |
| 903 | synchronized (mSafetyWarningLock) { |
| 904 | if (mSafetyWarning != null) { |
| 905 | return; |
| 906 | } |
| 907 | mSafetyWarning = new SafetyWarningDialog(mContext, mController.getAudioManager()) { |
| 908 | @Override |
| 909 | protected void cleanUp() { |
| 910 | synchronized (mSafetyWarningLock) { |
| 911 | mSafetyWarning = null; |
| 912 | } |
| 913 | recheckH(null); |
| 914 | } |
| 915 | }; |
| 916 | mSafetyWarning.show(); |
| 917 | } |
| 918 | recheckH(null); |
| 919 | } |
| 920 | rescheduleTimeoutH(); |
| 921 | } |
| 922 | |
Julia Reynolds | 24f411d | 2016-08-11 15:57:10 -0400 | [diff] [blame] | 923 | private AutoTransition getTransistion() { |
| 924 | AutoTransition transition = new AutoTransition(); |
| 925 | transition.setDuration(mExpandButtonAnimationDuration); |
| 926 | transition.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); |
| 927 | transition.addListener(new Transition.TransitionListener() { |
| 928 | @Override |
| 929 | public void onTransitionStart(Transition transition) { |
| 930 | } |
| 931 | |
| 932 | @Override |
| 933 | public void onTransitionEnd(Transition transition) { |
| 934 | mWindow.setLayout( |
| 935 | mWindow.getAttributes().width, ViewGroup.LayoutParams.WRAP_CONTENT); |
| 936 | } |
| 937 | |
| 938 | @Override |
| 939 | public void onTransitionCancel(Transition transition) { |
| 940 | } |
| 941 | |
| 942 | @Override |
| 943 | public void onTransitionPause(Transition transition) { |
| 944 | mWindow.setLayout( |
| 945 | mWindow.getAttributes().width, ViewGroup.LayoutParams.WRAP_CONTENT); |
| 946 | } |
| 947 | |
| 948 | @Override |
| 949 | public void onTransitionResume(Transition transition) { |
| 950 | } |
| 951 | }); |
| 952 | return transition; |
| 953 | } |
| 954 | |
Takayuki Hoshi | bb0ec55 | 2015-12-17 20:50:25 +0900 | [diff] [blame] | 955 | private boolean hasTouchFeature() { |
| 956 | final PackageManager pm = mContext.getPackageManager(); |
| 957 | return pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN); |
| 958 | } |
| 959 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 960 | private final VolumeDialogController.Callbacks mControllerCallbackH |
| 961 | = new VolumeDialogController.Callbacks() { |
| 962 | @Override |
| 963 | public void onShowRequested(int reason) { |
| 964 | showH(reason); |
| 965 | } |
| 966 | |
| 967 | @Override |
| 968 | public void onDismissRequested(int reason) { |
| 969 | dismissH(reason); |
| 970 | } |
| 971 | |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 972 | @Override |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 973 | public void onScreenOff() { |
| 974 | dismissH(Events.DISMISS_REASON_SCREEN_OFF); |
| 975 | } |
| 976 | |
| 977 | @Override |
| 978 | public void onStateChanged(State state) { |
| 979 | onStateChangedH(state); |
| 980 | } |
| 981 | |
| 982 | @Override |
| 983 | public void onLayoutDirectionChanged(int layoutDirection) { |
| 984 | mDialogView.setLayoutDirection(layoutDirection); |
| 985 | } |
| 986 | |
| 987 | @Override |
| 988 | public void onConfigurationChanged() { |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 989 | Configuration newConfig = mContext.getResources().getConfiguration(); |
| 990 | final int density = newConfig.densityDpi; |
| 991 | if (density != mDensity) { |
| 992 | mDialog.dismiss(); |
Julia Reynolds | 8d0a400 | 2016-06-14 15:24:39 -0400 | [diff] [blame] | 993 | mZenFooter.cleanup(); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 994 | initDialog(); |
Julia Reynolds | 494f0de | 2016-07-26 12:57:08 -0400 | [diff] [blame] | 995 | mDensity = density; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 996 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 997 | updateWindowWidthH(); |
| 998 | mSpTexts.update(); |
John Spurlock | 9ea3a1e | 2015-05-06 17:12:18 -0400 | [diff] [blame] | 999 | mZenFooter.onConfigurationChanged(); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | @Override |
| 1003 | public void onShowVibrateHint() { |
| 1004 | if (mSilentMode) { |
| 1005 | mController.setRingerMode(AudioManager.RINGER_MODE_SILENT, false); |
| 1006 | } |
| 1007 | } |
| 1008 | |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 1009 | @Override |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1010 | public void onShowSilentHint() { |
| 1011 | if (mSilentMode) { |
| 1012 | mController.setRingerMode(AudioManager.RINGER_MODE_NORMAL, false); |
| 1013 | } |
| 1014 | } |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 1015 | |
| 1016 | @Override |
| 1017 | public void onShowSafetyWarning(int flags) { |
| 1018 | showSafetyWarningH(flags); |
| 1019 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1020 | }; |
| 1021 | |
Jason Monk | e138f55 | 2016-01-18 09:21:45 -0500 | [diff] [blame] | 1022 | private final ZenModePanel.Callback mZenPanelCallback = new ZenModePanel.Callback() { |
| 1023 | @Override |
| 1024 | public void onPrioritySettings() { |
| 1025 | mCallback.onZenPrioritySettingsClicked(); |
| 1026 | } |
| 1027 | |
| 1028 | @Override |
| 1029 | public void onInteraction() { |
| 1030 | mHandler.sendEmptyMessage(H.RESCHEDULE_TIMEOUT); |
| 1031 | } |
| 1032 | |
| 1033 | @Override |
| 1034 | public void onExpanded(boolean expanded) { |
| 1035 | // noop. |
| 1036 | } |
| 1037 | }; |
| 1038 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1039 | private final OnClickListener mClickExpand = new OnClickListener() { |
| 1040 | @Override |
| 1041 | public void onClick(View v) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1042 | if (mExpandButtonAnimationRunning) return; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1043 | final boolean newExpand = !mExpanded; |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 1044 | Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand); |
Julia Reynolds | 48242f0 | 2016-08-10 11:42:56 -0400 | [diff] [blame] | 1045 | updateExpandedH(newExpand, false /* dismissing */); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1046 | } |
| 1047 | }; |
| 1048 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1049 | private final class H extends Handler { |
| 1050 | private static final int SHOW = 1; |
| 1051 | private static final int DISMISS = 2; |
| 1052 | private static final int RECHECK = 3; |
| 1053 | private static final int RECHECK_ALL = 4; |
| 1054 | private static final int SET_STREAM_IMPORTANT = 5; |
| 1055 | private static final int RESCHEDULE_TIMEOUT = 6; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1056 | private static final int STATE_CHANGED = 7; |
| 1057 | private static final int UPDATE_BOTTOM_MARGIN = 8; |
Jason Monk | aa911b3 | 2016-02-10 21:01:30 -0500 | [diff] [blame] | 1058 | private static final int UPDATE_FOOTER = 9; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1059 | |
| 1060 | public H() { |
| 1061 | super(Looper.getMainLooper()); |
| 1062 | } |
| 1063 | |
| 1064 | @Override |
| 1065 | public void handleMessage(Message msg) { |
| 1066 | switch (msg.what) { |
| 1067 | case SHOW: showH(msg.arg1); break; |
| 1068 | case DISMISS: dismissH(msg.arg1); break; |
| 1069 | case RECHECK: recheckH((VolumeRow) msg.obj); break; |
| 1070 | case RECHECK_ALL: recheckH(null); break; |
| 1071 | case SET_STREAM_IMPORTANT: setStreamImportantH(msg.arg1, msg.arg2 != 0); break; |
| 1072 | case RESCHEDULE_TIMEOUT: rescheduleTimeoutH(); break; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1073 | case STATE_CHANGED: onStateChangedH(mState); break; |
| 1074 | case UPDATE_BOTTOM_MARGIN: updateDialogBottomMarginH(); break; |
Jason Monk | aa911b3 | 2016-02-10 21:01:30 -0500 | [diff] [blame] | 1075 | case UPDATE_FOOTER: updateFooterH(); break; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1076 | } |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | private final class CustomDialog extends Dialog { |
| 1081 | public CustomDialog(Context context) { |
| 1082 | super(context); |
| 1083 | } |
| 1084 | |
| 1085 | @Override |
| 1086 | public boolean dispatchTouchEvent(MotionEvent ev) { |
| 1087 | rescheduleTimeoutH(); |
| 1088 | return super.dispatchTouchEvent(ev); |
| 1089 | } |
| 1090 | |
| 1091 | @Override |
| 1092 | protected void onStop() { |
| 1093 | super.onStop(); |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1094 | final boolean animating = mMotion.isAnimating(); |
| 1095 | if (D.BUG) Log.d(TAG, "onStop animating=" + animating); |
| 1096 | if (animating) { |
| 1097 | mPendingRecheckAll = true; |
| 1098 | return; |
| 1099 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1100 | mHandler.sendEmptyMessage(H.RECHECK_ALL); |
| 1101 | } |
| 1102 | |
| 1103 | @Override |
| 1104 | public boolean onTouchEvent(MotionEvent event) { |
| 1105 | if (isShowing()) { |
| 1106 | if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { |
| 1107 | dismissH(Events.DISMISS_REASON_TOUCH_OUTSIDE); |
| 1108 | return true; |
| 1109 | } |
| 1110 | } |
| 1111 | return false; |
| 1112 | } |
Julia Reynolds | 2feab16 | 2016-04-21 14:58:52 -0400 | [diff] [blame] | 1113 | |
| 1114 | @Override |
| 1115 | public boolean dispatchPopulateAccessibilityEvent(@NonNull AccessibilityEvent event) { |
| 1116 | event.setClassName(getClass().getSuperclass().getName()); |
| 1117 | event.setPackageName(mContext.getPackageName()); |
| 1118 | |
| 1119 | ViewGroup.LayoutParams params = getWindow().getAttributes(); |
| 1120 | boolean isFullScreen = (params.width == ViewGroup.LayoutParams.MATCH_PARENT) && |
| 1121 | (params.height == ViewGroup.LayoutParams.MATCH_PARENT); |
| 1122 | event.setFullScreen(isFullScreen); |
| 1123 | |
| 1124 | if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { |
| 1125 | if (mShowing) { |
| 1126 | event.getText().add(mContext.getString( |
| 1127 | R.string.volume_dialog_accessibility_shown_message, |
| 1128 | getActiveRow().ss.name)); |
| 1129 | return true; |
| 1130 | } |
| 1131 | } |
| 1132 | return false; |
| 1133 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | private final class VolumeSeekBarChangeListener implements OnSeekBarChangeListener { |
| 1137 | private final VolumeRow mRow; |
| 1138 | |
| 1139 | private VolumeSeekBarChangeListener(VolumeRow row) { |
| 1140 | mRow = row; |
| 1141 | } |
| 1142 | |
| 1143 | @Override |
| 1144 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { |
| 1145 | if (mRow.ss == null) return; |
| 1146 | if (D.BUG) Log.d(TAG, AudioSystem.streamToString(mRow.stream) |
| 1147 | + " onProgressChanged " + progress + " fromUser=" + fromUser); |
| 1148 | if (!fromUser) return; |
| 1149 | if (mRow.ss.levelMin > 0) { |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1150 | final int minProgress = mRow.ss.levelMin * 100; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1151 | if (progress < minProgress) { |
| 1152 | seekBar.setProgress(minProgress); |
Julia Reynolds | 798b0c3 | 2015-09-01 14:35:53 -0400 | [diff] [blame] | 1153 | progress = minProgress; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1154 | } |
| 1155 | } |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1156 | final int userLevel = getImpliedLevel(seekBar, progress); |
| 1157 | if (mRow.ss.level != userLevel || mRow.ss.muted && userLevel > 0) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1158 | mRow.userAttempt = SystemClock.uptimeMillis(); |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1159 | if (mRow.requestedLevel != userLevel) { |
| 1160 | mController.setStreamVolume(mRow.stream, userLevel); |
| 1161 | mRow.requestedLevel = userLevel; |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 1162 | Events.writeEvent(mContext, Events.EVENT_TOUCH_LEVEL_CHANGED, mRow.stream, |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1163 | userLevel); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1164 | } |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | @Override |
| 1169 | public void onStartTrackingTouch(SeekBar seekBar) { |
| 1170 | if (D.BUG) Log.d(TAG, "onStartTrackingTouch"+ " " + mRow.stream); |
| 1171 | mController.setActiveStream(mRow.stream); |
| 1172 | mRow.tracking = true; |
| 1173 | } |
| 1174 | |
| 1175 | @Override |
| 1176 | public void onStopTrackingTouch(SeekBar seekBar) { |
| 1177 | if (D.BUG) Log.d(TAG, "onStopTrackingTouch"+ " " + mRow.stream); |
| 1178 | mRow.tracking = false; |
| 1179 | mRow.userAttempt = SystemClock.uptimeMillis(); |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1180 | final int userLevel = getImpliedLevel(seekBar, seekBar.getProgress()); |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 1181 | Events.writeEvent(mContext, Events.EVENT_TOUCH_LEVEL_DONE, mRow.stream, userLevel); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1182 | if (mRow.ss.level != userLevel) { |
| 1183 | mHandler.sendMessageDelayed(mHandler.obtainMessage(H.RECHECK, mRow), |
| 1184 | USER_ATTEMPT_GRACE_PERIOD); |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1189 | private final class Accessibility extends AccessibilityDelegate { |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1190 | private boolean mFeedbackEnabled; |
| 1191 | |
| 1192 | public void init() { |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1193 | mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { |
| 1194 | @Override |
| 1195 | public void onViewDetachedFromWindow(View v) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1196 | if (D.BUG) Log.d(TAG, "onViewDetachedFromWindow"); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | @Override |
| 1200 | public void onViewAttachedToWindow(View v) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1201 | if (D.BUG) Log.d(TAG, "onViewAttachedToWindow"); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1202 | updateFeedbackEnabled(); |
| 1203 | } |
| 1204 | }); |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1205 | mDialogView.setAccessibilityDelegate(this); |
Julia Reynolds | 2feab16 | 2016-04-21 14:58:52 -0400 | [diff] [blame] | 1206 | mAccessibilityMgr.addAccessibilityStateChangeListener( |
| 1207 | new AccessibilityStateChangeListener() { |
| 1208 | @Override |
| 1209 | public void onAccessibilityStateChanged(boolean enabled) { |
| 1210 | updateFeedbackEnabled(); |
| 1211 | } |
| 1212 | }); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1213 | updateFeedbackEnabled(); |
| 1214 | } |
| 1215 | |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1216 | @Override |
| 1217 | public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, |
| 1218 | AccessibilityEvent event) { |
| 1219 | rescheduleTimeoutH(); |
| 1220 | return super.onRequestSendAccessibilityEvent(host, child, event); |
| 1221 | } |
| 1222 | |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1223 | private void updateFeedbackEnabled() { |
| 1224 | mFeedbackEnabled = computeFeedbackEnabled(); |
| 1225 | } |
| 1226 | |
| 1227 | private boolean computeFeedbackEnabled() { |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1228 | // are there any enabled non-generic a11y services? |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1229 | final List<AccessibilityServiceInfo> services = |
Julia Reynolds | 2feab16 | 2016-04-21 14:58:52 -0400 | [diff] [blame] | 1230 | mAccessibilityMgr.getEnabledAccessibilityServiceList(FEEDBACK_ALL_MASK); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1231 | for (AccessibilityServiceInfo asi : services) { |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1232 | if (asi.feedbackType != 0 && asi.feedbackType != FEEDBACK_GENERIC) { |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1233 | return true; |
| 1234 | } |
| 1235 | } |
| 1236 | return false; |
| 1237 | } |
| 1238 | } |
| 1239 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1240 | private static class VolumeRow { |
| 1241 | private View view; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1242 | private TextView header; |
| 1243 | private ImageButton icon; |
| 1244 | private SeekBar slider; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1245 | private int stream; |
| 1246 | private StreamState ss; |
| 1247 | private long userAttempt; // last user-driven slider change |
| 1248 | private boolean tracking; // tracking slider touch |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 1249 | private int requestedLevel = -1; // pending user-requested level via progress changed |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1250 | private int iconRes; |
| 1251 | private int iconMuteRes; |
| 1252 | private boolean important; |
| 1253 | private int cachedIconRes; |
John Spurlock | ecc8058 | 2015-05-13 16:23:14 -0400 | [diff] [blame] | 1254 | private ColorStateList cachedSliderTint; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1255 | private int iconState; // from Events |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 1256 | private boolean cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS; |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1257 | private ObjectAnimator anim; // slider progress animation for non-touch-related updates |
| 1258 | private int animTargetProgress; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1259 | private int lastAudibleLevel = 1; |
| 1260 | } |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 1261 | |
| 1262 | public interface Callback { |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 1263 | void onZenSettingsClicked(); |
| 1264 | void onZenPrioritySettingsClicked(); |
| 1265 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1266 | } |