blob: b0670fd0a91a034450621882971a587e574cda98 [file] [log] [blame]
Jim Millerdcb3d842012-08-23 19:18:12 -07001/*
2 * Copyright (C) 2012 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
Jim Miller5ecd8112013-01-09 18:50:26 -080017package com.android.keyguard;
Jim Millerdcb3d842012-08-23 19:18:12 -070018
Alex Chauff7653d2018-02-01 17:18:08 +000019import android.app.ActivityManager;
Alex Chauff7653d2018-02-01 17:18:08 +000020import android.app.IActivityManager;
Jim Millerdcb3d842012-08-23 19:18:12 -070021import android.content.Context;
Jim Miller0c486892013-10-11 16:21:45 -070022import android.content.res.Resources;
Lucas Dupin76d38e72017-05-13 22:04:22 -070023import android.graphics.Color;
Geoffrey Pitschc239fef2017-07-14 09:55:16 -040024import android.os.Handler;
25import android.os.Looper;
Alex Chauff7653d2018-02-01 17:18:08 +000026import android.os.RemoteException;
Adrian Roos9dd16eb2015-01-08 16:20:49 +010027import android.os.UserHandle;
Jim Milleredc74ab2012-11-06 21:46:11 -080028import android.text.TextUtils;
Jim Miller38ab2772013-10-08 15:32:09 -070029import android.text.format.DateFormat;
Lucas Dupin6bd86012017-12-05 17:58:57 -080030import android.util.ArraySet;
Jim Millerdcb3d842012-08-23 19:18:12 -070031import android.util.AttributeSet;
Jim Miller20daffd2013-10-07 14:59:53 -070032import android.util.Log;
Jim Milleredc74ab2012-11-06 21:46:11 -080033import android.util.Slog;
Jorim Jaggie210cc82014-08-12 23:44:59 +020034import android.util.TypedValue;
Jim Milleredc74ab2012-11-06 21:46:11 -080035import android.view.View;
Jim Millerdcb3d842012-08-23 19:18:12 -070036import android.widget.GridLayout;
Jim Milleredc74ab2012-11-06 21:46:11 -080037import android.widget.TextView;
Jim Millerdcb3d842012-08-23 19:18:12 -070038
Lucas Dupin43976f82018-10-22 19:52:59 -070039import androidx.core.graphics.ColorUtils;
40
Michael Jurka1254f2f2012-10-25 11:44:31 -070041import com.android.internal.widget.LockPatternUtils;
Lucas Dupin4e023812018-04-02 21:19:23 -070042import com.android.systemui.Dependency;
Lucas Dupin4e023812018-04-02 21:19:23 -070043import com.android.systemui.statusbar.policy.ConfigurationController;
Michael Jurka1254f2f2012-10-25 11:44:31 -070044
Lucas Dupin6bd86012017-12-05 17:58:57 -080045import com.google.android.collect.Sets;
46
Chris Wren56018e52013-01-15 10:59:43 -050047import java.util.Locale;
Robert Snoeberger9c1074f2018-12-07 17:35:21 -050048import java.util.TimeZone;
Chris Wren56018e52013-01-15 10:59:43 -050049
Lucas Dupin4e023812018-04-02 21:19:23 -070050public class KeyguardStatusView extends GridLayout implements
Lucas Dupine570af62019-02-10 14:52:30 -080051 ConfigurationController.ConfigurationListener {
Jorim Jaggi5cf17872014-03-26 18:31:48 +010052 private static final boolean DEBUG = KeyguardConstants.DEBUG;
Jim Milleredc74ab2012-11-06 21:46:11 -080053 private static final String TAG = "KeyguardStatusView";
Geoffrey Pitschc239fef2017-07-14 09:55:16 -040054 private static final int MARQUEE_DELAY_MS = 2000;
Jim Milleredc74ab2012-11-06 21:46:11 -080055
Adrian Roos9dd16eb2015-01-08 16:20:49 +010056 private final LockPatternUtils mLockPatternUtils;
Alex Chauff7653d2018-02-01 17:18:08 +000057 private final IActivityManager mIActivityManager;
Jim Milleredc74ab2012-11-06 21:46:11 -080058
Alex Chauff7653d2018-02-01 17:18:08 +000059 private TextView mLogoutView;
Kunhung Li29007e62018-07-30 19:30:25 +080060 private KeyguardClockSwitch mClockView;
Jorim Jaggi93afa1d2014-06-03 20:56:32 +020061 private TextView mOwnerInfo;
Lucas Dupin957e50c2017-10-10 11:23:27 -070062 private KeyguardSliceView mKeyguardSlice;
Geoffrey Pitschc239fef2017-07-14 09:55:16 -040063 private Runnable mPendingMarqueeStart;
64 private Handler mHandler;
Jim Milleredc74ab2012-11-06 21:46:11 -080065
Lucas Dupin6bd86012017-12-05 17:58:57 -080066 private ArraySet<View> mVisibleInDoze;
Adrian Roosd83e9992017-03-16 15:17:57 -070067 private boolean mPulsing;
Adrian Roos7f910722017-07-12 19:15:59 +020068 private float mDarkAmount = 0;
Lucas Dupin76d38e72017-05-13 22:04:22 -070069 private int mTextColor;
Adrian Roosd83e9992017-03-16 15:17:57 -070070
Jim Milleredc74ab2012-11-06 21:46:11 -080071 private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
72
73 @Override
74 public void onTimeChanged() {
Lucas Dupin08c013e2018-04-26 17:45:14 -070075 refreshTime();
Jim Milleredc74ab2012-11-06 21:46:11 -080076 }
77
78 @Override
Robert Snoeberger9c1074f2018-12-07 17:35:21 -050079 public void onTimeZoneChanged(TimeZone timeZone) {
80 updateTimeZone(timeZone);
81 }
82
83 @Override
Jorim Jaggi5cf17872014-03-26 18:31:48 +010084 public void onKeyguardVisibilityChanged(boolean showing) {
Jim Milleredc74ab2012-11-06 21:46:11 -080085 if (showing) {
86 if (DEBUG) Slog.v(TAG, "refresh statusview showing:" + showing);
Lucas Dupin08c013e2018-04-26 17:45:14 -070087 refreshTime();
Jorim Jaggi93afa1d2014-06-03 20:56:32 +020088 updateOwnerInfo();
Alex Chauff7653d2018-02-01 17:18:08 +000089 updateLogoutView();
Jim Milleredc74ab2012-11-06 21:46:11 -080090 }
Jorim Jaggi5cf17872014-03-26 18:31:48 +010091 }
Jim Miller20daffd2013-10-07 14:59:53 -070092
Jim Miller38ab2772013-10-08 15:32:09 -070093 @Override
Jorim Jaggi0d210f62015-07-10 14:24:44 -070094 public void onStartedWakingUp() {
Jim Miller20daffd2013-10-07 14:59:53 -070095 setEnableMarquee(true);
Jorim Jaggi5cf17872014-03-26 18:31:48 +010096 }
Jim Miller20daffd2013-10-07 14:59:53 -070097
Jim Miller38ab2772013-10-08 15:32:09 -070098 @Override
Jorim Jaggi0d210f62015-07-10 14:24:44 -070099 public void onFinishedGoingToSleep(int why) {
Jim Miller20daffd2013-10-07 14:59:53 -0700100 setEnableMarquee(false);
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100101 }
Jorim Jaggic7dea6e2014-07-26 14:36:57 +0200102
103 @Override
104 public void onUserSwitchComplete(int userId) {
Lucas Dupin08c013e2018-04-26 17:45:14 -0700105 refreshFormat();
Adrian Roose32dac82014-07-28 15:58:50 +0200106 updateOwnerInfo();
Alex Chauff7653d2018-02-01 17:18:08 +0000107 updateLogoutView();
108 }
109
110 @Override
111 public void onLogoutEnabledChanged() {
112 updateLogoutView();
Jorim Jaggic7dea6e2014-07-26 14:36:57 +0200113 }
Jim Milleredc74ab2012-11-06 21:46:11 -0800114 };
Jim Miller6212cc02012-09-05 17:35:31 -0700115
Jim Millerdcb3d842012-08-23 19:18:12 -0700116 public KeyguardStatusView(Context context) {
117 this(context, null, 0);
118 }
119
120 public KeyguardStatusView(Context context, AttributeSet attrs) {
121 this(context, attrs, 0);
122 }
123
124 public KeyguardStatusView(Context context, AttributeSet attrs, int defStyle) {
125 super(context, attrs, defStyle);
Alex Chauff7653d2018-02-01 17:18:08 +0000126 mIActivityManager = ActivityManager.getService();
Adrian Roos9dd16eb2015-01-08 16:20:49 +0100127 mLockPatternUtils = new LockPatternUtils(getContext());
Geoffrey Pitschc239fef2017-07-14 09:55:16 -0400128 mHandler = new Handler(Looper.myLooper());
Lucas Dupin4e023812018-04-02 21:19:23 -0700129 onDensityOrFontScaleChanged();
Jim Millerdcb3d842012-08-23 19:18:12 -0700130 }
131
Lucas Dupin7fc9dc12019-01-03 09:19:43 -0800132 /**
133 * If we're presenting a custom clock of just the default one.
134 */
135 public boolean hasCustomClock() {
136 return mClockView.hasCustomClock();
137 }
138
Jim Miller20daffd2013-10-07 14:59:53 -0700139 private void setEnableMarquee(boolean enabled) {
Geoffrey Pitschc239fef2017-07-14 09:55:16 -0400140 if (DEBUG) Log.v(TAG, "Schedule setEnableMarquee: " + (enabled ? "Enable" : "Disable"));
141 if (enabled) {
142 if (mPendingMarqueeStart == null) {
143 mPendingMarqueeStart = () -> {
144 setEnableMarqueeImpl(true);
145 mPendingMarqueeStart = null;
146 };
147 mHandler.postDelayed(mPendingMarqueeStart, MARQUEE_DELAY_MS);
148 }
149 } else {
150 if (mPendingMarqueeStart != null) {
151 mHandler.removeCallbacks(mPendingMarqueeStart);
152 mPendingMarqueeStart = null;
153 }
154 setEnableMarqueeImpl(false);
155 }
156 }
157
158 private void setEnableMarqueeImpl(boolean enabled) {
Jim Miller20daffd2013-10-07 14:59:53 -0700159 if (DEBUG) Log.v(TAG, (enabled ? "Enable" : "Disable") + " transport text marquee");
John Spurlock1e6eb172014-07-13 11:59:50 -0400160 if (mOwnerInfo != null) mOwnerInfo.setSelected(enabled);
Jim Miller20daffd2013-10-07 14:59:53 -0700161 }
162
Jim Milleredc74ab2012-11-06 21:46:11 -0800163 @Override
164 protected void onFinishInflate() {
165 super.onFinishInflate();
Alex Chauff7653d2018-02-01 17:18:08 +0000166 mLogoutView = findViewById(R.id.logout);
Lucas Dupin0cf5e4a2018-05-02 00:33:17 -0700167 if (mLogoutView != null) {
168 mLogoutView.setOnClickListener(this::onLogoutClicked);
169 }
Alex Chauff7653d2018-02-01 17:18:08 +0000170
Robert Snoebergere3b3e782018-12-17 13:32:15 -0500171 mClockView = findViewById(R.id.keyguard_clock_container);
Selim Cinek9c4a7072014-11-21 17:44:34 +0100172 mClockView.setShowCurrentUserTime(true);
Adrian Roosb670f4b2017-07-20 20:06:54 +0200173 if (KeyguardClockAccessibilityDelegate.isNeeded(mContext)) {
174 mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
175 }
Alan Viverette51efddb2017-04-05 10:00:01 -0400176 mOwnerInfo = findViewById(R.id.owner_info);
Lucas Dupin957e50c2017-10-10 11:23:27 -0700177 mKeyguardSlice = findViewById(R.id.keyguard_status_area);
Lucas Dupin4e023812018-04-02 21:19:23 -0700178 mVisibleInDoze = Sets.newArraySet(mClockView, mKeyguardSlice);
Lucas Dupin76d38e72017-05-13 22:04:22 -0700179 mTextColor = mClockView.getCurrentTextColor();
Adrian Roos9dd16eb2015-01-08 16:20:49 +0100180
Lucas Dupin4e023812018-04-02 21:19:23 -0700181 mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged);
Lucas Dupin3978e6e2018-05-22 18:08:35 -0700182 onSliceContentChanged();
Lucas Dupin6bd86012017-12-05 17:58:57 -0800183
Jorim Jaggi0d210f62015-07-10 14:24:44 -0700184 boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
185 setEnableMarquee(shouldMarquee);
Lucas Dupin08c013e2018-04-26 17:45:14 -0700186 refreshFormat();
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200187 updateOwnerInfo();
Alex Chauff7653d2018-02-01 17:18:08 +0000188 updateLogoutView();
Lucas Dupin4e023812018-04-02 21:19:23 -0700189 updateDark();
Jim Milleredc74ab2012-11-06 21:46:11 -0800190 }
191
Lucas Dupin1a388512018-06-28 11:09:09 -0700192 /**
Lucas Dupinc9d28b72018-10-22 17:59:18 -0700193 * Moves clock, adjusting margins when slice content changes.
Lucas Dupin1a388512018-06-28 11:09:09 -0700194 */
Lucas Dupin3978e6e2018-05-22 18:08:35 -0700195 private void onSliceContentChanged() {
Lucas Dupine570af62019-02-10 14:52:30 -0800196 mClockView.setKeyguardShowingHeader(mKeyguardSlice.hasHeader());
Lucas Dupin6bd86012017-12-05 17:58:57 -0800197 }
198
Jorim Jaggie210cc82014-08-12 23:44:59 +0200199 @Override
Lucas Dupin4e023812018-04-02 21:19:23 -0700200 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
201 super.onLayout(changed, left, top, right, bottom);
Lucas Dupin09952ee2018-06-06 18:19:18 -0700202 layoutOwnerInfo();
Lucas Dupin4e023812018-04-02 21:19:23 -0700203 }
204
205 @Override
206 public void onDensityOrFontScaleChanged() {
Lucas Dupin4e023812018-04-02 21:19:23 -0700207 if (mClockView != null) {
208 mClockView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
209 getResources().getDimensionPixelSize(R.dimen.widget_big_font_size));
210 }
Jorim Jaggiad15b492017-05-30 18:01:49 -0700211 if (mOwnerInfo != null) {
212 mOwnerInfo.setTextSize(TypedValue.COMPLEX_UNIT_PX,
213 getResources().getDimensionPixelSize(R.dimen.widget_label_font_size));
214 }
Jorim Jaggie210cc82014-08-12 23:44:59 +0200215 }
216
Lucas Dupin9fedb892018-05-04 17:42:33 -0700217 public void dozeTimeTick() {
218 refreshTime();
219 mKeyguardSlice.refresh();
Robert Snoebergerffbe3152018-11-08 15:53:27 -0500220 mClockView.dozeTimeTick();
Lucas Dupin9fedb892018-05-04 17:42:33 -0700221 }
222
223 private void refreshTime() {
Lucas Dupinf9583c42018-04-05 22:20:44 -0700224 mClockView.refresh();
Jorim Jaggid09def7512014-09-02 18:36:45 +0200225 }
Jim Miller0c486892013-10-11 16:21:45 -0700226
Robert Snoeberger9c1074f2018-12-07 17:35:21 -0500227 private void updateTimeZone(TimeZone timeZone) {
228 mClockView.onTimeZoneChanged(timeZone);
229 }
230
Lucas Dupin08c013e2018-04-26 17:45:14 -0700231 private void refreshFormat() {
Lucas Dupinca46ae92018-04-02 11:05:09 -0700232 Patterns.update(mContext);
Lucas Dupin08c013e2018-04-26 17:45:14 -0700233 mClockView.setFormat12Hour(Patterns.clockView12);
234 mClockView.setFormat24Hour(Patterns.clockView24);
Jim Milleredc74ab2012-11-06 21:46:11 -0800235 }
236
Alex Chauff7653d2018-02-01 17:18:08 +0000237 public int getLogoutButtonHeight() {
Lucas Dupin0cf5e4a2018-05-02 00:33:17 -0700238 if (mLogoutView == null) {
239 return 0;
240 }
Alex Chauff7653d2018-02-01 17:18:08 +0000241 return mLogoutView.getVisibility() == VISIBLE ? mLogoutView.getHeight() : 0;
Adrian Roosc934c432017-01-13 11:44:56 -0800242 }
243
Lucas Dupin987f1932017-05-13 21:02:52 -0700244 public float getClockTextSize() {
245 return mClockView.getTextSize();
246 }
247
Alex Chauff7653d2018-02-01 17:18:08 +0000248 private void updateLogoutView() {
Lucas Dupin0cf5e4a2018-05-02 00:33:17 -0700249 if (mLogoutView == null) {
250 return;
251 }
Alex Chauff7653d2018-02-01 17:18:08 +0000252 mLogoutView.setVisibility(shouldShowLogout() ? VISIBLE : GONE);
253 // Logout button will stay in language of user 0 if we don't set that manually.
254 mLogoutView.setText(mContext.getResources().getString(
255 com.android.internal.R.string.global_action_logout));
256 }
257
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200258 private void updateOwnerInfo() {
John Spurlock1e6eb172014-07-13 11:59:50 -0400259 if (mOwnerInfo == null) return;
Lucas Dupin4e023812018-04-02 21:19:23 -0700260 String info = mLockPatternUtils.getDeviceOwnerInfo();
261 if (info == null) {
Andrei Stingaceanu04e245b2015-11-12 12:15:56 +0000262 // Use the current user owner information if enabled.
263 final boolean ownerInfoEnabled = mLockPatternUtils.isOwnerInfoEnabled(
264 KeyguardUpdateMonitor.getCurrentUser());
265 if (ownerInfoEnabled) {
266 info = mLockPatternUtils.getOwnerInfo(KeyguardUpdateMonitor.getCurrentUser());
267 }
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200268 }
Lucas Dupin4e023812018-04-02 21:19:23 -0700269 mOwnerInfo.setText(info);
Lucas Dupin43976f82018-10-22 19:52:59 -0700270 updateDark();
Lucas Dupin4e023812018-04-02 21:19:23 -0700271 }
272
273 @Override
274 protected void onAttachedToWindow() {
275 super.onAttachedToWindow();
276 KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mInfoCallback);
277 Dependency.get(ConfigurationController.class).addCallback(this);
278 }
279
280 @Override
281 protected void onDetachedFromWindow() {
282 super.onDetachedFromWindow();
283 KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mInfoCallback);
284 Dependency.get(ConfigurationController.class).removeCallback(this);
Jorim Jaggi93afa1d2014-06-03 20:56:32 +0200285 }
286
Selim Cinekf99d0002014-06-13 07:36:01 +0200287 @Override
Lucas Dupin08c013e2018-04-26 17:45:14 -0700288 public void onLocaleListChanged() {
289 refreshFormat();
290 }
291
292 @Override
Selim Cinekf99d0002014-06-13 07:36:01 +0200293 public boolean hasOverlappingRendering() {
294 return false;
295 }
296
John Spurlock385a63d2013-10-30 19:40:48 -0400297 // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often.
298 // This is an optimization to ensure we only recompute the patterns when the inputs change.
299 private static final class Patterns {
John Spurlock385a63d2013-10-30 19:40:48 -0400300 static String clockView12;
301 static String clockView24;
302 static String cacheKey;
303
Lucas Dupinca46ae92018-04-02 11:05:09 -0700304 static void update(Context context) {
John Spurlock385a63d2013-10-30 19:40:48 -0400305 final Locale locale = Locale.getDefault();
306 final Resources res = context.getResources();
John Spurlock385a63d2013-10-30 19:40:48 -0400307 final String clockView12Skel = res.getString(R.string.clock_12hr_format);
308 final String clockView24Skel = res.getString(R.string.clock_24hr_format);
Lucas Dupinca46ae92018-04-02 11:05:09 -0700309 final String key = locale.toString() + clockView12Skel + clockView24Skel;
John Spurlock385a63d2013-10-30 19:40:48 -0400310 if (key.equals(cacheKey)) return;
311
John Spurlock385a63d2013-10-30 19:40:48 -0400312 clockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel);
313 // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton
314 // format. The following code removes the AM/PM indicator if we didn't want it.
315 if (!clockView12Skel.contains("a")) {
316 clockView12 = clockView12.replaceAll("a", "").trim();
317 }
318
319 clockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel);
320
Jorim Jaggicc12a9d2014-05-26 01:55:29 +0200321 // Use fancy colon.
322 clockView24 = clockView24.replace(':', '\uee01');
323 clockView12 = clockView12.replace(':', '\uee01');
324
John Spurlock385a63d2013-10-30 19:40:48 -0400325 cacheKey = key;
326 }
327 }
Adrian Roos7907ff22017-01-17 15:44:11 -0800328
Lucas Dupin4272f442018-01-13 22:00:35 -0800329 public void setDarkAmount(float darkAmount) {
Lucas Dupin76d38e72017-05-13 22:04:22 -0700330 if (mDarkAmount == darkAmount) {
Adrian Roos52414e32017-04-28 09:23:19 -0700331 return;
332 }
Lucas Dupin76d38e72017-05-13 22:04:22 -0700333 mDarkAmount = darkAmount;
Robert Snoebergere32efd72018-11-12 08:38:34 -0500334 mClockView.setDarkAmount(darkAmount);
Lucas Dupin4e023812018-04-02 21:19:23 -0700335 updateDark();
Adrian Roos7907ff22017-01-17 15:44:11 -0800336 }
Adrian Roosd83e9992017-03-16 15:17:57 -0700337
Lucas Dupin4e023812018-04-02 21:19:23 -0700338 private void updateDark() {
339 boolean dark = mDarkAmount == 1;
Lucas Dupin0cf5e4a2018-05-02 00:33:17 -0700340 if (mLogoutView != null) {
341 mLogoutView.setAlpha(dark ? 0 : 1);
342 }
Lucas Dupin09952ee2018-06-06 18:19:18 -0700343
Lucas Dupin4e023812018-04-02 21:19:23 -0700344 if (mOwnerInfo != null) {
345 boolean hasText = !TextUtils.isEmpty(mOwnerInfo.getText());
Lucas Dupin09952ee2018-06-06 18:19:18 -0700346 mOwnerInfo.setVisibility(hasText ? VISIBLE : GONE);
347 layoutOwnerInfo();
Lucas Dupin4e023812018-04-02 21:19:23 -0700348 }
349
350 final int blendedTextColor = ColorUtils.blendARGB(mTextColor, Color.WHITE, mDarkAmount);
351 updateDozeVisibleViews();
352 mKeyguardSlice.setDarkAmount(mDarkAmount);
353 mClockView.setTextColor(blendedTextColor);
Lucas Dupin4e023812018-04-02 21:19:23 -0700354 }
355
Lucas Dupin09952ee2018-06-06 18:19:18 -0700356 private void layoutOwnerInfo() {
357 if (mOwnerInfo != null && mOwnerInfo.getVisibility() != GONE) {
358 // Animate owner info during wake-up transition
359 mOwnerInfo.setAlpha(1f - mDarkAmount);
360
361 float ratio = mDarkAmount;
362 // Calculate how much of it we should crop in order to have a smooth transition
363 int collapsed = mOwnerInfo.getTop() - mOwnerInfo.getPaddingTop();
364 int expanded = mOwnerInfo.getBottom() + mOwnerInfo.getPaddingBottom();
365 int toRemove = (int) ((expanded - collapsed) * ratio);
366 setBottom(getMeasuredHeight() - toRemove);
367 }
368 }
369
Lucas Dupin00be88f2019-01-03 17:50:52 -0800370 public void setPulsing(boolean pulsing) {
Lucas Dupin2a6bdfd2018-06-12 17:45:21 -0700371 if (mPulsing == pulsing) {
372 return;
373 }
Adrian Roosd83e9992017-03-16 15:17:57 -0700374 mPulsing = pulsing;
375 updateDozeVisibleViews();
376 }
377
378 private void updateDozeVisibleViews() {
379 for (View child : mVisibleInDoze) {
Lucas Dupin76d38e72017-05-13 22:04:22 -0700380 child.setAlpha(mDarkAmount == 1 && mPulsing ? 0.8f : 1);
Adrian Roosd83e9992017-03-16 15:17:57 -0700381 }
382 }
Alex Chauff7653d2018-02-01 17:18:08 +0000383
384 private boolean shouldShowLogout() {
385 return KeyguardUpdateMonitor.getInstance(mContext).isLogoutEnabled()
386 && KeyguardUpdateMonitor.getCurrentUser() != UserHandle.USER_SYSTEM;
387 }
388
389 private void onLogoutClicked(View view) {
390 int currentUserId = KeyguardUpdateMonitor.getCurrentUser();
391 try {
392 mIActivityManager.switchUser(UserHandle.USER_SYSTEM);
393 mIActivityManager.stopUser(currentUserId, true /*force*/, null);
394 } catch (RemoteException re) {
395 Log.e(TAG, "Failed to logout user", re);
396 }
397 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700398}