Jason Monk | aa573e9 | 2017-01-27 17:00: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.statusbar.phone; |
| 16 | |
Evan Laird | 4b68e2f7 | 2018-03-29 18:21:48 -0400 | [diff] [blame] | 17 | import static android.app.StatusBarManager.DISABLE_CLOCK; |
Jason Monk | d3ee70c | 2017-08-30 17:05:24 -0400 | [diff] [blame] | 18 | import static android.app.StatusBarManager.DISABLE_NOTIFICATION_ICONS; |
| 19 | import static android.app.StatusBarManager.DISABLE_SYSTEM_INFO; |
| 20 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 21 | import android.annotation.Nullable; |
| 22 | import android.app.Fragment; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 23 | import android.os.Bundle; |
felkachang | e6c03a0 | 2018-05-24 15:38:04 +0800 | [diff] [blame] | 24 | import android.os.Parcelable; |
| 25 | import android.util.SparseArray; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 26 | import android.view.LayoutInflater; |
| 27 | import android.view.View; |
| 28 | import android.view.ViewGroup; |
Yoshinori Hirano | 2696aa3 | 2017-04-10 20:33:49 +0900 | [diff] [blame] | 29 | import android.view.ViewStub; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 30 | import android.widget.LinearLayout; |
| 31 | |
| 32 | import com.android.systemui.Dependency; |
| 33 | import com.android.systemui.Interpolators; |
| 34 | import com.android.systemui.R; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 35 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 36 | import com.android.systemui.statusbar.CommandQueue; |
Selim Cinek | c7e4cb5 | 2019-06-20 15:41:45 -0700 | [diff] [blame] | 37 | import com.android.systemui.statusbar.StatusBarState; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 38 | import com.android.systemui.statusbar.phone.StatusBarIconController.DarkIconManager; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 39 | import com.android.systemui.statusbar.policy.EncryptionHelper; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 40 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 41 | import com.android.systemui.statusbar.policy.NetworkController; |
Yoshinori Hirano | 2696aa3 | 2017-04-10 20:33:49 +0900 | [diff] [blame] | 42 | import com.android.systemui.statusbar.policy.NetworkController.SignalCallback; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Contains the collapsed status bar and handles hiding/showing based on disable flags |
| 46 | * and keyguard state. Also manages lifecycle to make sure the views it contains are being |
| 47 | * updated by the StatusBarIconController and DarkIconManager while it is attached. |
| 48 | */ |
Lucas Dupin | 2e43cfc | 2018-11-12 14:07:18 -0800 | [diff] [blame] | 49 | public class CollapsedStatusBarFragment extends Fragment implements CommandQueue.Callbacks, |
| 50 | StatusBarStateController.StateListener { |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 51 | |
| 52 | public static final String TAG = "CollapsedStatusBarFragment"; |
Jason Monk | 0a7d9f2 | 2017-03-15 11:03:06 -0400 | [diff] [blame] | 53 | private static final String EXTRA_PANEL_STATE = "panel_state"; |
Evan Laird | 937d9fa | 2018-02-08 10:12:16 -0800 | [diff] [blame] | 54 | public static final String STATUS_BAR_ICON_MANAGER_TAG = "status_bar_icon_manager"; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 55 | public static final int FADE_IN_DURATION = 320; |
| 56 | public static final int FADE_IN_DELAY = 50; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 57 | private PhoneStatusBarView mStatusBar; |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 58 | private StatusBarStateController mStatusBarStateController; |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 59 | private KeyguardStateController mKeyguardStateController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 60 | private NetworkController mNetworkController; |
| 61 | private LinearLayout mSystemIconArea; |
Evan Laird | 2cf5682 | 2017-12-18 11:22:39 -0500 | [diff] [blame] | 62 | private View mClockView; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 63 | private View mNotificationIconAreaInner; |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 64 | private View mCenteredIconArea; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 65 | private int mDisabled1; |
| 66 | private StatusBar mStatusBarComponent; |
| 67 | private DarkIconManager mDarkIconManager; |
Kensuke Matsui | 21d1bf1 | 2017-03-14 13:27:20 +0900 | [diff] [blame] | 68 | private View mOperatorNameFrame; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 69 | private CommandQueue mCommandQueue; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 70 | |
Yoshinori Hirano | 2696aa3 | 2017-04-10 20:33:49 +0900 | [diff] [blame] | 71 | private SignalCallback mSignalCallback = new SignalCallback() { |
| 72 | @Override |
| 73 | public void setIsAirplaneMode(NetworkController.IconState icon) { |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 74 | mCommandQueue.recomputeDisableFlags(getContext().getDisplayId(), true /* animate */); |
Yoshinori Hirano | 2696aa3 | 2017-04-10 20:33:49 +0900 | [diff] [blame] | 75 | } |
| 76 | }; |
| 77 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 78 | @Override |
| 79 | public void onCreate(@Nullable Bundle savedInstanceState) { |
| 80 | super.onCreate(savedInstanceState); |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 81 | mKeyguardStateController = Dependency.get(KeyguardStateController.class); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 82 | mNetworkController = Dependency.get(NetworkController.class); |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 83 | mStatusBarStateController = Dependency.get(StatusBarStateController.class); |
Dave Mankoff | 4dd47fa | 2019-11-07 10:44:48 -0500 | [diff] [blame] | 84 | mStatusBarComponent = Dependency.get(StatusBar.class); |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 85 | mCommandQueue = Dependency.get(CommandQueue.class); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, |
| 90 | Bundle savedInstanceState) { |
| 91 | return inflater.inflate(R.layout.status_bar, container, false); |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 96 | super.onViewCreated(view, savedInstanceState); |
| 97 | mStatusBar = (PhoneStatusBarView) view; |
Jason Monk | 0a7d9f2 | 2017-03-15 11:03:06 -0400 | [diff] [blame] | 98 | if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_PANEL_STATE)) { |
felkachang | e6c03a0 | 2018-05-24 15:38:04 +0800 | [diff] [blame] | 99 | mStatusBar.restoreHierarchyState( |
| 100 | savedInstanceState.getSparseParcelableArray(EXTRA_PANEL_STATE)); |
Jason Monk | 0a7d9f2 | 2017-03-15 11:03:06 -0400 | [diff] [blame] | 101 | } |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 102 | mDarkIconManager = new DarkIconManager(view.findViewById(R.id.statusIcons), |
| 103 | Dependency.get(CommandQueue.class)); |
Evan Laird | 937d9fa | 2018-02-08 10:12:16 -0800 | [diff] [blame] | 104 | mDarkIconManager.setShouldLog(true); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 105 | Dependency.get(StatusBarIconController.class).addIconGroup(mDarkIconManager); |
Jason Monk | 0a7d9f2 | 2017-03-15 11:03:06 -0400 | [diff] [blame] | 106 | mSystemIconArea = mStatusBar.findViewById(R.id.system_icon_area); |
Evan Laird | 2cf5682 | 2017-12-18 11:22:39 -0500 | [diff] [blame] | 107 | mClockView = mStatusBar.findViewById(R.id.clock); |
Jason Monk | 60033fc | 2017-03-24 11:26:35 -0400 | [diff] [blame] | 108 | showSystemIconArea(false); |
Evan Laird | 4b68e2f7 | 2018-03-29 18:21:48 -0400 | [diff] [blame] | 109 | showClock(false); |
Yoshinori Hirano | 2696aa3 | 2017-04-10 20:33:49 +0900 | [diff] [blame] | 110 | initEmergencyCryptkeeperText(); |
Kensuke Matsui | 21d1bf1 | 2017-03-14 13:27:20 +0900 | [diff] [blame] | 111 | initOperatorName(); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | @Override |
Jason Monk | 0a7d9f2 | 2017-03-15 11:03:06 -0400 | [diff] [blame] | 115 | public void onSaveInstanceState(Bundle outState) { |
| 116 | super.onSaveInstanceState(outState); |
felkachang | e6c03a0 | 2018-05-24 15:38:04 +0800 | [diff] [blame] | 117 | SparseArray<Parcelable> states = new SparseArray<>(); |
| 118 | mStatusBar.saveHierarchyState(states); |
| 119 | outState.putSparseParcelableArray(EXTRA_PANEL_STATE, states); |
Jason Monk | 0a7d9f2 | 2017-03-15 11:03:06 -0400 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | @Override |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 123 | public void onResume() { |
| 124 | super.onResume(); |
Jason Monk | d7c9855 | 2018-12-04 11:14:50 -0500 | [diff] [blame] | 125 | mCommandQueue.addCallback(this); |
Jason Monk | af08c15 | 2018-12-04 11:12:39 -0500 | [diff] [blame] | 126 | mStatusBarStateController.addCallback(this); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | @Override |
| 130 | public void onPause() { |
| 131 | super.onPause(); |
Jason Monk | d7c9855 | 2018-12-04 11:14:50 -0500 | [diff] [blame] | 132 | mCommandQueue.removeCallback(this); |
Jason Monk | af08c15 | 2018-12-04 11:12:39 -0500 | [diff] [blame] | 133 | mStatusBarStateController.removeCallback(this); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public void onDestroyView() { |
| 138 | super.onDestroyView(); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 139 | Dependency.get(StatusBarIconController.class).removeIconGroup(mDarkIconManager); |
Yoshinori Hirano | 2696aa3 | 2017-04-10 20:33:49 +0900 | [diff] [blame] | 140 | if (mNetworkController.hasEmergencyCryptKeeperText()) { |
| 141 | mNetworkController.removeCallback(mSignalCallback); |
| 142 | } |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | public void initNotificationIconArea(NotificationIconAreaController |
| 146 | notificationIconAreaController) { |
Jason Monk | 0a7d9f2 | 2017-03-15 11:03:06 -0400 | [diff] [blame] | 147 | ViewGroup notificationIconArea = mStatusBar.findViewById(R.id.notification_icon_area); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 148 | mNotificationIconAreaInner = |
| 149 | notificationIconAreaController.getNotificationInnerAreaView(); |
| 150 | if (mNotificationIconAreaInner.getParent() != null) { |
| 151 | ((ViewGroup) mNotificationIconAreaInner.getParent()) |
| 152 | .removeView(mNotificationIconAreaInner); |
| 153 | } |
| 154 | notificationIconArea.addView(mNotificationIconAreaInner); |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 155 | |
| 156 | ViewGroup statusBarCenteredIconArea = mStatusBar.findViewById(R.id.centered_icon_area); |
| 157 | mCenteredIconArea = notificationIconAreaController.getCenteredNotificationAreaView(); |
| 158 | if (mCenteredIconArea.getParent() != null) { |
| 159 | ((ViewGroup) mCenteredIconArea.getParent()) |
| 160 | .removeView(mCenteredIconArea); |
| 161 | } |
| 162 | statusBarCenteredIconArea.addView(mCenteredIconArea); |
| 163 | |
Jason Monk | 60033fc | 2017-03-24 11:26:35 -0400 | [diff] [blame] | 164 | // Default to showing until we know otherwise. |
| 165 | showNotificationIconArea(false); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | @Override |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 169 | public void disable(int displayId, int state1, int state2, boolean animate) { |
| 170 | if (displayId != getContext().getDisplayId()) { |
| 171 | return; |
| 172 | } |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 173 | state1 = adjustDisableFlags(state1); |
| 174 | final int old1 = mDisabled1; |
| 175 | final int diff1 = state1 ^ old1; |
| 176 | mDisabled1 = state1; |
Jason Monk | d3ee70c | 2017-08-30 17:05:24 -0400 | [diff] [blame] | 177 | if ((diff1 & DISABLE_SYSTEM_INFO) != 0) { |
| 178 | if ((state1 & DISABLE_SYSTEM_INFO) != 0) { |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 179 | hideSystemIconArea(animate); |
Kensuke Matsui | 21d1bf1 | 2017-03-14 13:27:20 +0900 | [diff] [blame] | 180 | hideOperatorName(animate); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 181 | } else { |
| 182 | showSystemIconArea(animate); |
Kensuke Matsui | 21d1bf1 | 2017-03-14 13:27:20 +0900 | [diff] [blame] | 183 | showOperatorName(animate); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 184 | } |
| 185 | } |
Jason Monk | d3ee70c | 2017-08-30 17:05:24 -0400 | [diff] [blame] | 186 | if ((diff1 & DISABLE_NOTIFICATION_ICONS) != 0) { |
| 187 | if ((state1 & DISABLE_NOTIFICATION_ICONS) != 0) { |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 188 | hideNotificationIconArea(animate); |
| 189 | } else { |
| 190 | showNotificationIconArea(animate); |
| 191 | } |
| 192 | } |
Evan Laird | c1f231f | 2018-05-16 19:43:19 -0400 | [diff] [blame] | 193 | // The clock may have already been hidden, but we might want to shift its |
| 194 | // visibility to GONE from INVISIBLE or vice versa |
| 195 | if ((diff1 & DISABLE_CLOCK) != 0 || mClockView.getVisibility() != clockHiddenMode()) { |
Evan Laird | 4b68e2f7 | 2018-03-29 18:21:48 -0400 | [diff] [blame] | 196 | if ((state1 & DISABLE_CLOCK) != 0) { |
| 197 | hideClock(animate); |
| 198 | } else { |
| 199 | showClock(animate); |
| 200 | } |
| 201 | } |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | protected int adjustDisableFlags(int state) { |
Selim Cinek | c7e4cb5 | 2019-06-20 15:41:45 -0700 | [diff] [blame] | 205 | boolean headsUpVisible = mStatusBarComponent.headsUpShouldBeVisible(); |
| 206 | if (headsUpVisible) { |
| 207 | state |= DISABLE_CLOCK; |
| 208 | } |
| 209 | |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 210 | if (!mKeyguardStateController.isLaunchTransitionFadingAway() |
| 211 | && !mKeyguardStateController.isKeyguardFadingAway() |
Selim Cinek | c7e4cb5 | 2019-06-20 15:41:45 -0700 | [diff] [blame] | 212 | && shouldHideNotificationIcons() |
| 213 | && !(mStatusBarStateController.getState() == StatusBarState.KEYGUARD |
| 214 | && headsUpVisible)) { |
Jason Monk | d3ee70c | 2017-08-30 17:05:24 -0400 | [diff] [blame] | 215 | state |= DISABLE_NOTIFICATION_ICONS; |
| 216 | state |= DISABLE_SYSTEM_INFO; |
Evan Laird | 4b68e2f7 | 2018-03-29 18:21:48 -0400 | [diff] [blame] | 217 | state |= DISABLE_CLOCK; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 218 | } |
felkachang | ca4eee8 | 2018-06-29 15:34:28 +0800 | [diff] [blame] | 219 | |
felkachang | ca4eee8 | 2018-06-29 15:34:28 +0800 | [diff] [blame] | 220 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 221 | if (mNetworkController != null && EncryptionHelper.IS_DATA_ENCRYPTED) { |
| 222 | if (mNetworkController.hasEmergencyCryptKeeperText()) { |
Jason Monk | d3ee70c | 2017-08-30 17:05:24 -0400 | [diff] [blame] | 223 | state |= DISABLE_NOTIFICATION_ICONS; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 224 | } |
| 225 | if (!mNetworkController.isRadioOn()) { |
Jason Monk | d3ee70c | 2017-08-30 17:05:24 -0400 | [diff] [blame] | 226 | state |= DISABLE_SYSTEM_INFO; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 227 | } |
| 228 | } |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 229 | |
Lucas Dupin | 7fc9dc1 | 2019-01-03 09:19:43 -0800 | [diff] [blame] | 230 | // The shelf will be hidden when dozing with a custom clock, we must show notification |
| 231 | // icons in this occasion. |
| 232 | if (mStatusBarStateController.isDozing() |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 233 | && mStatusBarComponent.getPanelController().hasCustomClock()) { |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 234 | state |= DISABLE_CLOCK | DISABLE_SYSTEM_INFO; |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 237 | return state; |
| 238 | } |
| 239 | |
| 240 | private boolean shouldHideNotificationIcons() { |
Selim Cinek | 3a49ba2 | 2017-08-10 11:17:39 -0700 | [diff] [blame] | 241 | if (!mStatusBar.isClosed() && mStatusBarComponent.hideStatusBarIconsWhenExpanded()) { |
| 242 | return true; |
| 243 | } |
| 244 | if (mStatusBarComponent.hideStatusBarIconsForBouncer()) { |
| 245 | return true; |
| 246 | } |
| 247 | return false; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | public void hideSystemIconArea(boolean animate) { |
| 251 | animateHide(mSystemIconArea, animate); |
| 252 | } |
| 253 | |
| 254 | public void showSystemIconArea(boolean animate) { |
| 255 | animateShow(mSystemIconArea, animate); |
Evan Laird | 4b68e2f7 | 2018-03-29 18:21:48 -0400 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | public void hideClock(boolean animate) { |
Evan Laird | c1f231f | 2018-05-16 19:43:19 -0400 | [diff] [blame] | 259 | animateHiddenState(mClockView, clockHiddenMode(), animate); |
Evan Laird | 4b68e2f7 | 2018-03-29 18:21:48 -0400 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | public void showClock(boolean animate) { |
Evan Laird | 2cf5682 | 2017-12-18 11:22:39 -0500 | [diff] [blame] | 263 | animateShow(mClockView, animate); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 264 | } |
| 265 | |
Evan Laird | c1f231f | 2018-05-16 19:43:19 -0400 | [diff] [blame] | 266 | /** |
| 267 | * If panel is expanded/expanding it usually means QS shade is opening, so |
| 268 | * don't set the clock GONE otherwise it'll mess up the animation. |
| 269 | */ |
| 270 | private int clockHiddenMode() { |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 271 | if (!mStatusBar.isClosed() && !mKeyguardStateController.isShowing() |
Lucas Dupin | 23a8d3b | 2018-10-08 20:57:35 -0700 | [diff] [blame] | 272 | && !mStatusBarStateController.isDozing()) { |
Evan Laird | c1f231f | 2018-05-16 19:43:19 -0400 | [diff] [blame] | 273 | return View.INVISIBLE; |
| 274 | } |
| 275 | return View.GONE; |
| 276 | } |
| 277 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 278 | public void hideNotificationIconArea(boolean animate) { |
| 279 | animateHide(mNotificationIconAreaInner, animate); |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 280 | animateHide(mCenteredIconArea, animate); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | public void showNotificationIconArea(boolean animate) { |
| 284 | animateShow(mNotificationIconAreaInner, animate); |
Beverly | 4077065 | 2019-02-15 15:49:49 -0500 | [diff] [blame] | 285 | animateShow(mCenteredIconArea, animate); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 286 | } |
| 287 | |
Kensuke Matsui | 21d1bf1 | 2017-03-14 13:27:20 +0900 | [diff] [blame] | 288 | public void hideOperatorName(boolean animate) { |
| 289 | if (mOperatorNameFrame != null) { |
| 290 | animateHide(mOperatorNameFrame, animate); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | public void showOperatorName(boolean animate) { |
| 295 | if (mOperatorNameFrame != null) { |
| 296 | animateShow(mOperatorNameFrame, animate); |
| 297 | } |
| 298 | } |
| 299 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 300 | /** |
Evan Laird | 74435e6 | 2018-05-04 11:58:30 -0400 | [diff] [blame] | 301 | * Animate a view to INVISIBLE or GONE |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 302 | */ |
Evan Laird | 74435e6 | 2018-05-04 11:58:30 -0400 | [diff] [blame] | 303 | private void animateHiddenState(final View v, int state, boolean animate) { |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 304 | v.animate().cancel(); |
| 305 | if (!animate) { |
| 306 | v.setAlpha(0f); |
Evan Laird | 74435e6 | 2018-05-04 11:58:30 -0400 | [diff] [blame] | 307 | v.setVisibility(state); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 308 | return; |
| 309 | } |
Evan Laird | 74435e6 | 2018-05-04 11:58:30 -0400 | [diff] [blame] | 310 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 311 | v.animate() |
| 312 | .alpha(0f) |
| 313 | .setDuration(160) |
| 314 | .setStartDelay(0) |
| 315 | .setInterpolator(Interpolators.ALPHA_OUT) |
Evan Laird | 74435e6 | 2018-05-04 11:58:30 -0400 | [diff] [blame] | 316 | .withEndAction(() -> v.setVisibility(state)); |
| 317 | } |
| 318 | |
| 319 | /** |
| 320 | * Hides a view. |
| 321 | */ |
| 322 | private void animateHide(final View v, boolean animate) { |
| 323 | animateHiddenState(v, View.INVISIBLE, animate); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Shows a view, and synchronizes the animation with Keyguard exit animations, if applicable. |
| 328 | */ |
| 329 | private void animateShow(View v, boolean animate) { |
| 330 | v.animate().cancel(); |
| 331 | v.setVisibility(View.VISIBLE); |
| 332 | if (!animate) { |
| 333 | v.setAlpha(1f); |
| 334 | return; |
| 335 | } |
| 336 | v.animate() |
| 337 | .alpha(1f) |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 338 | .setDuration(FADE_IN_DURATION) |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 339 | .setInterpolator(Interpolators.ALPHA_IN) |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 340 | .setStartDelay(FADE_IN_DELAY) |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 341 | |
| 342 | // We need to clean up any pending end action from animateHide if we call |
| 343 | // both hide and show in the same frame before the animation actually gets started. |
| 344 | // cancel() doesn't really remove the end action. |
| 345 | .withEndAction(null); |
| 346 | |
| 347 | // Synchronize the motion with the Keyguard fading if necessary. |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 348 | if (mKeyguardStateController.isKeyguardFadingAway()) { |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 349 | v.animate() |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 350 | .setDuration(mKeyguardStateController.getKeyguardFadingAwayDuration()) |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 351 | .setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN) |
Lucas Dupin | c8f16e8 | 2019-09-17 18:24:50 -0400 | [diff] [blame] | 352 | .setStartDelay(mKeyguardStateController.getKeyguardFadingAwayDelay()) |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 353 | .start(); |
| 354 | } |
| 355 | } |
Yoshinori Hirano | 2696aa3 | 2017-04-10 20:33:49 +0900 | [diff] [blame] | 356 | |
| 357 | private void initEmergencyCryptkeeperText() { |
| 358 | View emergencyViewStub = mStatusBar.findViewById(R.id.emergency_cryptkeeper_text); |
| 359 | if (mNetworkController.hasEmergencyCryptKeeperText()) { |
| 360 | if (emergencyViewStub != null) { |
| 361 | ((ViewStub) emergencyViewStub).inflate(); |
| 362 | } |
| 363 | mNetworkController.addCallback(mSignalCallback); |
| 364 | } else if (emergencyViewStub != null) { |
| 365 | ViewGroup parent = (ViewGroup) emergencyViewStub.getParent(); |
| 366 | parent.removeView(emergencyViewStub); |
| 367 | } |
| 368 | } |
Kensuke Matsui | 21d1bf1 | 2017-03-14 13:27:20 +0900 | [diff] [blame] | 369 | |
| 370 | private void initOperatorName() { |
| 371 | if (getResources().getBoolean(R.bool.config_showOperatorNameInStatusBar)) { |
| 372 | ViewStub stub = mStatusBar.findViewById(R.id.operator_name); |
| 373 | mOperatorNameFrame = stub.inflate(); |
| 374 | } |
| 375 | } |
Lucas Dupin | 2e43cfc | 2018-11-12 14:07:18 -0800 | [diff] [blame] | 376 | |
| 377 | @Override |
| 378 | public void onStateChanged(int newState) { |
| 379 | |
| 380 | } |
| 381 | |
| 382 | @Override |
| 383 | public void onDozingChanged(boolean isDozing) { |
Charles Chen | f3d295c | 2018-11-30 18:15:21 +0800 | [diff] [blame] | 384 | disable(getContext().getDisplayId(), mDisabled1, mDisabled1, false /* animate */); |
Lucas Dupin | 2e43cfc | 2018-11-12 14:07:18 -0800 | [diff] [blame] | 385 | } |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 386 | } |