Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 19 | import android.annotation.ColorInt; |
| 20 | import android.annotation.DrawableRes; |
| 21 | import android.annotation.LayoutRes; |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 22 | import android.app.StatusBarManager; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 23 | import android.content.Context; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 24 | import android.content.res.Configuration; |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 25 | import android.content.res.TypedArray; |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 26 | import android.graphics.Canvas; |
| 27 | import android.graphics.Paint; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 28 | import android.graphics.PorterDuff; |
| 29 | import android.graphics.PorterDuffXfermode; |
John Spurlock | fba9120 | 2014-04-22 12:58:26 -0400 | [diff] [blame] | 30 | import android.graphics.Rect; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 31 | import android.graphics.drawable.Drawable; |
Issei Suzuki | ca19e6e | 2019-02-26 12:39:11 +0100 | [diff] [blame] | 32 | import android.hardware.display.AmbientDisplayConfiguration; |
Jaewan Kim | 5026936 | 2016-12-23 11:22:02 +0900 | [diff] [blame] | 33 | import android.media.AudioManager; |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 34 | import android.media.session.MediaSessionLegacyHelper; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 35 | import android.net.Uri; |
| 36 | import android.os.Bundle; |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 37 | import android.os.SystemClock; |
Lucas Dupin | 34f6d96 | 2019-02-22 14:47:50 -0800 | [diff] [blame] | 38 | import android.os.UserHandle; |
| 39 | import android.provider.Settings; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 40 | import android.util.AttributeSet; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 41 | import android.view.ActionMode; |
felkachang | 7749c9a | 2018-06-11 15:56:15 +0800 | [diff] [blame] | 42 | import android.view.DisplayCutout; |
Lucas Dupin | 34f6d96 | 2019-02-22 14:47:50 -0800 | [diff] [blame] | 43 | import android.view.GestureDetector; |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 44 | import android.view.InputDevice; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 45 | import android.view.InputQueue; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 46 | import android.view.KeyEvent; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 47 | import android.view.LayoutInflater; |
| 48 | import android.view.Menu; |
| 49 | import android.view.MenuItem; |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 50 | import android.view.MotionEvent; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 51 | import android.view.SurfaceHolder; |
Daniel Sandler | b4e56ed | 2012-09-12 23:07:44 -0700 | [diff] [blame] | 52 | import android.view.View; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 53 | import android.view.ViewGroup; |
| 54 | import android.view.ViewTreeObserver; |
| 55 | import android.view.Window; |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 56 | import android.view.WindowInsetsController; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 57 | import android.widget.FrameLayout; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 58 | |
Selim Cinek | f8c4add | 2017-06-08 09:54:58 -0700 | [diff] [blame] | 59 | import com.android.internal.annotations.VisibleForTesting; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 60 | import com.android.internal.view.FloatingActionMode; |
| 61 | import com.android.internal.widget.FloatingToolbar; |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 62 | import com.android.systemui.Dependency; |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 63 | import com.android.systemui.ExpandHelper; |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 64 | import com.android.systemui.R; |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 65 | import com.android.systemui.classifier.FalsingManager; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 66 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 67 | import com.android.systemui.statusbar.DragDownHelper; |
| 68 | import com.android.systemui.statusbar.StatusBarState; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 69 | import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; |
Lucas Dupin | 34f6d96 | 2019-02-22 14:47:50 -0800 | [diff] [blame] | 70 | import com.android.systemui.tuner.TunerService; |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 71 | |
Selim Cinek | fc5c199 | 2018-01-29 12:40:32 -0800 | [diff] [blame] | 72 | import java.io.FileDescriptor; |
| 73 | import java.io.PrintWriter; |
| 74 | |
Lucas Dupin | 34f6d96 | 2019-02-22 14:47:50 -0800 | [diff] [blame] | 75 | /** |
| 76 | * Combined status bar and notification panel view. Also holding backdrop and scrims. |
| 77 | */ |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 78 | public class StatusBarWindowView extends FrameLayout { |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 79 | public static final String TAG = "StatusBarWindowView"; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 80 | public static final boolean DEBUG = StatusBar.DEBUG; |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 81 | |
Lucas Dupin | 34f6d96 | 2019-02-22 14:47:50 -0800 | [diff] [blame] | 82 | private final GestureDetector mGestureDetector; |
| 83 | private final StatusBarStateController mStatusBarStateController; |
| 84 | private boolean mDoubleTapEnabled; |
| 85 | private boolean mSingleTapEnabled; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 86 | private DragDownHelper mDragDownHelper; |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 87 | private NotificationStackScrollLayout mStackScrollLayout; |
Daniel Sandler | b4e56ed | 2012-09-12 23:07:44 -0700 | [diff] [blame] | 88 | private NotificationPanelView mNotificationPanel; |
Adrian Roos | 9dc3209 | 2014-09-02 23:34:10 +0200 | [diff] [blame] | 89 | private View mBrightnessMirror; |
Jorim Jaggi | f0c3807 | 2018-06-19 17:27:08 +0200 | [diff] [blame] | 90 | private PhoneStatusBarView mStatusBarView; |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 91 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 92 | private int mRightInset = 0; |
Adrian Roos | 85d202b | 2016-06-02 16:27:47 -0700 | [diff] [blame] | 93 | private int mLeftInset = 0; |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 94 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 95 | private StatusBar mService; |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 96 | private final Paint mTransparentSrcPaint = new Paint(); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 97 | private FalsingManager mFalsingManager; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 98 | |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 99 | // Implements the floating action mode for TextView's Cut/Copy/Past menu. Normally provided by |
| 100 | // DecorView, but since this is a special window we have to roll our own. |
| 101 | private View mFloatingActionModeOriginatingView; |
| 102 | private ActionMode mFloatingActionMode; |
| 103 | private FloatingToolbar mFloatingToolbar; |
| 104 | private ViewTreeObserver.OnPreDrawListener mFloatingToolbarPreDrawListener; |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 105 | private boolean mTouchCancelled; |
| 106 | private boolean mTouchActive; |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 107 | private boolean mExpandAnimationRunning; |
Selim Cinek | 7e222c3c | 2018-01-25 12:22:41 -0800 | [diff] [blame] | 108 | private boolean mExpandAnimationPending; |
Lucas Dupin | 34f6d96 | 2019-02-22 14:47:50 -0800 | [diff] [blame] | 109 | |
| 110 | private final GestureDetector.SimpleOnGestureListener mGestureListener = |
| 111 | new GestureDetector.SimpleOnGestureListener() { |
| 112 | @Override |
| 113 | public boolean onSingleTapConfirmed(MotionEvent e) { |
| 114 | if (mSingleTapEnabled) { |
| 115 | mService.wakeUpIfDozing(SystemClock.uptimeMillis(), StatusBarWindowView.this, |
| 116 | "SINGLE_TAP"); |
| 117 | } |
| 118 | return mSingleTapEnabled; |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public boolean onDoubleTap(MotionEvent e) { |
| 123 | if (mDoubleTapEnabled) { |
| 124 | mService.wakeUpIfDozing(SystemClock.uptimeMillis(), StatusBarWindowView.this, |
| 125 | "DOUBLE_TAP"); |
| 126 | } |
| 127 | return mDoubleTapEnabled; |
| 128 | } |
| 129 | }; |
| 130 | private final TunerService.Tunable mTunable = (key, newValue) -> { |
| 131 | AmbientDisplayConfiguration configuration = new AmbientDisplayConfiguration(mContext); |
| 132 | switch (key) { |
| 133 | case Settings.Secure.DOZE_DOUBLE_TAP_GESTURE: |
| 134 | mDoubleTapEnabled = configuration.doubleTapGestureEnabled(UserHandle.USER_CURRENT); |
| 135 | break; |
| 136 | case Settings.Secure.DOZE_TAP_SCREEN_GESTURE: |
| 137 | mSingleTapEnabled = configuration.tapGestureEnabled(UserHandle.USER_CURRENT); |
| 138 | } |
| 139 | }; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 140 | |
Jorim Jaggi | 0d4a995 | 2018-06-06 17:22:56 +0200 | [diff] [blame] | 141 | /** |
| 142 | * If set to true, the current gesture started below the notch and we need to dispatch touch |
| 143 | * events manually as it's outside of the regular view bounds. |
| 144 | */ |
| 145 | private boolean mExpandingBelowNotch; |
| 146 | |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 147 | public StatusBarWindowView(Context context, AttributeSet attrs) { |
| 148 | super(context, attrs); |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 149 | setMotionEventSplittingEnabled(false); |
Selim Cinek | a0fad3b | 2014-09-19 17:20:05 +0200 | [diff] [blame] | 150 | mTransparentSrcPaint.setColor(0); |
| 151 | mTransparentSrcPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 152 | mFalsingManager = FalsingManager.getInstance(context); |
Lucas Dupin | 34f6d96 | 2019-02-22 14:47:50 -0800 | [diff] [blame] | 153 | mGestureDetector = new GestureDetector(context, mGestureListener); |
| 154 | mStatusBarStateController = Dependency.get(StatusBarStateController.class); |
| 155 | Dependency.get(TunerService.class).addTunable(mTunable, |
| 156 | Settings.Secure.DOZE_DOUBLE_TAP_GESTURE, |
| 157 | Settings.Secure.DOZE_TAP_SCREEN_GESTURE); |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | @Override |
John Spurlock | fba9120 | 2014-04-22 12:58:26 -0400 | [diff] [blame] | 161 | protected boolean fitSystemWindows(Rect insets) { |
| 162 | if (getFitsSystemWindows()) { |
Adrian Roos | 85d202b | 2016-06-02 16:27:47 -0700 | [diff] [blame] | 163 | boolean paddingChanged = insets.top != getPaddingTop() |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 164 | || insets.bottom != getPaddingBottom(); |
Jorim Jaggi | aa80614 | 2015-05-20 18:04:16 -0700 | [diff] [blame] | 165 | |
felkachang | 7749c9a | 2018-06-11 15:56:15 +0800 | [diff] [blame] | 166 | int rightCutout = 0; |
| 167 | int leftCutout = 0; |
| 168 | DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout(); |
| 169 | if (displayCutout != null) { |
| 170 | leftCutout = displayCutout.getSafeInsetLeft(); |
| 171 | rightCutout = displayCutout.getSafeInsetRight(); |
| 172 | } |
| 173 | |
| 174 | int targetLeft = Math.max(insets.left, leftCutout); |
| 175 | int targetRight = Math.max(insets.right, rightCutout); |
| 176 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 177 | // Super-special right inset handling, because scrims and backdrop need to ignore it. |
felkachang | 7749c9a | 2018-06-11 15:56:15 +0800 | [diff] [blame] | 178 | if (targetRight != mRightInset || targetLeft != mLeftInset) { |
| 179 | mRightInset = targetRight; |
| 180 | mLeftInset = targetLeft; |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 181 | applyMargins(); |
| 182 | } |
Adrian Roos | 85d202b | 2016-06-02 16:27:47 -0700 | [diff] [blame] | 183 | // Drop top inset, and pass through bottom inset. |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 184 | if (paddingChanged) { |
Adrian Roos | 85d202b | 2016-06-02 16:27:47 -0700 | [diff] [blame] | 185 | setPadding(0, 0, 0, 0); |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 186 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 187 | insets.left = 0; |
| 188 | insets.top = 0; |
| 189 | insets.right = 0; |
John Spurlock | fba9120 | 2014-04-22 12:58:26 -0400 | [diff] [blame] | 190 | } else { |
Adrian Roos | 85d202b | 2016-06-02 16:27:47 -0700 | [diff] [blame] | 191 | if (mRightInset != 0 || mLeftInset != 0) { |
Adrian Roos | e49e409 | 2015-06-10 18:50:18 -0700 | [diff] [blame] | 192 | mRightInset = 0; |
Adrian Roos | 85d202b | 2016-06-02 16:27:47 -0700 | [diff] [blame] | 193 | mLeftInset = 0; |
Adrian Roos | e49e409 | 2015-06-10 18:50:18 -0700 | [diff] [blame] | 194 | applyMargins(); |
| 195 | } |
Jorim Jaggi | 416493b | 2014-09-13 03:57:32 +0200 | [diff] [blame] | 196 | boolean changed = getPaddingLeft() != 0 |
| 197 | || getPaddingRight() != 0 |
| 198 | || getPaddingTop() != 0 |
| 199 | || getPaddingBottom() != 0; |
| 200 | if (changed) { |
| 201 | setPadding(0, 0, 0, 0); |
| 202 | } |
Jorim Jaggi | aa80614 | 2015-05-20 18:04:16 -0700 | [diff] [blame] | 203 | insets.top = 0; |
John Spurlock | fba9120 | 2014-04-22 12:58:26 -0400 | [diff] [blame] | 204 | } |
Jorim Jaggi | d7daab7 | 2014-05-06 22:22:20 +0200 | [diff] [blame] | 205 | return false; |
John Spurlock | fba9120 | 2014-04-22 12:58:26 -0400 | [diff] [blame] | 206 | } |
| 207 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 208 | private void applyMargins() { |
| 209 | final int N = getChildCount(); |
| 210 | for (int i = 0; i < N; i++) { |
| 211 | View child = getChildAt(i); |
| 212 | if (child.getLayoutParams() instanceof LayoutParams) { |
| 213 | LayoutParams lp = (LayoutParams) child.getLayoutParams(); |
Adrian Roos | 85d202b | 2016-06-02 16:27:47 -0700 | [diff] [blame] | 214 | if (!lp.ignoreRightInset |
| 215 | && (lp.rightMargin != mRightInset || lp.leftMargin != mLeftInset)) { |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 216 | lp.rightMargin = mRightInset; |
Adrian Roos | 85d202b | 2016-06-02 16:27:47 -0700 | [diff] [blame] | 217 | lp.leftMargin = mLeftInset; |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 218 | child.requestLayout(); |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 224 | @VisibleForTesting |
| 225 | protected NotificationStackScrollLayout getStackScrollLayout() { |
| 226 | return mStackScrollLayout; |
| 227 | } |
| 228 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 229 | @Override |
| 230 | public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs) { |
| 231 | return new LayoutParams(getContext(), attrs); |
| 232 | } |
| 233 | |
| 234 | @Override |
| 235 | protected FrameLayout.LayoutParams generateDefaultLayoutParams() { |
| 236 | return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
| 237 | } |
| 238 | |
John Spurlock | fba9120 | 2014-04-22 12:58:26 -0400 | [diff] [blame] | 239 | @Override |
Selim Cinek | 4e6b2d3 | 2015-06-25 20:15:33 -0400 | [diff] [blame] | 240 | protected void onFinishInflate() { |
| 241 | super.onFinishInflate(); |
Selim Cinek | b6d85eb | 2014-03-28 20:21:01 +0100 | [diff] [blame] | 242 | mStackScrollLayout = (NotificationStackScrollLayout) findViewById( |
| 243 | R.id.notification_stack_scroller); |
Daniel Sandler | b4e56ed | 2012-09-12 23:07:44 -0700 | [diff] [blame] | 244 | mNotificationPanel = (NotificationPanelView) findViewById(R.id.notification_panel); |
Adrian Roos | 9dc3209 | 2014-09-02 23:34:10 +0200 | [diff] [blame] | 245 | mBrightnessMirror = findViewById(R.id.brightness_mirror); |
Selim Cinek | 4e6b2d3 | 2015-06-25 20:15:33 -0400 | [diff] [blame] | 246 | } |
| 247 | |
dooyoung.hwang | e4b841e | 2016-11-16 08:59:23 +0900 | [diff] [blame] | 248 | @Override |
| 249 | public void onViewAdded(View child) { |
| 250 | super.onViewAdded(child); |
| 251 | if (child.getId() == R.id.brightness_mirror) { |
| 252 | mBrightnessMirror = child; |
| 253 | } |
| 254 | } |
| 255 | |
Jorim Jaggi | f0c3807 | 2018-06-19 17:27:08 +0200 | [diff] [blame] | 256 | public void setStatusBarView(PhoneStatusBarView statusBarView) { |
| 257 | mStatusBarView = statusBarView; |
| 258 | } |
| 259 | |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 260 | public void setService(StatusBar service) { |
Selim Cinek | 4e6b2d3 | 2015-06-25 20:15:33 -0400 | [diff] [blame] | 261 | mService = service; |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 262 | NotificationStackScrollLayout stackScrollLayout = getStackScrollLayout(); |
| 263 | ExpandHelper.Callback expandHelperCallback = stackScrollLayout.getExpandHelperCallback(); |
| 264 | DragDownHelper.DragDownCallback dragDownCallback = stackScrollLayout.getDragDownCallback(); |
| 265 | setDragDownHelper(new DragDownHelper(getContext(), this, expandHelperCallback, |
| 266 | dragDownCallback)); |
Selim Cinek | f8c4add | 2017-06-08 09:54:58 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | @VisibleForTesting |
| 270 | void setDragDownHelper(DragDownHelper dragDownHelper) { |
| 271 | mDragDownHelper = dragDownHelper; |
Selim Cinek | 4e6b2d3 | 2015-06-25 20:15:33 -0400 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | @Override |
| 275 | protected void onAttachedToWindow () { |
| 276 | super.onAttachedToWindow(); |
Lucas Dupin | 90a38dd | 2018-09-05 09:37:37 -0700 | [diff] [blame] | 277 | setWillNotDraw(!DEBUG); |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | @Override |
| 281 | public boolean dispatchKeyEvent(KeyEvent event) { |
Adrian Roos | 56cf73a | 2016-07-18 14:23:32 -0700 | [diff] [blame] | 282 | if (mService.interceptMediaKey(event)) { |
| 283 | return true; |
| 284 | } |
| 285 | if (super.dispatchKeyEvent(event)) { |
| 286 | return true; |
| 287 | } |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 288 | boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 289 | switch (event.getKeyCode()) { |
Jorim Jaggi | 8c8bcc1 | 2014-04-16 21:36:51 +0200 | [diff] [blame] | 290 | case KeyEvent.KEYCODE_BACK: |
| 291 | if (!down) { |
| 292 | mService.onBackPressed(); |
| 293 | } |
| 294 | return true; |
| 295 | case KeyEvent.KEYCODE_MENU: |
| 296 | if (!down) { |
| 297 | return mService.onMenuPressed(); |
| 298 | } |
Jorim Jaggi | 3425076 | 2014-07-03 23:51:19 +0200 | [diff] [blame] | 299 | case KeyEvent.KEYCODE_SPACE: |
| 300 | if (!down) { |
| 301 | return mService.onSpacePressed(); |
| 302 | } |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 303 | break; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 304 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 305 | case KeyEvent.KEYCODE_VOLUME_UP: |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 306 | if (mService.isDozing()) { |
Jaewan Kim | 5026936 | 2016-12-23 11:22:02 +0900 | [diff] [blame] | 307 | MediaSessionLegacyHelper.getHelper(mContext).sendVolumeKeyEvent( |
| 308 | event, AudioManager.USE_DEFAULT_STREAM_TYPE, true); |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 309 | return true; |
John Spurlock | d06aa57 | 2014-09-10 10:40:49 -0400 | [diff] [blame] | 310 | } |
John Spurlock | 0b99ea9 | 2014-10-01 15:32:22 -0400 | [diff] [blame] | 311 | break; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 312 | } |
Adrian Roos | 56cf73a | 2016-07-18 14:23:32 -0700 | [diff] [blame] | 313 | return false; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 314 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 315 | |
Selim Cinek | d95ca7c | 2017-07-26 12:20:38 -0700 | [diff] [blame] | 316 | public void setTouchActive(boolean touchActive) { |
| 317 | mTouchActive = touchActive; |
Selim Cinek | d95ca7c | 2017-07-26 12:20:38 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 320 | @Override |
Adrian Roos | 9dc3209 | 2014-09-02 23:34:10 +0200 | [diff] [blame] | 321 | public boolean dispatchTouchEvent(MotionEvent ev) { |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 322 | boolean isDown = ev.getActionMasked() == MotionEvent.ACTION_DOWN; |
Jorim Jaggi | 0d4a995 | 2018-06-06 17:22:56 +0200 | [diff] [blame] | 323 | boolean isUp = ev.getActionMasked() == MotionEvent.ACTION_UP; |
Adrian Roos | a6c03f8 | 2017-07-26 16:20:30 +0200 | [diff] [blame] | 324 | boolean isCancel = ev.getActionMasked() == MotionEvent.ACTION_CANCEL; |
Jorim Jaggi | 0d4a995 | 2018-06-06 17:22:56 +0200 | [diff] [blame] | 325 | |
| 326 | // Reset manual touch dispatch state here but make sure the UP/CANCEL event still gets |
| 327 | // delivered. |
| 328 | boolean expandingBelowNotch = mExpandingBelowNotch; |
| 329 | if (isUp || isCancel) { |
| 330 | mExpandingBelowNotch = false; |
| 331 | } |
| 332 | |
Adrian Roos | a6c03f8 | 2017-07-26 16:20:30 +0200 | [diff] [blame] | 333 | if (!isCancel && mService.shouldIgnoreTouch()) { |
| 334 | return false; |
| 335 | } |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 336 | if (isDown && mNotificationPanel.isFullyCollapsed()) { |
Jorim Jaggi | e05256e | 2016-09-08 14:58:20 -0700 | [diff] [blame] | 337 | mNotificationPanel.startExpandLatencyTracking(); |
| 338 | } |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 339 | if (isDown) { |
Selim Cinek | d95ca7c | 2017-07-26 12:20:38 -0700 | [diff] [blame] | 340 | setTouchActive(true); |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 341 | mTouchCancelled = false; |
| 342 | } else if (ev.getActionMasked() == MotionEvent.ACTION_UP |
| 343 | || ev.getActionMasked() == MotionEvent.ACTION_CANCEL) { |
Selim Cinek | d95ca7c | 2017-07-26 12:20:38 -0700 | [diff] [blame] | 344 | setTouchActive(false); |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 345 | } |
Selim Cinek | 7e222c3c | 2018-01-25 12:22:41 -0800 | [diff] [blame] | 346 | if (mTouchCancelled || mExpandAnimationRunning || mExpandAnimationPending) { |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 347 | return false; |
| 348 | } |
Blazej Magnowski | 0e2ffbd | 2015-09-10 14:37:17 -0700 | [diff] [blame] | 349 | mFalsingManager.onTouchEvent(ev, getWidth(), getHeight()); |
Lucas Dupin | 34f6d96 | 2019-02-22 14:47:50 -0800 | [diff] [blame] | 350 | mGestureDetector.onTouchEvent(ev); |
Adrian Roos | 9dc3209 | 2014-09-02 23:34:10 +0200 | [diff] [blame] | 351 | if (mBrightnessMirror != null && mBrightnessMirror.getVisibility() == VISIBLE) { |
| 352 | // Disallow new pointers while the brightness mirror is visible. This is so that you |
| 353 | // can't touch anything other than the brightness slider while the mirror is showing |
| 354 | // and the rest of the panel is transparent. |
| 355 | if (ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) { |
| 356 | return false; |
| 357 | } |
| 358 | } |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 359 | if (isDown) { |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 360 | getStackScrollLayout().closeControlsIfOutsideTouch(ev); |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 361 | } |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 362 | if (mService.isDozing()) { |
| 363 | mService.mDozeScrimController.extendPulse(); |
| 364 | } |
Mady Mellor | 7a9b2a6 | 2016-03-23 07:41:47 -0700 | [diff] [blame] | 365 | |
Jorim Jaggi | 0d4a995 | 2018-06-06 17:22:56 +0200 | [diff] [blame] | 366 | // In case we start outside of the view bounds (below the status bar), we need to dispatch |
| 367 | // the touch manually as the view system can't accomodate for touches outside of the |
| 368 | // regular view bounds. |
| 369 | if (isDown && ev.getY() >= mBottom) { |
| 370 | mExpandingBelowNotch = true; |
| 371 | expandingBelowNotch = true; |
| 372 | } |
| 373 | if (expandingBelowNotch) { |
Jorim Jaggi | f0c3807 | 2018-06-19 17:27:08 +0200 | [diff] [blame] | 374 | return mStatusBarView.dispatchTouchEvent(ev); |
Jorim Jaggi | 0d4a995 | 2018-06-06 17:22:56 +0200 | [diff] [blame] | 375 | } |
| 376 | |
Adrian Roos | 9dc3209 | 2014-09-02 23:34:10 +0200 | [diff] [blame] | 377 | return super.dispatchTouchEvent(ev); |
| 378 | } |
| 379 | |
| 380 | @Override |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 381 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 382 | NotificationStackScrollLayout stackScrollLayout = getStackScrollLayout(); |
Lucas Dupin | 1c32743 | 2019-01-03 13:37:53 -0800 | [diff] [blame] | 383 | if (mService.isDozing() && !mService.isPulsing()) { |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 384 | // Capture all touch events in always-on. |
Adrian Roos | ebea7a7 | 2016-10-26 12:51:26 -0700 | [diff] [blame] | 385 | return true; |
| 386 | } |
Daniel Sandler | b4e56ed | 2012-09-12 23:07:44 -0700 | [diff] [blame] | 387 | boolean intercept = false; |
Selim Cinek | fab078b | 2014-03-27 22:45:58 +0100 | [diff] [blame] | 388 | if (mNotificationPanel.isFullyExpanded() |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 389 | && stackScrollLayout.getVisibility() == View.VISIBLE |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 390 | && mStatusBarStateController.getState() == StatusBarState.KEYGUARD |
Lucas Dupin | 1c32743 | 2019-01-03 13:37:53 -0800 | [diff] [blame] | 391 | && !mService.isBouncerShowing()) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 392 | intercept = mDragDownHelper.onInterceptTouchEvent(ev); |
Daniel Sandler | b4e56ed | 2012-09-12 23:07:44 -0700 | [diff] [blame] | 393 | } |
| 394 | if (!intercept) { |
| 395 | super.onInterceptTouchEvent(ev); |
| 396 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 397 | if (intercept) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 398 | MotionEvent cancellation = MotionEvent.obtain(ev); |
| 399 | cancellation.setAction(MotionEvent.ACTION_CANCEL); |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 400 | stackScrollLayout.onInterceptTouchEvent(cancellation); |
Selim Cinek | 31094df | 2014-08-14 19:28:15 +0200 | [diff] [blame] | 401 | mNotificationPanel.onInterceptTouchEvent(cancellation); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 402 | cancellation.recycle(); |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 403 | } |
| 404 | return intercept; |
| 405 | } |
| 406 | |
| 407 | @Override |
| 408 | public boolean onTouchEvent(MotionEvent ev) { |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 409 | boolean handled = false; |
| 410 | if (mService.isDozing()) { |
Lucas Dupin | 1c32743 | 2019-01-03 13:37:53 -0800 | [diff] [blame] | 411 | handled = !mService.isPulsing(); |
Adrian Roos | 8008bd1 | 2017-02-22 15:02:09 +0100 | [diff] [blame] | 412 | } |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 413 | if ((mStatusBarStateController.getState() == StatusBarState.KEYGUARD && !handled) |
Selim Cinek | f8c4add | 2017-06-08 09:54:58 -0700 | [diff] [blame] | 414 | || mDragDownHelper.isDraggingDown()) { |
Selim Cinek | 740c111 | 2016-12-22 16:39:54 +0100 | [diff] [blame] | 415 | // we still want to finish our drag down gesture when locking the screen |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 416 | handled = mDragDownHelper.onTouchEvent(ev); |
Daniel Sandler | b4e56ed | 2012-09-12 23:07:44 -0700 | [diff] [blame] | 417 | } |
| 418 | if (!handled) { |
| 419 | handled = super.onTouchEvent(ev); |
| 420 | } |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 421 | final int action = ev.getAction(); |
John Spurlock | d157ca0 | 2013-11-04 10:28:05 -0500 | [diff] [blame] | 422 | if (!handled && (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL)) { |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 423 | mService.setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false); |
| 424 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 425 | return handled; |
| 426 | } |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 427 | |
| 428 | @Override |
| 429 | public void onDraw(Canvas canvas) { |
| 430 | super.onDraw(canvas); |
| 431 | if (DEBUG) { |
| 432 | Paint pt = new Paint(); |
| 433 | pt.setColor(0x80FFFF00); |
| 434 | pt.setStrokeWidth(12.0f); |
| 435 | pt.setStyle(Paint.Style.STROKE); |
| 436 | canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), pt); |
| 437 | } |
| 438 | } |
Daniel Sandler | ac47ff7 | 2012-10-23 10:41:44 -0400 | [diff] [blame] | 439 | |
| 440 | public void cancelExpandHelper() { |
Aaron Heuckroth | cd944dc | 2018-10-01 16:31:08 -0400 | [diff] [blame] | 441 | NotificationStackScrollLayout stackScrollLayout = getStackScrollLayout(); |
| 442 | if (stackScrollLayout != null) { |
| 443 | stackScrollLayout.cancelExpandHelper(); |
Daniel Sandler | 1a3bdd5 | 2012-10-23 19:21:20 -0400 | [diff] [blame] | 444 | } |
Daniel Sandler | ac47ff7 | 2012-10-23 10:41:44 -0400 | [diff] [blame] | 445 | } |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 446 | |
Selim Cinek | 48a92a5 | 2017-05-02 20:02:30 -0700 | [diff] [blame] | 447 | public void cancelCurrentTouch() { |
| 448 | if (mTouchActive) { |
| 449 | final long now = SystemClock.uptimeMillis(); |
| 450 | MotionEvent event = MotionEvent.obtain(now, now, |
| 451 | MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); |
| 452 | event.setSource(InputDevice.SOURCE_TOUCHSCREEN); |
| 453 | dispatchTouchEvent(event); |
| 454 | event.recycle(); |
| 455 | mTouchCancelled = true; |
| 456 | } |
| 457 | } |
| 458 | |
Selim Cinek | 2627d72 | 2018-01-19 12:16:49 -0800 | [diff] [blame] | 459 | public void setExpandAnimationRunning(boolean expandAnimationRunning) { |
| 460 | mExpandAnimationRunning = expandAnimationRunning; |
| 461 | } |
| 462 | |
Selim Cinek | 7e222c3c | 2018-01-25 12:22:41 -0800 | [diff] [blame] | 463 | public void setExpandAnimationPending(boolean pending) { |
| 464 | mExpandAnimationPending = pending; |
| 465 | } |
| 466 | |
Selim Cinek | fc5c199 | 2018-01-29 12:40:32 -0800 | [diff] [blame] | 467 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 468 | pw.print(" mExpandAnimationPending="); pw.println(mExpandAnimationPending); |
| 469 | pw.print(" mExpandAnimationRunning="); pw.println(mExpandAnimationRunning); |
| 470 | pw.print(" mTouchCancelled="); pw.println(mTouchCancelled); |
| 471 | pw.print(" mTouchActive="); pw.println(mTouchActive); |
| 472 | } |
| 473 | |
Adrian Roos | 2f2bd9a | 2015-06-04 18:11:14 -0700 | [diff] [blame] | 474 | public class LayoutParams extends FrameLayout.LayoutParams { |
| 475 | |
| 476 | public boolean ignoreRightInset; |
| 477 | |
| 478 | public LayoutParams(int width, int height) { |
| 479 | super(width, height); |
| 480 | } |
| 481 | |
| 482 | public LayoutParams(Context c, AttributeSet attrs) { |
| 483 | super(c, attrs); |
| 484 | |
| 485 | TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.StatusBarWindowView_Layout); |
| 486 | ignoreRightInset = a.getBoolean( |
| 487 | R.styleable.StatusBarWindowView_Layout_ignoreRightInset, false); |
| 488 | a.recycle(); |
| 489 | } |
| 490 | } |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 491 | |
| 492 | @Override |
| 493 | public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, |
| 494 | int type) { |
| 495 | if (type == ActionMode.TYPE_FLOATING) { |
| 496 | return startActionMode(originalView, callback, type); |
| 497 | } |
| 498 | return super.startActionModeForChild(originalView, callback, type); |
| 499 | } |
| 500 | |
| 501 | private ActionMode createFloatingActionMode( |
| 502 | View originatingView, ActionMode.Callback2 callback) { |
| 503 | if (mFloatingActionMode != null) { |
| 504 | mFloatingActionMode.finish(); |
| 505 | } |
| 506 | cleanupFloatingActionModeViews(); |
Tarandeep Singh | c9c83a9 | 2017-08-29 14:39:22 -0700 | [diff] [blame] | 507 | mFloatingToolbar = new FloatingToolbar(mFakeWindow); |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 508 | final FloatingActionMode mode = |
Abodunrinwa Toki | 17293cc | 2017-05-22 14:16:04 +0100 | [diff] [blame] | 509 | new FloatingActionMode(mContext, callback, originatingView, mFloatingToolbar); |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 510 | mFloatingActionModeOriginatingView = originatingView; |
| 511 | mFloatingToolbarPreDrawListener = |
| 512 | new ViewTreeObserver.OnPreDrawListener() { |
| 513 | @Override |
| 514 | public boolean onPreDraw() { |
| 515 | mode.updateViewLocationInWindow(); |
| 516 | return true; |
| 517 | } |
| 518 | }; |
| 519 | return mode; |
| 520 | } |
| 521 | |
| 522 | private void setHandledFloatingActionMode(ActionMode mode) { |
| 523 | mFloatingActionMode = mode; |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 524 | mFloatingActionMode.invalidate(); // Will show the floating toolbar if necessary. |
| 525 | mFloatingActionModeOriginatingView.getViewTreeObserver() |
| 526 | .addOnPreDrawListener(mFloatingToolbarPreDrawListener); |
| 527 | } |
| 528 | |
| 529 | private void cleanupFloatingActionModeViews() { |
| 530 | if (mFloatingToolbar != null) { |
| 531 | mFloatingToolbar.dismiss(); |
| 532 | mFloatingToolbar = null; |
| 533 | } |
| 534 | if (mFloatingActionModeOriginatingView != null) { |
| 535 | if (mFloatingToolbarPreDrawListener != null) { |
| 536 | mFloatingActionModeOriginatingView.getViewTreeObserver() |
| 537 | .removeOnPreDrawListener(mFloatingToolbarPreDrawListener); |
| 538 | mFloatingToolbarPreDrawListener = null; |
| 539 | } |
| 540 | mFloatingActionModeOriginatingView = null; |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | private ActionMode startActionMode( |
| 545 | View originatingView, ActionMode.Callback callback, int type) { |
| 546 | ActionMode.Callback2 wrappedCallback = new ActionModeCallback2Wrapper(callback); |
| 547 | ActionMode mode = createFloatingActionMode(originatingView, wrappedCallback); |
| 548 | if (mode != null && wrappedCallback.onCreateActionMode(mode, mode.getMenu())) { |
| 549 | setHandledFloatingActionMode(mode); |
| 550 | } else { |
| 551 | mode = null; |
| 552 | } |
| 553 | return mode; |
| 554 | } |
| 555 | |
| 556 | private class ActionModeCallback2Wrapper extends ActionMode.Callback2 { |
| 557 | private final ActionMode.Callback mWrapped; |
| 558 | |
| 559 | public ActionModeCallback2Wrapper(ActionMode.Callback wrapped) { |
| 560 | mWrapped = wrapped; |
| 561 | } |
| 562 | |
| 563 | public boolean onCreateActionMode(ActionMode mode, Menu menu) { |
| 564 | return mWrapped.onCreateActionMode(mode, menu); |
| 565 | } |
| 566 | |
| 567 | public boolean onPrepareActionMode(ActionMode mode, Menu menu) { |
| 568 | requestFitSystemWindows(); |
| 569 | return mWrapped.onPrepareActionMode(mode, menu); |
| 570 | } |
| 571 | |
| 572 | public boolean onActionItemClicked(ActionMode mode, MenuItem item) { |
| 573 | return mWrapped.onActionItemClicked(mode, item); |
| 574 | } |
| 575 | |
| 576 | public void onDestroyActionMode(ActionMode mode) { |
| 577 | mWrapped.onDestroyActionMode(mode); |
| 578 | if (mode == mFloatingActionMode) { |
| 579 | cleanupFloatingActionModeViews(); |
| 580 | mFloatingActionMode = null; |
| 581 | } |
| 582 | requestFitSystemWindows(); |
| 583 | } |
| 584 | |
| 585 | @Override |
| 586 | public void onGetContentRect(ActionMode mode, View view, Rect outRect) { |
| 587 | if (mWrapped instanceof ActionMode.Callback2) { |
| 588 | ((ActionMode.Callback2) mWrapped).onGetContentRect(mode, view, outRect); |
| 589 | } else { |
| 590 | super.onGetContentRect(mode, view, outRect); |
| 591 | } |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | /** |
| 596 | * Minimal window to satisfy FloatingToolbar. |
| 597 | */ |
| 598 | private Window mFakeWindow = new Window(mContext) { |
| 599 | @Override |
| 600 | public void takeSurface(SurfaceHolder.Callback2 callback) { |
| 601 | } |
| 602 | |
| 603 | @Override |
| 604 | public void takeInputQueue(InputQueue.Callback callback) { |
| 605 | } |
| 606 | |
| 607 | @Override |
| 608 | public boolean isFloating() { |
| 609 | return false; |
| 610 | } |
| 611 | |
| 612 | @Override |
| 613 | public void alwaysReadCloseOnTouchAttr() { |
| 614 | } |
| 615 | |
| 616 | @Override |
| 617 | public void setContentView(@LayoutRes int layoutResID) { |
| 618 | } |
| 619 | |
| 620 | @Override |
| 621 | public void setContentView(View view) { |
| 622 | } |
| 623 | |
| 624 | @Override |
| 625 | public void setContentView(View view, ViewGroup.LayoutParams params) { |
| 626 | } |
| 627 | |
| 628 | @Override |
| 629 | public void addContentView(View view, ViewGroup.LayoutParams params) { |
| 630 | } |
| 631 | |
| 632 | @Override |
| 633 | public void clearContentView() { |
| 634 | } |
| 635 | |
| 636 | @Override |
| 637 | public View getCurrentFocus() { |
| 638 | return null; |
| 639 | } |
| 640 | |
| 641 | @Override |
| 642 | public LayoutInflater getLayoutInflater() { |
| 643 | return null; |
| 644 | } |
| 645 | |
| 646 | @Override |
| 647 | public void setTitle(CharSequence title) { |
| 648 | } |
| 649 | |
| 650 | @Override |
| 651 | public void setTitleColor(@ColorInt int textColor) { |
| 652 | } |
| 653 | |
| 654 | @Override |
| 655 | public void openPanel(int featureId, KeyEvent event) { |
| 656 | } |
| 657 | |
| 658 | @Override |
| 659 | public void closePanel(int featureId) { |
| 660 | } |
| 661 | |
| 662 | @Override |
| 663 | public void togglePanel(int featureId, KeyEvent event) { |
| 664 | } |
| 665 | |
| 666 | @Override |
| 667 | public void invalidatePanelMenu(int featureId) { |
| 668 | } |
| 669 | |
| 670 | @Override |
| 671 | public boolean performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags) { |
| 672 | return false; |
| 673 | } |
| 674 | |
| 675 | @Override |
| 676 | public boolean performPanelIdentifierAction(int featureId, int id, int flags) { |
| 677 | return false; |
| 678 | } |
| 679 | |
| 680 | @Override |
| 681 | public void closeAllPanels() { |
| 682 | } |
| 683 | |
| 684 | @Override |
| 685 | public boolean performContextMenuIdentifierAction(int id, int flags) { |
| 686 | return false; |
| 687 | } |
| 688 | |
| 689 | @Override |
| 690 | public void onConfigurationChanged(Configuration newConfig) { |
| 691 | } |
| 692 | |
| 693 | @Override |
| 694 | public void setBackgroundDrawable(Drawable drawable) { |
| 695 | } |
| 696 | |
| 697 | @Override |
| 698 | public void setFeatureDrawableResource(int featureId, @DrawableRes int resId) { |
| 699 | } |
| 700 | |
| 701 | @Override |
| 702 | public void setFeatureDrawableUri(int featureId, Uri uri) { |
| 703 | } |
| 704 | |
| 705 | @Override |
| 706 | public void setFeatureDrawable(int featureId, Drawable drawable) { |
| 707 | } |
| 708 | |
| 709 | @Override |
| 710 | public void setFeatureDrawableAlpha(int featureId, int alpha) { |
| 711 | } |
| 712 | |
| 713 | @Override |
| 714 | public void setFeatureInt(int featureId, int value) { |
| 715 | } |
| 716 | |
| 717 | @Override |
| 718 | public void takeKeyEvents(boolean get) { |
| 719 | } |
| 720 | |
| 721 | @Override |
| 722 | public boolean superDispatchKeyEvent(KeyEvent event) { |
| 723 | return false; |
| 724 | } |
| 725 | |
| 726 | @Override |
| 727 | public boolean superDispatchKeyShortcutEvent(KeyEvent event) { |
| 728 | return false; |
| 729 | } |
| 730 | |
| 731 | @Override |
| 732 | public boolean superDispatchTouchEvent(MotionEvent event) { |
| 733 | return false; |
| 734 | } |
| 735 | |
| 736 | @Override |
| 737 | public boolean superDispatchTrackballEvent(MotionEvent event) { |
| 738 | return false; |
| 739 | } |
| 740 | |
| 741 | @Override |
| 742 | public boolean superDispatchGenericMotionEvent(MotionEvent event) { |
| 743 | return false; |
| 744 | } |
| 745 | |
| 746 | @Override |
| 747 | public View getDecorView() { |
| 748 | return StatusBarWindowView.this; |
| 749 | } |
| 750 | |
| 751 | @Override |
| 752 | public View peekDecorView() { |
| 753 | return null; |
| 754 | } |
| 755 | |
| 756 | @Override |
| 757 | public Bundle saveHierarchyState() { |
| 758 | return null; |
| 759 | } |
| 760 | |
| 761 | @Override |
| 762 | public void restoreHierarchyState(Bundle savedInstanceState) { |
| 763 | } |
| 764 | |
| 765 | @Override |
| 766 | protected void onActive() { |
| 767 | } |
| 768 | |
| 769 | @Override |
| 770 | public void setChildDrawable(int featureId, Drawable drawable) { |
| 771 | } |
| 772 | |
| 773 | @Override |
| 774 | public void setChildInt(int featureId, int value) { |
| 775 | } |
| 776 | |
| 777 | @Override |
| 778 | public boolean isShortcutKey(int keyCode, KeyEvent event) { |
| 779 | return false; |
| 780 | } |
| 781 | |
| 782 | @Override |
| 783 | public void setVolumeControlStream(int streamType) { |
| 784 | } |
| 785 | |
| 786 | @Override |
| 787 | public int getVolumeControlStream() { |
| 788 | return 0; |
| 789 | } |
| 790 | |
| 791 | @Override |
| 792 | public int getStatusBarColor() { |
| 793 | return 0; |
| 794 | } |
| 795 | |
| 796 | @Override |
| 797 | public void setStatusBarColor(@ColorInt int color) { |
| 798 | } |
| 799 | |
| 800 | @Override |
| 801 | public int getNavigationBarColor() { |
| 802 | return 0; |
| 803 | } |
| 804 | |
| 805 | @Override |
| 806 | public void setNavigationBarColor(@ColorInt int color) { |
| 807 | } |
| 808 | |
| 809 | @Override |
| 810 | public void setDecorCaptionShade(int decorCaptionShade) { |
| 811 | } |
| 812 | |
| 813 | @Override |
| 814 | public void setResizingCaptionDrawable(Drawable drawable) { |
| 815 | } |
| 816 | |
| 817 | @Override |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 818 | public void onMultiWindowModeChanged() { |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | @Override |
Winson Chung | 4d8681f | 2017-05-23 16:22:08 -0700 | [diff] [blame] | 822 | public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) { |
| 823 | } |
| 824 | |
| 825 | @Override |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 826 | public void reportActivityRelaunched() { |
| 827 | } |
Jorim Jaggi | b603095 | 2018-10-23 18:31:52 +0200 | [diff] [blame] | 828 | |
| 829 | @Override |
| 830 | public WindowInsetsController getInsetsController() { |
| 831 | return null; |
| 832 | } |
Adrian Roos | 0bd8a4b | 2016-03-14 16:21:44 -0700 | [diff] [blame] | 833 | }; |
| 834 | |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 835 | } |
| 836 | |