Merge "Introduce NotificationInsetsController." into tm-qpr-dev
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.dagger;
|
package com.android.systemui.dagger;
|
||||||
|
|
||||||
import com.android.systemui.keyguard.KeyguardQuickAffordanceProvider;
|
import com.android.systemui.keyguard.KeyguardQuickAffordanceProvider;
|
||||||
|
import com.android.systemui.statusbar.NotificationInsetsModule;
|
||||||
import com.android.systemui.statusbar.QsFrameTranslateModule;
|
import com.android.systemui.statusbar.QsFrameTranslateModule;
|
||||||
|
|
||||||
import dagger.Subcomponent;
|
import dagger.Subcomponent;
|
||||||
@@ -28,6 +29,7 @@ import dagger.Subcomponent;
|
|||||||
@Subcomponent(modules = {
|
@Subcomponent(modules = {
|
||||||
DefaultComponentBinder.class,
|
DefaultComponentBinder.class,
|
||||||
DependencyProvider.class,
|
DependencyProvider.class,
|
||||||
|
NotificationInsetsModule.class,
|
||||||
QsFrameTranslateModule.class,
|
QsFrameTranslateModule.class,
|
||||||
SystemUIBinder.class,
|
SystemUIBinder.class,
|
||||||
SystemUIModule.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.muteawait.MediaMuteAwaitConnectionCli;
|
||||||
import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
|
import com.android.systemui.media.nearby.NearbyMediaDevicesManager;
|
||||||
import com.android.systemui.people.PeopleProvider;
|
import com.android.systemui.people.PeopleProvider;
|
||||||
|
import com.android.systemui.statusbar.NotificationInsetsModule;
|
||||||
import com.android.systemui.statusbar.QsFrameTranslateModule;
|
import com.android.systemui.statusbar.QsFrameTranslateModule;
|
||||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||||
import com.android.systemui.unfold.FoldStateLogger;
|
import com.android.systemui.unfold.FoldStateLogger;
|
||||||
@@ -65,6 +66,7 @@ import dagger.Subcomponent;
|
|||||||
@Subcomponent(modules = {
|
@Subcomponent(modules = {
|
||||||
DefaultComponentBinder.class,
|
DefaultComponentBinder.class,
|
||||||
DependencyProvider.class,
|
DependencyProvider.class,
|
||||||
|
NotificationInsetsModule.class,
|
||||||
QsFrameTranslateModule.class,
|
QsFrameTranslateModule.class,
|
||||||
SystemUIBinder.class,
|
SystemUIBinder.class,
|
||||||
SystemUIModule.class,
|
SystemUIModule.class,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG;
|
|||||||
import android.annotation.ColorInt;
|
import android.annotation.ColorInt;
|
||||||
import android.annotation.DrawableRes;
|
import android.annotation.DrawableRes;
|
||||||
import android.annotation.LayoutRes;
|
import android.annotation.LayoutRes;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
@@ -36,6 +37,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Pair;
|
||||||
import android.view.ActionMode;
|
import android.view.ActionMode;
|
||||||
import android.view.DisplayCutout;
|
import android.view.DisplayCutout;
|
||||||
import android.view.InputQueue;
|
import android.view.InputQueue;
|
||||||
@@ -74,6 +76,7 @@ public class NotificationShadeWindowView extends FrameLayout {
|
|||||||
private ViewTreeObserver.OnPreDrawListener mFloatingToolbarPreDrawListener;
|
private ViewTreeObserver.OnPreDrawListener mFloatingToolbarPreDrawListener;
|
||||||
|
|
||||||
private InteractionEventHandler mInteractionEventHandler;
|
private InteractionEventHandler mInteractionEventHandler;
|
||||||
|
private LayoutInsetsController mLayoutInsetProvider;
|
||||||
|
|
||||||
public NotificationShadeWindowView(Context context, AttributeSet attrs) {
|
public NotificationShadeWindowView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -108,12 +111,10 @@ public class NotificationShadeWindowView extends FrameLayout {
|
|||||||
mLeftInset = 0;
|
mLeftInset = 0;
|
||||||
mRightInset = 0;
|
mRightInset = 0;
|
||||||
DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout();
|
DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout();
|
||||||
if (displayCutout != null) {
|
Pair<Integer, Integer> pairInsets = mLayoutInsetProvider
|
||||||
mLeftInset = displayCutout.getSafeInsetLeft();
|
.getinsets(windowInsets, displayCutout);
|
||||||
mRightInset = displayCutout.getSafeInsetRight();
|
mLeftInset = pairInsets.first;
|
||||||
}
|
mRightInset = pairInsets.second;
|
||||||
mLeftInset = Math.max(insets.left, mLeftInset);
|
|
||||||
mRightInset = Math.max(insets.right, mRightInset);
|
|
||||||
applyMargins();
|
applyMargins();
|
||||||
return windowInsets;
|
return windowInsets;
|
||||||
}
|
}
|
||||||
@@ -172,6 +173,10 @@ public class NotificationShadeWindowView extends FrameLayout {
|
|||||||
mInteractionEventHandler = listener;
|
mInteractionEventHandler = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setLayoutInsetsController(LayoutInsetsController provider) {
|
||||||
|
mLayoutInsetProvider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||||
Boolean result = mInteractionEventHandler.handleDispatchTouchEvent(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 {
|
interface InteractionEventHandler {
|
||||||
/**
|
/**
|
||||||
* Returns a result for {@link ViewGroup#dispatchTouchEvent(MotionEvent)} or null to defer
|
* 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.keyguard.ui.viewmodel.KeyguardBouncerViewModel;
|
||||||
import com.android.systemui.statusbar.DragDownHelper;
|
import com.android.systemui.statusbar.DragDownHelper;
|
||||||
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
|
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
|
||||||
|
import com.android.systemui.statusbar.NotificationInsetsController;
|
||||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||||
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
||||||
@@ -76,6 +77,7 @@ public class NotificationShadeWindowViewController {
|
|||||||
private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
|
private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
|
||||||
private final AmbientState mAmbientState;
|
private final AmbientState mAmbientState;
|
||||||
private final PulsingGestureListener mPulsingGestureListener;
|
private final PulsingGestureListener mPulsingGestureListener;
|
||||||
|
private final NotificationInsetsController mNotificationInsetsController;
|
||||||
|
|
||||||
private GestureDetector mPulsingWakeupGestureHandler;
|
private GestureDetector mPulsingWakeupGestureHandler;
|
||||||
private View mBrightnessMirror;
|
private View mBrightnessMirror;
|
||||||
@@ -111,6 +113,7 @@ public class NotificationShadeWindowViewController {
|
|||||||
CentralSurfaces centralSurfaces,
|
CentralSurfaces centralSurfaces,
|
||||||
NotificationShadeWindowController controller,
|
NotificationShadeWindowController controller,
|
||||||
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
|
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
|
||||||
|
NotificationInsetsController notificationInsetsController,
|
||||||
AmbientState ambientState,
|
AmbientState ambientState,
|
||||||
PulsingGestureListener pulsingGestureListener,
|
PulsingGestureListener pulsingGestureListener,
|
||||||
FeatureFlags featureFlags,
|
FeatureFlags featureFlags,
|
||||||
@@ -134,6 +137,7 @@ public class NotificationShadeWindowViewController {
|
|||||||
mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
|
mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
|
||||||
mAmbientState = ambientState;
|
mAmbientState = ambientState;
|
||||||
mPulsingGestureListener = pulsingGestureListener;
|
mPulsingGestureListener = pulsingGestureListener;
|
||||||
|
mNotificationInsetsController = notificationInsetsController;
|
||||||
|
|
||||||
// This view is not part of the newly inflated expanded status bar.
|
// This view is not part of the newly inflated expanded status bar.
|
||||||
mBrightnessMirror = mView.findViewById(R.id.brightness_mirror_container);
|
mBrightnessMirror = mView.findViewById(R.id.brightness_mirror_container);
|
||||||
@@ -165,6 +169,7 @@ public class NotificationShadeWindowViewController {
|
|||||||
mPulsingWakeupGestureHandler = new GestureDetector(mView.getContext(),
|
mPulsingWakeupGestureHandler = new GestureDetector(mView.getContext(),
|
||||||
mPulsingGestureListener);
|
mPulsingGestureListener);
|
||||||
|
|
||||||
|
mView.setLayoutInsetsController(mNotificationInsetsController);
|
||||||
mView.setInteractionEventHandler(new NotificationShadeWindowView.InteractionEventHandler() {
|
mView.setInteractionEventHandler(new NotificationShadeWindowView.InteractionEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean handleDispatchTouchEvent(MotionEvent ev) {
|
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.keyguard.ui.viewmodel.KeyguardBouncerViewModel
|
||||||
import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler
|
import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler
|
||||||
import com.android.systemui.statusbar.LockscreenShadeTransitionController
|
import com.android.systemui.statusbar.LockscreenShadeTransitionController
|
||||||
|
import com.android.systemui.statusbar.NotificationInsetsController
|
||||||
import com.android.systemui.statusbar.NotificationShadeDepthController
|
import com.android.systemui.statusbar.NotificationShadeDepthController
|
||||||
import com.android.systemui.statusbar.NotificationShadeWindowController
|
import com.android.systemui.statusbar.NotificationShadeWindowController
|
||||||
import com.android.systemui.statusbar.SysuiStatusBarStateController
|
import com.android.systemui.statusbar.SysuiStatusBarStateController
|
||||||
@@ -94,6 +95,8 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
|
|||||||
private lateinit var phoneStatusBarViewController: PhoneStatusBarViewController
|
private lateinit var phoneStatusBarViewController: PhoneStatusBarViewController
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var pulsingGestureListener: PulsingGestureListener
|
private lateinit var pulsingGestureListener: PulsingGestureListener
|
||||||
|
@Mock
|
||||||
|
private lateinit var notificationInsetsController: NotificationInsetsController
|
||||||
@Mock lateinit var keyguardBouncerComponentFactory: KeyguardBouncerComponent.Factory
|
@Mock lateinit var keyguardBouncerComponentFactory: KeyguardBouncerComponent.Factory
|
||||||
@Mock lateinit var keyguardBouncerContainer: ViewGroup
|
@Mock lateinit var keyguardBouncerContainer: ViewGroup
|
||||||
@Mock lateinit var keyguardBouncerComponent: KeyguardBouncerComponent
|
@Mock lateinit var keyguardBouncerComponent: KeyguardBouncerComponent
|
||||||
@@ -124,6 +127,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
|
|||||||
centralSurfaces,
|
centralSurfaces,
|
||||||
notificationShadeWindowController,
|
notificationShadeWindowController,
|
||||||
keyguardUnlockAnimationController,
|
keyguardUnlockAnimationController,
|
||||||
|
notificationInsetsController,
|
||||||
ambientState,
|
ambientState,
|
||||||
pulsingGestureListener,
|
pulsingGestureListener,
|
||||||
featureFlags,
|
featureFlags,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
|
|||||||
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBouncerViewModel;
|
import com.android.systemui.keyguard.ui.viewmodel.KeyguardBouncerViewModel;
|
||||||
import com.android.systemui.statusbar.DragDownHelper;
|
import com.android.systemui.statusbar.DragDownHelper;
|
||||||
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
|
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
|
||||||
|
import com.android.systemui.statusbar.NotificationInsetsController;
|
||||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||||
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
import com.android.systemui.statusbar.NotificationShadeWindowController;
|
||||||
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
||||||
@@ -91,6 +92,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase {
|
|||||||
@Mock private FeatureFlags mFeatureFlags;
|
@Mock private FeatureFlags mFeatureFlags;
|
||||||
@Mock private KeyguardBouncerViewModel mKeyguardBouncerViewModel;
|
@Mock private KeyguardBouncerViewModel mKeyguardBouncerViewModel;
|
||||||
@Mock private KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory;
|
@Mock private KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory;
|
||||||
|
@Mock private NotificationInsetsController mNotificationInsetsController;
|
||||||
|
|
||||||
@Captor private ArgumentCaptor<NotificationShadeWindowView.InteractionEventHandler>
|
@Captor private ArgumentCaptor<NotificationShadeWindowView.InteractionEventHandler>
|
||||||
mInteractionEventHandlerCaptor;
|
mInteractionEventHandlerCaptor;
|
||||||
@@ -125,6 +127,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase {
|
|||||||
mCentralSurfaces,
|
mCentralSurfaces,
|
||||||
mNotificationShadeWindowController,
|
mNotificationShadeWindowController,
|
||||||
mKeyguardUnlockAnimationController,
|
mKeyguardUnlockAnimationController,
|
||||||
|
mNotificationInsetsController,
|
||||||
mAmbientState,
|
mAmbientState,
|
||||||
mPulsingGestureListener,
|
mPulsingGestureListener,
|
||||||
mFeatureFlags,
|
mFeatureFlags,
|
||||||
|
|||||||
Reference in New Issue
Block a user