Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
| 5 | * except in compliance with the License. You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the |
| 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
| 13 | */ |
| 14 | |
| 15 | package com.android.systemui.qs; |
| 16 | |
Charles He | ce2a7c0 | 2017-10-11 20:25:20 +0100 | [diff] [blame] | 17 | import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS; |
Charles He | ce2a7c0 | 2017-10-11 20:25:20 +0100 | [diff] [blame] | 18 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
Amin Shaikh | 0e00331 | 2018-03-08 11:39:01 -0500 | [diff] [blame] | 21 | import android.annotation.ColorInt; |
Lucas Dupin | 1f7374a | 2018-02-26 18:08:33 -0800 | [diff] [blame] | 22 | import android.app.ActivityManager; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 23 | import android.app.AlarmManager; |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 24 | import android.content.BroadcastReceiver; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 25 | import android.content.Context; |
Evan Laird | 4ea2a49 | 2018-01-22 11:29:12 -0500 | [diff] [blame] | 26 | import android.content.Intent; |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 27 | import android.content.IntentFilter; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 28 | import android.content.res.Configuration; |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 29 | import android.content.res.Resources; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 30 | import android.graphics.Color; |
| 31 | import android.graphics.Rect; |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 32 | import android.media.AudioManager; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 33 | import android.os.Handler; |
Evan Laird | 4ea2a49 | 2018-01-22 11:29:12 -0500 | [diff] [blame] | 34 | import android.provider.AlarmClock; |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 35 | import android.service.notification.ZenModeConfig; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 36 | import android.support.annotation.VisibleForTesting; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 37 | import android.text.format.DateUtils; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 38 | import android.util.AttributeSet; |
Rohan Shah | a160ab1 | 2018-03-09 15:47:36 -0800 | [diff] [blame] | 39 | import android.util.Log; |
Adrian Roos | 1383605 | 2018-03-15 21:06:37 +0100 | [diff] [blame] | 40 | import android.util.Pair; |
Jason Monk | 824ffff | 2017-04-11 15:49:06 -0400 | [diff] [blame] | 41 | import android.view.View; |
Adrian Roos | 1383605 | 2018-03-15 21:06:37 +0100 | [diff] [blame] | 42 | import android.view.WindowInsets; |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 43 | import android.widget.ImageView; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 44 | import android.widget.RelativeLayout; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 45 | import android.widget.TextView; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 46 | |
| 47 | import com.android.settingslib.Utils; |
| 48 | import com.android.systemui.BatteryMeterView; |
| 49 | import com.android.systemui.Dependency; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 50 | import com.android.systemui.Prefs; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 51 | import com.android.systemui.R; |
| 52 | import com.android.systemui.plugins.ActivityStarter; |
| 53 | import com.android.systemui.qs.QSDetail.Callback; |
Adrian Roos | 1383605 | 2018-03-15 21:06:37 +0100 | [diff] [blame] | 54 | import com.android.systemui.statusbar.phone.PhoneStatusBarView; |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 55 | import com.android.systemui.statusbar.phone.StatusBarIconController; |
| 56 | import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager; |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 57 | import com.android.systemui.statusbar.policy.Clock; |
Evan Laird | 20b87bf | 2018-04-12 09:54:11 -0400 | [diff] [blame] | 58 | import com.android.systemui.statusbar.phone.StatusIconContainer; |
Evan Laird | 39254d4 | 2018-01-18 16:05:30 -0500 | [diff] [blame] | 59 | import com.android.systemui.statusbar.policy.DarkIconDispatcher; |
Jason Monk | 824ffff | 2017-04-11 15:49:06 -0400 | [diff] [blame] | 60 | import com.android.systemui.statusbar.policy.DarkIconDispatcher.DarkReceiver; |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 61 | import com.android.systemui.statusbar.policy.DateView; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 62 | import com.android.systemui.statusbar.policy.NextAlarmController; |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 63 | import com.android.systemui.statusbar.policy.ZenModeController; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 64 | |
Lucas Dupin | 1f7374a | 2018-02-26 18:08:33 -0800 | [diff] [blame] | 65 | import java.util.Locale; |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 66 | import java.util.Objects; |
Lucas Dupin | 1f7374a | 2018-02-26 18:08:33 -0800 | [diff] [blame] | 67 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 68 | /** |
| 69 | * View that contains the top-most bits of the screen (primarily the status bar with date, time, and |
| 70 | * battery) and also contains the {@link QuickQSPanel} along with some of the panel's inner |
| 71 | * contents. |
| 72 | */ |
Amin Shaikh | f09450b | 2018-04-06 17:32:45 -0400 | [diff] [blame] | 73 | public class QuickStatusBarHeader extends RelativeLayout implements |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 74 | View.OnClickListener, NextAlarmController.NextAlarmChangeCallback, |
| 75 | ZenModeController.Callback { |
Rohan Shah | a160ab1 | 2018-03-09 15:47:36 -0800 | [diff] [blame] | 76 | private static final String TAG = "QuickStatusBarHeader"; |
| 77 | private static final boolean DEBUG = false; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 78 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 79 | /** Delay for auto fading out the long press tooltip after it's fully visible (in ms). */ |
| 80 | private static final long AUTO_FADE_OUT_DELAY_MS = DateUtils.SECOND_IN_MILLIS * 6; |
| 81 | private static final int FADE_ANIMATION_DURATION_MS = 300; |
| 82 | private static final int TOOLTIP_NOT_YET_SHOWN_COUNT = 0; |
Rohan Shah | b6a915c | 2018-03-01 11:57:00 -0800 | [diff] [blame] | 83 | public static final int MAX_TOOLTIP_SHOWN_COUNT = 2; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 84 | |
| 85 | private final Handler mHandler = new Handler(); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 86 | |
| 87 | private QSPanel mQsPanel; |
| 88 | |
| 89 | private boolean mExpanded; |
| 90 | private boolean mListening; |
Charles He | ce2a7c0 | 2017-10-11 20:25:20 +0100 | [diff] [blame] | 91 | private boolean mQsDisabled; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 92 | |
| 93 | protected QuickQSPanel mHeaderQsPanel; |
| 94 | protected QSTileHost mHost; |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 95 | private TintedIconManager mIconManager; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 96 | private TouchAnimator mStatusIconsAlphaAnimator; |
| 97 | private TouchAnimator mHeaderTextContainerAlphaAnimator; |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 98 | |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 99 | private View mSystemIconsView; |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 100 | private View mQuickQsStatusIcons; |
Evan Laird | 4ea2a49 | 2018-01-22 11:29:12 -0500 | [diff] [blame] | 101 | private View mDate; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 102 | private View mHeaderTextContainerView; |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 103 | /** View containing the next alarm and ringer mode info. */ |
| 104 | private View mStatusContainer; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 105 | /** Tooltip for educating users that they can long press on icons to see more details. */ |
| 106 | private View mLongPressTooltipView; |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 107 | |
| 108 | private int mRingerMode = AudioManager.RINGER_MODE_NORMAL; |
| 109 | private AlarmManager.AlarmClockInfo mNextAlarm; |
| 110 | |
| 111 | private ImageView mNextAlarmIcon; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 112 | /** {@link TextView} containing the actual text indicating when the next alarm will go off. */ |
| 113 | private TextView mNextAlarmTextView; |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 114 | private View mStatusSeparator; |
| 115 | private ImageView mRingerModeIcon; |
| 116 | private TextView mRingerModeTextView; |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 117 | private BatteryMeterView mBatteryMeterView; |
| 118 | private Clock mClockView; |
| 119 | private DateView mDateView; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 120 | |
| 121 | private NextAlarmController mAlarmController; |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 122 | private ZenModeController mZenController; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 123 | /** Counts how many times the long press tooltip has been shown to the user. */ |
| 124 | private int mShownCount; |
| 125 | |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 126 | private final BroadcastReceiver mRingerReceiver = new BroadcastReceiver() { |
| 127 | @Override |
| 128 | public void onReceive(Context context, Intent intent) { |
| 129 | mRingerMode = intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1); |
| 130 | updateStatusText(); |
| 131 | } |
| 132 | }; |
| 133 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 134 | /** |
| 135 | * Runnable for automatically fading out the long press tooltip (as if it were animating away). |
| 136 | */ |
| 137 | private final Runnable mAutoFadeOutTooltipRunnable = () -> hideLongPressTooltip(false); |
Evan Laird | 4ea2a49 | 2018-01-22 11:29:12 -0500 | [diff] [blame] | 138 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 139 | public QuickStatusBarHeader(Context context, AttributeSet attrs) { |
| 140 | super(context, attrs); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 141 | mAlarmController = Dependency.get(NextAlarmController.class); |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 142 | mZenController = Dependency.get(ZenModeController.class); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 143 | mShownCount = getStoredShownCount(); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | @Override |
| 147 | protected void onFinishInflate() { |
| 148 | super.onFinishInflate(); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 149 | |
| 150 | mHeaderQsPanel = findViewById(R.id.quick_qs_panel); |
Evan Laird | 4ea2a49 | 2018-01-22 11:29:12 -0500 | [diff] [blame] | 151 | mDate = findViewById(R.id.date); |
| 152 | mDate.setOnClickListener(this); |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 153 | mSystemIconsView = findViewById(R.id.quick_status_bar_system_icons); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 154 | mQuickQsStatusIcons = findViewById(R.id.quick_qs_status_icons); |
Evan Laird | 20b87bf | 2018-04-12 09:54:11 -0400 | [diff] [blame] | 155 | StatusIconContainer iconContainer = findViewById(R.id.statusIcons); |
| 156 | iconContainer.setShouldRestrictIcons(false); |
| 157 | mIconManager = new TintedIconManager(iconContainer); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 158 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 159 | // Views corresponding to the header info section (e.g. tooltip and next alarm). |
| 160 | mHeaderTextContainerView = findViewById(R.id.header_text_container); |
| 161 | mLongPressTooltipView = findViewById(R.id.long_press_tooltip); |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 162 | mStatusContainer = findViewById(R.id.status_container); |
| 163 | mStatusSeparator = findViewById(R.id.status_separator); |
| 164 | mNextAlarmIcon = findViewById(R.id.next_alarm_icon); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 165 | mNextAlarmTextView = findViewById(R.id.next_alarm_text); |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 166 | mRingerModeIcon = findViewById(R.id.ringer_mode_icon); |
| 167 | mRingerModeTextView = findViewById(R.id.ringer_mode_text); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 168 | |
| 169 | updateResources(); |
| 170 | |
Jason Monk | 824ffff | 2017-04-11 15:49:06 -0400 | [diff] [blame] | 171 | Rect tintArea = new Rect(0, 0, 0, 0); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 172 | int colorForeground = Utils.getColorAttr(getContext(), android.R.attr.colorForeground); |
Amin Shaikh | 0e00331 | 2018-03-08 11:39:01 -0500 | [diff] [blame] | 173 | float intensity = getColorIntensity(colorForeground); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 174 | int fillColor = fillColorForIntensity(intensity, getContext()); |
| 175 | |
| 176 | // Set light text on the header icons because they will always be on a black background |
Evan Laird | 39254d4 | 2018-01-18 16:05:30 -0500 | [diff] [blame] | 177 | applyDarkness(R.id.clock, tintArea, 0, DarkIconDispatcher.DEFAULT_ICON_TINT); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 178 | |
| 179 | // Set the correct tint for the status icons so they contrast |
| 180 | mIconManager.setTint(fillColor); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 181 | |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 182 | mBatteryMeterView = findViewById(R.id.battery); |
| 183 | mBatteryMeterView.setForceShowPercent(true); |
| 184 | mClockView = findViewById(R.id.clock); |
| 185 | mDateView = findViewById(R.id.date); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 186 | } |
| 187 | |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 188 | private void updateStatusText() { |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 189 | boolean changed = updateRingerStatus() || updateAlarmStatus(); |
| 190 | |
| 191 | if (changed) { |
| 192 | boolean alarmVisible = mNextAlarmTextView.getVisibility() == View.VISIBLE; |
| 193 | boolean ringerVisible = mRingerModeTextView.getVisibility() == View.VISIBLE; |
| 194 | mStatusSeparator.setVisibility(alarmVisible && ringerVisible ? View.VISIBLE |
| 195 | : View.GONE); |
| 196 | updateTooltipShow(); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | private boolean updateRingerStatus() { |
| 201 | boolean isOriginalVisible = mRingerModeTextView.getVisibility() == View.VISIBLE; |
| 202 | CharSequence originalRingerText = mRingerModeTextView.getText(); |
| 203 | |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 204 | boolean ringerVisible = false; |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 205 | if (!ZenModeConfig.isZenOverridingRinger(mZenController.getZen(), |
| 206 | mZenController.getConfig())) { |
| 207 | if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { |
| 208 | mRingerModeIcon.setImageResource(R.drawable.stat_sys_ringer_vibrate); |
| 209 | mRingerModeTextView.setText(R.string.qs_status_phone_vibrate); |
| 210 | ringerVisible = true; |
| 211 | } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT) { |
| 212 | mRingerModeIcon.setImageResource(R.drawable.stat_sys_ringer_silent); |
| 213 | mRingerModeTextView.setText(R.string.qs_status_phone_muted); |
| 214 | ringerVisible = true; |
| 215 | } |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 216 | } |
| 217 | mRingerModeIcon.setVisibility(ringerVisible ? View.VISIBLE : View.GONE); |
| 218 | mRingerModeTextView.setVisibility(ringerVisible ? View.VISIBLE : View.GONE); |
| 219 | |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 220 | return isOriginalVisible != ringerVisible || |
| 221 | !Objects.equals(originalRingerText, mRingerModeTextView.getText()); |
| 222 | } |
| 223 | |
| 224 | private boolean updateAlarmStatus() { |
| 225 | boolean isOriginalVisible = mNextAlarmTextView.getVisibility() == View.VISIBLE; |
| 226 | CharSequence originalAlarmText = mNextAlarmTextView.getText(); |
| 227 | |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 228 | boolean alarmVisible = false; |
| 229 | if (mNextAlarm != null) { |
| 230 | alarmVisible = true; |
| 231 | mNextAlarmTextView.setText(formatNextAlarm(mNextAlarm)); |
| 232 | } |
| 233 | mNextAlarmIcon.setVisibility(alarmVisible ? View.VISIBLE : View.GONE); |
| 234 | mNextAlarmTextView.setVisibility(alarmVisible ? View.VISIBLE : View.GONE); |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 235 | |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 236 | return isOriginalVisible != alarmVisible || |
| 237 | !Objects.equals(originalAlarmText, mNextAlarmTextView.getText()); |
| 238 | } |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 239 | |
Jason Monk | 824ffff | 2017-04-11 15:49:06 -0400 | [diff] [blame] | 240 | private void applyDarkness(int id, Rect tintArea, float intensity, int color) { |
| 241 | View v = findViewById(id); |
| 242 | if (v instanceof DarkReceiver) { |
| 243 | ((DarkReceiver) v).onDarkChanged(tintArea, intensity, color); |
| 244 | } |
| 245 | } |
| 246 | |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 247 | private int fillColorForIntensity(float intensity, Context context) { |
| 248 | if (intensity == 0) { |
Amin Shaikh | 9cac338 | 2018-04-11 17:10:07 -0400 | [diff] [blame] | 249 | return context.getColor(R.color.light_mode_icon_color_single_tone); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 250 | } |
Amin Shaikh | 9cac338 | 2018-04-11 17:10:07 -0400 | [diff] [blame] | 251 | return context.getColor(R.color.dark_mode_icon_color_single_tone); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 252 | } |
| 253 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 254 | @Override |
| 255 | protected void onConfigurationChanged(Configuration newConfig) { |
| 256 | super.onConfigurationChanged(newConfig); |
| 257 | updateResources(); |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 258 | |
| 259 | // Update color schemes in landscape to use wallpaperTextColor |
| 260 | boolean shouldUseWallpaperTextColor = |
| 261 | newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE; |
| 262 | mBatteryMeterView.useWallpaperTextColor(shouldUseWallpaperTextColor); |
| 263 | mClockView.useWallpaperTextColor(shouldUseWallpaperTextColor); |
| 264 | mDateView.useWallpaperTextColor(shouldUseWallpaperTextColor); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | @Override |
| 268 | public void onRtlPropertiesChanged(int layoutDirection) { |
| 269 | super.onRtlPropertiesChanged(layoutDirection); |
| 270 | updateResources(); |
| 271 | } |
| 272 | |
| 273 | private void updateResources() { |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 274 | Resources resources = mContext.getResources(); |
| 275 | |
| 276 | // Update height for a few views, especially due to landscape mode restricting space. |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 277 | mHeaderTextContainerView.getLayoutParams().height = |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 278 | resources.getDimensionPixelSize(R.dimen.qs_header_tooltip_height); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 279 | mHeaderTextContainerView.setLayoutParams(mHeaderTextContainerView.getLayoutParams()); |
| 280 | |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 281 | mSystemIconsView.getLayoutParams().height = resources.getDimensionPixelSize( |
| 282 | com.android.internal.R.dimen.quick_qs_offset_height); |
| 283 | mSystemIconsView.setLayoutParams(mSystemIconsView.getLayoutParams()); |
| 284 | |
Amin Shaikh | f09450b | 2018-04-06 17:32:45 -0400 | [diff] [blame] | 285 | getLayoutParams().height = resources.getDimensionPixelSize(mQsDisabled |
| 286 | ? com.android.internal.R.dimen.quick_qs_offset_height |
| 287 | : com.android.internal.R.dimen.quick_qs_total_height); |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 288 | setLayoutParams(getLayoutParams()); |
| 289 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 290 | updateStatusIconAlphaAnimator(); |
| 291 | updateHeaderTextContainerAlphaAnimator(); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 292 | } |
| 293 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 294 | private void updateStatusIconAlphaAnimator() { |
| 295 | mStatusIconsAlphaAnimator = new TouchAnimator.Builder() |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 296 | .addFloat(mQuickQsStatusIcons, "alpha", 1, 0) |
| 297 | .build(); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 298 | } |
| 299 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 300 | private void updateHeaderTextContainerAlphaAnimator() { |
| 301 | mHeaderTextContainerAlphaAnimator = new TouchAnimator.Builder() |
| 302 | .addFloat(mHeaderTextContainerView, "alpha", 0, 1) |
| 303 | .setStartDelay(.5f) |
| 304 | .build(); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | public void setExpanded(boolean expanded) { |
| 308 | if (mExpanded == expanded) return; |
| 309 | mExpanded = expanded; |
| 310 | mHeaderQsPanel.setExpanded(expanded); |
| 311 | updateEverything(); |
| 312 | } |
| 313 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 314 | /** |
| 315 | * Animates the inner contents based on the given expansion details. |
| 316 | * |
| 317 | * @param isKeyguardShowing whether or not we're showing the keyguard (a.k.a. lockscreen) |
| 318 | * @param expansionFraction how much the QS panel is expanded/pulled out (up to 1f) |
| 319 | * @param panelTranslationY how much the panel has physically moved down vertically (required |
| 320 | * for keyguard animations only) |
| 321 | */ |
| 322 | public void setExpansion(boolean isKeyguardShowing, float expansionFraction, |
| 323 | float panelTranslationY) { |
| 324 | final float keyguardExpansionFraction = isKeyguardShowing ? 1f : expansionFraction; |
| 325 | if (mStatusIconsAlphaAnimator != null) { |
| 326 | mStatusIconsAlphaAnimator.setPosition(keyguardExpansionFraction); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 327 | } |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 328 | |
| 329 | if (isKeyguardShowing) { |
| 330 | // If the keyguard is showing, we want to offset the text so that it comes in at the |
| 331 | // same time as the panel as it slides down. |
| 332 | mHeaderTextContainerView.setTranslationY(panelTranslationY); |
| 333 | } else { |
| 334 | mHeaderTextContainerView.setTranslationY(0f); |
| 335 | } |
| 336 | |
| 337 | if (mHeaderTextContainerAlphaAnimator != null) { |
| 338 | mHeaderTextContainerAlphaAnimator.setPosition(keyguardExpansionFraction); |
| 339 | } |
| 340 | |
| 341 | // Check the original expansion fraction - we don't want to show the tooltip until the |
| 342 | // panel is pulled all the way out. |
| 343 | if (expansionFraction == 1f) { |
| 344 | // QS is fully expanded, bring in the tooltip. |
| 345 | showLongPressTooltip(); |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | /** Returns the latest stored tooltip shown count from SharedPreferences. */ |
| 350 | private int getStoredShownCount() { |
| 351 | return Prefs.getInt( |
| 352 | mContext, |
| 353 | Prefs.Key.QS_LONG_PRESS_TOOLTIP_SHOWN_COUNT, |
| 354 | TOOLTIP_NOT_YET_SHOWN_COUNT); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 355 | } |
| 356 | |
Charles He | ce2a7c0 | 2017-10-11 20:25:20 +0100 | [diff] [blame] | 357 | public void disable(int state1, int state2, boolean animate) { |
| 358 | final boolean disabled = (state2 & DISABLE2_QUICK_SETTINGS) != 0; |
| 359 | if (disabled == mQsDisabled) return; |
| 360 | mQsDisabled = disabled; |
| 361 | mHeaderQsPanel.setDisabledByPolicy(disabled); |
Amin Shaikh | f09450b | 2018-04-06 17:32:45 -0400 | [diff] [blame] | 362 | mHeaderTextContainerView.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE); |
| 363 | mQuickQsStatusIcons.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE); |
| 364 | updateResources(); |
Charles He | ce2a7c0 | 2017-10-11 20:25:20 +0100 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | @Override |
| 368 | public void onAttachedToWindow() { |
Amin Shaikh | a59215a | 2018-04-23 08:52:38 -0400 | [diff] [blame^] | 369 | super.onAttachedToWindow(); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 370 | Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager); |
Adrian Roos | 1383605 | 2018-03-15 21:06:37 +0100 | [diff] [blame] | 371 | requestApplyInsets(); |
| 372 | } |
| 373 | |
| 374 | @Override |
| 375 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
| 376 | Pair<Integer, Integer> padding = PhoneStatusBarView.cornerCutoutMargins( |
| 377 | insets.getDisplayCutout(), getDisplay()); |
| 378 | if (padding == null) { |
Amin Shaikh | 7d86b04 | 2018-04-16 16:00:12 -0400 | [diff] [blame] | 379 | mSystemIconsView.setPaddingRelative( |
| 380 | getResources().getDimensionPixelSize(R.dimen.status_bar_padding_start), 0, |
| 381 | getResources().getDimensionPixelSize(R.dimen.status_bar_padding_end), 0); |
Adrian Roos | 1383605 | 2018-03-15 21:06:37 +0100 | [diff] [blame] | 382 | } else { |
Amin Shaikh | 7d86b04 | 2018-04-16 16:00:12 -0400 | [diff] [blame] | 383 | mSystemIconsView.setPadding(padding.first, 0, padding.second, 0); |
| 384 | |
Adrian Roos | 1383605 | 2018-03-15 21:06:37 +0100 | [diff] [blame] | 385 | } |
| 386 | return super.onApplyWindowInsets(insets); |
Charles He | ce2a7c0 | 2017-10-11 20:25:20 +0100 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | @Override |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 390 | @VisibleForTesting |
| 391 | public void onDetachedFromWindow() { |
| 392 | setListening(false); |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 393 | Dependency.get(StatusBarIconController.class).removeIconGroup(mIconManager); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 394 | super.onDetachedFromWindow(); |
| 395 | } |
| 396 | |
| 397 | public void setListening(boolean listening) { |
| 398 | if (listening == mListening) { |
| 399 | return; |
| 400 | } |
| 401 | mHeaderQsPanel.setListening(listening); |
| 402 | mListening = listening; |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 403 | |
| 404 | if (listening) { |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 405 | mZenController.addCallback(this); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 406 | mAlarmController.addCallback(this); |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 407 | mContext.registerReceiver(mRingerReceiver, |
| 408 | new IntentFilter(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION)); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 409 | } else { |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 410 | mZenController.removeCallback(this); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 411 | mAlarmController.removeCallback(this); |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 412 | mContext.unregisterReceiver(mRingerReceiver); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 413 | } |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 414 | } |
| 415 | |
Evan Laird | 9589695 | 2018-01-22 19:30:05 -0500 | [diff] [blame] | 416 | @Override |
| 417 | public void onClick(View v) { |
| 418 | if(v == mDate){ |
| 419 | Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(new Intent( |
| 420 | AlarmClock.ACTION_SHOW_ALARMS),0); |
| 421 | } |
| 422 | } |
| 423 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 424 | @Override |
| 425 | public void onNextAlarmChanged(AlarmManager.AlarmClockInfo nextAlarm) { |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 426 | mNextAlarm = nextAlarm; |
| 427 | updateStatusText(); |
| 428 | } |
Rohan Shah | a160ab1 | 2018-03-09 15:47:36 -0800 | [diff] [blame] | 429 | |
Beverly | b9826dd | 2018-04-12 15:02:45 -0400 | [diff] [blame] | 430 | @Override |
| 431 | public void onZenChanged(int zen) { |
| 432 | updateStatusText(); |
| 433 | |
| 434 | } |
| 435 | |
| 436 | @Override |
| 437 | public void onConfigChanged(ZenModeConfig config) { |
| 438 | updateStatusText(); |
| 439 | } |
| 440 | |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 441 | private void updateTooltipShow() { |
| 442 | if (hasStatusText()) { |
| 443 | hideLongPressTooltip(true /* shouldShowStatusText */); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 444 | } else { |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 445 | hideStatusText(); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 446 | } |
| 447 | updateHeaderTextContainerAlphaAnimator(); |
| 448 | } |
| 449 | |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 450 | private boolean hasStatusText() { |
| 451 | return mNextAlarmTextView.getVisibility() == View.VISIBLE |
| 452 | || mRingerModeTextView.getVisibility() == View.VISIBLE; |
| 453 | } |
| 454 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 455 | /** |
| 456 | * Animates in the long press tooltip (as long as the next alarm text isn't currently occupying |
| 457 | * the space). |
| 458 | */ |
| 459 | public void showLongPressTooltip() { |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 460 | // If we have status text to show, don't bother fading in the tooltip. |
| 461 | if (hasStatusText()) { |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 462 | return; |
| 463 | } |
| 464 | |
| 465 | if (mShownCount < MAX_TOOLTIP_SHOWN_COUNT) { |
| 466 | mLongPressTooltipView.animate().cancel(); |
| 467 | mLongPressTooltipView.setVisibility(View.VISIBLE); |
| 468 | mLongPressTooltipView.animate() |
| 469 | .alpha(1f) |
| 470 | .setDuration(FADE_ANIMATION_DURATION_MS) |
| 471 | .setListener(new AnimatorListenerAdapter() { |
| 472 | @Override |
| 473 | public void onAnimationEnd(Animator animation) { |
| 474 | mHandler.postDelayed( |
| 475 | mAutoFadeOutTooltipRunnable, AUTO_FADE_OUT_DELAY_MS); |
| 476 | } |
| 477 | }) |
| 478 | .start(); |
| 479 | |
| 480 | // Increment and drop the shown count in prefs for the next time we're deciding to |
| 481 | // fade in the tooltip. We first sanity check that the tooltip count hasn't changed yet |
| 482 | // in prefs (say, from a long press). |
| 483 | if (getStoredShownCount() <= mShownCount) { |
| 484 | Prefs.putInt(mContext, Prefs.Key.QS_LONG_PRESS_TOOLTIP_SHOWN_COUNT, ++mShownCount); |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | /** |
| 490 | * Fades out the long press tooltip if it's partially visible - short circuits any running |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 491 | * animation. Additionally has the ability to fade in the status info text. |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 492 | * |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 493 | * @param shouldShowStatusText whether we should fade in the status text |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 494 | */ |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 495 | private void hideLongPressTooltip(boolean shouldShowStatusText) { |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 496 | mLongPressTooltipView.animate().cancel(); |
| 497 | if (mLongPressTooltipView.getVisibility() == View.VISIBLE |
| 498 | && mLongPressTooltipView.getAlpha() != 0f) { |
| 499 | mHandler.removeCallbacks(mAutoFadeOutTooltipRunnable); |
| 500 | mLongPressTooltipView.animate() |
| 501 | .alpha(0f) |
| 502 | .setDuration(FADE_ANIMATION_DURATION_MS) |
| 503 | .setListener(new AnimatorListenerAdapter() { |
| 504 | @Override |
| 505 | public void onAnimationEnd(Animator animation) { |
Rohan Shah | a160ab1 | 2018-03-09 15:47:36 -0800 | [diff] [blame] | 506 | if (DEBUG) Log.d(TAG, "hideLongPressTooltip: Hid long press tip"); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 507 | mLongPressTooltipView.setVisibility(View.INVISIBLE); |
| 508 | |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 509 | if (shouldShowStatusText) { |
| 510 | showStatus(); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 511 | } |
| 512 | } |
| 513 | }) |
| 514 | .start(); |
| 515 | } else { |
| 516 | mLongPressTooltipView.setVisibility(View.INVISIBLE); |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 517 | if (shouldShowStatusText) { |
| 518 | showStatus(); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | /** |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 524 | * Fades in the updated status text. Note that if there's already a status showing, this will |
| 525 | * immediately hide it and fade in the updated status. |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 526 | */ |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 527 | private void showStatus() { |
| 528 | mStatusContainer.setAlpha(0f); |
| 529 | mStatusContainer.setVisibility(View.VISIBLE); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 530 | |
Rohan Shah | a160ab1 | 2018-03-09 15:47:36 -0800 | [diff] [blame] | 531 | // Animate the alarm back in. Make sure to clear the animator listener for the animation! |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 532 | mStatusContainer.animate() |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 533 | .alpha(1f) |
| 534 | .setDuration(FADE_ANIMATION_DURATION_MS) |
Rohan Shah | a160ab1 | 2018-03-09 15:47:36 -0800 | [diff] [blame] | 535 | .setListener(null) |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 536 | .start(); |
| 537 | } |
| 538 | |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 539 | /** Fades out and hides the status text. */ |
| 540 | private void hideStatusText() { |
| 541 | if (mStatusContainer.getVisibility() == View.VISIBLE) { |
| 542 | mStatusContainer.animate() |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 543 | .alpha(0f) |
| 544 | .setListener(new AnimatorListenerAdapter() { |
| 545 | @Override |
| 546 | public void onAnimationEnd(Animator animation) { |
Rohan Shah | a160ab1 | 2018-03-09 15:47:36 -0800 | [diff] [blame] | 547 | if (DEBUG) Log.d(TAG, "hideAlarmText: Hid alarm text"); |
| 548 | |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 549 | // Reset the alpha regardless of how the animation ends for the next |
| 550 | // time we show this view/want to animate it. |
Amin Shaikh | 761c566 | 2018-03-27 16:55:43 -0400 | [diff] [blame] | 551 | mStatusContainer.setVisibility(View.INVISIBLE); |
| 552 | mStatusContainer.setAlpha(1f); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 553 | } |
| 554 | }) |
| 555 | .start(); |
Rohan Shah | d3cf756 | 2018-02-23 11:12:28 -0800 | [diff] [blame] | 556 | } |
| 557 | } |
| 558 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 559 | public void updateEverything() { |
Jason Monk | 1fdde2d | 2017-03-08 09:39:21 -0500 | [diff] [blame] | 560 | post(() -> setClickable(false)); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | public void setQSPanel(final QSPanel qsPanel) { |
| 564 | mQsPanel = qsPanel; |
| 565 | setupHost(qsPanel.getHost()); |
| 566 | } |
| 567 | |
| 568 | public void setupHost(final QSTileHost host) { |
| 569 | mHost = host; |
| 570 | //host.setHeaderView(mExpandIndicator); |
| 571 | mHeaderQsPanel.setQSPanelAndHeader(mQsPanel, this); |
| 572 | mHeaderQsPanel.setHost(host, null /* No customization in header */); |
Evan Laird | ef160f2 | 2018-01-29 14:08:45 -0500 | [diff] [blame] | 573 | |
| 574 | // Use SystemUI context to get battery meter colors, and let it use the default tint (white) |
Rohan Shah | cc3d1d8 | 2018-03-30 21:24:17 +0000 | [diff] [blame] | 575 | mBatteryMeterView.setColorsFromContext(mHost.getContext()); |
| 576 | mBatteryMeterView.onDarkChanged(new Rect(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | public void setCallback(Callback qsPanelCallback) { |
| 580 | mHeaderQsPanel.setCallback(qsPanelCallback); |
| 581 | } |
Lucas Dupin | 1f7374a | 2018-02-26 18:08:33 -0800 | [diff] [blame] | 582 | |
| 583 | private String formatNextAlarm(AlarmManager.AlarmClockInfo info) { |
| 584 | if (info == null) { |
| 585 | return ""; |
| 586 | } |
| 587 | String skeleton = android.text.format.DateFormat |
| 588 | .is24HourFormat(mContext, ActivityManager.getCurrentUser()) ? "EHm" : "Ehma"; |
| 589 | String pattern = android.text.format.DateFormat |
| 590 | .getBestDateTimePattern(Locale.getDefault(), skeleton); |
| 591 | return android.text.format.DateFormat.format(pattern, info.getTriggerTime()).toString(); |
| 592 | } |
Amin Shaikh | 0e00331 | 2018-03-08 11:39:01 -0500 | [diff] [blame] | 593 | |
| 594 | public static float getColorIntensity(@ColorInt int color) { |
| 595 | return color == Color.WHITE ? 0 : 1; |
| 596 | } |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 597 | } |