Merge changes I9a7abce3,I770c4572 into sc-v2-dev
* changes: [View Controllers] Move KeyguardStatusBarView#setTopClipping calls out of NotificationPanelViewController. [View Controllers] Move KeyguardStatusBarView#setKeyguardUserSwitcherEnabled to the controller.
This commit is contained in:
committed by
Android (Google) Code Review
commit
b6f65265ab
@@ -321,7 +321,7 @@ public class KeyguardStatusBarView extends RelativeLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyguardUserSwitcherEnabled(boolean enabled) {
|
void setKeyguardUserSwitcherEnabled(boolean enabled) {
|
||||||
mKeyguardUserSwitcherEnabled = enabled;
|
mKeyguardUserSwitcherEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,8 +475,10 @@ public class KeyguardStatusBarView extends RelativeLayout {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the clipping on the top of the view.
|
* Set the clipping on the top of the view.
|
||||||
|
*
|
||||||
|
* Should only be called from {@link KeyguardStatusBarViewController}.
|
||||||
*/
|
*/
|
||||||
public void setTopClipping(int topClipping) {
|
void setTopClipping(int topClipping) {
|
||||||
if (topClipping != mTopClipping) {
|
if (topClipping != mTopClipping) {
|
||||||
mTopClipping = topClipping;
|
mTopClipping = topClipping;
|
||||||
updateClipping();
|
updateClipping();
|
||||||
|
|||||||
@@ -183,6 +183,11 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
mView.onThemeChanged(mTintedIconManager);
|
mView.onThemeChanged(mTintedIconManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Sets whether user switcher is enabled. */
|
||||||
|
public void setKeyguardUserSwitcherEnabled(boolean enabled) {
|
||||||
|
mView.setKeyguardUserSwitcherEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
/** Sets whether this controller should listen to battery updates. */
|
/** Sets whether this controller should listen to battery updates. */
|
||||||
public void setBatteryListening(boolean listening) {
|
public void setBatteryListening(boolean listening) {
|
||||||
if (listening == mBatteryListening) {
|
if (listening == mBatteryListening) {
|
||||||
@@ -196,6 +201,21 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set the view to have no top clipping. */
|
||||||
|
public void setNoTopClipping() {
|
||||||
|
mView.setTopClipping(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the view's top clipping based on the value of notificationPanelTop and the view's
|
||||||
|
* current top.
|
||||||
|
*
|
||||||
|
* @param notificationPanelTop the current top of the notification panel view.
|
||||||
|
*/
|
||||||
|
public void updateTopClipping(int notificationPanelTop) {
|
||||||
|
mView.setTopClipping(notificationPanelTop - mView.getTop());
|
||||||
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
pw.println("KeyguardStatusBarView:");
|
pw.println("KeyguardStatusBarView:");
|
||||||
|
|||||||
@@ -1014,16 +1014,16 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
userSwitcherComponent.getKeyguardQsUserSwitchController();
|
userSwitcherComponent.getKeyguardQsUserSwitchController();
|
||||||
mKeyguardQsUserSwitchController.setNotificationPanelViewController(this);
|
mKeyguardQsUserSwitchController.setNotificationPanelViewController(this);
|
||||||
mKeyguardQsUserSwitchController.init();
|
mKeyguardQsUserSwitchController.init();
|
||||||
mKeyguardStatusBar.setKeyguardUserSwitcherEnabled(true);
|
mKeyguardStatusBarViewController.setKeyguardUserSwitcherEnabled(true);
|
||||||
} else if (keyguardUserSwitcherView != null) {
|
} else if (keyguardUserSwitcherView != null) {
|
||||||
KeyguardUserSwitcherComponent userSwitcherComponent =
|
KeyguardUserSwitcherComponent userSwitcherComponent =
|
||||||
mKeyguardUserSwitcherComponentFactory.build(keyguardUserSwitcherView);
|
mKeyguardUserSwitcherComponentFactory.build(keyguardUserSwitcherView);
|
||||||
mKeyguardUserSwitcherController =
|
mKeyguardUserSwitcherController =
|
||||||
userSwitcherComponent.getKeyguardUserSwitcherController();
|
userSwitcherComponent.getKeyguardUserSwitcherController();
|
||||||
mKeyguardUserSwitcherController.init();
|
mKeyguardUserSwitcherController.init();
|
||||||
mKeyguardStatusBar.setKeyguardUserSwitcherEnabled(true);
|
mKeyguardStatusBarViewController.setKeyguardUserSwitcherEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
mKeyguardStatusBar.setKeyguardUserSwitcherEnabled(false);
|
mKeyguardStatusBarViewController.setKeyguardUserSwitcherEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2445,7 +2445,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
boolean qsVisible) {
|
boolean qsVisible) {
|
||||||
// Fancy clipping for quick settings
|
// Fancy clipping for quick settings
|
||||||
int radius = mScrimCornerRadius;
|
int radius = mScrimCornerRadius;
|
||||||
int statusBarClipTop = 0;
|
|
||||||
boolean clipStatusView = false;
|
boolean clipStatusView = false;
|
||||||
if (!mShouldUseSplitNotificationShade) {
|
if (!mShouldUseSplitNotificationShade) {
|
||||||
// The padding on this area is large enough that we can use a cheaper clipping strategy
|
// The padding on this area is large enough that we can use a cheaper clipping strategy
|
||||||
@@ -2454,7 +2453,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
float screenCornerRadius = mRecordingController.isRecording() ? 0 : mScreenCornerRadius;
|
float screenCornerRadius = mRecordingController.isRecording() ? 0 : mScreenCornerRadius;
|
||||||
radius = (int) MathUtils.lerp(screenCornerRadius, mScrimCornerRadius,
|
radius = (int) MathUtils.lerp(screenCornerRadius, mScrimCornerRadius,
|
||||||
Math.min(top / (float) mScrimCornerRadius, 1f));
|
Math.min(top / (float) mScrimCornerRadius, 1f));
|
||||||
statusBarClipTop = top - mKeyguardStatusBar.getTop();
|
|
||||||
}
|
}
|
||||||
if (mQs != null) {
|
if (mQs != null) {
|
||||||
float qsTranslation = 0;
|
float qsTranslation = 0;
|
||||||
@@ -2492,8 +2490,13 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
mScrimController.setNotificationsBounds(left, top, right, bottom);
|
mScrimController.setNotificationsBounds(left, top, right, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mShouldUseSplitNotificationShade) {
|
||||||
|
mKeyguardStatusBarViewController.setNoTopClipping();
|
||||||
|
} else {
|
||||||
|
mKeyguardStatusBarViewController.updateTopClipping(top);
|
||||||
|
}
|
||||||
|
|
||||||
mScrimController.setScrimCornerRadius(radius);
|
mScrimController.setScrimCornerRadius(radius);
|
||||||
mKeyguardStatusBar.setTopClipping(statusBarClipTop);
|
|
||||||
int nsslLeft = left - mNotificationStackScrollLayoutController.getLeft();
|
int nsslLeft = left - mNotificationStackScrollLayoutController.getLeft();
|
||||||
int nsslRight = right - mNotificationStackScrollLayoutController.getLeft();
|
int nsslRight = right - mNotificationStackScrollLayoutController.getLeft();
|
||||||
int nsslTop = top - mNotificationStackScrollLayoutController.getTop();
|
int nsslTop = top - mNotificationStackScrollLayoutController.getTop();
|
||||||
|
|||||||
@@ -17,11 +17,14 @@
|
|||||||
package com.android.systemui.statusbar.phone;
|
package com.android.systemui.statusbar.phone;
|
||||||
|
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import android.view.ViewGroup;
|
import android.testing.AndroidTestingRunner;
|
||||||
|
import android.testing.TestableLooper;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
@@ -37,15 +40,14 @@ import com.android.systemui.statusbar.policy.UserInfoController;
|
|||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
|
@RunWith(AndroidTestingRunner.class)
|
||||||
|
@TestableLooper.RunWithLooper
|
||||||
public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
||||||
@Mock
|
|
||||||
private KeyguardStatusBarView mKeyguardStatusBarView;
|
|
||||||
@Mock
|
|
||||||
private ViewGroup mViewGroup;
|
|
||||||
@Mock
|
@Mock
|
||||||
private CarrierTextController mCarrierTextController;
|
private CarrierTextController mCarrierTextController;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -63,15 +65,19 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private BatteryMeterViewController mBatteryMeterViewController;
|
private BatteryMeterViewController mBatteryMeterViewController;
|
||||||
|
|
||||||
|
private KeyguardStatusBarView mKeyguardStatusBarView;
|
||||||
private KeyguardStatusBarViewController mController;
|
private KeyguardStatusBarViewController mController;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
when(mKeyguardStatusBarView.getResources()).thenReturn(mContext.getResources());
|
allowTestableLooperAsMainThread();
|
||||||
when(mKeyguardStatusBarView.findViewById(R.id.statusIcons)).thenReturn(mViewGroup);
|
TestableLooper.get(this).runWithLooper(() -> {
|
||||||
when(mViewGroup.getContext()).thenReturn(mContext);
|
mKeyguardStatusBarView =
|
||||||
|
(KeyguardStatusBarView) LayoutInflater.from(mContext)
|
||||||
|
.inflate(R.layout.keyguard_status_bar, null);
|
||||||
|
});
|
||||||
|
|
||||||
mController = new KeyguardStatusBarViewController(
|
mController = new KeyguardStatusBarViewController(
|
||||||
mKeyguardStatusBarView,
|
mKeyguardStatusBarView,
|
||||||
@@ -133,4 +139,27 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
verify(mBatteryController).addCallback(any());
|
verify(mBatteryController).addCallback(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateTopClipping_viewClippingUpdated() {
|
||||||
|
int viewTop = 20;
|
||||||
|
mKeyguardStatusBarView.setTop(viewTop);
|
||||||
|
int notificationPanelTop = 30;
|
||||||
|
|
||||||
|
mController.updateTopClipping(notificationPanelTop);
|
||||||
|
|
||||||
|
assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo(
|
||||||
|
notificationPanelTop - viewTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setNotTopClipping_viewClippingUpdatedToZero() {
|
||||||
|
// Start out with some amount of top clipping.
|
||||||
|
mController.updateTopClipping(50);
|
||||||
|
assertThat(mKeyguardStatusBarView.getClipBounds().top).isGreaterThan(0);
|
||||||
|
|
||||||
|
mController.setNoTopClipping();
|
||||||
|
|
||||||
|
assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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.phone;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import android.testing.AndroidTestingRunner;
|
||||||
|
import android.testing.TestableLooper;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
|
||||||
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
@RunWith(AndroidTestingRunner.class)
|
||||||
|
@TestableLooper.RunWithLooper
|
||||||
|
public class KeyguardStatusBarViewTest extends SysuiTestCase {
|
||||||
|
|
||||||
|
private KeyguardStatusBarView mKeyguardStatusBarView;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() throws Exception {
|
||||||
|
allowTestableLooperAsMainThread();
|
||||||
|
TestableLooper.get(this).runWithLooper(() -> {
|
||||||
|
mKeyguardStatusBarView =
|
||||||
|
(KeyguardStatusBarView) LayoutInflater.from(mContext)
|
||||||
|
.inflate(R.layout.keyguard_status_bar, null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setTopClipping_clippingUpdated() {
|
||||||
|
int topClipping = 40;
|
||||||
|
|
||||||
|
mKeyguardStatusBarView.setTopClipping(topClipping);
|
||||||
|
|
||||||
|
assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo(topClipping);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user