Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
Hongwei Wang | 0e62574 | 2019-08-14 14:55:27 -0700 | [diff] [blame] | 19 | import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; |
| 20 | |
Winson Chung | a706700 | 2019-05-07 11:50:42 -0700 | [diff] [blame] | 21 | import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED; |
Winson Chung | a313298 | 2019-04-08 13:27:47 -0700 | [diff] [blame] | 22 | import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED; |
Winson Chung | a706700 | 2019-05-07 11:50:42 -0700 | [diff] [blame] | 23 | import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED; |
Winson Chung | 5b6a1fe | 2019-07-26 16:38:08 -0700 | [diff] [blame] | 24 | import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED; |
Winson Chung | a706700 | 2019-05-07 11:50:42 -0700 | [diff] [blame] | 25 | import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; |
Winson Chung | cb6454e | 2019-07-23 09:58:47 -0700 | [diff] [blame] | 26 | import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SEARCH_DISABLED; |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 27 | import static com.android.systemui.shared.system.QuickStepContract.isGesturalMode; |
Winson Chung | 775d287 | 2019-03-27 14:14:01 -0700 | [diff] [blame] | 28 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE; |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 29 | import static com.android.systemui.util.Utils.isGesturalModeOnDefaultDisplay; |
Winson Chung | c4e0620 | 2018-02-13 10:37:35 -0800 | [diff] [blame] | 30 | |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 31 | import android.animation.LayoutTransition; |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 32 | import android.animation.LayoutTransition.TransitionListener; |
| 33 | import android.animation.ObjectAnimator; |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 34 | import android.animation.PropertyValuesHolder; |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 35 | import android.animation.TimeInterpolator; |
| 36 | import android.animation.ValueAnimator; |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 37 | import android.annotation.DrawableRes; |
Vinit Nayak | d2fe92f | 2020-06-04 13:12:02 -0700 | [diff] [blame] | 38 | import android.annotation.Nullable; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 39 | import android.app.StatusBarManager; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 40 | import android.content.Context; |
Selim Cinek | 17a327a | 2014-08-25 15:03:48 +0200 | [diff] [blame] | 41 | import android.content.res.Configuration; |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 42 | import android.graphics.Canvas; |
Jeff Brown | a8b9def | 2012-07-23 14:22:49 -0700 | [diff] [blame] | 43 | import android.graphics.Point; |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 44 | import android.graphics.Rect; |
Sunny Goyal | aac6c88 | 2019-02-11 11:57:58 -0800 | [diff] [blame] | 45 | import android.graphics.Region; |
| 46 | import android.graphics.Region.Op; |
Matthew Ng | 44b1450 | 2018-05-04 11:10:14 -0700 | [diff] [blame] | 47 | import android.os.Bundle; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 48 | import android.util.AttributeSet; |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 49 | import android.util.Log; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 50 | import android.util.SparseArray; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 51 | import android.view.Display; |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 52 | import android.view.MotionEvent; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 53 | import android.view.Surface; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 54 | import android.view.View; |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 55 | import android.view.ViewGroup; |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 56 | import android.view.ViewTreeObserver.InternalInsetsInfo; |
| 57 | import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; |
Adrian Roos | 7e58a08 | 2018-03-09 16:40:56 +0100 | [diff] [blame] | 58 | import android.view.WindowInsets; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 59 | import android.view.WindowManager; |
Matthew Ng | 44b1450 | 2018-05-04 11:10:14 -0700 | [diff] [blame] | 60 | import android.view.accessibility.AccessibilityNodeInfo; |
| 61 | import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 62 | import android.view.inputmethod.InputMethodManager; |
Jason Monk | 86bc331 | 2016-08-16 13:17:56 -0400 | [diff] [blame] | 63 | import android.widget.FrameLayout; |
Jason Monk | 67e6c80 | 2016-08-30 14:09:21 -0400 | [diff] [blame] | 64 | |
Jeff Chang | 2aaa91a | 2018-11-08 18:04:16 +0800 | [diff] [blame] | 65 | import com.android.internal.annotations.VisibleForTesting; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 66 | import com.android.systemui.Dependency; |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 67 | import com.android.systemui.Interpolators; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 68 | import com.android.systemui.R; |
shawnlin | 2624bec | 2019-10-07 16:43:21 +0800 | [diff] [blame] | 69 | import com.android.systemui.assist.AssistHandleViewController; |
Vinit Nayak | 59b114e6 | 2019-08-12 11:50:00 -0700 | [diff] [blame] | 70 | import com.android.systemui.model.SysUiState; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 71 | import com.android.systemui.recents.OverviewProxyService; |
Matthew Ng | 44b1450 | 2018-05-04 11:10:14 -0700 | [diff] [blame] | 72 | import com.android.systemui.recents.Recents; |
Tony Wickham | 05c1f85 | 2018-02-06 12:32:54 -0800 | [diff] [blame] | 73 | import com.android.systemui.recents.RecentsOnboarding; |
Andy Wickham | 2029701 | 2019-11-06 14:56:26 -0800 | [diff] [blame] | 74 | import com.android.systemui.shared.plugins.PluginManager; |
Matthew Ng | 87cbf34 | 2018-02-15 12:21:18 -0800 | [diff] [blame] | 75 | import com.android.systemui.shared.system.ActivityManagerWrapper; |
Winson Chung | e108b67 | 2019-03-06 16:11:28 -0800 | [diff] [blame] | 76 | import com.android.systemui.shared.system.QuickStepContract; |
Matthew Ng | 84db161 | 2018-04-17 16:48:21 -0700 | [diff] [blame] | 77 | import com.android.systemui.shared.system.WindowManagerWrapper; |
Evan Rosky | af9f27c | 2020-02-18 18:58:35 +0000 | [diff] [blame] | 78 | import com.android.systemui.stackdivider.Divider; |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 79 | import com.android.systemui.statusbar.CommandQueue; |
shawnlin | 2624bec | 2019-10-07 16:43:21 +0800 | [diff] [blame] | 80 | import com.android.systemui.statusbar.NavigationBarController; |
Daniel Sandler | c26185b | 2012-08-29 15:49:53 -0400 | [diff] [blame] | 81 | import com.android.systemui.statusbar.policy.DeadZone; |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 82 | import com.android.systemui.statusbar.policy.KeyButtonDrawable; |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 83 | |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 84 | import java.io.FileDescriptor; |
| 85 | import java.io.PrintWriter; |
Jason Monk | 32e3bb5 | 2017-07-27 12:35:41 -0400 | [diff] [blame] | 86 | import java.util.function.Consumer; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 87 | |
Matthew Ng | e0d5ccd3 | 2019-05-08 15:13:22 -0700 | [diff] [blame] | 88 | public class NavigationBarView extends FrameLayout implements |
Winson Chung | 1aa24b9 | 2019-04-24 15:17:33 -0700 | [diff] [blame] | 89 | NavigationModeController.ModeChangedListener { |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 90 | final static boolean DEBUG = false; |
Adrian Roos | a98b32c | 2016-08-11 10:41:08 -0700 | [diff] [blame] | 91 | final static String TAG = "StatusBar/NavBarView"; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 92 | |
Daniel Sandler | c3fc322 | 2012-10-25 13:28:33 -0400 | [diff] [blame] | 93 | // slippery nav bar when everything is disabled, e.g. during setup |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 94 | final static boolean SLIPPERY_WHEN_DISABLED = true; |
Daniel Sandler | c3fc322 | 2012-10-25 13:28:33 -0400 | [diff] [blame] | 95 | |
Justin Paupore | 01915a1 | 2016-09-28 17:41:26 -0700 | [diff] [blame] | 96 | final static boolean ALTERNATE_CAR_MODE_UI = false; |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 97 | private final RegionSamplingHelper mRegionSamplingHelper; |
| 98 | private final int mNavColorSampleMargin; |
Vinit Nayak | 59b114e6 | 2019-08-12 11:50:00 -0700 | [diff] [blame] | 99 | private final SysUiState mSysUiFlagContainer; |
Andy Wickham | 2029701 | 2019-11-06 14:56:26 -0800 | [diff] [blame] | 100 | private final PluginManager mPluginManager; |
Justin Paupore | 01915a1 | 2016-09-28 17:41:26 -0700 | [diff] [blame] | 101 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 102 | View mCurrentView = null; |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 103 | private View mVertical; |
| 104 | private View mHorizontal; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 105 | |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 106 | /** Indicates that navigation bar is vertical. */ |
| 107 | private boolean mIsVertical; |
Adrian Roos | 090b7d8 | 2016-08-02 18:36:12 -0700 | [diff] [blame] | 108 | private int mCurrentRotation = -1; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 109 | |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 110 | boolean mLongClickableAccessibilityButton; |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 111 | int mDisabledFlags = 0; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 112 | int mNavigationIconHints = 0; |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 113 | private int mNavBarMode; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 114 | |
Winson Chung | c4e0620 | 2018-02-13 10:37:35 -0800 | [diff] [blame] | 115 | private Rect mHomeButtonBounds = new Rect(); |
| 116 | private Rect mBackButtonBounds = new Rect(); |
Matthew Ng | 8a8c89c | 2018-03-01 13:21:43 -0800 | [diff] [blame] | 117 | private Rect mRecentsButtonBounds = new Rect(); |
Winson Chung | 8079af7 | 2018-05-10 11:12:55 -0700 | [diff] [blame] | 118 | private Rect mRotationButtonBounds = new Rect(); |
Sunny Goyal | aac6c88 | 2019-02-11 11:57:58 -0800 | [diff] [blame] | 119 | private final Region mActiveRegion = new Region(); |
Winson Chung | c4e0620 | 2018-02-13 10:37:35 -0800 | [diff] [blame] | 120 | private int[] mTmpPosition = new int[2]; |
| 121 | |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 122 | private KeyButtonDrawable mBackIcon; |
Matthew Ng | ec5b841 | 2018-08-22 10:45:08 -0700 | [diff] [blame] | 123 | private KeyButtonDrawable mHomeDefaultIcon; |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 124 | private KeyButtonDrawable mRecentIcon; |
| 125 | private KeyButtonDrawable mDockedIcon; |
Fabrice Di Meglio | 18d9824 | 2013-01-17 10:57:40 -0800 | [diff] [blame] | 126 | |
Sunny Goyal | 3841295 | 2020-04-17 11:35:37 -0700 | [diff] [blame] | 127 | private EdgeBackGestureHandler mEdgeBackGestureHandler; |
Matthew Ng | 603b329 | 2018-03-30 17:15:39 -0700 | [diff] [blame] | 128 | private final DeadZone mDeadZone; |
Matthew Ng | 1e14e96 | 2018-05-03 12:51:43 -0700 | [diff] [blame] | 129 | private boolean mDeadZoneConsuming = false; |
John Spurlock | 89835dd | 2013-08-16 15:06:51 -0400 | [diff] [blame] | 130 | private final NavigationBarTransitions mBarTransitions; |
Matthew Ng | dc79e5c | 2017-12-14 17:37:35 -0800 | [diff] [blame] | 131 | private final OverviewProxyService mOverviewProxyService; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 132 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 133 | // performs manual animation in sync with layout transitions |
| 134 | private final NavTransitionListener mTransitionListener = new NavTransitionListener(); |
| 135 | |
Jorim Jaggi | f479792 | 2014-08-04 22:49:41 +0200 | [diff] [blame] | 136 | private OnVerticalChangedListener mOnVerticalChangedListener; |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 137 | private boolean mLayoutTransitionsEnabled = true; |
| 138 | private boolean mWakeAndUnlocking; |
Justin Paupore | 01915a1 | 2016-09-28 17:41:26 -0700 | [diff] [blame] | 139 | private boolean mUseCarModeUi = false; |
| 140 | private boolean mInCarMode = false; |
Jorim Jaggi | d30d95d | 2016-02-17 20:27:22 -0800 | [diff] [blame] | 141 | private boolean mDockedStackExists; |
Matthew Ng | f03c3a6 | 2019-04-03 13:52:57 -0700 | [diff] [blame] | 142 | private boolean mImeVisible; |
Jorim Jaggi | f479792 | 2014-08-04 22:49:41 +0200 | [diff] [blame] | 143 | |
Felipe Leme | 15f915c | 2016-10-31 12:47:15 -0700 | [diff] [blame] | 144 | private final SparseArray<ButtonDispatcher> mButtonDispatchers = new SparseArray<>(); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 145 | private final ContextualButtonGroup mContextualButtonGroup; |
Winson | fde2e6a | 2016-03-22 16:03:10 -0700 | [diff] [blame] | 146 | private Configuration mConfiguration; |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 147 | private Configuration mTmpLastConfiguration; |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 148 | |
Adrian Roos | db12b15 | 2016-07-12 15:38:55 -0700 | [diff] [blame] | 149 | private NavigationBarInflaterView mNavigationInflaterView; |
Tony Wickham | 05c1f85 | 2018-02-06 12:32:54 -0800 | [diff] [blame] | 150 | private RecentsOnboarding mRecentsOnboarding; |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 151 | private NotificationPanelViewController mPanelView; |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 152 | private FloatingRotationButton mFloatingRotationButton; |
| 153 | private RotationButtonController mRotationButtonController; |
Adrian Roos | db12b15 | 2016-07-12 15:38:55 -0700 | [diff] [blame] | 154 | |
Matthew Ng | 20136e6 | 2018-05-30 12:20:31 -0700 | [diff] [blame] | 155 | /** |
| 156 | * Helper that is responsible for showing the right toast when a disallowed activity operation |
| 157 | * occurred. In pinned mode, we show instructions on how to break out of this mode, whilst in |
| 158 | * fully locked mode we only show that unlocking is blocked. |
| 159 | */ |
| 160 | private ScreenPinningNotify mScreenPinningNotify; |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 161 | private Rect mSamplingBounds = new Rect(); |
Vinit Nayak | d2fe92f | 2020-06-04 13:12:02 -0700 | [diff] [blame] | 162 | /** |
| 163 | * When quickswitching between apps of different orientations, we draw a secondary home handle |
| 164 | * in the position of the first app's orientation. This rect represents the region of that |
| 165 | * home handle so we can apply the correct light/dark luma on that. |
| 166 | * @see {@link NavigationBarFragment#mOrientationHandle} |
| 167 | */ |
| 168 | @Nullable |
| 169 | private Rect mOrientedHandleSamplingRegion; |
Matthew Ng | 20136e6 | 2018-05-30 12:20:31 -0700 | [diff] [blame] | 170 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 171 | private class NavTransitionListener implements TransitionListener { |
| 172 | private boolean mBackTransitioning; |
| 173 | private boolean mHomeAppearing; |
| 174 | private long mStartDelay; |
| 175 | private long mDuration; |
| 176 | private TimeInterpolator mInterpolator; |
| 177 | |
| 178 | @Override |
| 179 | public void startTransition(LayoutTransition transition, ViewGroup container, |
| 180 | View view, int transitionType) { |
| 181 | if (view.getId() == R.id.back) { |
| 182 | mBackTransitioning = true; |
| 183 | } else if (view.getId() == R.id.home && transitionType == LayoutTransition.APPEARING) { |
| 184 | mHomeAppearing = true; |
| 185 | mStartDelay = transition.getStartDelay(transitionType); |
| 186 | mDuration = transition.getDuration(transitionType); |
| 187 | mInterpolator = transition.getInterpolator(transitionType); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public void endTransition(LayoutTransition transition, ViewGroup container, |
| 193 | View view, int transitionType) { |
| 194 | if (view.getId() == R.id.back) { |
| 195 | mBackTransitioning = false; |
| 196 | } else if (view.getId() == R.id.home && transitionType == LayoutTransition.APPEARING) { |
| 197 | mHomeAppearing = false; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | public void onBackAltCleared() { |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 202 | ButtonDispatcher backButton = getBackButton(); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 203 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 204 | // When dismissing ime during unlock, force the back button to run the same appearance |
| 205 | // animation as home (if we catch this condition early enough). |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 206 | if (!mBackTransitioning && backButton.getVisibility() == VISIBLE |
| 207 | && mHomeAppearing && getHomeButton().getAlpha() == 0) { |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 208 | getBackButton().setAlpha(0); |
Anthony Chen | ada1304 | 2016-01-19 16:57:20 -0800 | [diff] [blame] | 209 | ValueAnimator a = ObjectAnimator.ofFloat(backButton, "alpha", 0, 1); |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 210 | a.setStartDelay(mStartDelay); |
| 211 | a.setDuration(mDuration); |
| 212 | a.setInterpolator(mInterpolator); |
| 213 | a.start(); |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 218 | private final OnClickListener mImeSwitcherClickListener = new OnClickListener() { |
| 219 | @Override |
| 220 | public void onClick(View view) { |
lumark | 0b05f9e | 2018-11-26 15:09:06 +0800 | [diff] [blame] | 221 | mContext.getSystemService(InputMethodManager.class).showInputMethodPickerFromSystem( |
| 222 | true /* showAuxiliarySubtypes */, getContext().getDisplayId()); |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 223 | } |
| 224 | }; |
| 225 | |
Dave Mankoff | 6c64d1f | 2019-11-07 17:27:50 -0500 | [diff] [blame] | 226 | private final AccessibilityDelegate mQuickStepAccessibilityDelegate = |
| 227 | new AccessibilityDelegate() { |
| 228 | private AccessibilityAction mToggleOverviewAction; |
Matthew Ng | 44b1450 | 2018-05-04 11:10:14 -0700 | [diff] [blame] | 229 | |
Dave Mankoff | 6c64d1f | 2019-11-07 17:27:50 -0500 | [diff] [blame] | 230 | @Override |
| 231 | public void onInitializeAccessibilityNodeInfo(View host, |
| 232 | AccessibilityNodeInfo info) { |
| 233 | super.onInitializeAccessibilityNodeInfo(host, info); |
| 234 | if (mToggleOverviewAction == null) { |
| 235 | mToggleOverviewAction = new AccessibilityAction( |
| 236 | R.id.action_toggle_overview, getContext().getString( |
| 237 | R.string.quick_step_accessibility_toggle_overview)); |
| 238 | } |
| 239 | info.addAction(mToggleOverviewAction); |
| 240 | } |
Matthew Ng | 44b1450 | 2018-05-04 11:10:14 -0700 | [diff] [blame] | 241 | |
Dave Mankoff | 6c64d1f | 2019-11-07 17:27:50 -0500 | [diff] [blame] | 242 | @Override |
| 243 | public boolean performAccessibilityAction(View host, int action, Bundle args) { |
| 244 | if (action == R.id.action_toggle_overview) { |
| 245 | Dependency.get(Recents.class).toggleRecentApps(); |
| 246 | } else { |
| 247 | return super.performAccessibilityAction(host, action, args); |
| 248 | } |
| 249 | return true; |
| 250 | } |
| 251 | }; |
Matthew Ng | 44b1450 | 2018-05-04 11:10:14 -0700 | [diff] [blame] | 252 | |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 253 | private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener = info -> { |
| 254 | // When the nav bar is in 2-button or 3-button mode, or when IME is visible in fully |
| 255 | // gestural mode, the entire nav bar should be touchable. |
Sunny Goyal | 3841295 | 2020-04-17 11:35:37 -0700 | [diff] [blame] | 256 | if (!mEdgeBackGestureHandler.isHandlingGestures() || mImeVisible) { |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 257 | info.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_FRAME); |
| 258 | return; |
| 259 | } |
Winson Chung | d882ce1 | 2019-06-05 09:57:01 -0700 | [diff] [blame] | 260 | |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 261 | info.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_REGION); |
Winson Chung | d882ce1 | 2019-06-05 09:57:01 -0700 | [diff] [blame] | 262 | ButtonDispatcher imeSwitchButton = getImeSwitchButton(); |
| 263 | if (imeSwitchButton.getVisibility() == VISIBLE) { |
| 264 | // If the IME is not up, but the ime switch button is visible, then make sure that |
| 265 | // button is touchable |
| 266 | int[] loc = new int[2]; |
| 267 | View buttonView = imeSwitchButton.getCurrentView(); |
| 268 | buttonView.getLocationInWindow(loc); |
| 269 | info.touchableRegion.set(loc[0], loc[1], loc[0] + buttonView.getWidth(), |
| 270 | loc[1] + buttonView.getHeight()); |
| 271 | return; |
| 272 | } |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 273 | info.touchableRegion.setEmpty(); |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 274 | }; |
| 275 | |
John Spurlock | e932e30 | 2013-08-12 10:16:29 -0400 | [diff] [blame] | 276 | public NavigationBarView(Context context, AttributeSet attrs) { |
| 277 | super(context, attrs); |
| 278 | |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 279 | mIsVertical = false; |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 280 | mLongClickableAccessibilityButton = false; |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 281 | mNavBarMode = Dependency.get(NavigationModeController.class).addListener(this); |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 282 | boolean isGesturalMode = isGesturalMode(mNavBarMode); |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 283 | |
Vinit Nayak | 59b114e6 | 2019-08-12 11:50:00 -0700 | [diff] [blame] | 284 | mSysUiFlagContainer = Dependency.get(SysUiState.class); |
Andy Wickham | 2029701 | 2019-11-06 14:56:26 -0800 | [diff] [blame] | 285 | mPluginManager = Dependency.get(PluginManager.class); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 286 | // Set up the context group of buttons |
| 287 | mContextualButtonGroup = new ContextualButtonGroup(R.id.menu_container); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 288 | final ContextualButton imeSwitcherButton = new ContextualButton(R.id.ime_switcher, |
| 289 | R.drawable.ic_ime_switcher_default); |
| 290 | final RotationContextButton rotateSuggestionButton = new RotationContextButton( |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 291 | R.id.rotate_suggestion, R.drawable.ic_sysbar_rotate_button); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 292 | final ContextualButton accessibilityButton = |
| 293 | new ContextualButton(R.id.accessibility_button, |
| 294 | R.drawable.ic_sysbar_accessibility_button); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 295 | mContextualButtonGroup.addButton(imeSwitcherButton); |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 296 | if (!isGesturalMode) { |
| 297 | mContextualButtonGroup.addButton(rotateSuggestionButton); |
| 298 | } |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 299 | mContextualButtonGroup.addButton(accessibilityButton); |
| 300 | |
Matthew Ng | f294654 | 2018-02-12 14:13:18 -0800 | [diff] [blame] | 301 | mOverviewProxyService = Dependency.get(OverviewProxyService.class); |
| 302 | mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService); |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 303 | mFloatingRotationButton = new FloatingRotationButton(context); |
| 304 | mRotationButtonController = new RotationButtonController(context, |
| 305 | R.style.RotateButtonCCWStart90, |
| 306 | isGesturalMode ? mFloatingRotationButton : rotateSuggestionButton); |
Matthew Ng | f294654 | 2018-02-12 14:13:18 -0800 | [diff] [blame] | 307 | |
Winson | fde2e6a | 2016-03-22 16:03:10 -0700 | [diff] [blame] | 308 | mConfiguration = new Configuration(); |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 309 | mTmpLastConfiguration = new Configuration(); |
Winson | fde2e6a | 2016-03-22 16:03:10 -0700 | [diff] [blame] | 310 | mConfiguration.updateFrom(context.getResources().getConfiguration()); |
John Spurlock | e932e30 | 2013-08-12 10:16:29 -0400 | [diff] [blame] | 311 | |
Matthew Ng | 20136e6 | 2018-05-30 12:20:31 -0700 | [diff] [blame] | 312 | mScreenPinningNotify = new ScreenPinningNotify(mContext); |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 313 | mBarTransitions = new NavigationBarTransitions(this, Dependency.get(CommandQueue.class)); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 314 | |
Sunny Goyal | 3841295 | 2020-04-17 11:35:37 -0700 | [diff] [blame] | 315 | mButtonDispatchers.put(R.id.back, new ButtonDispatcher(R.id.back)); |
Felipe Leme | 15f915c | 2016-10-31 12:47:15 -0700 | [diff] [blame] | 316 | mButtonDispatchers.put(R.id.home, new ButtonDispatcher(R.id.home)); |
Matthew Ng | b55c02c | 2019-02-15 16:20:31 -0800 | [diff] [blame] | 317 | mButtonDispatchers.put(R.id.home_handle, new ButtonDispatcher(R.id.home_handle)); |
Felipe Leme | 15f915c | 2016-10-31 12:47:15 -0700 | [diff] [blame] | 318 | mButtonDispatchers.put(R.id.recent_apps, new ButtonDispatcher(R.id.recent_apps)); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 319 | mButtonDispatchers.put(R.id.ime_switcher, imeSwitcherButton); |
| 320 | mButtonDispatchers.put(R.id.accessibility_button, accessibilityButton); |
| 321 | mButtonDispatchers.put(R.id.rotate_suggestion, rotateSuggestionButton); |
| 322 | mButtonDispatchers.put(R.id.menu_container, mContextualButtonGroup); |
Matthew Ng | 603b329 | 2018-03-30 17:15:39 -0700 | [diff] [blame] | 323 | mDeadZone = new DeadZone(this); |
Matthew Ng | 86a436e | 2018-10-26 16:00:53 -0700 | [diff] [blame] | 324 | |
Vinit Nayak | 59b114e6 | 2019-08-12 11:50:00 -0700 | [diff] [blame] | 325 | mNavColorSampleMargin = getResources() |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 326 | .getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin); |
Andy Wickham | 2029701 | 2019-11-06 14:56:26 -0800 | [diff] [blame] | 327 | mEdgeBackGestureHandler = new EdgeBackGestureHandler( |
| 328 | context, mOverviewProxyService, mSysUiFlagContainer, mPluginManager); |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 329 | mRegionSamplingHelper = new RegionSamplingHelper(this, |
| 330 | new RegionSamplingHelper.SamplingCallback() { |
| 331 | @Override |
| 332 | public void onRegionDarknessChanged(boolean isRegionDark) { |
| 333 | getLightTransitionsController().setIconsDark(!isRegionDark , |
| 334 | true /* animate */); |
| 335 | } |
| 336 | |
| 337 | @Override |
| 338 | public Rect getSampledRegion(View sampledView) { |
Vinit Nayak | d2fe92f | 2020-06-04 13:12:02 -0700 | [diff] [blame] | 339 | if (mOrientedHandleSamplingRegion != null) { |
| 340 | return mOrientedHandleSamplingRegion; |
| 341 | } |
| 342 | |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 343 | updateSamplingRect(); |
| 344 | return mSamplingBounds; |
| 345 | } |
| 346 | |
| 347 | @Override |
| 348 | public boolean isSamplingEnabled() { |
| 349 | return isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode); |
| 350 | } |
| 351 | }); |
John Spurlock | e932e30 | 2013-08-12 10:16:29 -0400 | [diff] [blame] | 352 | } |
| 353 | |
James O'Leary | 4335c70 | 2019-05-29 12:38:51 -0400 | [diff] [blame] | 354 | public NavigationBarTransitions getBarTransitions() { |
John Spurlock | e932e30 | 2013-08-12 10:16:29 -0400 | [diff] [blame] | 355 | return mBarTransitions; |
| 356 | } |
| 357 | |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 358 | public LightBarTransitionsController getLightTransitionsController() { |
| 359 | return mBarTransitions.getLightTransitionsController(); |
| 360 | } |
| 361 | |
Dave Mankoff | af8163f | 2020-01-08 14:24:35 -0500 | [diff] [blame] | 362 | public void setComponents(NotificationPanelViewController panel) { |
Matthew Ng | 78f88d1 | 2018-01-23 12:39:55 -0800 | [diff] [blame] | 363 | mPanelView = panel; |
Winson Chung | 56a667b | 2019-07-30 13:51:27 -0700 | [diff] [blame] | 364 | updatePanelSystemUiStateFlags(); |
Matthew Ng | 1cf6eac | 2018-11-27 15:06:55 -0800 | [diff] [blame] | 365 | } |
| 366 | |
Jorim Jaggi | f479792 | 2014-08-04 22:49:41 +0200 | [diff] [blame] | 367 | public void setOnVerticalChangedListener(OnVerticalChangedListener onVerticalChangedListener) { |
| 368 | mOnVerticalChangedListener = onVerticalChangedListener; |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 369 | notifyVerticalChangedListener(mIsVertical); |
Jorim Jaggi | f479792 | 2014-08-04 22:49:41 +0200 | [diff] [blame] | 370 | } |
| 371 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 372 | @Override |
| 373 | public boolean onInterceptTouchEvent(MotionEvent event) { |
Sunny Goyal | a6a5812 | 2019-04-02 10:20:29 -0700 | [diff] [blame] | 374 | return shouldDeadZoneConsumeTouchEvents(event) || super.onInterceptTouchEvent(event); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Winson Chung | 4faf38a | 2018-02-06 08:53:37 -0800 | [diff] [blame] | 377 | @Override |
| 378 | public boolean onTouchEvent(MotionEvent event) { |
Matthew Ng | 472d3e4 | 2018-06-14 15:16:55 -0700 | [diff] [blame] | 379 | shouldDeadZoneConsumeTouchEvents(event); |
Winson Chung | 4965884 | 2018-02-08 12:52:21 -0800 | [diff] [blame] | 380 | return super.onTouchEvent(event); |
Winson Chung | 4faf38a | 2018-02-06 08:53:37 -0800 | [diff] [blame] | 381 | } |
| 382 | |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 383 | void onTransientStateChanged(boolean isTransient) { |
| 384 | mEdgeBackGestureHandler.onNavBarTransientStateChanged(isTransient); |
Winson Chung | 3d6c080 | 2019-10-04 10:37:12 -0700 | [diff] [blame] | 385 | } |
| 386 | |
Winson Chung | 775d287 | 2019-03-27 14:14:01 -0700 | [diff] [blame] | 387 | void onBarTransition(int newMode) { |
| 388 | if (newMode == MODE_OPAQUE) { |
| 389 | // If the nav bar background is opaque, stop auto tinting since we know the icons are |
| 390 | // showing over a dark background |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 391 | mRegionSamplingHelper.stop(); |
Winson Chung | 775d287 | 2019-03-27 14:14:01 -0700 | [diff] [blame] | 392 | getLightTransitionsController().setIconsDark(false /* dark */, true /* animate */); |
| 393 | } else { |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 394 | mRegionSamplingHelper.start(mSamplingBounds); |
Winson Chung | 775d287 | 2019-03-27 14:14:01 -0700 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | |
Matthew Ng | 1e14e96 | 2018-05-03 12:51:43 -0700 | [diff] [blame] | 398 | private boolean shouldDeadZoneConsumeTouchEvents(MotionEvent event) { |
Sunny Goyal | a6a5812 | 2019-04-02 10:20:29 -0700 | [diff] [blame] | 399 | int action = event.getActionMasked(); |
| 400 | if (action == MotionEvent.ACTION_DOWN) { |
| 401 | mDeadZoneConsuming = false; |
| 402 | } |
Matthew Ng | 1e14e96 | 2018-05-03 12:51:43 -0700 | [diff] [blame] | 403 | if (mDeadZone.onTouchEvent(event) || mDeadZoneConsuming) { |
Sunny Goyal | a6a5812 | 2019-04-02 10:20:29 -0700 | [diff] [blame] | 404 | switch (action) { |
Matthew Ng | 1e14e96 | 2018-05-03 12:51:43 -0700 | [diff] [blame] | 405 | case MotionEvent.ACTION_DOWN: |
| 406 | // Allow gestures starting in the deadzone to be slippery |
| 407 | setSlippery(true); |
| 408 | mDeadZoneConsuming = true; |
| 409 | break; |
| 410 | case MotionEvent.ACTION_CANCEL: |
| 411 | case MotionEvent.ACTION_UP: |
| 412 | // When a gesture started in the deadzone is finished, restore slippery state |
| 413 | updateSlippery(); |
| 414 | mDeadZoneConsuming = false; |
| 415 | break; |
| 416 | } |
| 417 | return true; |
| 418 | } |
| 419 | return false; |
| 420 | } |
| 421 | |
Xiyuan Xia | ee7dd05 | 2015-05-15 09:46:27 -0700 | [diff] [blame] | 422 | public void abortCurrentGesture() { |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 423 | getHomeButton().abortCurrentGesture(); |
Xiyuan Xia | ee7dd05 | 2015-05-15 09:46:27 -0700 | [diff] [blame] | 424 | } |
| 425 | |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 426 | public View getCurrentView() { |
| 427 | return mCurrentView; |
| 428 | } |
| 429 | |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 430 | public RotationButtonController getRotationButtonController() { |
| 431 | return mRotationButtonController; |
| 432 | } |
| 433 | |
| 434 | public FloatingRotationButton getFloatingRotationButton() { |
| 435 | return mFloatingRotationButton; |
| 436 | } |
| 437 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 438 | public ButtonDispatcher getRecentsButton() { |
Felipe Leme | 15f915c | 2016-10-31 12:47:15 -0700 | [diff] [blame] | 439 | return mButtonDispatchers.get(R.id.recent_apps); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 440 | } |
| 441 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 442 | public ButtonDispatcher getBackButton() { |
Felipe Leme | 15f915c | 2016-10-31 12:47:15 -0700 | [diff] [blame] | 443 | return mButtonDispatchers.get(R.id.back); |
Mike Lockwood | e3646dd | 2011-09-01 12:46:28 -0400 | [diff] [blame] | 444 | } |
| 445 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 446 | public ButtonDispatcher getHomeButton() { |
Felipe Leme | 15f915c | 2016-10-31 12:47:15 -0700 | [diff] [blame] | 447 | return mButtonDispatchers.get(R.id.home); |
Mike Lockwood | e3646dd | 2011-09-01 12:46:28 -0400 | [diff] [blame] | 448 | } |
| 449 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 450 | public ButtonDispatcher getImeSwitchButton() { |
Felipe Leme | 15f915c | 2016-10-31 12:47:15 -0700 | [diff] [blame] | 451 | return mButtonDispatchers.get(R.id.ime_switcher); |
Jason Monk | f1ff209 | 2014-04-29 16:50:53 -0400 | [diff] [blame] | 452 | } |
| 453 | |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 454 | public ButtonDispatcher getAccessibilityButton() { |
| 455 | return mButtonDispatchers.get(R.id.accessibility_button); |
| 456 | } |
| 457 | |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 458 | public RotationContextButton getRotateSuggestionButton() { |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 459 | return (RotationContextButton) mButtonDispatchers.get(R.id.rotate_suggestion); |
| 460 | } |
| 461 | |
Matthew Ng | b55c02c | 2019-02-15 16:20:31 -0800 | [diff] [blame] | 462 | public ButtonDispatcher getHomeHandle() { |
| 463 | return mButtonDispatchers.get(R.id.home_handle); |
| 464 | } |
| 465 | |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 466 | public SparseArray<ButtonDispatcher> getButtonDispatchers() { |
| 467 | return mButtonDispatchers; |
| 468 | } |
| 469 | |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 470 | public boolean isRecentsButtonVisible() { |
| 471 | return getRecentsButton().getVisibility() == View.VISIBLE; |
| 472 | } |
| 473 | |
Matthew Ng | 6ff33b7 | 2018-02-27 13:47:38 -0800 | [diff] [blame] | 474 | public boolean isOverviewEnabled() { |
| 475 | return (mDisabledFlags & View.STATUS_BAR_DISABLE_RECENT) == 0; |
| 476 | } |
| 477 | |
Matthew Ng | 8f25fb96 | 2018-01-16 17:17:24 -0800 | [diff] [blame] | 478 | public boolean isQuickStepSwipeUpEnabled() { |
Matthew Ng | c1a97b1 | 2018-03-28 14:02:00 -0700 | [diff] [blame] | 479 | return mOverviewProxyService.shouldShowSwipeUpUI() && isOverviewEnabled(); |
Matthew Ng | 8f25fb96 | 2018-01-16 17:17:24 -0800 | [diff] [blame] | 480 | } |
| 481 | |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 482 | private void reloadNavIcons() { |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 483 | updateIcons(Configuration.EMPTY); |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 484 | } |
| 485 | |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 486 | private void updateIcons(Configuration oldConfig) { |
| 487 | final boolean orientationChange = oldConfig.orientation != mConfiguration.orientation; |
| 488 | final boolean densityChange = oldConfig.densityDpi != mConfiguration.densityDpi; |
| 489 | final boolean dirChange = oldConfig.getLayoutDirection() != mConfiguration.getLayoutDirection(); |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 490 | |
| 491 | if (orientationChange || densityChange) { |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 492 | mDockedIcon = getDrawable(R.drawable.ic_sysbar_docked); |
| 493 | mHomeDefaultIcon = getHomeDrawable(); |
Winson | fde2e6a | 2016-03-22 16:03:10 -0700 | [diff] [blame] | 494 | } |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 495 | if (densityChange || dirChange) { |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 496 | mRecentIcon = getDrawable(R.drawable.ic_sysbar_recent); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 497 | mContextualButtonGroup.updateIcons(); |
Winson | fde2e6a | 2016-03-22 16:03:10 -0700 | [diff] [blame] | 498 | } |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 499 | if (orientationChange || densityChange || dirChange) { |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 500 | mBackIcon = getBackDrawable(); |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 501 | } |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 504 | public KeyButtonDrawable getBackDrawable() { |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 505 | KeyButtonDrawable drawable = getDrawable(getBackDrawableRes()); |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 506 | orientBackButton(drawable); |
| 507 | return drawable; |
Matthew Ng | 87cbf34 | 2018-02-15 12:21:18 -0800 | [diff] [blame] | 508 | } |
| 509 | |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 510 | public @DrawableRes int getBackDrawableRes() { |
| 511 | return chooseNavigationIconDrawableRes(R.drawable.ic_sysbar_back, |
| 512 | R.drawable.ic_sysbar_back_quick_step); |
| 513 | } |
| 514 | |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 515 | public KeyButtonDrawable getHomeDrawable() { |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 516 | final boolean quickStepEnabled = mOverviewProxyService.shouldShowSwipeUpUI(); |
| 517 | KeyButtonDrawable drawable = quickStepEnabled |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 518 | ? getDrawable(R.drawable.ic_sysbar_home_quick_step) |
| 519 | : getDrawable(R.drawable.ic_sysbar_home); |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 520 | orientHomeButton(drawable); |
| 521 | return drawable; |
Matthew Ng | 87cbf34 | 2018-02-15 12:21:18 -0800 | [diff] [blame] | 522 | } |
| 523 | |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 524 | private void orientBackButton(KeyButtonDrawable drawable) { |
| 525 | final boolean useAltBack = |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 526 | (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0; |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 527 | final boolean isRtl = mConfiguration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; |
Matthew Ng | d04bd0f | 2019-04-08 17:29:45 -0700 | [diff] [blame] | 528 | float degrees = useAltBack ? (isRtl ? 90 : -90) : 0; |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 529 | if (drawable.getRotation() == degrees) { |
| 530 | return; |
| 531 | } |
| 532 | |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 533 | if (isGesturalMode(mNavBarMode)) { |
Matthew Ng | f03c3a6 | 2019-04-03 13:52:57 -0700 | [diff] [blame] | 534 | drawable.setRotation(degrees); |
| 535 | return; |
| 536 | } |
| 537 | |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 538 | // Animate the back button's rotation to the new degrees and only in portrait move up the |
| 539 | // back button to line up with the other buttons |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 540 | float targetY = !mOverviewProxyService.shouldShowSwipeUpUI() && !mIsVertical && useAltBack |
Matthew Ng | ca4592b | 2018-08-06 14:12:37 -0700 | [diff] [blame] | 541 | ? - getResources().getDimension(R.dimen.navbar_back_button_ime_offset) |
| 542 | : 0; |
| 543 | ObjectAnimator navBarAnimator = ObjectAnimator.ofPropertyValuesHolder(drawable, |
| 544 | PropertyValuesHolder.ofFloat(KeyButtonDrawable.KEY_DRAWABLE_ROTATE, degrees), |
| 545 | PropertyValuesHolder.ofFloat(KeyButtonDrawable.KEY_DRAWABLE_TRANSLATE_Y, targetY)); |
| 546 | navBarAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); |
| 547 | navBarAnimator.setDuration(200); |
| 548 | navBarAnimator.start(); |
Matthew Ng | 87cbf34 | 2018-02-15 12:21:18 -0800 | [diff] [blame] | 549 | } |
| 550 | |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 551 | private void orientHomeButton(KeyButtonDrawable drawable) { |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 552 | drawable.setRotation(mIsVertical ? 90 : 0); |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 553 | } |
| 554 | |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 555 | private KeyButtonDrawable chooseNavigationIconDrawable(@DrawableRes int icon, |
| 556 | @DrawableRes int quickStepIcon) { |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 557 | return getDrawable(chooseNavigationIconDrawableRes(icon, quickStepIcon)); |
| 558 | } |
| 559 | |
| 560 | private @DrawableRes int chooseNavigationIconDrawableRes(@DrawableRes int icon, |
| 561 | @DrawableRes int quickStepIcon) { |
Matthew Ng | c1a97b1 | 2018-03-28 14:02:00 -0700 | [diff] [blame] | 562 | final boolean quickStepEnabled = mOverviewProxyService.shouldShowSwipeUpUI(); |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 563 | return quickStepEnabled ? quickStepIcon : icon; |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 564 | } |
| 565 | |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 566 | private KeyButtonDrawable getDrawable(@DrawableRes int icon) { |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 567 | return KeyButtonDrawable.create(mContext, icon, true /* hasShadow */); |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 568 | } |
| 569 | |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 570 | private KeyButtonDrawable getDrawable(@DrawableRes int icon, boolean hasShadow) { |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 571 | return KeyButtonDrawable.create(mContext, icon, hasShadow); |
Mike Digman | 7d09277 | 2018-01-11 12:10:32 -0800 | [diff] [blame] | 572 | } |
| 573 | |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 574 | /** To be called when screen lock/unlock state changes */ |
| 575 | public void onScreenStateChanged(boolean isScreenOn) { |
| 576 | if (isScreenOn) { |
| 577 | if (isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode)) { |
| 578 | mRegionSamplingHelper.start(mSamplingBounds); |
| 579 | } |
| 580 | } else { |
| 581 | mRegionSamplingHelper.stop(); |
| 582 | } |
| 583 | } |
| 584 | |
Winson Chung | 2102ae8 | 2019-06-19 13:15:24 -0700 | [diff] [blame] | 585 | public void setWindowVisible(boolean visible) { |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 586 | mRegionSamplingHelper.setWindowVisible(visible); |
Winson Chung | 2102ae8 | 2019-06-19 13:15:24 -0700 | [diff] [blame] | 587 | mRotationButtonController.onNavigationBarWindowVisibilityChange(visible); |
| 588 | } |
| 589 | |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 590 | @Override |
| 591 | public void setLayoutDirection(int layoutDirection) { |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 592 | reloadNavIcons(); |
Fabrice Di Meglio | 8afcd14 | 2012-07-27 18:27:11 -0700 | [diff] [blame] | 593 | |
| 594 | super.setLayoutDirection(layoutDirection); |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 595 | } |
| 596 | |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 597 | public void setNavigationIconHints(int hints) { |
| 598 | if (hints == mNavigationIconHints) return; |
Matthew Ng | 691d558 | 2019-04-04 14:59:17 -0700 | [diff] [blame] | 599 | final boolean newBackAlt = (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0; |
| 600 | final boolean oldBackAlt = |
| 601 | (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0; |
| 602 | if (newBackAlt != oldBackAlt) { |
| 603 | onImeVisibilityChanged(newBackAlt); |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 604 | } |
Matthew Ng | 691d558 | 2019-04-04 14:59:17 -0700 | [diff] [blame] | 605 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 606 | if (DEBUG) { |
John Spurlock | 0153478 | 2014-01-13 11:59:22 -0500 | [diff] [blame] | 607 | android.widget.Toast.makeText(getContext(), |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 608 | "Navigation icon hints = " + hints, |
| 609 | 500).show(); |
| 610 | } |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 611 | mNavigationIconHints = hints; |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 612 | updateNavButtonIcons(); |
| 613 | } |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 614 | |
Matthew Ng | 691d558 | 2019-04-04 14:59:17 -0700 | [diff] [blame] | 615 | private void onImeVisibilityChanged(boolean visible) { |
| 616 | if (!visible) { |
| 617 | mTransitionListener.onBackAltCleared(); |
| 618 | } |
| 619 | mImeVisible = visible; |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 620 | mRotationButtonController.getRotationButton().setCanShowRotationButton(!mImeVisible); |
Matthew Ng | 691d558 | 2019-04-04 14:59:17 -0700 | [diff] [blame] | 621 | } |
| 622 | |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 623 | public void setDisabledFlags(int disabledFlags) { |
| 624 | if (mDisabledFlags == disabledFlags) return; |
| 625 | |
| 626 | final boolean overviewEnabledBefore = isOverviewEnabled(); |
| 627 | mDisabledFlags = disabledFlags; |
| 628 | |
| 629 | // Update icons if overview was just enabled to ensure the correct icons are present |
| 630 | if (!overviewEnabledBefore && isOverviewEnabled()) { |
| 631 | reloadNavIcons(); |
| 632 | } |
| 633 | |
| 634 | updateNavButtonIcons(); |
Winson Chung | 1be4c7e | 2018-05-23 18:24:13 -0700 | [diff] [blame] | 635 | updateSlippery(); |
Tracy Zhou | 9814091 | 2018-06-05 12:09:14 -0700 | [diff] [blame] | 636 | setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled()); |
Winson Chung | 56a667b | 2019-07-30 13:51:27 -0700 | [diff] [blame] | 637 | updateDisabledSystemUiStateFlags(); |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | public void updateNavButtonIcons() { |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 641 | // We have to replace or restore the back and home button icons when exiting or entering |
| 642 | // carmode, respectively. Recents are not available in CarMode in nav bar so change |
| 643 | // to recent icon is not required. |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 644 | final boolean useAltBack = |
| 645 | (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0; |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 646 | KeyButtonDrawable backIcon = mBackIcon; |
Matthew Ng | ec5b841 | 2018-08-22 10:45:08 -0700 | [diff] [blame] | 647 | orientBackButton(backIcon); |
Matthew Ng | d6865ba | 2018-08-27 17:58:41 -0700 | [diff] [blame] | 648 | KeyButtonDrawable homeIcon = mHomeDefaultIcon; |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 649 | if (!mUseCarModeUi) { |
Matthew Ng | eb5ce83 | 2018-05-15 17:50:37 -0700 | [diff] [blame] | 650 | orientHomeButton(homeIcon); |
| 651 | } |
| 652 | getHomeButton().setImageDrawable(homeIcon); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 653 | getBackButton().setImageDrawable(backIcon); |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 654 | |
Jorim Jaggi | d30d95d | 2016-02-17 20:27:22 -0800 | [diff] [blame] | 655 | updateRecentsIcon(); |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 656 | |
Mike Digman | a48cf19 | 2018-02-12 17:52:48 -0800 | [diff] [blame] | 657 | // Update IME button visibility, a11y and rotate button always overrides the appearance |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 658 | mContextualButtonGroup.setButtonVisibility(R.id.ime_switcher, |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 659 | (mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_IME_SHOWN) != 0); |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 660 | |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 661 | mBarTransitions.reapplyDarkIntensity(); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 662 | |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 663 | boolean disableHome = isGesturalMode(mNavBarMode) |
Winson Chung | e108b67 | 2019-03-06 16:11:28 -0800 | [diff] [blame] | 664 | || ((mDisabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0); |
Sriram Viswanathan | 469caae | 2016-03-22 13:11:50 -0700 | [diff] [blame] | 665 | |
Jeff Chang | 2aaa91a | 2018-11-08 18:04:16 +0800 | [diff] [blame] | 666 | // Always disable recents when alternate car mode UI is active and for secondary displays. |
| 667 | boolean disableRecent = isRecentsButtonDisabled(); |
Charles He | e57ff81 | 2017-10-26 10:01:35 +0100 | [diff] [blame] | 668 | |
Sunny Goyal | be4e054 | 2019-08-08 16:36:14 -0700 | [diff] [blame] | 669 | // Disable the home handle if both hone and recents are disabled |
| 670 | boolean disableHomeHandle = disableRecent |
| 671 | && ((mDisabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0); |
| 672 | |
Sunny Goyal | 3841295 | 2020-04-17 11:35:37 -0700 | [diff] [blame] | 673 | boolean disableBack = !useAltBack && (mEdgeBackGestureHandler.isHandlingGestures() |
Matthew Ng | f03c3a6 | 2019-04-03 13:52:57 -0700 | [diff] [blame] | 674 | || ((mDisabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0)); |
Daniel Sandler | 029d587 | 2011-09-12 00:58:58 -0400 | [diff] [blame] | 675 | |
Matthew Ng | 87cbf34 | 2018-02-15 12:21:18 -0800 | [diff] [blame] | 676 | // When screen pinning, don't hide back and home when connected service or back and |
| 677 | // recents buttons when disconnected from launcher service in screen pinning mode, |
| 678 | // as they are used for exiting. |
Matthew Ng | 6ff33b7 | 2018-02-27 13:47:38 -0800 | [diff] [blame] | 679 | final boolean pinningActive = ActivityManagerWrapper.getInstance().isScreenPinningActive(); |
Winson Chung | d95a225 | 2018-04-04 17:02:29 +0000 | [diff] [blame] | 680 | if (mOverviewProxyService.isEnabled()) { |
Winson Chung | 30c6260 | 2019-05-09 13:34:48 -0700 | [diff] [blame] | 681 | // Force disable recents when not in legacy mode |
| 682 | disableRecent |= !QuickStepContract.isLegacyMode(mNavBarMode); |
Tracy Zhou | 63b5047 | 2019-07-01 15:27:02 -0700 | [diff] [blame] | 683 | if (pinningActive && !QuickStepContract.isGesturalMode(mNavBarMode)) { |
Matthew Ng | 87cbf34 | 2018-02-15 12:21:18 -0800 | [diff] [blame] | 684 | disableBack = disableHome = false; |
Matthew Ng | 87cbf34 | 2018-02-15 12:21:18 -0800 | [diff] [blame] | 685 | } |
Matthew Ng | 6ff33b7 | 2018-02-27 13:47:38 -0800 | [diff] [blame] | 686 | } else if (pinningActive) { |
Matthew Ng | 87cbf34 | 2018-02-15 12:21:18 -0800 | [diff] [blame] | 687 | disableBack = disableRecent = false; |
Matthew Ng | dc79e5c | 2017-12-14 17:37:35 -0800 | [diff] [blame] | 688 | } |
Charles He | e57ff81 | 2017-10-26 10:01:35 +0100 | [diff] [blame] | 689 | |
Winson Chung | e108b67 | 2019-03-06 16:11:28 -0800 | [diff] [blame] | 690 | ViewGroup navButtons = getCurrentView().findViewById(R.id.nav_buttons); |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 691 | if (navButtons != null) { |
| 692 | LayoutTransition lt = navButtons.getLayoutTransition(); |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 693 | if (lt != null) { |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 694 | if (!lt.getTransitionListeners().contains(mTransitionListener)) { |
| 695 | lt.addTransitionListener(mTransitionListener); |
| 696 | } |
John Spurlock | 1bbd49d | 2012-10-19 11:09:32 -0400 | [diff] [blame] | 697 | } |
| 698 | } |
| 699 | |
Sunny Goyal | 3841295 | 2020-04-17 11:35:37 -0700 | [diff] [blame] | 700 | getBackButton().setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE); |
| 701 | getHomeButton().setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE); |
| 702 | getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE); |
Sunny Goyal | be4e054 | 2019-08-08 16:36:14 -0700 | [diff] [blame] | 703 | getHomeHandle().setVisibility(disableHomeHandle ? View.INVISIBLE : View.VISIBLE); |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 704 | } |
| 705 | |
Jeff Chang | 2aaa91a | 2018-11-08 18:04:16 +0800 | [diff] [blame] | 706 | @VisibleForTesting |
| 707 | boolean isRecentsButtonDisabled() { |
| 708 | return mUseCarModeUi || !isOverviewEnabled() |
| 709 | || getContext().getDisplayId() != Display.DEFAULT_DISPLAY; |
| 710 | } |
| 711 | |
| 712 | private Display getContextDisplay() { |
| 713 | return getContext().getDisplay(); |
| 714 | } |
| 715 | |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 716 | public void setLayoutTransitionsEnabled(boolean enabled) { |
| 717 | mLayoutTransitionsEnabled = enabled; |
| 718 | updateLayoutTransitionsEnabled(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 719 | } |
| 720 | |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 721 | public void setWakeAndUnlocking(boolean wakeAndUnlocking) { |
| 722 | setUseFadingAnimations(wakeAndUnlocking); |
| 723 | mWakeAndUnlocking = wakeAndUnlocking; |
| 724 | updateLayoutTransitionsEnabled(); |
| 725 | } |
| 726 | |
| 727 | private void updateLayoutTransitionsEnabled() { |
| 728 | boolean enabled = !mWakeAndUnlocking && mLayoutTransitionsEnabled; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 729 | ViewGroup navButtons = (ViewGroup) getCurrentView().findViewById(R.id.nav_buttons); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 730 | LayoutTransition lt = navButtons.getLayoutTransition(); |
Julia Reynolds | 8478aba | 2015-07-31 09:17:20 -0400 | [diff] [blame] | 731 | if (lt != null) { |
| 732 | if (enabled) { |
| 733 | lt.enableTransitionType(LayoutTransition.APPEARING); |
| 734 | lt.enableTransitionType(LayoutTransition.DISAPPEARING); |
| 735 | lt.enableTransitionType(LayoutTransition.CHANGE_APPEARING); |
| 736 | lt.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING); |
| 737 | } else { |
| 738 | lt.disableTransitionType(LayoutTransition.APPEARING); |
| 739 | lt.disableTransitionType(LayoutTransition.DISAPPEARING); |
| 740 | lt.disableTransitionType(LayoutTransition.CHANGE_APPEARING); |
| 741 | lt.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING); |
| 742 | } |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 743 | } |
| 744 | } |
| 745 | |
| 746 | private void setUseFadingAnimations(boolean useFadingAnimations) { |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 747 | WindowManager.LayoutParams lp = (WindowManager.LayoutParams) ((ViewGroup) getParent()) |
| 748 | .getLayoutParams(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 749 | if (lp != null) { |
| 750 | boolean old = lp.windowAnimations != 0; |
| 751 | if (!old && useFadingAnimations) { |
| 752 | lp.windowAnimations = R.style.Animation_NavigationBarFadeIn; |
| 753 | } else if (old && !useFadingAnimations) { |
| 754 | lp.windowAnimations = 0; |
| 755 | } else { |
| 756 | return; |
| 757 | } |
| 758 | WindowManager wm = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE); |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 759 | wm.updateViewLayout((View) getParent(), lp); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 760 | } |
| 761 | } |
| 762 | |
Winson Chung | 5b6a1fe | 2019-07-26 16:38:08 -0700 | [diff] [blame] | 763 | public void onStatusBarPanelStateChanged() { |
Matthew Ng | 78f88d1 | 2018-01-23 12:39:55 -0800 | [diff] [blame] | 764 | updateSlippery(); |
Winson Chung | 56a667b | 2019-07-30 13:51:27 -0700 | [diff] [blame] | 765 | updatePanelSystemUiStateFlags(); |
Winson Chung | a706700 | 2019-05-07 11:50:42 -0700 | [diff] [blame] | 766 | } |
| 767 | |
Winson Chung | 56a667b | 2019-07-30 13:51:27 -0700 | [diff] [blame] | 768 | public void updateDisabledSystemUiStateFlags() { |
Winson Chung | a706700 | 2019-05-07 11:50:42 -0700 | [diff] [blame] | 769 | int displayId = mContext.getDisplayId(); |
Vinit Nayak | 59b114e6 | 2019-08-12 11:50:00 -0700 | [diff] [blame] | 770 | |
| 771 | mSysUiFlagContainer.setFlag(SYSUI_STATE_SCREEN_PINNING, |
| 772 | ActivityManagerWrapper.getInstance().isScreenPinningActive()) |
| 773 | .setFlag(SYSUI_STATE_OVERVIEW_DISABLED, |
| 774 | (mDisabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0) |
| 775 | .setFlag(SYSUI_STATE_HOME_DISABLED, |
| 776 | (mDisabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0) |
| 777 | .setFlag(SYSUI_STATE_SEARCH_DISABLED, |
| 778 | (mDisabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0) |
| 779 | .commitUpdate(displayId); |
Winson Chung | 56a667b | 2019-07-30 13:51:27 -0700 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | public void updatePanelSystemUiStateFlags() { |
| 783 | int displayId = mContext.getDisplayId(); |
Winson Chung | 75375e0 | 2020-02-12 15:43:48 -0800 | [diff] [blame] | 784 | if (SysUiState.DEBUG) { |
| 785 | Log.d(TAG, "Updating panel sysui state flags: panelView=" + mPanelView); |
| 786 | } |
Winson Chung | a706700 | 2019-05-07 11:50:42 -0700 | [diff] [blame] | 787 | if (mPanelView != null) { |
Winson Chung | 75375e0 | 2020-02-12 15:43:48 -0800 | [diff] [blame] | 788 | if (SysUiState.DEBUG) { |
| 789 | Log.d(TAG, "Updating panel sysui state flags: fullyExpanded=" |
| 790 | + mPanelView.isFullyExpanded() + " inQs=" + mPanelView.isInSettings()); |
| 791 | } |
Vinit Nayak | 59b114e6 | 2019-08-12 11:50:00 -0700 | [diff] [blame] | 792 | mSysUiFlagContainer.setFlag(SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED, |
| 793 | mPanelView.isFullyExpanded() && !mPanelView.isInSettings()) |
| 794 | .setFlag(SYSUI_STATE_QUICK_SETTINGS_EXPANDED, |
| 795 | mPanelView.isInSettings()) |
| 796 | .commitUpdate(displayId); |
Winson Chung | a706700 | 2019-05-07 11:50:42 -0700 | [diff] [blame] | 797 | } |
Matthew Ng | 78f88d1 | 2018-01-23 12:39:55 -0800 | [diff] [blame] | 798 | } |
| 799 | |
Matthew Ng | 8f25fb96 | 2018-01-16 17:17:24 -0800 | [diff] [blame] | 800 | public void updateStates() { |
Matthew Ng | 44b1450 | 2018-05-04 11:10:14 -0700 | [diff] [blame] | 801 | final boolean showSwipeUpUI = mOverviewProxyService.shouldShowSwipeUpUI(); |
Mike Digman | f77fb91 | 2018-05-21 11:21:30 -0700 | [diff] [blame] | 802 | |
| 803 | if (mNavigationInflaterView != null) { |
| 804 | // Reinflate the navbar if needed, no-op unless the swipe up state changes |
| 805 | mNavigationInflaterView.onLikelyDefaultLayoutChange(); |
| 806 | } |
| 807 | |
Matthew Ng | 8f25fb96 | 2018-01-16 17:17:24 -0800 | [diff] [blame] | 808 | updateSlippery(); |
Winson Chung | 770d7e9 | 2018-03-20 17:51:39 -0700 | [diff] [blame] | 809 | reloadNavIcons(); |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 810 | updateNavButtonIcons(); |
Winson Chung | f9e3027 | 2018-03-26 17:25:36 -0700 | [diff] [blame] | 811 | setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled()); |
Matthew Ng | 44b1450 | 2018-05-04 11:10:14 -0700 | [diff] [blame] | 812 | WindowManagerWrapper.getInstance().setNavBarVirtualKeyHapticFeedbackEnabled(!showSwipeUpUI); |
| 813 | getHomeButton().setAccessibilityDelegate( |
| 814 | showSwipeUpUI ? mQuickStepAccessibilityDelegate : null); |
Matthew Ng | 8f25fb96 | 2018-01-16 17:17:24 -0800 | [diff] [blame] | 815 | } |
| 816 | |
Matthew Ng | 90ef063 | 2018-08-15 13:53:15 -0700 | [diff] [blame] | 817 | /** |
| 818 | * Updates the {@link WindowManager.LayoutParams.FLAG_SLIPPERY} state dependent on if swipe up |
| 819 | * is enabled, or the notifications is fully opened without being in an animated state. If |
| 820 | * slippery is enabled, touch events will leave the nav bar window and enter into the fullscreen |
| 821 | * app/home window, if not nav bar will receive a cancelled touch event once gesture leaves bar. |
| 822 | */ |
Matthew Ng | 472d3e4 | 2018-06-14 15:16:55 -0700 | [diff] [blame] | 823 | public void updateSlippery() { |
Matthew Ng | 90ef063 | 2018-08-15 13:53:15 -0700 | [diff] [blame] | 824 | setSlippery(!isQuickStepSwipeUpEnabled() || |
Dave Mankoff | 023e5da | 2020-06-17 11:35:01 -0400 | [diff] [blame] | 825 | (mPanelView != null && mPanelView.isFullyExpanded() && !mPanelView.isCollapsing())); |
Matthew Ng | 78f88d1 | 2018-01-23 12:39:55 -0800 | [diff] [blame] | 826 | } |
| 827 | |
Matthew Ng | 7d05e77 | 2017-11-09 14:41:07 -0800 | [diff] [blame] | 828 | private void setSlippery(boolean slippery) { |
Matthew Ng | b831fb4 | 2019-01-30 11:20:48 -0800 | [diff] [blame] | 829 | setWindowFlag(WindowManager.LayoutParams.FLAG_SLIPPERY, slippery); |
| 830 | } |
| 831 | |
Matthew Ng | b831fb4 | 2019-01-30 11:20:48 -0800 | [diff] [blame] | 832 | private void setWindowFlag(int flags, boolean enable) { |
Matthew Ng | 7d05e77 | 2017-11-09 14:41:07 -0800 | [diff] [blame] | 833 | final ViewGroup navbarView = ((ViewGroup) getParent()); |
Matthew Ng | b55c02c | 2019-02-15 16:20:31 -0800 | [diff] [blame] | 834 | if (navbarView == null) { |
| 835 | return; |
| 836 | } |
Matthew Ng | b831fb4 | 2019-01-30 11:20:48 -0800 | [diff] [blame] | 837 | WindowManager.LayoutParams lp = (WindowManager.LayoutParams) navbarView.getLayoutParams(); |
| 838 | if (lp == null || enable == ((lp.flags & flags) != 0)) { |
Matthew Ng | 9c3bce5 | 2018-02-01 22:00:31 +0000 | [diff] [blame] | 839 | return; |
| 840 | } |
Matthew Ng | b831fb4 | 2019-01-30 11:20:48 -0800 | [diff] [blame] | 841 | if (enable) { |
| 842 | lp.flags |= flags; |
| 843 | } else { |
| 844 | lp.flags &= ~flags; |
Matthew Ng | 7d05e77 | 2017-11-09 14:41:07 -0800 | [diff] [blame] | 845 | } |
Matthew Ng | b831fb4 | 2019-01-30 11:20:48 -0800 | [diff] [blame] | 846 | WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); |
| 847 | wm.updateViewLayout(navbarView, lp); |
Matthew Ng | 7d05e77 | 2017-11-09 14:41:07 -0800 | [diff] [blame] | 848 | } |
| 849 | |
Winson Chung | 1aa24b9 | 2019-04-24 15:17:33 -0700 | [diff] [blame] | 850 | @Override |
| 851 | public void onNavigationModeChanged(int mode) { |
| 852 | mNavBarMode = mode; |
| 853 | mBarTransitions.onNavigationModeChanged(mNavBarMode); |
Sunny Goyal | 3841295 | 2020-04-17 11:35:37 -0700 | [diff] [blame] | 854 | mEdgeBackGestureHandler.onNavigationModeChanged(mNavBarMode); |
Winson Chung | 1aa24b9 | 2019-04-24 15:17:33 -0700 | [diff] [blame] | 855 | mRecentsOnboarding.onNavigationModeChanged(mNavBarMode); |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 856 | getRotateSuggestionButton().onNavigationModeChanged(mNavBarMode); |
Matthew Ng | b55c02c | 2019-02-15 16:20:31 -0800 | [diff] [blame] | 857 | |
Winson Chung | efaacc3 | 2019-09-25 14:44:05 -0700 | [diff] [blame] | 858 | if (isGesturalMode(mNavBarMode)) { |
| 859 | mRegionSamplingHelper.start(mSamplingBounds); |
| 860 | } else { |
| 861 | mRegionSamplingHelper.stop(); |
| 862 | } |
Matthew Ng | b55c02c | 2019-02-15 16:20:31 -0800 | [diff] [blame] | 863 | } |
| 864 | |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 865 | public void setAccessibilityButtonState(final boolean visible, final boolean longClickable) { |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 866 | mLongClickableAccessibilityButton = longClickable; |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 867 | getAccessibilityButton().setLongClickable(longClickable); |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 868 | mContextualButtonGroup.setButtonVisibility(R.id.accessibility_button, visible); |
Mike Digman | a48cf19 | 2018-02-12 17:52:48 -0800 | [diff] [blame] | 869 | } |
| 870 | |
Tracy Zhou | 1ac592c | 2018-07-25 13:47:37 -0700 | [diff] [blame] | 871 | void hideRecentsOnboarding() { |
| 872 | mRecentsOnboarding.hide(true); |
| 873 | } |
| 874 | |
Jim Miller | 960892c | 2012-05-23 15:50:04 -0700 | [diff] [blame] | 875 | @Override |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 876 | public void onFinishInflate() { |
Sunny Goyal | 3841295 | 2020-04-17 11:35:37 -0700 | [diff] [blame] | 877 | super.onFinishInflate(); |
Winson Chung | 661d5f9 | 2018-05-21 18:41:39 -0700 | [diff] [blame] | 878 | mNavigationInflaterView = findViewById(R.id.navigation_inflater); |
Felipe Leme | 15f915c | 2016-10-31 12:47:15 -0700 | [diff] [blame] | 879 | mNavigationInflaterView.setButtonDispatchers(mButtonDispatchers); |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 880 | |
| 881 | getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener); |
Selim Cinek | 17a327a | 2014-08-25 15:03:48 +0200 | [diff] [blame] | 882 | |
Evan Rosky | af9f27c | 2020-02-18 18:58:35 +0000 | [diff] [blame] | 883 | Divider divider = Dependency.get(Divider.class); |
| 884 | divider.registerInSplitScreenListener(mDockedListener); |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 885 | updateOrientationViews(); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 886 | reloadNavIcons(); |
Jorim Jaggi | a6c934e | 2015-12-21 13:22:31 +0100 | [diff] [blame] | 887 | } |
| 888 | |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 889 | @Override |
| 890 | protected void onDraw(Canvas canvas) { |
Matthew Ng | 603b329 | 2018-03-30 17:15:39 -0700 | [diff] [blame] | 891 | mDeadZone.onDraw(canvas); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 892 | super.onDraw(canvas); |
| 893 | } |
| 894 | |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 895 | private void updateSamplingRect() { |
| 896 | mSamplingBounds.setEmpty(); |
| 897 | // TODO: Extend this to 2/3 button layout as well |
| 898 | View view = getHomeHandle().getCurrentView(); |
| 899 | |
| 900 | if (view != null) { |
| 901 | int[] pos = new int[2]; |
| 902 | view.getLocationOnScreen(pos); |
| 903 | Point displaySize = new Point(); |
| 904 | view.getContext().getDisplay().getRealSize(displaySize); |
| 905 | final Rect samplingBounds = new Rect(pos[0] - mNavColorSampleMargin, |
| 906 | displaySize.y - getNavBarHeight(), |
| 907 | pos[0] + view.getWidth() + mNavColorSampleMargin, |
| 908 | displaySize.y); |
| 909 | mSamplingBounds.set(samplingBounds); |
| 910 | } |
| 911 | } |
| 912 | |
Vinit Nayak | d2fe92f | 2020-06-04 13:12:02 -0700 | [diff] [blame] | 913 | void setOrientedHandleSamplingRegion(Rect orientedHandleSamplingRegion) { |
| 914 | mOrientedHandleSamplingRegion = orientedHandleSamplingRegion; |
| 915 | mRegionSamplingHelper.updateSamplingRect(); |
| 916 | } |
| 917 | |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 918 | @Override |
| 919 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 920 | super.onLayout(changed, left, top, right, bottom); |
Sunny Goyal | aac6c88 | 2019-02-11 11:57:58 -0800 | [diff] [blame] | 921 | |
| 922 | mActiveRegion.setEmpty(); |
| 923 | updateButtonLocation(getBackButton(), mBackButtonBounds, true); |
| 924 | updateButtonLocation(getHomeButton(), mHomeButtonBounds, false); |
| 925 | updateButtonLocation(getRecentsButton(), mRecentsButtonBounds, false); |
| 926 | updateButtonLocation(getRotateSuggestionButton(), mRotationButtonBounds, true); |
| 927 | // TODO: Handle button visibility changes |
| 928 | mOverviewProxyService.onActiveNavBarRegionChanges(mActiveRegion); |
Tracy Zhou | 559d97c | 2018-04-07 23:54:46 -0700 | [diff] [blame] | 929 | mRecentsOnboarding.setNavBarHeight(getMeasuredHeight()); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 930 | } |
| 931 | |
Sunny Goyal | aac6c88 | 2019-02-11 11:57:58 -0800 | [diff] [blame] | 932 | private void updateButtonLocation(ButtonDispatcher button, Rect buttonBounds, |
| 933 | boolean isActive) { |
Winson Chung | c4e0620 | 2018-02-13 10:37:35 -0800 | [diff] [blame] | 934 | View view = button.getCurrentView(); |
| 935 | if (view == null) { |
| 936 | buttonBounds.setEmpty(); |
| 937 | return; |
| 938 | } |
Matthew Ng | 3b7e390 | 2018-03-22 16:06:09 -0700 | [diff] [blame] | 939 | // Temporarily reset the translation back to origin to get the position in window |
| 940 | final float posX = view.getTranslationX(); |
| 941 | final float posY = view.getTranslationY(); |
| 942 | view.setTranslationX(0); |
| 943 | view.setTranslationY(0); |
Sunny Goyal | aac6c88 | 2019-02-11 11:57:58 -0800 | [diff] [blame] | 944 | |
| 945 | if (isActive) { |
| 946 | view.getLocationOnScreen(mTmpPosition); |
| 947 | buttonBounds.set(mTmpPosition[0], mTmpPosition[1], |
| 948 | mTmpPosition[0] + view.getMeasuredWidth(), |
| 949 | mTmpPosition[1] + view.getMeasuredHeight()); |
| 950 | mActiveRegion.op(buttonBounds, Op.UNION); |
| 951 | } |
Winson Chung | c4e0620 | 2018-02-13 10:37:35 -0800 | [diff] [blame] | 952 | view.getLocationInWindow(mTmpPosition); |
| 953 | buttonBounds.set(mTmpPosition[0], mTmpPosition[1], |
| 954 | mTmpPosition[0] + view.getMeasuredWidth(), |
| 955 | mTmpPosition[1] + view.getMeasuredHeight()); |
Matthew Ng | 3b7e390 | 2018-03-22 16:06:09 -0700 | [diff] [blame] | 956 | view.setTranslationX(posX); |
| 957 | view.setTranslationY(posY); |
Winson Chung | c4e0620 | 2018-02-13 10:37:35 -0800 | [diff] [blame] | 958 | } |
| 959 | |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 960 | private void updateOrientationViews() { |
| 961 | mHorizontal = findViewById(R.id.horizontal); |
| 962 | mVertical = findViewById(R.id.vertical); |
Jason Monk | 9a6552d | 2016-05-20 11:21:59 -0400 | [diff] [blame] | 963 | |
Jason Monk | 199a2d0 | 2017-07-28 11:08:27 -0400 | [diff] [blame] | 964 | updateCurrentView(); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 965 | } |
| 966 | |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 967 | boolean needsReorient(int rotation) { |
Adrian Roos | a98b32c | 2016-08-11 10:41:08 -0700 | [diff] [blame] | 968 | return mCurrentRotation != rotation; |
Adrian Roos | 090b7d8 | 2016-08-02 18:36:12 -0700 | [diff] [blame] | 969 | } |
| 970 | |
Jason Monk | 199a2d0 | 2017-07-28 11:08:27 -0400 | [diff] [blame] | 971 | private void updateCurrentView() { |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 972 | resetViews(); |
| 973 | mCurrentView = mIsVertical ? mVertical : mHorizontal; |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 974 | mCurrentView.setVisibility(View.VISIBLE); |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 975 | mNavigationInflaterView.setVertical(mIsVertical); |
| 976 | mCurrentRotation = getContextDisplay().getRotation(); |
| 977 | mNavigationInflaterView.setAlternativeOrder(mCurrentRotation == Surface.ROTATION_90); |
Matthew Ng | 1efc9c3 | 2018-04-11 18:13:56 -0700 | [diff] [blame] | 978 | mNavigationInflaterView.updateButtonDispatchersCurrentView(); |
Jorim Jaggi | 37c1180 | 2015-08-18 20:27:54 -0700 | [diff] [blame] | 979 | updateLayoutTransitionsEnabled(); |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | private void resetViews() { |
| 983 | mHorizontal.setVisibility(View.GONE); |
| 984 | mVertical.setVisibility(View.GONE); |
Jason Monk | 9a6552d | 2016-05-20 11:21:59 -0400 | [diff] [blame] | 985 | } |
| 986 | |
| 987 | private void updateRecentsIcon() { |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 988 | mDockedIcon.setRotation(mDockedStackExists && mIsVertical ? 90 : 0); |
Jason Monk | 9a6552d | 2016-05-20 11:21:59 -0400 | [diff] [blame] | 989 | getRecentsButton().setImageDrawable(mDockedStackExists ? mDockedIcon : mRecentIcon); |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 990 | mBarTransitions.reapplyDarkIntensity(); |
Jason Monk | 9a6552d | 2016-05-20 11:21:59 -0400 | [diff] [blame] | 991 | } |
| 992 | |
Matthew Ng | 20136e6 | 2018-05-30 12:20:31 -0700 | [diff] [blame] | 993 | public void showPinningEnterExitToast(boolean entering) { |
| 994 | if (entering) { |
| 995 | mScreenPinningNotify.showPinningStartToast(); |
| 996 | } else { |
| 997 | mScreenPinningNotify.showPinningExitToast(); |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | public void showPinningEscapeToast() { |
Hongwei Wang | 0e62574 | 2019-08-14 14:55:27 -0700 | [diff] [blame] | 1002 | mScreenPinningNotify.showEscapeToast( |
| 1003 | mNavBarMode == NAV_BAR_MODE_GESTURAL, isRecentsButtonVisible()); |
Matthew Ng | 20136e6 | 2018-05-30 12:20:31 -0700 | [diff] [blame] | 1004 | } |
| 1005 | |
Jason Monk | 9a6552d | 2016-05-20 11:21:59 -0400 | [diff] [blame] | 1006 | public boolean isVertical() { |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 1007 | return mIsVertical; |
Jason Monk | 9a6552d | 2016-05-20 11:21:59 -0400 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | public void reorient() { |
Jason Monk | 199a2d0 | 2017-07-28 11:08:27 -0400 | [diff] [blame] | 1011 | updateCurrentView(); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1012 | |
Siarhei Vishniakou | fdb4277 | 2017-06-29 10:32:11 -0700 | [diff] [blame] | 1013 | ((NavigationBarFrame) getRootView()).setDeadZone(mDeadZone); |
Matthew Ng | 603b329 | 2018-03-30 17:15:39 -0700 | [diff] [blame] | 1014 | mDeadZone.onConfigurationChanged(mCurrentRotation); |
Daniel Sandler | c26185b | 2012-08-29 15:49:53 -0400 | [diff] [blame] | 1015 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 1016 | // force the low profile & disabled states into compliance |
Adrian Roos | 8a8ffd4 | 2015-05-26 18:30:37 -0700 | [diff] [blame] | 1017 | mBarTransitions.init(); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 1018 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1019 | if (DEBUG) { |
Adrian Roos | a98b32c | 2016-08-11 10:41:08 -0700 | [diff] [blame] | 1020 | Log.d(TAG, "reorient(): rot=" + mCurrentRotation); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1021 | } |
Michael Jurka | a5d0ddb | 2012-03-09 17:41:41 -0800 | [diff] [blame] | 1022 | |
Matthew Ng | 5fd8041 | 2018-02-14 14:40:31 -0800 | [diff] [blame] | 1023 | // Resolve layout direction if not resolved since components changing layout direction such |
| 1024 | // as changing languages will recreate this view and the direction will be resolved later |
| 1025 | if (!isLayoutDirectionResolved()) { |
| 1026 | resolveLayoutDirection(); |
| 1027 | } |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 1028 | updateNavButtonIcons(); |
Xiaohui Chen | 9efa5de | 2016-11-22 10:34:38 -0800 | [diff] [blame] | 1029 | |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 1030 | getHomeButton().setVertical(mIsVertical); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1031 | } |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1032 | |
Daniel Sandler | 0b69b59 | 2012-01-23 21:08:36 -0500 | [diff] [blame] | 1033 | @Override |
Matthew Ng | ff63812 | 2019-03-21 17:17:18 -0700 | [diff] [blame] | 1034 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 1035 | int w = MeasureSpec.getSize(widthMeasureSpec); |
| 1036 | int h = MeasureSpec.getSize(heightMeasureSpec); |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 1037 | if (DEBUG) Log.d(TAG, String.format( |
Matthew Ng | ff63812 | 2019-03-21 17:17:18 -0700 | [diff] [blame] | 1038 | "onMeasure: (%dx%d) old: (%dx%d)", w, h, getMeasuredWidth(), getMeasuredHeight())); |
Daniel Sandler | e03bc95 | 2012-04-27 16:11:22 -0400 | [diff] [blame] | 1039 | |
Winson Chung | 4723b4e | 2019-03-25 16:49:36 -0700 | [diff] [blame] | 1040 | final boolean newVertical = w > 0 && h > w |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 1041 | && !isGesturalMode(mNavBarMode); |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 1042 | if (newVertical != mIsVertical) { |
| 1043 | mIsVertical = newVertical; |
| 1044 | if (DEBUG) { |
Matthew Ng | ff63812 | 2019-03-21 17:17:18 -0700 | [diff] [blame] | 1045 | Log.d(TAG, String.format("onMeasure: h=%d, w=%d, vert=%s", h, w, |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 1046 | mIsVertical ? "y" : "n")); |
| 1047 | } |
Daniel Sandler | e03bc95 | 2012-04-27 16:11:22 -0400 | [diff] [blame] | 1048 | reorient(); |
Selim Cinek | 92d892c | 2014-09-11 15:11:00 +0200 | [diff] [blame] | 1049 | notifyVerticalChangedListener(newVertical); |
Daniel Sandler | e03bc95 | 2012-04-27 16:11:22 -0400 | [diff] [blame] | 1050 | } |
Winson Chung | 775d287 | 2019-03-27 14:14:01 -0700 | [diff] [blame] | 1051 | |
Tracy Zhou | 24fd028 | 2019-05-20 14:40:38 -0700 | [diff] [blame] | 1052 | if (isGesturalMode(mNavBarMode)) { |
Winson Chung | 775d287 | 2019-03-27 14:14:01 -0700 | [diff] [blame] | 1053 | // Update the nav bar background to match the height of the visible nav bar |
| 1054 | int height = mIsVertical |
| 1055 | ? getResources().getDimensionPixelSize( |
| 1056 | com.android.internal.R.dimen.navigation_bar_height_landscape) |
| 1057 | : getResources().getDimensionPixelSize( |
| 1058 | com.android.internal.R.dimen.navigation_bar_height); |
| 1059 | int frameHeight = getResources().getDimensionPixelSize( |
| 1060 | com.android.internal.R.dimen.navigation_bar_frame_height); |
| 1061 | mBarTransitions.setBackgroundFrame(new Rect(0, frameHeight - height, w, h)); |
| 1062 | } |
| 1063 | |
Matthew Ng | ff63812 | 2019-03-21 17:17:18 -0700 | [diff] [blame] | 1064 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
Daniel Sandler | 0b69b59 | 2012-01-23 21:08:36 -0500 | [diff] [blame] | 1065 | } |
| 1066 | |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 1067 | private int getNavBarHeight() { |
| 1068 | return mIsVertical |
| 1069 | ? getResources().getDimensionPixelSize( |
| 1070 | com.android.internal.R.dimen.navigation_bar_height_landscape) |
| 1071 | : getResources().getDimensionPixelSize( |
| 1072 | com.android.internal.R.dimen.navigation_bar_height); |
| 1073 | } |
| 1074 | |
Selim Cinek | 92d892c | 2014-09-11 15:11:00 +0200 | [diff] [blame] | 1075 | private void notifyVerticalChangedListener(boolean newVertical) { |
| 1076 | if (mOnVerticalChangedListener != null) { |
| 1077 | mOnVerticalChangedListener.onVerticalChanged(newVertical); |
| 1078 | } |
| 1079 | } |
| 1080 | |
Selim Cinek | 17a327a | 2014-08-25 15:03:48 +0200 | [diff] [blame] | 1081 | @Override |
| 1082 | protected void onConfigurationChanged(Configuration newConfig) { |
| 1083 | super.onConfigurationChanged(newConfig); |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 1084 | mTmpLastConfiguration.updateFrom(mConfiguration); |
| 1085 | mConfiguration.updateFrom(newConfig); |
| 1086 | boolean uiCarModeChanged = updateCarMode(); |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 1087 | updateIcons(mTmpLastConfiguration); |
Winson | fde2e6a | 2016-03-22 16:03:10 -0700 | [diff] [blame] | 1088 | updateRecentsIcon(); |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 1089 | mRecentsOnboarding.onConfigurationChanged(mConfiguration); |
| 1090 | if (uiCarModeChanged || mTmpLastConfiguration.densityDpi != mConfiguration.densityDpi |
| 1091 | || mTmpLastConfiguration.getLayoutDirection() != mConfiguration.getLayoutDirection()) { |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 1092 | // If car mode or density changes, we need to reset the icons. |
Matthew Ng | d0a73e7 | 2018-03-02 15:16:03 -0800 | [diff] [blame] | 1093 | updateNavButtonIcons(); |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 1094 | } |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1095 | } |
| 1096 | |
| 1097 | /** |
| 1098 | * If the configuration changed, update the carmode and return that it was updated. |
| 1099 | */ |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 1100 | private boolean updateCarMode() { |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1101 | boolean uiCarModeChanged = false; |
Matthew Ng | 8c056c1 | 2018-10-15 15:16:46 -0700 | [diff] [blame] | 1102 | if (mConfiguration != null) { |
| 1103 | int uiMode = mConfiguration.uiMode & Configuration.UI_MODE_TYPE_MASK; |
Justin Paupore | 01915a1 | 2016-09-28 17:41:26 -0700 | [diff] [blame] | 1104 | final boolean isCarMode = (uiMode == Configuration.UI_MODE_TYPE_CAR); |
| 1105 | |
| 1106 | if (isCarMode != mInCarMode) { |
| 1107 | mInCarMode = isCarMode; |
Justin Paupore | 01915a1 | 2016-09-28 17:41:26 -0700 | [diff] [blame] | 1108 | if (ALTERNATE_CAR_MODE_UI) { |
| 1109 | mUseCarModeUi = isCarMode; |
| 1110 | uiCarModeChanged = true; |
| 1111 | } else { |
| 1112 | // Don't use car mode behavior if ALTERNATE_CAR_MODE_UI not set. |
| 1113 | mUseCarModeUi = false; |
| 1114 | } |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1115 | } |
| 1116 | } |
| 1117 | return uiCarModeChanged; |
Selim Cinek | 17a327a | 2014-08-25 15:03:48 +0200 | [diff] [blame] | 1118 | } |
| 1119 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1120 | private String getResourceName(int resId) { |
| 1121 | if (resId != 0) { |
John Spurlock | 0153478 | 2014-01-13 11:59:22 -0500 | [diff] [blame] | 1122 | final android.content.res.Resources res = getContext().getResources(); |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1123 | try { |
| 1124 | return res.getResourceName(resId); |
| 1125 | } catch (android.content.res.Resources.NotFoundException ex) { |
| 1126 | return "(unknown)"; |
| 1127 | } |
| 1128 | } else { |
| 1129 | return "(null)"; |
| 1130 | } |
| 1131 | } |
| 1132 | |
| 1133 | private static String visibilityToString(int vis) { |
| 1134 | switch (vis) { |
| 1135 | case View.INVISIBLE: |
| 1136 | return "INVISIBLE"; |
| 1137 | case View.GONE: |
| 1138 | return "GONE"; |
| 1139 | default: |
| 1140 | return "VISIBLE"; |
| 1141 | } |
| 1142 | } |
| 1143 | |
Jason Monk | 67e6c80 | 2016-08-30 14:09:21 -0400 | [diff] [blame] | 1144 | @Override |
| 1145 | protected void onAttachedToWindow() { |
| 1146 | super.onAttachedToWindow(); |
Adrian Roos | 7e58a08 | 2018-03-09 16:40:56 +0100 | [diff] [blame] | 1147 | requestApplyInsets(); |
Siarhei Vishniakou | fdb4277 | 2017-06-29 10:32:11 -0700 | [diff] [blame] | 1148 | reorient(); |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 1149 | onNavigationModeChanged(mNavBarMode); |
Winson Chung | f9e3027 | 2018-03-26 17:25:36 -0700 | [diff] [blame] | 1150 | setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled()); |
Tracy Zhou | cb0362a | 2019-06-18 10:59:11 -0700 | [diff] [blame] | 1151 | if (mRotationButtonController != null) { |
| 1152 | mRotationButtonController.registerListeners(); |
| 1153 | } |
Matthew Ng | b831fb4 | 2019-01-30 11:20:48 -0800 | [diff] [blame] | 1154 | |
Sunny Goyal | a6a5812 | 2019-04-02 10:20:29 -0700 | [diff] [blame] | 1155 | mEdgeBackGestureHandler.onNavBarAttached(); |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 1156 | getViewTreeObserver().addOnComputeInternalInsetsListener(mOnComputeInternalInsetsListener); |
Jason Monk | 67e6c80 | 2016-08-30 14:09:21 -0400 | [diff] [blame] | 1157 | } |
| 1158 | |
| 1159 | @Override |
| 1160 | protected void onDetachedFromWindow() { |
| 1161 | super.onDetachedFromWindow(); |
Winson Chung | 1aa24b9 | 2019-04-24 15:17:33 -0700 | [diff] [blame] | 1162 | Dependency.get(NavigationModeController.class).removeListener(this); |
Tony Wickham | fb63fe8 | 2018-01-16 12:14:06 -0800 | [diff] [blame] | 1163 | setUpSwipeUpOnboarding(false); |
Matthew Ng | 761562d | 2018-09-17 11:13:21 -0700 | [diff] [blame] | 1164 | for (int i = 0; i < mButtonDispatchers.size(); ++i) { |
| 1165 | mButtonDispatchers.valueAt(i).onDestroy(); |
| 1166 | } |
Tracy Zhou | cb0362a | 2019-06-18 10:59:11 -0700 | [diff] [blame] | 1167 | if (mRotationButtonController != null) { |
| 1168 | mRotationButtonController.unregisterListeners(); |
| 1169 | } |
| 1170 | |
Sunny Goyal | a6a5812 | 2019-04-02 10:20:29 -0700 | [diff] [blame] | 1171 | mEdgeBackGestureHandler.onNavBarDetached(); |
Tracy Zhou | efc3466 | 2019-04-22 13:37:12 -0700 | [diff] [blame] | 1172 | getViewTreeObserver().removeOnComputeInternalInsetsListener( |
| 1173 | mOnComputeInternalInsetsListener); |
Tony Wickham | fb63fe8 | 2018-01-16 12:14:06 -0800 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | private void setUpSwipeUpOnboarding(boolean connectedToOverviewProxy) { |
| 1177 | if (connectedToOverviewProxy) { |
Tony Wickham | 05c1f85 | 2018-02-06 12:32:54 -0800 | [diff] [blame] | 1178 | mRecentsOnboarding.onConnectedToLauncher(); |
Tony Wickham | fb63fe8 | 2018-01-16 12:14:06 -0800 | [diff] [blame] | 1179 | } else { |
Tony Wickham | 05c1f85 | 2018-02-06 12:32:54 -0800 | [diff] [blame] | 1180 | mRecentsOnboarding.onDisconnectedFromLauncher(); |
Tony Wickham | fb63fe8 | 2018-01-16 12:14:06 -0800 | [diff] [blame] | 1181 | } |
Jason Monk | 67e6c80 | 2016-08-30 14:09:21 -0400 | [diff] [blame] | 1182 | } |
| 1183 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1184 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 1185 | pw.println("NavigationBarView {"); |
| 1186 | final Rect r = new Rect(); |
Jeff Brown | a8b9def | 2012-07-23 14:22:49 -0700 | [diff] [blame] | 1187 | final Point size = new Point(); |
Jeff Chang | 2aaa91a | 2018-11-08 18:04:16 +0800 | [diff] [blame] | 1188 | getContextDisplay().getRealSize(size); |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1189 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 1190 | pw.println(String.format(" this: " + StatusBar.viewInfo(this) |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1191 | + " " + visibilityToString(getVisibility()))); |
| 1192 | |
| 1193 | getWindowVisibleDisplayFrame(r); |
Jeff Brown | a8b9def | 2012-07-23 14:22:49 -0700 | [diff] [blame] | 1194 | final boolean offscreen = r.right > size.x || r.bottom > size.y; |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 1195 | pw.println(" window: " |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1196 | + r.toShortString() |
| 1197 | + " " + visibilityToString(getWindowVisibility()) |
| 1198 | + (offscreen ? " OFFSCREEN!" : "")); |
| 1199 | |
Winson Chung | 661d5f9 | 2018-05-21 18:41:39 -0700 | [diff] [blame] | 1200 | pw.println(String.format(" mCurrentView: id=%s (%dx%d) %s %f", |
Rakesh Iyer | f51fe4e | 2016-02-09 10:51:50 -0800 | [diff] [blame] | 1201 | getResourceName(getCurrentView().getId()), |
| 1202 | getCurrentView().getWidth(), getCurrentView().getHeight(), |
Winson Chung | 661d5f9 | 2018-05-21 18:41:39 -0700 | [diff] [blame] | 1203 | visibilityToString(getCurrentView().getVisibility()), |
| 1204 | getCurrentView().getAlpha())); |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1205 | |
Sunny Goyal | ded62f0 | 2019-05-01 14:35:49 -0700 | [diff] [blame] | 1206 | pw.println(String.format(" disabled=0x%08x vertical=%s darkIntensity=%.2f", |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1207 | mDisabledFlags, |
Charles Chen | aa94d95b | 2019-02-19 14:18:19 +0800 | [diff] [blame] | 1208 | mIsVertical ? "true" : "false", |
Matthew Ng | eb0b094 | 2018-10-12 16:42:11 -0700 | [diff] [blame] | 1209 | getLightTransitionsController().getCurrentDarkIntensity())); |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1210 | |
Vinit Nayak | d2fe92f | 2020-06-04 13:12:02 -0700 | [diff] [blame] | 1211 | pw.println(" mOrientedHandleSamplingRegion: " + mOrientedHandleSamplingRegion); |
| 1212 | |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 1213 | dumpButton(pw, "back", getBackButton()); |
| 1214 | dumpButton(pw, "home", getHomeButton()); |
| 1215 | dumpButton(pw, "rcnt", getRecentsButton()); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 1216 | dumpButton(pw, "rota", getRotateSuggestionButton()); |
Casey Burkhardt | 048c2bc | 2016-12-08 16:09:20 -0800 | [diff] [blame] | 1217 | dumpButton(pw, "a11y", getAccessibilityButton()); |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1218 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1219 | pw.println(" }"); |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 1220 | |
Winson Chung | 7379e25 | 2020-05-29 16:01:18 -0700 | [diff] [blame] | 1221 | if (mNavigationInflaterView != null) { |
| 1222 | mNavigationInflaterView.dump(pw); |
| 1223 | } |
Matthew Ng | 25593cc | 2018-09-12 16:05:41 -0700 | [diff] [blame] | 1224 | mContextualButtonGroup.dump(pw); |
| 1225 | mRecentsOnboarding.dump(pw); |
Vinit Nayak | 3f35db5 | 2019-08-08 17:31:48 -0700 | [diff] [blame] | 1226 | mRegionSamplingHelper.dump(pw); |
Winson Chung | 316f673 | 2019-06-14 09:31:46 -0700 | [diff] [blame] | 1227 | mEdgeBackGestureHandler.dump(pw); |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1228 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1229 | |
Adrian Roos | 7e58a08 | 2018-03-09 16:40:56 +0100 | [diff] [blame] | 1230 | @Override |
| 1231 | public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
Selim Cinek | e50b121 | 2019-06-04 18:40:31 -0700 | [diff] [blame] | 1232 | int leftInset = insets.getSystemWindowInsetLeft(); |
| 1233 | int rightInset = insets.getSystemWindowInsetRight(); |
| 1234 | setPadding(leftInset, insets.getSystemWindowInsetTop(), rightInset, |
| 1235 | insets.getSystemWindowInsetBottom()); |
| 1236 | // we're passing the insets onto the gesture handler since the back arrow is only |
| 1237 | // conditionally added and doesn't always get all the insets. |
| 1238 | mEdgeBackGestureHandler.setInsets(leftInset, rightInset); |
shawnlin | 2624bec | 2019-10-07 16:43:21 +0800 | [diff] [blame] | 1239 | |
| 1240 | // this allows assist handle to be drawn outside its bound so that it can align screen |
| 1241 | // bottom by translating its y position. |
| 1242 | final boolean shouldClip = |
| 1243 | !isGesturalMode(mNavBarMode) || insets.getSystemWindowInsetBottom() == 0; |
| 1244 | setClipChildren(shouldClip); |
| 1245 | setClipToPadding(shouldClip); |
| 1246 | |
Govinda Wasserman | a596ca3 | 2019-10-16 10:09:44 -0400 | [diff] [blame] | 1247 | NavigationBarController navigationBarController = |
| 1248 | Dependency.get(NavigationBarController.class); |
| 1249 | AssistHandleViewController controller = |
| 1250 | navigationBarController == null |
| 1251 | ? null : navigationBarController.getAssistHandlerViewController(); |
shawnlin | 2624bec | 2019-10-07 16:43:21 +0800 | [diff] [blame] | 1252 | if (controller != null) { |
| 1253 | controller.setBottomOffset(insets.getSystemWindowInsetBottom()); |
| 1254 | } |
Adrian Roos | 7e58a08 | 2018-03-09 16:40:56 +0100 | [diff] [blame] | 1255 | return super.onApplyWindowInsets(insets); |
| 1256 | } |
| 1257 | |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1258 | private static void dumpButton(PrintWriter pw, String caption, ButtonDispatcher button) { |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 1259 | pw.print(" " + caption + ": "); |
| 1260 | if (button == null) { |
| 1261 | pw.print("null"); |
| 1262 | } else { |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1263 | pw.print(visibilityToString(button.getVisibility()) |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 1264 | + " alpha=" + button.getAlpha() |
| 1265 | ); |
John Spurlock | 56d007b | 2013-10-28 18:40:56 -0400 | [diff] [blame] | 1266 | } |
| 1267 | pw.println(); |
| 1268 | } |
| 1269 | |
Jorim Jaggi | f479792 | 2014-08-04 22:49:41 +0200 | [diff] [blame] | 1270 | public interface OnVerticalChangedListener { |
| 1271 | void onVerticalChanged(boolean isVertical); |
| 1272 | } |
Jason Monk | a208182 | 2016-01-18 14:41:03 -0500 | [diff] [blame] | 1273 | |
Matthew Ng | ff63812 | 2019-03-21 17:17:18 -0700 | [diff] [blame] | 1274 | private final Consumer<Boolean> mDockedListener = exists -> post(() -> { |
Jason Monk | 32e3bb5 | 2017-07-27 12:35:41 -0400 | [diff] [blame] | 1275 | mDockedStackExists = exists; |
| 1276 | updateRecentsIcon(); |
| 1277 | }); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1278 | } |