Merge "Introduce NotificationInsetsController." into tm-qpr-dev am: f4c9850288
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20314123 Change-Id: I69f5d251a2f1522e74f1b568dc1673dace0f9aa4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -26,12 +26,12 @@
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.android.systemui.statusbar.BackDropView
|
||||
android:id="@+id/backdrop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
sysui:ignoreRightInset="true"
|
||||
>
|
||||
android:id="@+id/backdrop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
sysui:ignoreRightInset="true"
|
||||
>
|
||||
<ImageView android:id="@+id/backdrop_back"
|
||||
android:layout_width="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
@@ -49,7 +49,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:importantForAccessibility="no"
|
||||
sysui:ignoreRightInset="true"
|
||||
/>
|
||||
/>
|
||||
|
||||
<com.android.systemui.scrim.ScrimView
|
||||
android:id="@+id/scrim_notifications"
|
||||
@@ -57,17 +57,17 @@
|
||||
android:layout_height="match_parent"
|
||||
android:importantForAccessibility="no"
|
||||
sysui:ignoreRightInset="true"
|
||||
/>
|
||||
/>
|
||||
|
||||
<com.android.systemui.statusbar.LightRevealScrim
|
||||
android:id="@+id/light_reveal_scrim"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:id="@+id/light_reveal_scrim"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<include layout="@layout/status_bar_expanded"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="invisible" />
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<include layout="@layout/brightness_mirror_container" />
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.dagger;
|
||||
|
||||
import com.android.systemui.keyguard.KeyguardQuickAffordanceProvider;
|
||||
import com.android.systemui.statusbar.NotificationInsetsModule;
|
||||
import com.android.systemui.statusbar.QsFrameTranslateModule;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
@@ -28,6 +29,7 @@ import dagger.Subcomponent;
|
||||
@Subcomponent(modules = {
|
||||
DefaultComponentBinder.class,
|
||||
DependencyProvider.class,
|
||||
NotificationInsetsModule.class,
|
||||
QsFrameTranslateModule.class,
|
||||
SystemUIBinder.class,
|
||||
SystemUIModule.class,
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.android.systemui.keyguard.KeyguardSliceProvider;
|
||||
import com.android.systemui.media.muteawait.MediaMuteAwaitConnectionCli;
|
||||
import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
|
||||
import com.android.systemui.people.PeopleProvider;
|
||||
import com.android.systemui.statusbar.NotificationInsetsModule;
|
||||
import com.android.systemui.statusbar.QsFrameTranslateModule;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.unfold.FoldStateLogger;
|
||||
@@ -65,6 +66,7 @@ import dagger.Subcomponent;
|
||||
@Subcomponent(modules = {
|
||||
DefaultComponentBinder.class,
|
||||
DependencyProvider.class,
|
||||
NotificationInsetsModule.class,
|
||||
QsFrameTranslateModule.class,
|
||||
SystemUIBinder.class,
|
||||
SystemUIModule.class,
|
||||
|
||||
@@ -24,6 +24,7 @@ import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG;
|
||||
import android.annotation.ColorInt;
|
||||
import android.annotation.DrawableRes;
|
||||
import android.annotation.LayoutRes;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
@@ -36,6 +37,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Trace;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.view.ActionMode;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.InputQueue;
|
||||
@@ -74,6 +76,7 @@ public class NotificationShadeWindowView extends FrameLayout {
|
||||
private ViewTreeObserver.OnPreDrawListener mFloatingToolbarPreDrawListener;
|
||||
|
||||
private InteractionEventHandler mInteractionEventHandler;
|
||||
private LayoutInsetsController mLayoutInsetProvider;
|
||||
|
||||
public NotificationShadeWindowView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -108,12 +111,10 @@ public class NotificationShadeWindowView extends FrameLayout {
|
||||
mLeftInset = 0;
|
||||
mRightInset = 0;
|
||||
DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout();
|
||||
if (displayCutout != null) {
|
||||
mLeftInset = displayCutout.getSafeInsetLeft();
|
||||
mRightInset = displayCutout.getSafeInsetRight();
|
||||
}
|
||||
mLeftInset = Math.max(insets.left, mLeftInset);
|
||||
mRightInset = Math.max(insets.right, mRightInset);
|
||||
Pair<Integer, Integer> pairInsets = mLayoutInsetProvider
|
||||
.getinsets(windowInsets, displayCutout);
|
||||
mLeftInset = pairInsets.first;
|
||||
mRightInset = pairInsets.second;
|
||||
applyMargins();
|
||||
return windowInsets;
|
||||
}
|
||||
@@ -172,6 +173,10 @@ public class NotificationShadeWindowView extends FrameLayout {
|
||||
mInteractionEventHandler = listener;
|
||||
}
|
||||
|
||||
protected void setLayoutInsetsController(LayoutInsetsController provider) {
|
||||
mLayoutInsetProvider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
Boolean result = mInteractionEventHandler.handleDispatchTouchEvent(ev);
|
||||
@@ -353,6 +358,18 @@ public class NotificationShadeWindowView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller responsible for calculating insets for the shade window.
|
||||
*/
|
||||
public interface LayoutInsetsController {
|
||||
|
||||
/**
|
||||
* Update the insets and calculate them accordingly.
|
||||
*/
|
||||
Pair<Integer, Integer> getinsets(@Nullable WindowInsets windowInsets,
|
||||
@Nullable DisplayCutout displayCutout);
|
||||
}
|
||||
|
||||
interface InteractionEventHandler {
|
||||
/**
|
||||
* Returns a result for {@link ViewGroup#dispatchTouchEvent(MotionEvent)} or null to defer
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.android.systemui.keyguard.ui.binder.KeyguardBouncerViewBinder;
|
||||
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBouncerViewModel;
|
||||
import com.android.systemui.statusbar.DragDownHelper;
|
||||
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
|
||||
import com.android.systemui.statusbar.NotificationInsetsController;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
||||
@@ -76,6 +77,7 @@ public class NotificationShadeWindowViewController {
|
||||
private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
|
||||
private final AmbientState mAmbientState;
|
||||
private final PulsingGestureListener mPulsingGestureListener;
|
||||
private final NotificationInsetsController mNotificationInsetsController;
|
||||
|
||||
private GestureDetector mPulsingWakeupGestureHandler;
|
||||
private View mBrightnessMirror;
|
||||
@@ -111,6 +113,7 @@ public class NotificationShadeWindowViewController {
|
||||
CentralSurfaces centralSurfaces,
|
||||
NotificationShadeWindowController controller,
|
||||
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
|
||||
NotificationInsetsController notificationInsetsController,
|
||||
AmbientState ambientState,
|
||||
PulsingGestureListener pulsingGestureListener,
|
||||
FeatureFlags featureFlags,
|
||||
@@ -134,6 +137,7 @@ public class NotificationShadeWindowViewController {
|
||||
mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
|
||||
mAmbientState = ambientState;
|
||||
mPulsingGestureListener = pulsingGestureListener;
|
||||
mNotificationInsetsController = notificationInsetsController;
|
||||
|
||||
// This view is not part of the newly inflated expanded status bar.
|
||||
mBrightnessMirror = mView.findViewById(R.id.brightness_mirror_container);
|
||||
@@ -165,6 +169,7 @@ public class NotificationShadeWindowViewController {
|
||||
mPulsingWakeupGestureHandler = new GestureDetector(mView.getContext(),
|
||||
mPulsingGestureListener);
|
||||
|
||||
mView.setLayoutInsetsController(mNotificationInsetsController);
|
||||
mView.setInteractionEventHandler(new NotificationShadeWindowView.InteractionEventHandler() {
|
||||
@Override
|
||||
public Boolean handleDispatchTouchEvent(MotionEvent ev) {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar;
|
||||
|
||||
import com.android.systemui.shade.NotificationShadeWindowView;
|
||||
|
||||
/**
|
||||
* Calculates insets for the notification shade window view.
|
||||
*/
|
||||
public abstract class NotificationInsetsController
|
||||
implements NotificationShadeWindowView.LayoutInsetsController {
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar;
|
||||
|
||||
import static android.view.WindowInsets.Type.systemBars;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.graphics.Insets;
|
||||
import android.util.Pair;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Default implementation of NotificationsInsetsController.
|
||||
*/
|
||||
@SysUISingleton
|
||||
public class NotificationInsetsImpl extends NotificationInsetsController {
|
||||
|
||||
@Inject
|
||||
public NotificationInsetsImpl() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getinsets(@Nullable WindowInsets windowInsets,
|
||||
@Nullable DisplayCutout displayCutout) {
|
||||
final Insets insets = windowInsets.getInsetsIgnoringVisibility(systemBars());
|
||||
int leftInset = 0;
|
||||
int rightInset = 0;
|
||||
|
||||
if (displayCutout != null) {
|
||||
leftInset = displayCutout.getSafeInsetLeft();
|
||||
rightInset = displayCutout.getSafeInsetRight();
|
||||
}
|
||||
leftInset = Math.max(insets.left, leftInset);
|
||||
rightInset = Math.max(insets.right, rightInset);
|
||||
|
||||
return new Pair(leftInset, rightInset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar;
|
||||
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
|
||||
@Module
|
||||
public interface NotificationInsetsModule {
|
||||
|
||||
@Binds
|
||||
@SysUISingleton
|
||||
NotificationInsetsController bindNotificationInsetsController(NotificationInsetsImpl impl);
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController
|
||||
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBouncerViewModel
|
||||
import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler
|
||||
import com.android.systemui.statusbar.LockscreenShadeTransitionController
|
||||
import com.android.systemui.statusbar.NotificationInsetsController
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController
|
||||
import com.android.systemui.statusbar.NotificationShadeWindowController
|
||||
import com.android.systemui.statusbar.SysuiStatusBarStateController
|
||||
@@ -94,6 +95,8 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
|
||||
private lateinit var phoneStatusBarViewController: PhoneStatusBarViewController
|
||||
@Mock
|
||||
private lateinit var pulsingGestureListener: PulsingGestureListener
|
||||
@Mock
|
||||
private lateinit var notificationInsetsController: NotificationInsetsController
|
||||
@Mock lateinit var keyguardBouncerComponentFactory: KeyguardBouncerComponent.Factory
|
||||
@Mock lateinit var keyguardBouncerContainer: ViewGroup
|
||||
@Mock lateinit var keyguardBouncerComponent: KeyguardBouncerComponent
|
||||
@@ -124,6 +127,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
|
||||
centralSurfaces,
|
||||
notificationShadeWindowController,
|
||||
keyguardUnlockAnimationController,
|
||||
notificationInsetsController,
|
||||
ambientState,
|
||||
pulsingGestureListener,
|
||||
featureFlags,
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
|
||||
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBouncerViewModel;
|
||||
import com.android.systemui.statusbar.DragDownHelper;
|
||||
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
|
||||
import com.android.systemui.statusbar.NotificationInsetsController;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
||||
@@ -91,6 +92,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase {
|
||||
@Mock private FeatureFlags mFeatureFlags;
|
||||
@Mock private KeyguardBouncerViewModel mKeyguardBouncerViewModel;
|
||||
@Mock private KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory;
|
||||
@Mock private NotificationInsetsController mNotificationInsetsController;
|
||||
|
||||
@Captor private ArgumentCaptor<NotificationShadeWindowView.InteractionEventHandler>
|
||||
mInteractionEventHandlerCaptor;
|
||||
@@ -125,6 +127,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase {
|
||||
mCentralSurfaces,
|
||||
mNotificationShadeWindowController,
|
||||
mKeyguardUnlockAnimationController,
|
||||
mNotificationInsetsController,
|
||||
mAmbientState,
|
||||
mPulsingGestureListener,
|
||||
mFeatureFlags,
|
||||
|
||||
Reference in New Issue
Block a user