From 199b699c1e3e25494ae1491d1669baedade1a9aa Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Wed, 9 Feb 2022 21:16:49 -0500 Subject: [PATCH] Add ViewController for KeyguardBottomAreaView. This CL doesn't do much by itself. It merely adds scaffolding upon which more work can be built later. Bug: 218354102 Test: manual Change-Id: I3945214b2670ddd6a9f48736407ebdb89203c017 --- .../phone/KeyguardBottomAreaViewController.kt | 34 +++++++++++++++++++ .../NotificationPanelViewController.java | 7 ++-- .../phone/dagger/StatusBarViewModule.java | 14 ++++++++ .../NotificationPanelViewControllerTest.java | 7 +++- 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaViewController.kt diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaViewController.kt new file mode 100644 index 0000000000000..3942dae7e0c30 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaViewController.kt @@ -0,0 +1,34 @@ +/* + * 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.phone + +import com.android.systemui.util.ViewController +import javax.inject.Inject + +class KeyguardBottomAreaViewController @Inject constructor(view: KeyguardBottomAreaView) : + ViewController (view) { + override fun onViewAttached() { + } + + override fun onViewDetached() { + } + + fun getView(): KeyguardBottomAreaView { + // TODO: remove this method. + return mView + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 314484e978bac..4a7d83aa9448a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -351,6 +351,8 @@ public class NotificationPanelViewController extends PanelViewController { private LockIconViewController mLockIconViewController; private NotificationsQuickSettingsContainer mNotificationContainerParent; private NotificationsQSContainerController mNotificationsQSContainerController; + private final Provider + mKeyguardBottomAreaViewControllerProvider; private boolean mAnimateNextPositionUpdate; private float mQuickQsHeaderHeight; private ScreenOffAnimationController mScreenOffAnimationController; @@ -768,6 +770,7 @@ public class NotificationPanelViewController extends PanelViewController { InteractionJankMonitor interactionJankMonitor, QsFrameTranslateController qsFrameTranslateController, SysUiState sysUiState, + Provider keyguardBottomAreaViewControllerProvider, KeyguardUnlockAnimationController keyguardUnlockAnimationController, NotificationListContainer notificationListContainer, PanelEventsEmitter panelEventsEmitter, @@ -808,6 +811,7 @@ public class NotificationPanelViewController extends PanelViewController { mNotificationsQSContainerController = notificationsQSContainerController; mNotificationListContainer = notificationListContainer; mNotificationStackSizeCalculator = notificationStackSizeCalculator; + mKeyguardBottomAreaViewControllerProvider = keyguardBottomAreaViewControllerProvider; mNotificationsQSContainerController.init(); mNotificationStackScrollLayoutController = notificationStackScrollLayoutController; mNotificationIconAreaController = notificationIconAreaController; @@ -1241,8 +1245,7 @@ public class NotificationPanelViewController extends PanelViewController { int index = mView.indexOfChild(mKeyguardBottomArea); mView.removeView(mKeyguardBottomArea); KeyguardBottomAreaView oldBottomArea = mKeyguardBottomArea; - mKeyguardBottomArea = (KeyguardBottomAreaView) mLayoutInflater.inflate( - R.layout.keyguard_bottom_area, mView, false); + mKeyguardBottomArea = mKeyguardBottomAreaViewControllerProvider.get().getView(); mKeyguardBottomArea.initFrom(oldBottomArea); mKeyguardBottomArea.setPreviewContainer(mPreviewContainer); mView.addView(mKeyguardBottomArea, index); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java index 61051c2856acd..449bac6324c0c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java @@ -41,6 +41,7 @@ import com.android.systemui.statusbar.OperatorNameViewController; import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler; import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; +import com.android.systemui.statusbar.phone.KeyguardBottomAreaView; import com.android.systemui.statusbar.phone.NotificationIconAreaController; import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.NotificationPanelViewController; @@ -287,4 +288,17 @@ public abstract class StatusBarViewModule { secureSettings, mainExecutor); } + + /** + * Constructs a new, unattached {@link KeyguardBottomAreaView}. + * + * Note that this is explicitly _not_ a singleton, as we want to be able to reinflate it + */ + @Provides + public static KeyguardBottomAreaView providesKeyguardBottomAreaView( + NotificationPanelView npv, LayoutInflater layoutInflater) { + return (KeyguardBottomAreaView) layoutInflater.inflate(R + .layout.keyguard_bottom_area, npv, false); + } + } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java index 018c4531b3828..517e81afd7a25 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java @@ -172,6 +172,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { @Mock private KeyguardBottomAreaView mKeyguardBottomArea; @Mock + private KeyguardBottomAreaViewController mKeyguardBottomAreaViewController; + @Mock private KeyguardBottomAreaView mQsFrame; private KeyguardStatusView mKeyguardStatusView; @Mock @@ -397,6 +399,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { when(mNotificationStackScrollLayoutController.getHeight()).thenReturn(1000); when(mNotificationStackScrollLayoutController.getHeadsUpCallback()) .thenReturn(mHeadsUpCallback); + when(mKeyguardBottomAreaViewController.getView()).thenReturn(mKeyguardBottomArea); when(mView.findViewById(R.id.keyguard_bottom_area)).thenReturn(mKeyguardBottomArea); when(mKeyguardBottomArea.getLeftView()).thenReturn(mock(KeyguardAffordanceView.class)); when(mKeyguardBottomArea.getRightView()).thenReturn(mock(KeyguardAffordanceView.class)); @@ -480,7 +483,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mMainHandler = new Handler(Looper.getMainLooper()); mPanelEventsEmitter = new NotificationPanelViewController.PanelEventsEmitter(); - mNotificationPanelViewController = new NotificationPanelViewController(mView, + mNotificationPanelViewController = new NotificationPanelViewController( + mView, mResources, mMainHandler, mLayoutInflater, @@ -534,6 +538,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mInteractionJankMonitor, mQsFrameTranslateController, mSysUiState, + () -> mKeyguardBottomAreaViewController, mKeyguardUnlockAnimationController, mNotificationListContainer, mPanelEventsEmitter,