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