blob: 0ae8f6c9de5b98361c038b8dc2b3f97cefcca44f [file] [log] [blame]
Anthony Chen54daefe2017-04-07 17:19:54 -07001/*
2 * Copyright (C) 2017 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
17package com.android.systemui.qs;
18
Charles Hece2a7c02017-10-11 20:25:20 +010019import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;
20
Jason Monk7a56b832018-12-27 13:45:51 -050021import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;
22
Anthony Chen54daefe2017-04-07 17:19:54 -070023import android.content.Context;
24import android.content.Intent;
Amin Shaikh50c17892018-03-21 18:15:22 -040025import android.content.pm.UserInfo;
Anthony Chen54daefe2017-04-07 17:19:54 -070026import android.content.res.Configuration;
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -050027import android.database.ContentObserver;
Anthony Chen54daefe2017-04-07 17:19:54 -070028import android.graphics.PorterDuff.Mode;
29import android.graphics.drawable.Drawable;
30import android.graphics.drawable.RippleDrawable;
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -050031import android.net.Uri;
32import android.os.Build;
Amin Shaikh8a3e23c2018-04-17 11:14:32 -040033import android.os.Bundle;
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -050034import android.os.Handler;
35import android.os.UserHandle;
Anthony Chen54daefe2017-04-07 17:19:54 -070036import android.os.UserManager;
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -050037import android.provider.Settings;
Anthony Chen54daefe2017-04-07 17:19:54 -070038import android.util.AttributeSet;
39import android.view.View;
40import android.view.View.OnClickListener;
Amin Shaikh8a3e23c2018-04-17 11:14:32 -040041import android.view.accessibility.AccessibilityNodeInfo;
Anthony Chen54daefe2017-04-07 17:19:54 -070042import android.widget.FrameLayout;
43import android.widget.ImageView;
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -050044import android.widget.TextView;
Anthony Chen54daefe2017-04-07 17:19:54 -070045import android.widget.Toast;
46
Gus Prevasab336792018-11-14 13:52:20 -050047import androidx.annotation.Nullable;
48import androidx.annotation.VisibleForTesting;
49
Anthony Chen54daefe2017-04-07 17:19:54 -070050import com.android.internal.logging.MetricsLogger;
51import com.android.internal.logging.nano.MetricsProto;
Selim Cinek1a891a92017-12-04 17:41:27 +010052import com.android.keyguard.KeyguardUpdateMonitor;
Anthony Chen54daefe2017-04-07 17:19:54 -070053import com.android.settingslib.Utils;
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -050054import com.android.settingslib.development.DevelopmentSettingsEnabler;
Jason Monk826b6092017-08-29 11:30:52 -040055import com.android.settingslib.drawable.UserIconDrawable;
Fabian Kozynskibf6fef32019-02-04 09:21:38 -050056import com.android.systemui.Dependency;
Anthony Chen54daefe2017-04-07 17:19:54 -070057import com.android.systemui.R;
58import com.android.systemui.R.dimen;
Anthony Chen54daefe2017-04-07 17:19:54 -070059import com.android.systemui.plugins.ActivityStarter;
60import com.android.systemui.qs.TouchAnimator.Builder;
Anthony Chen54daefe2017-04-07 17:19:54 -070061import com.android.systemui.statusbar.phone.MultiUserSwitch;
62import com.android.systemui.statusbar.phone.SettingsButton;
63import com.android.systemui.statusbar.policy.DeviceProvisionedController;
Anthony Chen54daefe2017-04-07 17:19:54 -070064import com.android.systemui.statusbar.policy.UserInfoController;
65import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
66import com.android.systemui.tuner.TunerService;
67
Jason Monk7a56b832018-12-27 13:45:51 -050068import javax.inject.Inject;
69import javax.inject.Named;
70
Anthony Chen54daefe2017-04-07 17:19:54 -070071public class QSFooterImpl extends FrameLayout implements QSFooter,
Fabian Kozynskia48d2d02019-02-27 11:36:02 -050072 OnClickListener, OnUserInfoChangedListener {
Fabian Kozynski1823f112019-01-18 11:43:29 -050073
Fabian Kozynski1823f112019-01-18 11:43:29 -050074 private static final String TAG = "QSFooterImpl";
Evan Lairdeb38aa72018-02-02 11:10:30 -050075
Jason Monk7a56b832018-12-27 13:45:51 -050076 private final ActivityStarter mActivityStarter;
77 private final UserInfoController mUserInfoController;
Jason Monk7a56b832018-12-27 13:45:51 -050078 private final DeviceProvisionedController mDeviceProvisionedController;
Anthony Chen54daefe2017-04-07 17:19:54 -070079 private SettingsButton mSettingsButton;
80 protected View mSettingsContainer;
Rohan Shah3090e792018-04-12 00:01:00 -040081 private PageIndicator mPageIndicator;
Anthony Chen54daefe2017-04-07 17:19:54 -070082
Charles Hece2a7c02017-10-11 20:25:20 +010083 private boolean mQsDisabled;
Anthony Chen54daefe2017-04-07 17:19:54 -070084 private QSPanel mQsPanel;
85
86 private boolean mExpanded;
Anthony Chen54daefe2017-04-07 17:19:54 -070087
88 private boolean mListening;
Anthony Chen54daefe2017-04-07 17:19:54 -070089
Amin Shaikhacf322d2018-01-31 17:04:56 -050090 private View mDivider;
Anthony Chen54daefe2017-04-07 17:19:54 -070091 protected MultiUserSwitch mMultiUserSwitch;
92 private ImageView mMultiUserAvatar;
93
Evan Lairdeb38aa72018-02-02 11:10:30 -050094 protected TouchAnimator mFooterAnimator;
Anthony Chen54daefe2017-04-07 17:19:54 -070095 private float mExpansionAmount;
96
97 protected View mEdit;
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -050098 protected View mEditContainer;
Evan Lairdeb38aa72018-02-02 11:10:30 -050099 private TouchAnimator mSettingsCogAnimator;
Anthony Chen54daefe2017-04-07 17:19:54 -0700100
Evan Laird00e43c42018-01-22 20:25:45 -0500101 private View mActionsContainer;
Evan Lairdeb38aa72018-02-02 11:10:30 -0500102 private View mDragHandle;
Fabian Kozynski1823f112019-01-18 11:43:29 -0500103
Amin Shaikh8a3e23c2018-04-17 11:14:32 -0400104 private OnClickListener mExpandClickListener;
Evan Laird00e43c42018-01-22 20:25:45 -0500105
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -0500106 private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(
107 new Handler(mContext.getMainLooper())) {
108 @Override
109 public void onChange(boolean selfChange, Uri uri) {
110 super.onChange(selfChange, uri);
111 setBuildText();
112 }
113 };
114
Jason Monk7a56b832018-12-27 13:45:51 -0500115 @Inject
116 public QSFooterImpl(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
117 ActivityStarter activityStarter, UserInfoController userInfoController,
Jason Monk7a56b832018-12-27 13:45:51 -0500118 DeviceProvisionedController deviceProvisionedController) {
Anthony Chen54daefe2017-04-07 17:19:54 -0700119 super(context, attrs);
Jason Monk7a56b832018-12-27 13:45:51 -0500120 mActivityStarter = activityStarter;
121 mUserInfoController = userInfoController;
Jason Monk7a56b832018-12-27 13:45:51 -0500122 mDeviceProvisionedController = deviceProvisionedController;
Anthony Chen54daefe2017-04-07 17:19:54 -0700123 }
124
Fabian Kozynskibf6fef32019-02-04 09:21:38 -0500125 @VisibleForTesting
126 public QSFooterImpl(Context context, AttributeSet attrs) {
127 this(context, attrs,
128 Dependency.get(ActivityStarter.class),
129 Dependency.get(UserInfoController.class),
Fabian Kozynskibf6fef32019-02-04 09:21:38 -0500130 Dependency.get(DeviceProvisionedController.class));
131 }
132
Anthony Chen54daefe2017-04-07 17:19:54 -0700133 @Override
134 protected void onFinishInflate() {
135 super.onFinishInflate();
Amin Shaikhacf322d2018-01-31 17:04:56 -0500136 mDivider = findViewById(R.id.qs_footer_divider);
Anthony Chen54daefe2017-04-07 17:19:54 -0700137 mEdit = findViewById(android.R.id.edit);
138 mEdit.setOnClickListener(view ->
Jason Monk7a56b832018-12-27 13:45:51 -0500139 mActivityStarter.postQSRunnableDismissingKeyguard(() ->
Anthony Chen54daefe2017-04-07 17:19:54 -0700140 mQsPanel.showEdit(view)));
141
Rohan Shah3090e792018-04-12 00:01:00 -0400142 mPageIndicator = findViewById(R.id.footer_page_indicator);
143
Anthony Chen54daefe2017-04-07 17:19:54 -0700144 mSettingsButton = findViewById(R.id.settings_button);
145 mSettingsContainer = findViewById(R.id.settings_button_container);
146 mSettingsButton.setOnClickListener(this);
147
Anthony Chen54daefe2017-04-07 17:19:54 -0700148 mMultiUserSwitch = findViewById(R.id.multi_user_switch);
149 mMultiUserAvatar = mMultiUserSwitch.findViewById(R.id.multi_user_avatar);
150
Evan Lairdeb38aa72018-02-02 11:10:30 -0500151 mDragHandle = findViewById(R.id.qs_drag_handle_view);
Evan Laird00e43c42018-01-22 20:25:45 -0500152 mActionsContainer = findViewById(R.id.qs_footer_actions_container);
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -0500153 mEditContainer = findViewById(R.id.qs_footer_actions_edit_container);
Evan Laird00e43c42018-01-22 20:25:45 -0500154
Anthony Chen54daefe2017-04-07 17:19:54 -0700155 // RenderThread is doing more harm than good when touching the header (to expand quick
156 // settings), so disable it for this view
157 ((RippleDrawable) mSettingsButton.getBackground()).setForceSoftware(true);
Anthony Chen54daefe2017-04-07 17:19:54 -0700158
159 updateResources();
160
Anthony Chen54daefe2017-04-07 17:19:54 -0700161 addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight,
162 oldBottom) -> updateAnimator(right - left));
Amin Shaikh8a3e23c2018-04-17 11:14:32 -0400163 setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
Fabian Kozynskic99b3792019-02-07 11:15:29 -0500164 updateEverything();
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -0500165 setBuildText();
166 }
167
168 private void setBuildText() {
169 TextView v = findViewById(R.id.build);
170 if (v == null) return;
171 if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)) {
172 v.setText(mContext.getString(
173 com.android.internal.R.string.bugreport_status,
174 Build.VERSION.RELEASE,
175 Build.ID));
176 v.setVisibility(View.VISIBLE);
177 } else {
178 v.setVisibility(View.GONE);
179 }
Anthony Chen54daefe2017-04-07 17:19:54 -0700180 }
181
182 private void updateAnimator(int width) {
183 int numTiles = QuickQSPanel.getNumQuickTiles(mContext);
184 int size = mContext.getResources().getDimensionPixelSize(R.dimen.qs_quick_tile_size)
185 - mContext.getResources().getDimensionPixelSize(dimen.qs_quick_tile_padding);
186 int remaining = (width - numTiles * size) / (numTiles - 1);
187 int defSpace = mContext.getResources().getDimensionPixelOffset(R.dimen.default_gear_space);
188
Evan Lairdeb38aa72018-02-02 11:10:30 -0500189 mSettingsCogAnimator = new Builder()
Jason Monk6dadd3e42017-09-01 09:36:19 -0400190 .addFloat(mSettingsContainer, "translationX",
191 isLayoutRtl() ? (remaining - defSpace) : -(remaining - defSpace), 0)
Anthony Chen54daefe2017-04-07 17:19:54 -0700192 .addFloat(mSettingsButton, "rotation", -120, 0)
193 .build();
Anthony Chen54daefe2017-04-07 17:19:54 -0700194
Anthony Chen54daefe2017-04-07 17:19:54 -0700195 setExpansion(mExpansionAmount);
196 }
197
198 @Override
199 protected void onConfigurationChanged(Configuration newConfig) {
200 super.onConfigurationChanged(newConfig);
201 updateResources();
202 }
203
204 @Override
205 public void onRtlPropertiesChanged(int layoutDirection) {
206 super.onRtlPropertiesChanged(layoutDirection);
207 updateResources();
208 }
209
210 private void updateResources() {
Evan Lairdeb38aa72018-02-02 11:10:30 -0500211 updateFooterAnimator();
Anthony Chen54daefe2017-04-07 17:19:54 -0700212 }
213
Evan Lairdeb38aa72018-02-02 11:10:30 -0500214 private void updateFooterAnimator() {
215 mFooterAnimator = createFooterAnimator();
Anthony Chen54daefe2017-04-07 17:19:54 -0700216 }
217
218 @Nullable
Evan Lairdeb38aa72018-02-02 11:10:30 -0500219 private TouchAnimator createFooterAnimator() {
Anthony Chen54daefe2017-04-07 17:19:54 -0700220 return new TouchAnimator.Builder()
Amin Shaikhacf322d2018-01-31 17:04:56 -0500221 .addFloat(mDivider, "alpha", 0, 1)
Evan Laird00e43c42018-01-22 20:25:45 -0500222 .addFloat(mActionsContainer, "alpha", 0, 1)
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -0500223 .addFloat(mEditContainer, "alpha", 0, 1)
Amin Shaikhd620def2018-02-27 16:52:53 -0500224 .addFloat(mDragHandle, "alpha", 1, 0, 0)
Rohan Shah3090e792018-04-12 00:01:00 -0400225 .addFloat(mPageIndicator, "alpha", 0, 1)
Amin Shaikh92fac562018-02-16 15:08:16 -0500226 .setStartDelay(0.15f)
Anthony Chen54daefe2017-04-07 17:19:54 -0700227 .build();
228 }
229
230 @Override
231 public void setKeyguardShowing(boolean keyguardShowing) {
Anthony Chen54daefe2017-04-07 17:19:54 -0700232 setExpansion(mExpansionAmount);
233 }
234
235 @Override
Amin Shaikh8a3e23c2018-04-17 11:14:32 -0400236 public void setExpandClickListener(OnClickListener onClickListener) {
237 mExpandClickListener = onClickListener;
238 }
239
240 @Override
Anthony Chen54daefe2017-04-07 17:19:54 -0700241 public void setExpanded(boolean expanded) {
242 if (mExpanded == expanded) return;
243 mExpanded = expanded;
244 updateEverything();
245 }
246
247 @Override
Anthony Chen54daefe2017-04-07 17:19:54 -0700248 public void setExpansion(float headerExpansionFraction) {
249 mExpansionAmount = headerExpansionFraction;
Evan Lairdeb38aa72018-02-02 11:10:30 -0500250 if (mSettingsCogAnimator != null) mSettingsCogAnimator.setPosition(headerExpansionFraction);
Anthony Chen54daefe2017-04-07 17:19:54 -0700251
Evan Lairdeb38aa72018-02-02 11:10:30 -0500252 if (mFooterAnimator != null) {
253 mFooterAnimator.setPosition(headerExpansionFraction);
Anthony Chen54daefe2017-04-07 17:19:54 -0700254 }
Anthony Chen54daefe2017-04-07 17:19:54 -0700255 }
256
257 @Override
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -0500258 protected void onAttachedToWindow() {
259 super.onAttachedToWindow();
260 mContext.getContentResolver().registerContentObserver(
261 Settings.Global.getUriFor(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED), false,
262 mDeveloperSettingsObserver, UserHandle.USER_ALL);
263 }
264
265 @Override
Anthony Chen54daefe2017-04-07 17:19:54 -0700266 @VisibleForTesting
267 public void onDetachedFromWindow() {
268 setListening(false);
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -0500269 mContext.getContentResolver().unregisterContentObserver(mDeveloperSettingsObserver);
Anthony Chen54daefe2017-04-07 17:19:54 -0700270 super.onDetachedFromWindow();
271 }
272
Anthony Chen54daefe2017-04-07 17:19:54 -0700273 @Override
274 public void setListening(boolean listening) {
275 if (listening == mListening) {
276 return;
277 }
278 mListening = listening;
279 updateListeners();
280 }
281
282 @Override
Amin Shaikh8a3e23c2018-04-17 11:14:32 -0400283 public boolean performAccessibilityAction(int action, Bundle arguments) {
284 if (action == AccessibilityNodeInfo.ACTION_EXPAND) {
285 if (mExpandClickListener != null) {
286 mExpandClickListener.onClick(null);
287 return true;
288 }
289 }
290 return super.performAccessibilityAction(action, arguments);
291 }
292
293 @Override
294 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
295 super.onInitializeAccessibilityNodeInfo(info);
296 info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
Anthony Chen54daefe2017-04-07 17:19:54 -0700297 }
298
Charles Hece2a7c02017-10-11 20:25:20 +0100299 @Override
300 public void disable(int state1, int state2, boolean animate) {
301 final boolean disabled = (state2 & DISABLE2_QUICK_SETTINGS) != 0;
302 if (disabled == mQsDisabled) return;
303 mQsDisabled = disabled;
304 updateEverything();
305 }
306
Anthony Chen54daefe2017-04-07 17:19:54 -0700307 public void updateEverything() {
308 post(() -> {
309 updateVisibilities();
Fabian Kozynskife90f562019-01-10 10:21:19 -0500310 updateClickabilities();
Anthony Chen54daefe2017-04-07 17:19:54 -0700311 setClickable(false);
312 });
313 }
314
Fabian Kozynskife90f562019-01-10 10:21:19 -0500315 private void updateClickabilities() {
316 mMultiUserSwitch.setClickable(mMultiUserSwitch.getVisibility() == View.VISIBLE);
317 mEdit.setClickable(mEdit.getVisibility() == View.VISIBLE);
318 mSettingsButton.setClickable(mSettingsButton.getVisibility() == View.VISIBLE);
319 }
320
Anthony Chen54daefe2017-04-07 17:19:54 -0700321 private void updateVisibilities() {
Charles Hece2a7c02017-10-11 20:25:20 +0100322 mSettingsContainer.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
Anthony Chen54daefe2017-04-07 17:19:54 -0700323 mSettingsContainer.findViewById(R.id.tuner_icon).setVisibility(
324 TunerService.isTunerEnabled(mContext) ? View.VISIBLE : View.INVISIBLE);
325 final boolean isDemo = UserManager.isDeviceInDemoMode(mContext);
Amin Shaikh50c17892018-03-21 18:15:22 -0400326 mMultiUserSwitch.setVisibility(showUserSwitcher(isDemo) ? View.VISIBLE : View.INVISIBLE);
Fabian Kozynski4e76d1f2019-02-25 16:30:04 -0500327 mEditContainer.setVisibility(isDemo || !mExpanded ? View.INVISIBLE : View.VISIBLE);
Amin Shaikha59215a2018-04-23 08:52:38 -0400328 mSettingsButton.setVisibility(isDemo || !mExpanded ? View.INVISIBLE : View.VISIBLE);
Anthony Chen54daefe2017-04-07 17:19:54 -0700329 }
330
Amin Shaikh50c17892018-03-21 18:15:22 -0400331 private boolean showUserSwitcher(boolean isDemo) {
332 if (!mExpanded || isDemo || !UserManager.supportsMultipleUsers()) {
333 return false;
334 }
335 UserManager userManager = UserManager.get(mContext);
336 if (userManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)) {
337 return false;
338 }
339 int switchableUserCount = 0;
340 for (UserInfo user : userManager.getUsers(true)) {
341 if (user.supportsSwitchToByUser()) {
342 ++switchableUserCount;
343 if (switchableUserCount > 1) {
344 return true;
345 }
346 }
347 }
348 return getResources().getBoolean(R.bool.qs_show_user_switcher_for_single_user);
349 }
350
Anthony Chen54daefe2017-04-07 17:19:54 -0700351 private void updateListeners() {
352 if (mListening) {
Anthony Chen54daefe2017-04-07 17:19:54 -0700353 mUserInfoController.addCallback(this);
Anthony Chen54daefe2017-04-07 17:19:54 -0700354 } else {
Anthony Chen54daefe2017-04-07 17:19:54 -0700355 mUserInfoController.removeCallback(this);
Anthony Chen54daefe2017-04-07 17:19:54 -0700356 }
357 }
358
359 @Override
360 public void setQSPanel(final QSPanel qsPanel) {
361 mQsPanel = qsPanel;
362 if (mQsPanel != null) {
363 mMultiUserSwitch.setQsPanel(qsPanel);
Rohan Shah3090e792018-04-12 00:01:00 -0400364 mQsPanel.setFooterPageIndicator(mPageIndicator);
Anthony Chen54daefe2017-04-07 17:19:54 -0700365 }
366 }
367
368 @Override
369 public void onClick(View v) {
Evan Laird00e43c42018-01-22 20:25:45 -0500370 // Don't do anything until view are unhidden
371 if (!mExpanded) {
372 return;
373 }
374
Anthony Chen54daefe2017-04-07 17:19:54 -0700375 if (v == mSettingsButton) {
Jason Monk7a56b832018-12-27 13:45:51 -0500376 if (!mDeviceProvisionedController.isCurrentUserSetup()) {
Anthony Chen54daefe2017-04-07 17:19:54 -0700377 // If user isn't setup just unlock the device and dump them back at SUW.
Fabian Kozynski1823f112019-01-18 11:43:29 -0500378 mActivityStarter.postQSRunnableDismissingKeyguard(() -> {
379 });
Anthony Chen54daefe2017-04-07 17:19:54 -0700380 return;
381 }
382 MetricsLogger.action(mContext,
383 mExpanded ? MetricsProto.MetricsEvent.ACTION_QS_EXPANDED_SETTINGS_LAUNCH
384 : MetricsProto.MetricsEvent.ACTION_QS_COLLAPSED_SETTINGS_LAUNCH);
385 if (mSettingsButton.isTunerClick()) {
Jason Monk7a56b832018-12-27 13:45:51 -0500386 mActivityStarter.postQSRunnableDismissingKeyguard(() -> {
Anthony Chen54daefe2017-04-07 17:19:54 -0700387 if (TunerService.isTunerEnabled(mContext)) {
388 TunerService.showResetRequest(mContext, () -> {
389 // Relaunch settings so that the tuner disappears.
390 startSettingsActivity();
391 });
392 } else {
393 Toast.makeText(getContext(), R.string.tuner_toast,
394 Toast.LENGTH_LONG).show();
395 TunerService.setTunerEnabled(mContext, true);
396 }
397 startSettingsActivity();
398
399 });
400 } else {
401 startSettingsActivity();
402 }
Anthony Chen54daefe2017-04-07 17:19:54 -0700403 }
404 }
405
406 private void startSettingsActivity() {
407 mActivityStarter.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS),
408 true /* dismissShade */);
409 }
410
411 @Override
Anthony Chen54daefe2017-04-07 17:19:54 -0700412 public void onUserInfoChanged(String name, Drawable picture, String userAccount) {
413 if (picture != null &&
Selim Cinek1a891a92017-12-04 17:41:27 +0100414 UserManager.get(mContext).isGuestUser(KeyguardUpdateMonitor.getCurrentUser()) &&
Jason Monk826b6092017-08-29 11:30:52 -0400415 !(picture instanceof UserIconDrawable)) {
416 picture = picture.getConstantState().newDrawable(mContext.getResources()).mutate();
Anthony Chen54daefe2017-04-07 17:19:54 -0700417 picture.setColorFilter(
Jason Changb4e879d2018-04-11 11:17:58 +0800418 Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorForeground),
Anthony Chen54daefe2017-04-07 17:19:54 -0700419 Mode.SRC_IN);
420 }
421 mMultiUserAvatar.setImageDrawable(picture);
422 }
Anthony Chen54daefe2017-04-07 17:19:54 -0700423}