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 | |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 19 | import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_ALL_MASK; |
| 20 | import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_GENERIC; |
Beverly | 34d271d | 2018-10-01 14:44:26 -0400 | [diff] [blame] | 21 | import static android.app.ActivityManager.LOCK_TASK_MODE_NONE; |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 22 | import static android.media.AudioManager.RINGER_MODE_NORMAL; |
| 23 | import static android.media.AudioManager.RINGER_MODE_SILENT; |
| 24 | import static android.media.AudioManager.RINGER_MODE_VIBRATE; |
Julia Reynolds | 7c62c31 | 2018-02-01 17:29:33 -0500 | [diff] [blame] | 25 | import static android.media.AudioManager.STREAM_ACCESSIBILITY; |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 26 | import static android.media.AudioManager.STREAM_ALARM; |
| 27 | import static android.media.AudioManager.STREAM_MUSIC; |
| 28 | import static android.media.AudioManager.STREAM_RING; |
| 29 | import static android.media.AudioManager.STREAM_VOICE_CALL; |
Julia Reynolds | a438675 | 2018-03-12 14:07:04 -0400 | [diff] [blame] | 30 | import static android.view.View.GONE; |
| 31 | import static android.view.View.VISIBLE; |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 32 | |
Julia Reynolds | 0a22856 | 2018-01-10 12:53:40 -0500 | [diff] [blame] | 33 | import static com.android.systemui.volume.Events.DISMISS_REASON_SETTINGS_CLICKED; |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 34 | |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 35 | import android.accessibilityservice.AccessibilityServiceInfo; |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 36 | import android.animation.ObjectAnimator; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 37 | import android.annotation.SuppressLint; |
Beverly | 34d271d | 2018-10-01 14:44:26 -0400 | [diff] [blame] | 38 | import android.app.ActivityManager; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 39 | import android.app.Dialog; |
| 40 | import android.app.KeyguardManager; |
Beverly | 38fcfd0 | 2018-05-18 17:33:40 -0400 | [diff] [blame] | 41 | import android.content.ContentResolver; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 42 | import android.content.Context; |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 43 | import android.content.DialogInterface; |
Julia Reynolds | 0a22856 | 2018-01-10 12:53:40 -0500 | [diff] [blame] | 44 | import android.content.Intent; |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 45 | import android.content.pm.PackageManager; |
John Spurlock | 77bb25af | 2015-05-11 12:12:07 -0400 | [diff] [blame] | 46 | import android.content.res.ColorStateList; |
Mike Digman | 827824c | 2018-03-27 12:10:35 -0700 | [diff] [blame] | 47 | import android.content.res.Configuration; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 48 | import android.content.res.Resources; |
Julia Reynolds | 027d3a6 | 2018-05-23 09:45:53 -0400 | [diff] [blame] | 49 | import android.content.res.TypedArray; |
Jason Monk | 98ad83c | 2017-06-13 14:03:45 -0400 | [diff] [blame] | 50 | import android.graphics.Color; |
Julia Reynolds | 30dd125 | 2018-02-09 15:40:20 -0500 | [diff] [blame] | 51 | import android.graphics.PixelFormat; |
Jason Monk | 98ad83c | 2017-06-13 14:03:45 -0400 | [diff] [blame] | 52 | import android.graphics.drawable.ColorDrawable; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 53 | import android.media.AudioManager; |
| 54 | import android.media.AudioSystem; |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 55 | import android.os.Debug; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 56 | import android.os.Handler; |
| 57 | import android.os.Looper; |
| 58 | import android.os.Message; |
| 59 | import android.os.SystemClock; |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 60 | import android.os.VibrationEffect; |
Julia Reynolds | 0a22856 | 2018-01-10 12:53:40 -0500 | [diff] [blame] | 61 | import android.provider.Settings; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 62 | import android.provider.Settings.Global; |
Julia Reynolds | 7c62c31 | 2018-02-01 17:29:33 -0500 | [diff] [blame] | 63 | import android.text.InputFilter; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 64 | import android.util.Log; |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 65 | import android.util.Slog; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 66 | import android.util.SparseBooleanArray; |
Lucas Dupin | 448786c | 2017-07-24 17:44:25 -0700 | [diff] [blame] | 67 | import android.view.ContextThemeWrapper; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 68 | import android.view.MotionEvent; |
| 69 | import android.view.View; |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 70 | import android.view.View.AccessibilityDelegate; |
| 71 | import android.view.View.OnAttachStateChangeListener; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 72 | import android.view.ViewGroup; |
Mike Digman | 827824c | 2018-03-27 12:10:35 -0700 | [diff] [blame] | 73 | import android.view.ViewPropertyAnimator; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 74 | import android.view.Window; |
| 75 | import android.view.WindowManager; |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 76 | import android.view.accessibility.AccessibilityEvent; |
Beverly | cab59e6 | 2018-04-16 17:47:39 -0400 | [diff] [blame] | 77 | import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener; |
Beverly | f138ba2 | 2018-05-03 17:32:41 -0400 | [diff] [blame] | 78 | import android.view.accessibility.AccessibilityNodeInfo; |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 79 | import android.view.animation.DecelerateInterpolator; |
Beverly | 0099195 | 2018-04-26 11:17:29 -0400 | [diff] [blame] | 80 | import android.widget.FrameLayout; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 81 | import android.widget.ImageButton; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 82 | import android.widget.SeekBar; |
| 83 | import android.widget.SeekBar.OnSeekBarChangeListener; |
| 84 | import android.widget.TextView; |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 85 | import android.widget.Toast; |
Lucas Dupin | 7224c1e | 2017-07-06 14:35:30 -0700 | [diff] [blame] | 86 | |
Andrew Sapperstein | 5c37344 | 2016-06-12 13:17:16 -0700 | [diff] [blame] | 87 | import com.android.settingslib.Utils; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 88 | import com.android.systemui.Dependency; |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 89 | import com.android.systemui.Prefs; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 90 | import com.android.systemui.R; |
Julia Reynolds | 6692b47 | 2018-01-24 07:23:56 -0500 | [diff] [blame] | 91 | import com.android.systemui.plugins.ActivityStarter; |
Rajeev Kumar | 5c964a4 | 2017-06-13 19:41:35 -0700 | [diff] [blame] | 92 | import com.android.systemui.plugins.VolumeDialog; |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 93 | import com.android.systemui.plugins.VolumeDialogController; |
| 94 | import com.android.systemui.plugins.VolumeDialogController.State; |
| 95 | import com.android.systemui.plugins.VolumeDialogController.StreamState; |
Julia Reynolds | 561d3f4 | 2018-01-26 11:31:02 -0500 | [diff] [blame] | 96 | import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; |
Julia Reynolds | a438675 | 2018-03-12 14:07:04 -0400 | [diff] [blame] | 97 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Lucas Dupin | 7224c1e | 2017-07-06 14:35:30 -0700 | [diff] [blame] | 98 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 99 | import java.io.PrintWriter; |
| 100 | import java.util.ArrayList; |
| 101 | import java.util.List; |
| 102 | |
| 103 | /** |
| 104 | * Visual presentation of the volume dialog. |
| 105 | * |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 106 | * A client of VolumeDialogControllerImpl and its state model. |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 107 | * |
| 108 | * Methods ending in "H" must be called on the (ui) handler. |
| 109 | */ |
Julia Reynolds | 66d2894 | 2017-11-07 09:43:54 -0500 | [diff] [blame] | 110 | public class VolumeDialogImpl implements VolumeDialog { |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 111 | private static final String TAG = Util.logTag(VolumeDialogImpl.class); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 112 | |
| 113 | private static final long USER_ATTEMPT_GRACE_PERIOD = 1000; |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 114 | private static final int UPDATE_ANIMATION_DURATION = 80; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 115 | |
| 116 | private final Context mContext; |
| 117 | private final H mHandler = new H(); |
Rajeev Kumar | 5c964a4 | 2017-06-13 19:41:35 -0700 | [diff] [blame] | 118 | private final VolumeDialogController mController; |
Julia Reynolds | a438675 | 2018-03-12 14:07:04 -0400 | [diff] [blame] | 119 | private final DeviceProvisionedController mDeviceProvisionedController; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 120 | |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 121 | private Window mWindow; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 122 | private CustomDialog mDialog; |
| 123 | private ViewGroup mDialogView; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 124 | private ViewGroup mDialogRowsView; |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 125 | private ViewGroup mRinger; |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 126 | private ImageButton mRingerIcon; |
Julia Reynolds | a438675 | 2018-03-12 14:07:04 -0400 | [diff] [blame] | 127 | private View mSettingsView; |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 128 | private ImageButton mSettingsIcon; |
Beverly | 0099195 | 2018-04-26 11:17:29 -0400 | [diff] [blame] | 129 | private FrameLayout mZenIcon; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 130 | private final List<VolumeRow> mRows = new ArrayList<>(); |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 131 | private ConfigurableTexts mConfigurableTexts; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 132 | private final SparseBooleanArray mDynamic = new SparseBooleanArray(); |
| 133 | private final KeyguardManager mKeyguard; |
Beverly | 34d271d | 2018-10-01 14:44:26 -0400 | [diff] [blame] | 134 | private final ActivityManager mActivityManager; |
Julia Reynolds | 561d3f4 | 2018-01-26 11:31:02 -0500 | [diff] [blame] | 135 | private final AccessibilityManagerWrapper mAccessibilityMgr; |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 136 | private final Object mSafetyWarningLock = new Object(); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 137 | private final Accessibility mAccessibility = new Accessibility(); |
Julia Reynolds | 027d3a6 | 2018-05-23 09:45:53 -0400 | [diff] [blame] | 138 | private ColorStateList mActiveTint; |
| 139 | private int mActiveAlpha; |
| 140 | private ColorStateList mInactiveTint; |
| 141 | private int mInactiveAlpha; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 142 | |
| 143 | private boolean mShowing; |
Julia Reynolds | dbfb40f | 2017-01-23 11:05:57 -0500 | [diff] [blame] | 144 | private boolean mShowA11yStream; |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 145 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 146 | private int mActiveStream; |
Beverly | fa4c8e7 | 2017-08-10 14:55:34 -0400 | [diff] [blame] | 147 | private int mPrevActiveStream; |
John Spurlock | f55b7f2 | 2015-04-13 19:21:26 -0400 | [diff] [blame] | 148 | private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE; |
| 149 | private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 150 | private State mState; |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 151 | private SafetyWarningDialog mSafetyWarning; |
Jun Mukai | 3f5d713 | 2015-07-21 14:10:09 -0700 | [diff] [blame] | 152 | private boolean mHovering = false; |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 153 | private boolean mShowActiveStreamOnly; |
Julia Reynolds | b104200 | 2018-08-01 12:49:02 -0400 | [diff] [blame] | 154 | private boolean mConfigChanged = false; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 155 | |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 156 | public VolumeDialogImpl(Context context) { |
Lucas Dupin | 448786c | 2017-07-24 17:44:25 -0700 | [diff] [blame] | 157 | mContext = new ContextThemeWrapper(context, com.android.systemui.R.style.qs_theme); |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 158 | mController = Dependency.get(VolumeDialogController.class); |
| 159 | mKeyguard = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); |
Beverly | 34d271d | 2018-10-01 14:44:26 -0400 | [diff] [blame] | 160 | mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); |
Julia Reynolds | 561d3f4 | 2018-01-26 11:31:02 -0500 | [diff] [blame] | 161 | mAccessibilityMgr = Dependency.get(AccessibilityManagerWrapper.class); |
Julia Reynolds | a438675 | 2018-03-12 14:07:04 -0400 | [diff] [blame] | 162 | mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class); |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 163 | mShowActiveStreamOnly = showActiveStreamOnly(); |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | public void init(int windowType, Callback callback) { |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 167 | initDialog(); |
| 168 | |
| 169 | mAccessibility.init(); |
| 170 | |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 171 | mController.addCallback(mControllerCallbackH, mHandler); |
| 172 | mController.getState(); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 173 | } |
| 174 | |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 175 | @Override |
| 176 | public void destroy() { |
Jason Monk | 3b9357f | 2017-07-14 09:40:54 -0400 | [diff] [blame] | 177 | mAccessibility.destroy(); |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 178 | mController.removeCallback(mControllerCallbackH); |
Jason Monk | 3b9357f | 2017-07-14 09:40:54 -0400 | [diff] [blame] | 179 | mHandler.removeCallbacksAndMessages(null); |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 180 | } |
| 181 | |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 182 | private void initDialog() { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 183 | mDialog = new CustomDialog(mContext); |
| 184 | |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 185 | mConfigurableTexts = new ConfigurableTexts(mContext); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 186 | mHovering = false; |
| 187 | mShowing = false; |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 188 | mWindow = mDialog.getWindow(); |
| 189 | mWindow.requestFeature(Window.FEATURE_NO_TITLE); |
Jason Monk | 98ad83c | 2017-06-13 14:03:45 -0400 | [diff] [blame] | 190 | mWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 191 | mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 192 | | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 193 | mWindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 194 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 195 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 196 | | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
| 197 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 198 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 199 | mWindow.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY); |
| 200 | mWindow.setWindowAnimations(com.android.internal.R.style.Animation_Toast); |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 201 | WindowManager.LayoutParams lp = mWindow.getAttributes(); |
Julia Reynolds | 30dd125 | 2018-02-09 15:40:20 -0500 | [diff] [blame] | 202 | lp.format = PixelFormat.TRANSLUCENT; |
| 203 | lp.setTitle(VolumeDialogImpl.class.getSimpleName()); |
Julia Reynolds | 30dd125 | 2018-02-09 15:40:20 -0500 | [diff] [blame] | 204 | lp.windowAnimations = -1; |
| 205 | mWindow.setAttributes(lp); |
| 206 | mWindow.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 207 | |
Jason Monk | 98ad83c | 2017-06-13 14:03:45 -0400 | [diff] [blame] | 208 | mDialog.setContentView(R.layout.volume_dialog); |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 209 | mDialogView = mDialog.findViewById(R.id.volume_dialog); |
| 210 | mDialog.setCanceledOnTouchOutside(true); |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 211 | mDialog.setOnShowListener(dialog -> { |
Mike Digman | 827824c | 2018-03-27 12:10:35 -0700 | [diff] [blame] | 212 | if (!isLandscape()) mDialogView.setTranslationX(mDialogView.getWidth() / 2); |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 213 | mDialogView.setAlpha(0); |
| 214 | mDialogView.animate() |
| 215 | .alpha(1) |
Julia Reynolds | 0a22856 | 2018-01-10 12:53:40 -0500 | [diff] [blame] | 216 | .translationX(0) |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 217 | .setDuration(300) |
| 218 | .setInterpolator(new SystemUIInterpolators.LogDecelerateInterpolator()) |
| 219 | .withEndAction(() -> { |
Julia Reynolds | bc9329a | 2018-04-03 15:23:03 -0400 | [diff] [blame] | 220 | if (!Prefs.getBoolean(mContext, Prefs.Key.TOUCHED_RINGER_TOGGLE, false)) { |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 221 | if (mRingerIcon != null) { |
| 222 | mRingerIcon.postOnAnimationDelayed(mSinglePress, 1500); |
| 223 | } |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 224 | } |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 225 | }) |
| 226 | .start(); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 227 | }); |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 228 | |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 229 | mDialogView.setOnHoverListener((v, event) -> { |
| 230 | int action = event.getActionMasked(); |
| 231 | mHovering = (action == MotionEvent.ACTION_HOVER_ENTER) |
| 232 | || (action == MotionEvent.ACTION_HOVER_MOVE); |
| 233 | rescheduleTimeoutH(); |
| 234 | return true; |
Jun Mukai | 3f5d713 | 2015-07-21 14:10:09 -0700 | [diff] [blame] | 235 | }); |
Lucas Dupin | c1cc759 | 2017-05-22 15:56:16 -0700 | [diff] [blame] | 236 | |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 237 | lp = mWindow.getAttributes(); |
| 238 | lp.gravity = ((FrameLayout.LayoutParams) mDialogView.getLayoutParams()).gravity; |
| 239 | mWindow.setAttributes(lp); |
| 240 | |
Julia Reynolds | 027d3a6 | 2018-05-23 09:45:53 -0400 | [diff] [blame] | 241 | mActiveTint = Utils.getColorAccent(mContext); |
| 242 | mActiveAlpha = Color.alpha(mActiveTint.getDefaultColor()); |
| 243 | mInactiveTint = Utils.getColorAttr(mContext, android.R.attr.colorForeground); |
| 244 | mInactiveAlpha = getAlphaAttr(android.R.attr.secondaryContentAlpha); |
| 245 | |
Julia Reynolds | 0a22856 | 2018-01-10 12:53:40 -0500 | [diff] [blame] | 246 | mDialogRowsView = mDialog.findViewById(R.id.volume_dialog_rows); |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 247 | mRinger = mDialog.findViewById(R.id.ringer); |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 248 | if (mRinger != null) { |
| 249 | mRingerIcon = mRinger.findViewById(R.id.ringer_icon); |
| 250 | mZenIcon = mRinger.findViewById(R.id.dnd_icon); |
| 251 | } |
Julia Reynolds | a438675 | 2018-03-12 14:07:04 -0400 | [diff] [blame] | 252 | mSettingsView = mDialog.findViewById(R.id.settings_container); |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 253 | mSettingsIcon = mDialog.findViewById(R.id.settings); |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 254 | |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 255 | if (mRows.isEmpty()) { |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 256 | if (!AudioSystem.isSingleVolume(mContext)) { |
| 257 | addRow(STREAM_ACCESSIBILITY, R.drawable.ic_volume_accessibility, |
| 258 | R.drawable.ic_volume_accessibility, true, false); |
| 259 | } |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 260 | addRow(AudioManager.STREAM_MUSIC, |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 261 | R.drawable.ic_volume_media, R.drawable.ic_volume_media_mute, true, true); |
Muyuan Li | 36007d2 | 2016-06-21 14:21:48 -0700 | [diff] [blame] | 262 | if (!AudioSystem.isSingleVolume(mContext)) { |
| 263 | addRow(AudioManager.STREAM_RING, |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 264 | R.drawable.ic_volume_ringer, R.drawable.ic_volume_ringer_mute, true, false); |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 265 | addRow(STREAM_ALARM, |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 266 | R.drawable.ic_volume_alarm, R.drawable.ic_volume_alarm_mute, true, false); |
Muyuan Li | 36007d2 | 2016-06-21 14:21:48 -0700 | [diff] [blame] | 267 | addRow(AudioManager.STREAM_VOICE_CALL, |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 268 | R.drawable.ic_volume_voice, R.drawable.ic_volume_voice, false, false); |
Muyuan Li | 36007d2 | 2016-06-21 14:21:48 -0700 | [diff] [blame] | 269 | addRow(AudioManager.STREAM_BLUETOOTH_SCO, |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 270 | R.drawable.ic_volume_bt_sco, R.drawable.ic_volume_bt_sco, false, false); |
| 271 | addRow(AudioManager.STREAM_SYSTEM, R.drawable.ic_volume_system, |
| 272 | R.drawable.ic_volume_system_mute, false, false); |
Muyuan Li | 36007d2 | 2016-06-21 14:21:48 -0700 | [diff] [blame] | 273 | } |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 274 | } else { |
| 275 | addExistingRows(); |
| 276 | } |
Julia Reynolds | 0a22856 | 2018-01-10 12:53:40 -0500 | [diff] [blame] | 277 | |
Julia Reynolds | 08ce310 | 2017-11-16 09:29:55 -0500 | [diff] [blame] | 278 | updateRowsH(getActiveRow()); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 279 | initRingerH(); |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 280 | initSettingsH(); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 281 | } |
| 282 | |
Julia Reynolds | 561d3f4 | 2018-01-26 11:31:02 -0500 | [diff] [blame] | 283 | protected ViewGroup getDialogView() { |
| 284 | return mDialogView; |
| 285 | } |
| 286 | |
Julia Reynolds | 027d3a6 | 2018-05-23 09:45:53 -0400 | [diff] [blame] | 287 | private int getAlphaAttr(int attr) { |
| 288 | TypedArray ta = mContext.obtainStyledAttributes(new int[]{attr}); |
| 289 | float alpha = ta.getFloat(0, 0); |
| 290 | ta.recycle(); |
| 291 | return (int) (alpha * 255); |
John Spurlock | 77bb25af | 2015-05-11 12:12:07 -0400 | [diff] [blame] | 292 | } |
| 293 | |
Mike Digman | 827824c | 2018-03-27 12:10:35 -0700 | [diff] [blame] | 294 | private boolean isLandscape() { |
| 295 | return mContext.getResources().getConfiguration().orientation == |
| 296 | Configuration.ORIENTATION_LANDSCAPE; |
| 297 | } |
| 298 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 299 | public void setStreamImportant(int stream, boolean important) { |
| 300 | mHandler.obtainMessage(H.SET_STREAM_IMPORTANT, stream, important ? 1 : 0).sendToTarget(); |
| 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 | |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 315 | private void addRow(int stream, int iconRes, int iconMuteRes, boolean important, |
| 316 | boolean defaultStream) { |
| 317 | addRow(stream, iconRes, iconMuteRes, important, defaultStream, false); |
Julia Reynolds | dbfb40f | 2017-01-23 11:05:57 -0500 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | private void addRow(int stream, int iconRes, int iconMuteRes, boolean important, |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 321 | boolean defaultStream, boolean dynamic) { |
Julia Reynolds | 561d3f4 | 2018-01-26 11:31:02 -0500 | [diff] [blame] | 322 | if (D.BUG) Slog.d(TAG, "Adding row for stream " + stream); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 323 | VolumeRow row = new VolumeRow(); |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 324 | initRow(row, stream, iconRes, iconMuteRes, important, defaultStream); |
Julia Reynolds | 5329ce8 | 2018-04-10 17:27:46 -0400 | [diff] [blame] | 325 | mDialogRowsView.addView(row.view); |
| 326 | mRows.add(row); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 327 | } |
| 328 | |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 329 | private void addExistingRows() { |
| 330 | int N = mRows.size(); |
| 331 | for (int i = 0; i < N; i++) { |
| 332 | final VolumeRow row = mRows.get(i); |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 333 | initRow(row, row.stream, row.iconRes, row.iconMuteRes, row.important, |
| 334 | row.defaultStream); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 335 | mDialogRowsView.addView(row.view); |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 336 | updateVolumeRowH(row); |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 337 | } |
| 338 | } |
| 339 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 340 | private VolumeRow getActiveRow() { |
| 341 | for (VolumeRow row : mRows) { |
| 342 | if (row.stream == mActiveStream) { |
| 343 | return row; |
| 344 | } |
| 345 | } |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 346 | for (VolumeRow row : mRows) { |
| 347 | if (row.stream == STREAM_MUSIC) { |
| 348 | return row; |
| 349 | } |
| 350 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 351 | return mRows.get(0); |
| 352 | } |
| 353 | |
| 354 | private VolumeRow findRow(int stream) { |
| 355 | for (VolumeRow row : mRows) { |
| 356 | if (row.stream == stream) return row; |
| 357 | } |
| 358 | return null; |
| 359 | } |
| 360 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 361 | public void dump(PrintWriter writer) { |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 362 | writer.println(VolumeDialogImpl.class.getSimpleName() + " state:"); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 363 | writer.print(" mShowing: "); writer.println(mShowing); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 364 | writer.print(" mActiveStream: "); writer.println(mActiveStream); |
| 365 | writer.print(" mDynamic: "); writer.println(mDynamic); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 366 | writer.print(" mAutomute: "); writer.println(mAutomute); |
| 367 | writer.print(" mSilentMode: "); writer.println(mSilentMode); |
John Spurlock | 84ee67c | 2015-05-20 23:33:43 -0400 | [diff] [blame] | 368 | writer.print(" mAccessibility.mFeedbackEnabled: "); |
| 369 | writer.println(mAccessibility.mFeedbackEnabled); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 370 | } |
| 371 | |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 372 | private static int getImpliedLevel(SeekBar seekBar, int progress) { |
| 373 | final int m = seekBar.getMax(); |
| 374 | final int n = m / 100 - 1; |
| 375 | final int level = progress == 0 ? 0 |
| 376 | : progress == m ? (m / 100) : (1 + (int)((progress / (float) m) * n)); |
| 377 | return level; |
| 378 | } |
| 379 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 380 | @SuppressLint("InflateParams") |
Julia Reynolds | c791e05 | 2016-02-19 16:02:01 -0500 | [diff] [blame] | 381 | private void initRow(final VolumeRow row, final int stream, int iconRes, int iconMuteRes, |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 382 | boolean important, boolean defaultStream) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 383 | row.stream = stream; |
| 384 | row.iconRes = iconRes; |
| 385 | row.iconMuteRes = iconMuteRes; |
| 386 | row.important = important; |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 387 | row.defaultStream = defaultStream; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 388 | row.view = mDialog.getLayoutInflater().inflate(R.layout.volume_dialog_row, null); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 389 | row.view.setId(row.stream); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 390 | row.view.setTag(row); |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 391 | row.header = row.view.findViewById(R.id.volume_row_header); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 392 | row.header.setId(20 * row.stream); |
Julia Reynolds | 7c62c31 | 2018-02-01 17:29:33 -0500 | [diff] [blame] | 393 | if (stream == STREAM_ACCESSIBILITY) { |
| 394 | row.header.setFilters(new InputFilter[] {new InputFilter.LengthFilter(13)}); |
| 395 | } |
Beverly | da0fe82 | 2018-02-08 17:19:01 -0500 | [diff] [blame] | 396 | row.dndIcon = row.view.findViewById(R.id.dnd_icon); |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 397 | row.slider = row.view.findViewById(R.id.volume_row_slider); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 398 | row.slider.setOnSeekBarChangeListener(new VolumeSeekBarChangeListener(row)); |
Julia Reynolds | 5774cf0 | 2016-05-26 13:43:38 -0400 | [diff] [blame] | 399 | row.anim = null; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 400 | |
Julia Reynolds | e2503dd | 2017-04-18 11:21:13 -0400 | [diff] [blame] | 401 | row.icon = row.view.findViewById(R.id.volume_row_icon); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 402 | row.icon.setImageResource(iconRes); |
Julia Reynolds | 7c502e0 | 2017-03-06 10:19:10 -0500 | [diff] [blame] | 403 | if (row.stream != AudioSystem.STREAM_ACCESSIBILITY) { |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 404 | row.icon.setOnClickListener(v -> { |
| 405 | Events.writeEvent(mContext, Events.EVENT_ICON_CLICK, row.stream, row.iconState); |
| 406 | mController.setActiveStream(row.stream); |
| 407 | if (row.stream == AudioManager.STREAM_RING) { |
| 408 | final boolean hasVibrator = mController.hasVibrator(); |
Julia Reynolds | 229b300 | 2018-01-23 09:30:09 -0500 | [diff] [blame] | 409 | if (mState.ringerModeInternal == AudioManager.RINGER_MODE_NORMAL) { |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 410 | if (hasVibrator) { |
Julia Reynolds | 229b300 | 2018-01-23 09:30:09 -0500 | [diff] [blame] | 411 | mController.setRingerMode(AudioManager.RINGER_MODE_VIBRATE, false); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 412 | } else { |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 413 | final boolean wasZero = row.ss.level == 0; |
| 414 | mController.setStreamVolume(stream, |
| 415 | wasZero ? row.lastAudibleLevel : 0); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 416 | } |
| 417 | } else { |
Julia Reynolds | 229b300 | 2018-01-23 09:30:09 -0500 | [diff] [blame] | 418 | mController.setRingerMode(AudioManager.RINGER_MODE_NORMAL, false); |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 419 | if (row.ss.level == 0) { |
| 420 | mController.setStreamVolume(stream, 1); |
| 421 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 422 | } |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 423 | } else { |
| 424 | final boolean vmute = row.ss.level == row.ss.levelMin; |
| 425 | mController.setStreamVolume(stream, |
| 426 | vmute ? row.lastAudibleLevel : row.ss.levelMin); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 427 | } |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 428 | row.userAttempt = 0; // reset the grace period, slider updates immediately |
Julia Reynolds | 7c502e0 | 2017-03-06 10:19:10 -0500 | [diff] [blame] | 429 | }); |
Julia Reynolds | e2503dd | 2017-04-18 11:21:13 -0400 | [diff] [blame] | 430 | } else { |
| 431 | row.icon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); |
Julia Reynolds | 7c502e0 | 2017-03-06 10:19:10 -0500 | [diff] [blame] | 432 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 433 | } |
| 434 | |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 435 | public void initSettingsH() { |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 436 | if (mSettingsView != null) { |
| 437 | mSettingsView.setVisibility( |
Beverly | 34d271d | 2018-10-01 14:44:26 -0400 | [diff] [blame] | 438 | mDeviceProvisionedController.isCurrentUserSetup() && |
| 439 | mActivityManager.getLockTaskModeState() == LOCK_TASK_MODE_NONE ? |
| 440 | VISIBLE : GONE); |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 441 | } |
| 442 | if (mSettingsIcon != null) { |
| 443 | mSettingsIcon.setOnClickListener(v -> { |
| 444 | Events.writeEvent(mContext, Events.EVENT_SETTINGS_CLICK); |
| 445 | Intent intent = new Intent(Settings.ACTION_SOUND_SETTINGS); |
| 446 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 447 | dismissH(DISMISS_REASON_SETTINGS_CLICKED); |
| 448 | Dependency.get(ActivityStarter.class).startActivity(intent, |
| 449 | true /* dismissShade */); |
| 450 | }); |
| 451 | } |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 452 | } |
| 453 | |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 454 | public void initRingerH() { |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 455 | if (mRingerIcon != null) { |
| 456 | mRingerIcon.setOnClickListener(v -> { |
| 457 | Prefs.putBoolean(mContext, Prefs.Key.TOUCHED_RINGER_TOGGLE, true); |
| 458 | final StreamState ss = mState.states.get(AudioManager.STREAM_RING); |
| 459 | if (ss == null) { |
| 460 | return; |
| 461 | } |
| 462 | // normal -> vibrate -> silent -> normal (skip vibrate if device doesn't have |
| 463 | // a vibrator. |
| 464 | int newRingerMode; |
| 465 | final boolean hasVibrator = mController.hasVibrator(); |
| 466 | if (mState.ringerModeInternal == AudioManager.RINGER_MODE_NORMAL) { |
| 467 | if (hasVibrator) { |
| 468 | newRingerMode = AudioManager.RINGER_MODE_VIBRATE; |
| 469 | } else { |
| 470 | newRingerMode = AudioManager.RINGER_MODE_SILENT; |
| 471 | } |
| 472 | } else if (mState.ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE) { |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 473 | newRingerMode = AudioManager.RINGER_MODE_SILENT; |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 474 | } else { |
| 475 | newRingerMode = AudioManager.RINGER_MODE_NORMAL; |
| 476 | if (ss.level == 0) { |
| 477 | mController.setStreamVolume(AudioManager.STREAM_RING, 1); |
| 478 | } |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 479 | } |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 480 | Events.writeEvent(mContext, Events.EVENT_RINGER_TOGGLE, newRingerMode); |
| 481 | incrementManualToggleCount(); |
| 482 | updateRingerH(); |
| 483 | provideTouchFeedbackH(newRingerMode); |
| 484 | mController.setRingerMode(newRingerMode, false); |
| 485 | maybeShowToastH(newRingerMode); |
| 486 | }); |
| 487 | } |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 488 | updateRingerH(); |
| 489 | } |
| 490 | |
Beverly | 38fcfd0 | 2018-05-18 17:33:40 -0400 | [diff] [blame] | 491 | private void incrementManualToggleCount() { |
| 492 | ContentResolver cr = mContext.getContentResolver(); |
| 493 | int ringerCount = Settings.Secure.getInt(cr, Settings.Secure.MANUAL_RINGER_TOGGLE_COUNT, 0); |
| 494 | Settings.Secure.putInt(cr, Settings.Secure.MANUAL_RINGER_TOGGLE_COUNT, ringerCount + 1); |
| 495 | } |
Beverly Tai | efd8e08 | 2018-05-15 23:49:05 +0000 | [diff] [blame] | 496 | |
| 497 | private void provideTouchFeedbackH(int newRingerMode) { |
| 498 | VibrationEffect effect = null; |
| 499 | switch (newRingerMode) { |
| 500 | case RINGER_MODE_NORMAL: |
| 501 | mController.scheduleTouchFeedback(); |
| 502 | break; |
| 503 | case RINGER_MODE_SILENT: |
| 504 | effect = VibrationEffect.get(VibrationEffect.EFFECT_CLICK); |
| 505 | break; |
| 506 | case RINGER_MODE_VIBRATE: |
| 507 | default: |
| 508 | effect = VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK); |
| 509 | } |
| 510 | if (effect != null) { |
| 511 | mController.vibrate(effect); |
| 512 | } |
| 513 | } |
| 514 | |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 515 | private void maybeShowToastH(int newRingerMode) { |
| 516 | int seenToastCount = Prefs.getInt(mContext, Prefs.Key.SEEN_RINGER_GUIDANCE_COUNT, 0); |
| 517 | |
| 518 | if (seenToastCount > VolumePrefs.SHOW_RINGER_TOAST_COUNT) { |
| 519 | return; |
| 520 | } |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 521 | CharSequence toastText = null; |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 522 | switch (newRingerMode) { |
| 523 | case RINGER_MODE_NORMAL: |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 524 | final StreamState ss = mState.states.get(AudioManager.STREAM_RING); |
| 525 | if (ss != null) { |
| 526 | toastText = mContext.getString( |
| 527 | R.string.volume_dialog_ringer_guidance_ring, |
| 528 | Utils.formatPercentage(ss.level, ss.levelMax)); |
| 529 | } |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 530 | break; |
| 531 | case RINGER_MODE_SILENT: |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 532 | toastText = mContext.getString( |
| 533 | com.android.internal.R.string.volume_dialog_ringer_guidance_silent); |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 534 | break; |
| 535 | case RINGER_MODE_VIBRATE: |
| 536 | default: |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 537 | toastText = mContext.getString( |
| 538 | com.android.internal.R.string.volume_dialog_ringer_guidance_vibrate); |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | Toast.makeText(mContext, toastText, Toast.LENGTH_SHORT).show(); |
| 542 | seenToastCount++; |
| 543 | Prefs.putInt(mContext, Prefs.Key.SEEN_RINGER_GUIDANCE_COUNT, seenToastCount); |
| 544 | } |
| 545 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 546 | public void show(int reason) { |
| 547 | mHandler.obtainMessage(H.SHOW, reason, 0).sendToTarget(); |
| 548 | } |
| 549 | |
| 550 | public void dismiss(int reason) { |
| 551 | mHandler.obtainMessage(H.DISMISS, reason, 0).sendToTarget(); |
| 552 | } |
| 553 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 554 | private void showH(int reason) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 555 | if (D.BUG) Log.d(TAG, "showH r=" + Events.DISMISS_REASONS[reason]); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 556 | mHandler.removeMessages(H.SHOW); |
| 557 | mHandler.removeMessages(H.DISMISS); |
| 558 | rescheduleTimeoutH(); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 559 | |
Julia Reynolds | b104200 | 2018-08-01 12:49:02 -0400 | [diff] [blame] | 560 | if (mConfigChanged) { |
Beverly | 17608f4 | 2018-10-16 10:56:47 -0400 | [diff] [blame^] | 561 | initDialog(); // resets mShowing to false |
Julia Reynolds | b104200 | 2018-08-01 12:49:02 -0400 | [diff] [blame] | 562 | mConfigurableTexts.update(); |
| 563 | mConfigChanged = false; |
| 564 | } |
Beverly | 17608f4 | 2018-10-16 10:56:47 -0400 | [diff] [blame^] | 565 | |
Julia Reynolds | 4531d84 | 2018-03-14 10:46:04 -0400 | [diff] [blame] | 566 | initSettingsH(); |
Beverly | 17608f4 | 2018-10-16 10:56:47 -0400 | [diff] [blame^] | 567 | mShowing = true; |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 568 | mDialog.show(); |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 569 | Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked()); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 570 | mController.notifyVisible(true); |
| 571 | } |
| 572 | |
| 573 | protected void rescheduleTimeoutH() { |
| 574 | mHandler.removeMessages(H.DISMISS); |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 575 | final int timeout = computeTimeoutH(); |
| 576 | mHandler.sendMessageDelayed(mHandler |
| 577 | .obtainMessage(H.DISMISS, Events.DISMISS_REASON_TIMEOUT, 0), timeout); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 578 | if (D.BUG) Log.d(TAG, "rescheduleTimeout " + timeout + " " + Debug.getCaller()); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 579 | mController.userActivity(); |
| 580 | } |
| 581 | |
| 582 | private int computeTimeoutH() { |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 583 | if (mAccessibility.mFeedbackEnabled) return 20000; |
Jun Mukai | 3f5d713 | 2015-07-21 14:10:09 -0700 | [diff] [blame] | 584 | if (mHovering) return 16000; |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 585 | if (mSafetyWarning != null) return 5000; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 586 | return 3000; |
| 587 | } |
| 588 | |
| 589 | protected void dismissH(int reason) { |
| 590 | mHandler.removeMessages(H.DISMISS); |
| 591 | mHandler.removeMessages(H.SHOW); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 592 | mDialogView.animate().cancel(); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 593 | mShowing = false; |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 594 | |
Julia Reynolds | 0a22856 | 2018-01-10 12:53:40 -0500 | [diff] [blame] | 595 | mDialogView.setTranslationX(0); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 596 | mDialogView.setAlpha(1); |
Mike Digman | 827824c | 2018-03-27 12:10:35 -0700 | [diff] [blame] | 597 | ViewPropertyAnimator animator = mDialogView.animate() |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 598 | .alpha(0) |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 599 | .setDuration(250) |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 600 | .setInterpolator(new SystemUIInterpolators.LogAccelerateInterpolator()) |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 601 | .withEndAction(() -> mHandler.postDelayed(() -> { |
| 602 | if (D.BUG) Log.d(TAG, "mDialog.dismiss()"); |
| 603 | mDialog.dismiss(); |
Mike Digman | 827824c | 2018-03-27 12:10:35 -0700 | [diff] [blame] | 604 | }, 50)); |
| 605 | if (!isLandscape()) animator.translationX(mDialogView.getWidth() / 2); |
| 606 | animator.start(); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 607 | |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 608 | Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 609 | mController.notifyVisible(false); |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 610 | synchronized (mSafetyWarningLock) { |
| 611 | if (mSafetyWarning != null) { |
| 612 | if (D.BUG) Log.d(TAG, "SafetyWarning dismissed"); |
| 613 | mSafetyWarning.dismiss(); |
| 614 | } |
| 615 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 616 | } |
| 617 | |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 618 | private boolean showActiveStreamOnly() { |
| 619 | return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK) |
| 620 | || mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION); |
| 621 | } |
| 622 | |
Beverly | fa4c8e7 | 2017-08-10 14:55:34 -0400 | [diff] [blame] | 623 | private boolean shouldBeVisibleH(VolumeRow row, VolumeRow activeRow) { |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 624 | boolean isActive = row.stream == activeRow.stream; |
Beverly | fa4c8e7 | 2017-08-10 14:55:34 -0400 | [diff] [blame] | 625 | |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 626 | if (isActive) { |
| 627 | return true; |
| 628 | } |
| 629 | |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 630 | if (!mShowActiveStreamOnly) { |
| 631 | if (row.stream == AudioSystem.STREAM_ACCESSIBILITY) { |
| 632 | return mShowA11yStream; |
| 633 | } |
| 634 | |
| 635 | // if the active row is accessibility, then continue to display previous |
| 636 | // active row since accessibility is displayed under it |
| 637 | if (activeRow.stream == AudioSystem.STREAM_ACCESSIBILITY && |
| 638 | row.stream == mPrevActiveStream) { |
| 639 | return true; |
| 640 | } |
| 641 | |
| 642 | if (row.defaultStream) { |
| 643 | return activeRow.stream == STREAM_RING |
| 644 | || activeRow.stream == STREAM_ALARM |
| 645 | || activeRow.stream == STREAM_VOICE_CALL |
| 646 | || activeRow.stream == STREAM_ACCESSIBILITY |
| 647 | || mDynamic.get(activeRow.stream); |
| 648 | } |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | return false; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 652 | } |
| 653 | |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 654 | private void updateRowsH(final VolumeRow activeRow) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 655 | if (D.BUG) Log.d(TAG, "updateRowsH"); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 656 | if (!mShowing) { |
| 657 | trimObsoleteH(); |
| 658 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 659 | // apply changes to all rows |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 660 | for (final VolumeRow row : mRows) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 661 | final boolean isActive = row == activeRow; |
Beverly | fa4c8e7 | 2017-08-10 14:55:34 -0400 | [diff] [blame] | 662 | final boolean shouldBeVisible = shouldBeVisibleH(row, activeRow); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 663 | Util.setVisOrGone(row.view, shouldBeVisible); |
| 664 | if (row.view.isShown()) { |
Julia Reynolds | 9b20717 | 2018-04-12 14:42:08 -0400 | [diff] [blame] | 665 | updateVolumeRowTintH(row, isActive); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 666 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 667 | } |
| 668 | } |
| 669 | |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 670 | protected void updateRingerH() { |
| 671 | if (mState != null) { |
| 672 | final StreamState ss = mState.states.get(AudioManager.STREAM_RING); |
Julia Reynolds | 41eae63 | 2018-01-09 09:21:44 -0500 | [diff] [blame] | 673 | if (ss == null) { |
| 674 | return; |
| 675 | } |
Beverly | da0fe82 | 2018-02-08 17:19:01 -0500 | [diff] [blame] | 676 | |
Beverly | 9e4214d | 2018-03-26 11:10:10 -0400 | [diff] [blame] | 677 | boolean isZenMuted = mState.zenMode == Global.ZEN_MODE_ALARMS |
| 678 | || mState.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS |
| 679 | || (mState.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS |
| 680 | && mState.disallowRinger); |
| 681 | enableRingerViewsH(!isZenMuted); |
Julia Reynolds | 229b300 | 2018-01-23 09:30:09 -0500 | [diff] [blame] | 682 | switch (mState.ringerModeInternal) { |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 683 | case AudioManager.RINGER_MODE_VIBRATE: |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 684 | mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_vibrate); |
Beverly | f138ba2 | 2018-05-03 17:32:41 -0400 | [diff] [blame] | 685 | addAccessibilityDescription(mRingerIcon, RINGER_MODE_VIBRATE, |
| 686 | mContext.getString(R.string.volume_ringer_hint_mute)); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 687 | mRingerIcon.setTag(Events.ICON_STATE_VIBRATE); |
| 688 | break; |
| 689 | case AudioManager.RINGER_MODE_SILENT: |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 690 | mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 691 | mRingerIcon.setTag(Events.ICON_STATE_MUTE); |
Beverly | f138ba2 | 2018-05-03 17:32:41 -0400 | [diff] [blame] | 692 | addAccessibilityDescription(mRingerIcon, RINGER_MODE_SILENT, |
| 693 | mContext.getString(R.string.volume_ringer_hint_unmute)); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 694 | break; |
| 695 | case AudioManager.RINGER_MODE_NORMAL: |
| 696 | default: |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 697 | boolean muted = (mAutomute && ss.level == 0) || ss.muted; |
Beverly | 9e4214d | 2018-03-26 11:10:10 -0400 | [diff] [blame] | 698 | if (!isZenMuted && muted) { |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 699 | mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute); |
Beverly | f138ba2 | 2018-05-03 17:32:41 -0400 | [diff] [blame] | 700 | addAccessibilityDescription(mRingerIcon, RINGER_MODE_NORMAL, |
| 701 | mContext.getString(R.string.volume_ringer_hint_unmute)); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 702 | mRingerIcon.setTag(Events.ICON_STATE_MUTE); |
| 703 | } else { |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 704 | mRingerIcon.setImageResource(R.drawable.ic_volume_ringer); |
| 705 | if (mController.hasVibrator()) { |
Beverly | f138ba2 | 2018-05-03 17:32:41 -0400 | [diff] [blame] | 706 | addAccessibilityDescription(mRingerIcon, RINGER_MODE_NORMAL, |
| 707 | mContext.getString(R.string.volume_ringer_hint_vibrate)); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 708 | } else { |
Beverly | f138ba2 | 2018-05-03 17:32:41 -0400 | [diff] [blame] | 709 | addAccessibilityDescription(mRingerIcon, RINGER_MODE_NORMAL, |
| 710 | mContext.getString(R.string.volume_ringer_hint_mute)); |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 711 | } |
| 712 | mRingerIcon.setTag(Events.ICON_STATE_UNMUTE); |
| 713 | } |
| 714 | break; |
| 715 | } |
| 716 | } |
| 717 | } |
| 718 | |
Beverly | f138ba2 | 2018-05-03 17:32:41 -0400 | [diff] [blame] | 719 | private void addAccessibilityDescription(View view, int currState, String hintLabel) { |
| 720 | int currStateResId; |
| 721 | switch (currState) { |
| 722 | case RINGER_MODE_SILENT: |
| 723 | currStateResId = R.string.volume_ringer_status_silent; |
| 724 | break; |
| 725 | case RINGER_MODE_VIBRATE: |
| 726 | currStateResId = R.string.volume_ringer_status_vibrate; |
| 727 | break; |
| 728 | case RINGER_MODE_NORMAL: |
| 729 | default: |
| 730 | currStateResId = R.string.volume_ringer_status_normal; |
| 731 | } |
| 732 | |
| 733 | view.setContentDescription(mContext.getString(currStateResId)); |
| 734 | |
| 735 | view.setAccessibilityDelegate(new AccessibilityDelegate() { |
| 736 | public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { |
| 737 | super.onInitializeAccessibilityNodeInfo(host, info); |
| 738 | info.addAction(new AccessibilityNodeInfo.AccessibilityAction( |
| 739 | AccessibilityNodeInfo.ACTION_CLICK, hintLabel)); |
| 740 | } |
| 741 | }); |
| 742 | } |
| 743 | |
Beverly | da0fe82 | 2018-02-08 17:19:01 -0500 | [diff] [blame] | 744 | /** |
Julia Reynolds | ee57193 | 2018-02-21 11:41:33 -0500 | [diff] [blame] | 745 | * Toggles enable state of views in a VolumeRow (not including seekbar or icon) |
Beverly | da0fe82 | 2018-02-08 17:19:01 -0500 | [diff] [blame] | 746 | * Hides/shows zen icon |
| 747 | * @param enable whether to enable volume row views and hide dnd icon |
| 748 | */ |
| 749 | private void enableVolumeRowViewsH(VolumeRow row, boolean enable) { |
Beverly | 0099195 | 2018-04-26 11:17:29 -0400 | [diff] [blame] | 750 | boolean showDndIcon = !enable; |
| 751 | row.dndIcon.setVisibility(showDndIcon ? VISIBLE : GONE); |
Beverly | da0fe82 | 2018-02-08 17:19:01 -0500 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | /** |
| 755 | * Toggles enable state of footer/ringer views |
| 756 | * Hides/shows zen icon |
| 757 | * @param enable whether to enable ringer views and hide dnd icon |
| 758 | */ |
| 759 | private void enableRingerViewsH(boolean enable) { |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 760 | if (mRingerIcon != null) { |
| 761 | mRingerIcon.setEnabled(enable); |
| 762 | } |
| 763 | if (mZenIcon != null) { |
| 764 | mZenIcon.setVisibility(enable ? GONE : VISIBLE); |
| 765 | } |
Beverly | da0fe82 | 2018-02-08 17:19:01 -0500 | [diff] [blame] | 766 | } |
| 767 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 768 | private void trimObsoleteH() { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 769 | if (D.BUG) Log.d(TAG, "trimObsoleteH"); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 770 | for (int i = mRows.size() - 1; i >= 0; i--) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 771 | final VolumeRow row = mRows.get(i); |
| 772 | if (row.ss == null || !row.ss.dynamic) continue; |
| 773 | if (!mDynamic.get(row.stream)) { |
| 774 | mRows.remove(i); |
Julia Reynolds | 568585b | 2016-07-25 08:55:15 -0400 | [diff] [blame] | 775 | mDialogRowsView.removeView(row.view); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 776 | } |
| 777 | } |
| 778 | } |
| 779 | |
Julia Reynolds | 561d3f4 | 2018-01-26 11:31:02 -0500 | [diff] [blame] | 780 | protected void onStateChangedH(State state) { |
Beverly | 83aaae4 | 2018-05-22 13:02:15 -0400 | [diff] [blame] | 781 | if (mState != null && state != null |
| 782 | && mState.ringerModeInternal != state.ringerModeInternal |
| 783 | && state.ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE) { |
| 784 | mController.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_HEAVY_CLICK)); |
| 785 | } |
| 786 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 787 | mState = state; |
| 788 | mDynamic.clear(); |
| 789 | // add any new dynamic rows |
| 790 | for (int i = 0; i < state.states.size(); i++) { |
| 791 | final int stream = state.states.keyAt(i); |
| 792 | final StreamState ss = state.states.valueAt(i); |
| 793 | if (!ss.dynamic) continue; |
| 794 | mDynamic.put(stream, true); |
| 795 | if (findRow(stream) == null) { |
Julia Reynolds | dbfb40f | 2017-01-23 11:05:57 -0500 | [diff] [blame] | 796 | addRow(stream, R.drawable.ic_volume_remote, R.drawable.ic_volume_remote_mute, true, |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 797 | false, true); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 798 | } |
| 799 | } |
| 800 | |
| 801 | if (mActiveStream != state.activeStream) { |
Beverly | fa4c8e7 | 2017-08-10 14:55:34 -0400 | [diff] [blame] | 802 | mPrevActiveStream = mActiveStream; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 803 | mActiveStream = state.activeStream; |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 804 | VolumeRow activeRow = getActiveRow(); |
| 805 | updateRowsH(activeRow); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 806 | rescheduleTimeoutH(); |
| 807 | } |
| 808 | for (VolumeRow row : mRows) { |
| 809 | updateVolumeRowH(row); |
| 810 | } |
Julia Reynolds | 36dd4f1 | 2017-12-06 15:47:46 -0500 | [diff] [blame] | 811 | updateRingerH(); |
Phil Weaver | 9054e09 | 2018-04-27 16:28:50 -0700 | [diff] [blame] | 812 | mWindow.setTitle(composeWindowTitle()); |
| 813 | } |
| 814 | |
| 815 | CharSequence composeWindowTitle() { |
| 816 | return mContext.getString(R.string.volume_dialog_title, getStreamLabelH(getActiveRow().ss)); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | private void updateVolumeRowH(VolumeRow row) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 820 | if (D.BUG) Log.d(TAG, "updateVolumeRowH s=" + row.stream); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 821 | if (mState == null) return; |
| 822 | final StreamState ss = mState.states.get(row.stream); |
| 823 | if (ss == null) return; |
| 824 | row.ss = ss; |
| 825 | if (ss.level > 0) { |
| 826 | row.lastAudibleLevel = ss.level; |
| 827 | } |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 828 | if (ss.level == row.requestedLevel) { |
| 829 | row.requestedLevel = -1; |
| 830 | } |
Julia Reynolds | 7c62c31 | 2018-02-01 17:29:33 -0500 | [diff] [blame] | 831 | final boolean isA11yStream = row.stream == STREAM_ACCESSIBILITY; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 832 | final boolean isRingStream = row.stream == AudioManager.STREAM_RING; |
| 833 | final boolean isSystemStream = row.stream == AudioManager.STREAM_SYSTEM; |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 834 | final boolean isAlarmStream = row.stream == STREAM_ALARM; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 835 | final boolean isMusicStream = row.stream == AudioManager.STREAM_MUSIC; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 836 | final boolean isRingVibrate = isRingStream |
Julia Reynolds | 229b300 | 2018-01-23 09:30:09 -0500 | [diff] [blame] | 837 | && mState.ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 838 | final boolean isRingSilent = isRingStream |
Julia Reynolds | 229b300 | 2018-01-23 09:30:09 -0500 | [diff] [blame] | 839 | && mState.ringerModeInternal == AudioManager.RINGER_MODE_SILENT; |
Beverly | 925cde8 | 2018-01-23 09:31:23 -0500 | [diff] [blame] | 840 | final boolean isZenPriorityOnly = mState.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 841 | final boolean isZenAlarms = mState.zenMode == Global.ZEN_MODE_ALARMS; |
| 842 | final boolean isZenNone = mState.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS; |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 843 | final boolean zenMuted = isZenAlarms ? (isRingStream || isSystemStream) |
| 844 | : isZenNone ? (isRingStream || isSystemStream || isAlarmStream || isMusicStream) |
Beverly | 925cde8 | 2018-01-23 09:31:23 -0500 | [diff] [blame] | 845 | : isZenPriorityOnly ? ((isAlarmStream && mState.disallowAlarms) || |
| 846 | (isMusicStream && mState.disallowMedia) || |
Beverly | d696476 | 2018-02-16 14:07:03 -0500 | [diff] [blame] | 847 | (isRingStream && mState.disallowRinger) || |
| 848 | (isSystemStream && mState.disallowSystem)) |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 849 | : false; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 850 | |
| 851 | // update slider max |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 852 | final int max = ss.levelMax * 100; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 853 | if (max != row.slider.getMax()) { |
| 854 | row.slider.setMax(max); |
| 855 | } |
jiabin | 48542d2 | 2018-04-18 16:49:00 -0700 | [diff] [blame] | 856 | // update slider min |
jiabin | 9058c7f | 2018-04-18 12:24:37 -0700 | [diff] [blame] | 857 | final int min = ss.levelMin * 100; |
jiabin | 48542d2 | 2018-04-18 16:49:00 -0700 | [diff] [blame] | 858 | if (min != row.slider.getMin()) { |
jiabin | 9058c7f | 2018-04-18 12:24:37 -0700 | [diff] [blame] | 859 | row.slider.setMin(min); |
| 860 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 861 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 862 | // update header text |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 863 | Util.setText(row.header, getStreamLabelH(ss)); |
Lucas Dupin | 421b20c | 2017-08-01 10:36:10 -0700 | [diff] [blame] | 864 | row.slider.setContentDescription(row.header.getText()); |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 865 | mConfigurableTexts.add(row.header, ss.name); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 866 | |
| 867 | // update icon |
John Spurlock | d9c75db | 2015-04-28 11:19:13 -0400 | [diff] [blame] | 868 | final boolean iconEnabled = (mAutomute || ss.muteSupported) && !zenMuted; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 869 | row.icon.setEnabled(iconEnabled); |
| 870 | row.icon.setAlpha(iconEnabled ? 1 : 0.5f); |
| 871 | final int iconRes = |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 872 | isRingVibrate ? R.drawable.ic_volume_ringer_vibrate |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 873 | : isRingSilent || zenMuted ? row.iconMuteRes |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 874 | : ss.routedToBluetooth ? |
John Spurlock | f15ef11 | 2015-04-09 22:04:14 -0400 | [diff] [blame] | 875 | (ss.muted ? R.drawable.ic_volume_media_bt_mute |
| 876 | : R.drawable.ic_volume_media_bt) |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 877 | : mAutomute && ss.level == 0 ? row.iconMuteRes |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 878 | : (ss.muted ? row.iconMuteRes : row.iconRes); |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 879 | row.icon.setImageResource(iconRes); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 880 | row.iconState = |
| 881 | iconRes == R.drawable.ic_volume_ringer_vibrate ? Events.ICON_STATE_VIBRATE |
John Spurlock | f15ef11 | 2015-04-09 22:04:14 -0400 | [diff] [blame] | 882 | : (iconRes == R.drawable.ic_volume_media_bt_mute || iconRes == row.iconMuteRes) |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 883 | ? Events.ICON_STATE_MUTE |
John Spurlock | f15ef11 | 2015-04-09 22:04:14 -0400 | [diff] [blame] | 884 | : (iconRes == R.drawable.ic_volume_media_bt || iconRes == row.iconRes) |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 885 | ? Events.ICON_STATE_UNMUTE |
| 886 | : Events.ICON_STATE_UNKNOWN; |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 887 | if (iconEnabled) { |
| 888 | if (isRingStream) { |
| 889 | if (isRingVibrate) { |
| 890 | row.icon.setContentDescription(mContext.getString( |
| 891 | R.string.volume_stream_content_description_unmute, |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 892 | getStreamLabelH(ss))); |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 893 | } else { |
| 894 | if (mController.hasVibrator()) { |
| 895 | row.icon.setContentDescription(mContext.getString( |
Julia Reynolds | 7c502e0 | 2017-03-06 10:19:10 -0500 | [diff] [blame] | 896 | mShowA11yStream |
| 897 | ? R.string.volume_stream_content_description_vibrate_a11y |
| 898 | : R.string.volume_stream_content_description_vibrate, |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 899 | getStreamLabelH(ss))); |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 900 | } else { |
| 901 | row.icon.setContentDescription(mContext.getString( |
Julia Reynolds | 7c502e0 | 2017-03-06 10:19:10 -0500 | [diff] [blame] | 902 | mShowA11yStream |
| 903 | ? R.string.volume_stream_content_description_mute_a11y |
| 904 | : R.string.volume_stream_content_description_mute, |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 905 | getStreamLabelH(ss))); |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 906 | } |
| 907 | } |
Julia Reynolds | 7c502e0 | 2017-03-06 10:19:10 -0500 | [diff] [blame] | 908 | } else if (isA11yStream) { |
| 909 | row.icon.setContentDescription(getStreamLabelH(ss)); |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 910 | } else { |
| 911 | if (ss.muted || mAutomute && ss.level == 0) { |
| 912 | row.icon.setContentDescription(mContext.getString( |
| 913 | R.string.volume_stream_content_description_unmute, |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 914 | getStreamLabelH(ss))); |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 915 | } else { |
| 916 | row.icon.setContentDescription(mContext.getString( |
Julia Reynolds | 7c502e0 | 2017-03-06 10:19:10 -0500 | [diff] [blame] | 917 | mShowA11yStream |
| 918 | ? R.string.volume_stream_content_description_mute_a11y |
| 919 | : R.string.volume_stream_content_description_mute, |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 920 | getStreamLabelH(ss))); |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 921 | } |
| 922 | } |
| 923 | } else { |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 924 | row.icon.setContentDescription(getStreamLabelH(ss)); |
Julia Reynolds | dfe0b4d | 2016-04-08 17:14:15 -0400 | [diff] [blame] | 925 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 926 | |
Beverly | e421abe | 2017-08-22 14:47:28 -0400 | [diff] [blame] | 927 | // ensure tracking is disabled if zenMuted |
| 928 | if (zenMuted) { |
| 929 | row.tracking = false; |
| 930 | } |
Beverly | da0fe82 | 2018-02-08 17:19:01 -0500 | [diff] [blame] | 931 | enableVolumeRowViewsH(row, !zenMuted); |
Beverly | e421abe | 2017-08-22 14:47:28 -0400 | [diff] [blame] | 932 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 933 | // update slider |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 934 | final boolean enableSlider = !zenMuted; |
Julia Reynolds | 5f84c19 | 2016-11-14 13:13:08 -0500 | [diff] [blame] | 935 | final int vlevel = row.ss.muted && (!isRingStream && !zenMuted) ? 0 |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 936 | : row.ss.level; |
| 937 | updateVolumeRowSliderH(row, enableSlider, vlevel); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 938 | } |
| 939 | |
Julia Reynolds | 9b20717 | 2018-04-12 14:42:08 -0400 | [diff] [blame] | 940 | private void updateVolumeRowTintH(VolumeRow row, boolean isActive) { |
Julia Reynolds | 66d2894 | 2017-11-07 09:43:54 -0500 | [diff] [blame] | 941 | if (isActive) { |
John Spurlock | 67a0f85 | 2015-06-15 15:35:47 -0400 | [diff] [blame] | 942 | row.slider.requestFocus(); |
John Spurlock | 67a0f85 | 2015-06-15 15:35:47 -0400 | [diff] [blame] | 943 | } |
Julia Reynolds | 027d3a6 | 2018-05-23 09:45:53 -0400 | [diff] [blame] | 944 | boolean useActiveColoring = isActive && row.slider.isEnabled(); |
| 945 | final ColorStateList tint = useActiveColoring ? mActiveTint : mInactiveTint; |
| 946 | final int alpha = useActiveColoring ? mActiveAlpha : mInactiveAlpha; |
Julia Reynolds | 9b20717 | 2018-04-12 14:42:08 -0400 | [diff] [blame] | 947 | if (tint == row.cachedTint) return; |
John Spurlock | ecc8058 | 2015-05-13 16:23:14 -0400 | [diff] [blame] | 948 | row.slider.setProgressTintList(tint); |
| 949 | row.slider.setThumbTintList(tint); |
Julia Reynolds | 027d3a6 | 2018-05-23 09:45:53 -0400 | [diff] [blame] | 950 | row.slider.setProgressBackgroundTintList(tint); |
| 951 | row.slider.setAlpha(((float) alpha) / 255); |
Julia Reynolds | 9b20717 | 2018-04-12 14:42:08 -0400 | [diff] [blame] | 952 | row.icon.setImageTintList(tint); |
Julia Reynolds | 027d3a6 | 2018-05-23 09:45:53 -0400 | [diff] [blame] | 953 | row.icon.setImageAlpha(alpha); |
Julia Reynolds | 9b20717 | 2018-04-12 14:42:08 -0400 | [diff] [blame] | 954 | row.cachedTint = tint; |
John Spurlock | ecc8058 | 2015-05-13 16:23:14 -0400 | [diff] [blame] | 955 | } |
| 956 | |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 957 | private void updateVolumeRowSliderH(VolumeRow row, boolean enable, int vlevel) { |
| 958 | row.slider.setEnabled(enable); |
Julia Reynolds | 9b20717 | 2018-04-12 14:42:08 -0400 | [diff] [blame] | 959 | updateVolumeRowTintH(row, row.stream == mActiveStream); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 960 | if (row.tracking) { |
| 961 | return; // don't update if user is sliding |
| 962 | } |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 963 | final int progress = row.slider.getProgress(); |
| 964 | final int level = getImpliedLevel(row.slider, progress); |
Julia Reynolds | a438675 | 2018-03-12 14:07:04 -0400 | [diff] [blame] | 965 | final boolean rowVisible = row.view.getVisibility() == VISIBLE; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 966 | final boolean inGracePeriod = (SystemClock.uptimeMillis() - row.userAttempt) |
| 967 | < USER_ATTEMPT_GRACE_PERIOD; |
| 968 | mHandler.removeMessages(H.RECHECK, row); |
| 969 | if (mShowing && rowVisible && inGracePeriod) { |
| 970 | if (D.BUG) Log.d(TAG, "inGracePeriod"); |
| 971 | mHandler.sendMessageAtTime(mHandler.obtainMessage(H.RECHECK, row), |
| 972 | row.userAttempt + USER_ATTEMPT_GRACE_PERIOD); |
| 973 | return; // don't update if visible and in grace period |
| 974 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 975 | if (vlevel == level) { |
| 976 | if (mShowing && rowVisible) { |
| 977 | return; // don't clamp if visible |
| 978 | } |
| 979 | } |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 980 | final int newProgress = vlevel * 100; |
| 981 | if (progress != newProgress) { |
| 982 | if (mShowing && rowVisible) { |
| 983 | // animate! |
| 984 | if (row.anim != null && row.anim.isRunning() |
| 985 | && row.animTargetProgress == newProgress) { |
| 986 | return; // already animating to the target progress |
| 987 | } |
| 988 | // start/update animation |
| 989 | if (row.anim == null) { |
| 990 | row.anim = ObjectAnimator.ofInt(row.slider, "progress", progress, newProgress); |
| 991 | row.anim.setInterpolator(new DecelerateInterpolator()); |
| 992 | } else { |
| 993 | row.anim.cancel(); |
| 994 | row.anim.setIntValues(progress, newProgress); |
| 995 | } |
| 996 | row.animTargetProgress = newProgress; |
| 997 | row.anim.setDuration(UPDATE_ANIMATION_DURATION); |
| 998 | row.anim.start(); |
| 999 | } else { |
| 1000 | // update slider directly to clamped value |
| 1001 | if (row.anim != null) { |
| 1002 | row.anim.cancel(); |
| 1003 | } |
Julia Reynolds | 88dabde | 2016-08-09 13:59:44 -0400 | [diff] [blame] | 1004 | row.slider.setProgress(newProgress, true); |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1005 | } |
| 1006 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | private void recheckH(VolumeRow row) { |
| 1010 | if (row == null) { |
| 1011 | if (D.BUG) Log.d(TAG, "recheckH ALL"); |
| 1012 | trimObsoleteH(); |
| 1013 | for (VolumeRow r : mRows) { |
| 1014 | updateVolumeRowH(r); |
| 1015 | } |
| 1016 | } else { |
| 1017 | if (D.BUG) Log.d(TAG, "recheckH " + row.stream); |
| 1018 | updateVolumeRowH(row); |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | private void setStreamImportantH(int stream, boolean important) { |
| 1023 | for (VolumeRow row : mRows) { |
| 1024 | if (row.stream == stream) { |
| 1025 | row.important = important; |
| 1026 | return; |
| 1027 | } |
| 1028 | } |
| 1029 | } |
| 1030 | |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 1031 | private void showSafetyWarningH(int flags) { |
| 1032 | if ((flags & (AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_SHOW_UI_WARNINGS)) != 0 |
| 1033 | || mShowing) { |
| 1034 | synchronized (mSafetyWarningLock) { |
| 1035 | if (mSafetyWarning != null) { |
| 1036 | return; |
| 1037 | } |
| 1038 | mSafetyWarning = new SafetyWarningDialog(mContext, mController.getAudioManager()) { |
| 1039 | @Override |
| 1040 | protected void cleanUp() { |
| 1041 | synchronized (mSafetyWarningLock) { |
| 1042 | mSafetyWarning = null; |
| 1043 | } |
| 1044 | recheckH(null); |
| 1045 | } |
| 1046 | }; |
| 1047 | mSafetyWarning.show(); |
| 1048 | } |
| 1049 | recheckH(null); |
| 1050 | } |
| 1051 | rescheduleTimeoutH(); |
| 1052 | } |
| 1053 | |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 1054 | private String getStreamLabelH(StreamState ss) { |
Julia Reynolds | 4c46fd3 | 2018-03-14 13:48:39 -0400 | [diff] [blame] | 1055 | if (ss == null) { |
| 1056 | return ""; |
| 1057 | } |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 1058 | if (ss.remoteLabel != null) { |
| 1059 | return ss.remoteLabel; |
| 1060 | } |
| 1061 | try { |
Julia Reynolds | 561d3f4 | 2018-01-26 11:31:02 -0500 | [diff] [blame] | 1062 | return mContext.getResources().getString(ss.name); |
Julia Reynolds | 03c548f | 2016-12-14 15:02:38 -0500 | [diff] [blame] | 1063 | } catch (Resources.NotFoundException e) { |
| 1064 | Slog.e(TAG, "Can't find translation for stream " + ss); |
| 1065 | return ""; |
| 1066 | } |
| 1067 | } |
| 1068 | |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 1069 | private Runnable mSinglePress = new Runnable() { |
| 1070 | @Override |
| 1071 | public void run() { |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 1072 | if (mRingerIcon != null) { |
| 1073 | mRingerIcon.setPressed(true); |
| 1074 | mRingerIcon.postOnAnimationDelayed(mSingleUnpress, 200); |
| 1075 | } |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 1076 | } |
| 1077 | }; |
| 1078 | |
| 1079 | private Runnable mSingleUnpress = new Runnable() { |
| 1080 | @Override |
| 1081 | public void run() { |
Julia Reynolds | 0389600 | 2018-07-25 13:02:43 -0400 | [diff] [blame] | 1082 | if (mRingerIcon != null) { |
| 1083 | mRingerIcon.setPressed(false); |
| 1084 | } |
Julia Reynolds | ac55e01 | 2018-03-27 11:17:30 -0400 | [diff] [blame] | 1085 | } |
| 1086 | }; |
| 1087 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1088 | private final VolumeDialogController.Callbacks mControllerCallbackH |
| 1089 | = new VolumeDialogController.Callbacks() { |
| 1090 | @Override |
| 1091 | public void onShowRequested(int reason) { |
| 1092 | showH(reason); |
| 1093 | } |
| 1094 | |
| 1095 | @Override |
| 1096 | public void onDismissRequested(int reason) { |
| 1097 | dismissH(reason); |
| 1098 | } |
| 1099 | |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 1100 | @Override |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1101 | public void onScreenOff() { |
| 1102 | dismissH(Events.DISMISS_REASON_SCREEN_OFF); |
| 1103 | } |
| 1104 | |
| 1105 | @Override |
| 1106 | public void onStateChanged(State state) { |
| 1107 | onStateChangedH(state); |
| 1108 | } |
| 1109 | |
| 1110 | @Override |
| 1111 | public void onLayoutDirectionChanged(int layoutDirection) { |
| 1112 | mDialogView.setLayoutDirection(layoutDirection); |
| 1113 | } |
| 1114 | |
| 1115 | @Override |
| 1116 | public void onConfigurationChanged() { |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 1117 | mDialog.dismiss(); |
Julia Reynolds | b104200 | 2018-08-01 12:49:02 -0400 | [diff] [blame] | 1118 | mConfigChanged = true; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | @Override |
| 1122 | public void onShowVibrateHint() { |
| 1123 | if (mSilentMode) { |
| 1124 | mController.setRingerMode(AudioManager.RINGER_MODE_SILENT, false); |
| 1125 | } |
| 1126 | } |
| 1127 | |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 1128 | @Override |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1129 | public void onShowSilentHint() { |
| 1130 | if (mSilentMode) { |
| 1131 | mController.setRingerMode(AudioManager.RINGER_MODE_NORMAL, false); |
| 1132 | } |
| 1133 | } |
John Spurlock | 76b52b3 | 2015-04-03 00:00:12 -0400 | [diff] [blame] | 1134 | |
| 1135 | @Override |
| 1136 | public void onShowSafetyWarning(int flags) { |
| 1137 | showSafetyWarningH(flags); |
| 1138 | } |
Julia Reynolds | dbfb40f | 2017-01-23 11:05:57 -0500 | [diff] [blame] | 1139 | |
| 1140 | @Override |
| 1141 | public void onAccessibilityModeChanged(Boolean showA11yStream) { |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 1142 | mShowA11yStream = showA11yStream == null ? false : showA11yStream; |
Julia Reynolds | 74cc650 | 2017-08-08 12:41:04 -0400 | [diff] [blame] | 1143 | VolumeRow activeRow = getActiveRow(); |
Julia Reynolds | 7c62c31 | 2018-02-01 17:29:33 -0500 | [diff] [blame] | 1144 | if (!mShowA11yStream && STREAM_ACCESSIBILITY == activeRow.stream) { |
Julia Reynolds | 74cc650 | 2017-08-08 12:41:04 -0400 | [diff] [blame] | 1145 | dismissH(Events.DISMISS_STREAM_GONE); |
| 1146 | } else { |
| 1147 | updateRowsH(activeRow); |
| 1148 | } |
Julia Reynolds | dbfb40f | 2017-01-23 11:05:57 -0500 | [diff] [blame] | 1149 | |
| 1150 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1151 | }; |
| 1152 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1153 | private final class H extends Handler { |
| 1154 | private static final int SHOW = 1; |
| 1155 | private static final int DISMISS = 2; |
| 1156 | private static final int RECHECK = 3; |
| 1157 | private static final int RECHECK_ALL = 4; |
| 1158 | private static final int SET_STREAM_IMPORTANT = 5; |
| 1159 | private static final int RESCHEDULE_TIMEOUT = 6; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1160 | private static final int STATE_CHANGED = 7; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1161 | |
| 1162 | public H() { |
| 1163 | super(Looper.getMainLooper()); |
| 1164 | } |
| 1165 | |
| 1166 | @Override |
| 1167 | public void handleMessage(Message msg) { |
| 1168 | switch (msg.what) { |
| 1169 | case SHOW: showH(msg.arg1); break; |
| 1170 | case DISMISS: dismissH(msg.arg1); break; |
| 1171 | case RECHECK: recheckH((VolumeRow) msg.obj); break; |
| 1172 | case RECHECK_ALL: recheckH(null); break; |
| 1173 | case SET_STREAM_IMPORTANT: setStreamImportantH(msg.arg1, msg.arg2 != 0); break; |
| 1174 | case RESCHEDULE_TIMEOUT: rescheduleTimeoutH(); break; |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1175 | case STATE_CHANGED: onStateChangedH(mState); break; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1176 | } |
| 1177 | } |
| 1178 | } |
| 1179 | |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 1180 | private final class CustomDialog extends Dialog implements DialogInterface { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1181 | public CustomDialog(Context context) { |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 1182 | super(context, com.android.systemui.R.style.qs_theme); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | @Override |
| 1186 | public boolean dispatchTouchEvent(MotionEvent ev) { |
| 1187 | rescheduleTimeoutH(); |
| 1188 | return super.dispatchTouchEvent(ev); |
| 1189 | } |
| 1190 | |
| 1191 | @Override |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 1192 | protected void onStart() { |
| 1193 | super.setCanceledOnTouchOutside(true); |
| 1194 | super.onStart(); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | @Override |
Julia Reynolds | 4241192 | 2017-11-08 11:19:09 -0500 | [diff] [blame] | 1198 | protected void onStop() { |
| 1199 | super.onStop(); |
| 1200 | mHandler.sendEmptyMessage(H.RECHECK_ALL); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1201 | } |
Julia Reynolds | 2feab16 | 2016-04-21 14:58:52 -0400 | [diff] [blame] | 1202 | |
| 1203 | @Override |
Julia Reynolds | 30dd125 | 2018-02-09 15:40:20 -0500 | [diff] [blame] | 1204 | public boolean onTouchEvent(MotionEvent event) { |
Beverly | cc2448e | 2018-08-15 12:56:53 -0400 | [diff] [blame] | 1205 | if (mShowing) { |
Julia Reynolds | 30dd125 | 2018-02-09 15:40:20 -0500 | [diff] [blame] | 1206 | if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { |
| 1207 | dismissH(Events.DISMISS_REASON_TOUCH_OUTSIDE); |
| 1208 | return true; |
| 1209 | } |
| 1210 | } |
| 1211 | return false; |
| 1212 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | private final class VolumeSeekBarChangeListener implements OnSeekBarChangeListener { |
| 1216 | private final VolumeRow mRow; |
| 1217 | |
| 1218 | private VolumeSeekBarChangeListener(VolumeRow row) { |
| 1219 | mRow = row; |
| 1220 | } |
| 1221 | |
| 1222 | @Override |
| 1223 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { |
| 1224 | if (mRow.ss == null) return; |
| 1225 | if (D.BUG) Log.d(TAG, AudioSystem.streamToString(mRow.stream) |
| 1226 | + " onProgressChanged " + progress + " fromUser=" + fromUser); |
| 1227 | if (!fromUser) return; |
| 1228 | if (mRow.ss.levelMin > 0) { |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1229 | final int minProgress = mRow.ss.levelMin * 100; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1230 | if (progress < minProgress) { |
| 1231 | seekBar.setProgress(minProgress); |
Julia Reynolds | 798b0c3 | 2015-09-01 14:35:53 -0400 | [diff] [blame] | 1232 | progress = minProgress; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1233 | } |
| 1234 | } |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1235 | final int userLevel = getImpliedLevel(seekBar, progress); |
| 1236 | if (mRow.ss.level != userLevel || mRow.ss.muted && userLevel > 0) { |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1237 | mRow.userAttempt = SystemClock.uptimeMillis(); |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1238 | if (mRow.requestedLevel != userLevel) { |
| 1239 | mController.setStreamVolume(mRow.stream, userLevel); |
| 1240 | mRow.requestedLevel = userLevel; |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 1241 | Events.writeEvent(mContext, Events.EVENT_TOUCH_LEVEL_CHANGED, mRow.stream, |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1242 | userLevel); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1243 | } |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | @Override |
| 1248 | public void onStartTrackingTouch(SeekBar seekBar) { |
| 1249 | if (D.BUG) Log.d(TAG, "onStartTrackingTouch"+ " " + mRow.stream); |
| 1250 | mController.setActiveStream(mRow.stream); |
| 1251 | mRow.tracking = true; |
| 1252 | } |
| 1253 | |
| 1254 | @Override |
| 1255 | public void onStopTrackingTouch(SeekBar seekBar) { |
| 1256 | if (D.BUG) Log.d(TAG, "onStopTrackingTouch"+ " " + mRow.stream); |
| 1257 | mRow.tracking = false; |
| 1258 | mRow.userAttempt = SystemClock.uptimeMillis(); |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1259 | final int userLevel = getImpliedLevel(seekBar, seekBar.getProgress()); |
Chris Wren | e565ee6 | 2015-06-17 15:24:56 -0400 | [diff] [blame] | 1260 | Events.writeEvent(mContext, Events.EVENT_TOUCH_LEVEL_DONE, mRow.stream, userLevel); |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1261 | if (mRow.ss.level != userLevel) { |
| 1262 | mHandler.sendMessageDelayed(mHandler.obtainMessage(H.RECHECK, mRow), |
| 1263 | USER_ATTEMPT_GRACE_PERIOD); |
| 1264 | } |
| 1265 | } |
| 1266 | } |
| 1267 | |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1268 | private final class Accessibility extends AccessibilityDelegate { |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1269 | private boolean mFeedbackEnabled; |
| 1270 | |
| 1271 | public void init() { |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1272 | mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { |
| 1273 | @Override |
| 1274 | public void onViewDetachedFromWindow(View v) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1275 | if (D.BUG) Log.d(TAG, "onViewDetachedFromWindow"); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1276 | } |
| 1277 | |
| 1278 | @Override |
| 1279 | public void onViewAttachedToWindow(View v) { |
John Spurlock | 22def3d | 2015-06-17 11:56:12 -0400 | [diff] [blame] | 1280 | if (D.BUG) Log.d(TAG, "onViewAttachedToWindow"); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1281 | updateFeedbackEnabled(); |
| 1282 | } |
| 1283 | }); |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1284 | mDialogView.setAccessibilityDelegate(this); |
Beverly | cab59e6 | 2018-04-16 17:47:39 -0400 | [diff] [blame] | 1285 | mAccessibilityMgr.addCallback(mListener); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1286 | updateFeedbackEnabled(); |
| 1287 | } |
| 1288 | |
Jason Monk | 3b9357f | 2017-07-14 09:40:54 -0400 | [diff] [blame] | 1289 | public void destroy() { |
Beverly | cab59e6 | 2018-04-16 17:47:39 -0400 | [diff] [blame] | 1290 | mAccessibilityMgr.removeCallback(mListener); |
Jason Monk | 3b9357f | 2017-07-14 09:40:54 -0400 | [diff] [blame] | 1291 | } |
| 1292 | |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1293 | @Override |
Phil Weaver | 9054e09 | 2018-04-27 16:28:50 -0700 | [diff] [blame] | 1294 | public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) { |
| 1295 | // Activities populate their title here. Follow that example. |
| 1296 | event.getText().add(composeWindowTitle()); |
| 1297 | return true; |
| 1298 | } |
| 1299 | |
| 1300 | @Override |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1301 | public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, |
| 1302 | AccessibilityEvent event) { |
| 1303 | rescheduleTimeoutH(); |
| 1304 | return super.onRequestSendAccessibilityEvent(host, child, event); |
| 1305 | } |
| 1306 | |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1307 | private void updateFeedbackEnabled() { |
| 1308 | mFeedbackEnabled = computeFeedbackEnabled(); |
| 1309 | } |
| 1310 | |
| 1311 | private boolean computeFeedbackEnabled() { |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1312 | // are there any enabled non-generic a11y services? |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1313 | final List<AccessibilityServiceInfo> services = |
Julia Reynolds | 2feab16 | 2016-04-21 14:58:52 -0400 | [diff] [blame] | 1314 | mAccessibilityMgr.getEnabledAccessibilityServiceList(FEEDBACK_ALL_MASK); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1315 | for (AccessibilityServiceInfo asi : services) { |
John Spurlock | f09838b | 2015-06-11 16:14:44 -0400 | [diff] [blame] | 1316 | if (asi.feedbackType != 0 && asi.feedbackType != FEEDBACK_GENERIC) { |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1317 | return true; |
| 1318 | } |
| 1319 | } |
| 1320 | return false; |
| 1321 | } |
Jason Monk | 3b9357f | 2017-07-14 09:40:54 -0400 | [diff] [blame] | 1322 | |
Beverly | cab59e6 | 2018-04-16 17:47:39 -0400 | [diff] [blame] | 1323 | private final AccessibilityServicesStateChangeListener mListener = |
Jason Monk | 3b9357f | 2017-07-14 09:40:54 -0400 | [diff] [blame] | 1324 | enabled -> updateFeedbackEnabled(); |
John Spurlock | 5adeabc | 2015-05-05 14:50:43 -0400 | [diff] [blame] | 1325 | } |
| 1326 | |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1327 | private static class VolumeRow { |
| 1328 | private View view; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1329 | private TextView header; |
| 1330 | private ImageButton icon; |
| 1331 | private SeekBar slider; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1332 | private int stream; |
| 1333 | private StreamState ss; |
| 1334 | private long userAttempt; // last user-driven slider change |
| 1335 | private boolean tracking; // tracking slider touch |
John Spurlock | b0a2e5f | 2015-06-09 14:41:52 -0400 | [diff] [blame] | 1336 | private int requestedLevel = -1; // pending user-requested level via progress changed |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1337 | private int iconRes; |
| 1338 | private int iconMuteRes; |
| 1339 | private boolean important; |
Julia Reynolds | edb2e7c | 2017-12-11 13:18:03 -0500 | [diff] [blame] | 1340 | private boolean defaultStream; |
Julia Reynolds | 9b20717 | 2018-04-12 14:42:08 -0400 | [diff] [blame] | 1341 | private ColorStateList cachedTint; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1342 | private int iconState; // from Events |
Julia Reynolds | 4b006a8 | 2016-04-20 16:09:06 -0400 | [diff] [blame] | 1343 | private ObjectAnimator anim; // slider progress animation for non-touch-related updates |
| 1344 | private int animTargetProgress; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1345 | private int lastAudibleLevel = 1; |
Beverly | 0099195 | 2018-04-26 11:17:29 -0400 | [diff] [blame] | 1346 | private FrameLayout dndIcon; |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1347 | } |
John Spurlock | f88d808 | 2015-03-25 18:09:51 -0400 | [diff] [blame] | 1348 | } |