Merge changes I9a7abce3,I770c4572 into sc-v2-dev am: b6f65265ab
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15475521 Change-Id: I0fbb75bb4d16fa5908848e084f80d790116bb0b6
This commit is contained in:
@@ -321,7 +321,7 @@ public class KeyguardStatusBarView extends RelativeLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public void setKeyguardUserSwitcherEnabled(boolean enabled) {
|
||||
void setKeyguardUserSwitcherEnabled(boolean enabled) {
|
||||
mKeyguardUserSwitcherEnabled = enabled;
|
||||
}
|
||||
|
||||
@@ -475,8 +475,10 @@ public class KeyguardStatusBarView extends RelativeLayout {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
mTopClipping = topClipping;
|
||||
updateClipping();
|
||||
|
||||
@@ -183,6 +183,11 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
|
||||
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. */
|
||||
public void setBatteryListening(boolean listening) {
|
||||
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) {
|
||||
pw.println("KeyguardStatusBarView:");
|
||||
|
||||
@@ -1011,16 +1011,16 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
userSwitcherComponent.getKeyguardQsUserSwitchController();
|
||||
mKeyguardQsUserSwitchController.setNotificationPanelViewController(this);
|
||||
mKeyguardQsUserSwitchController.init();
|
||||
mKeyguardStatusBar.setKeyguardUserSwitcherEnabled(true);
|
||||
mKeyguardStatusBarViewController.setKeyguardUserSwitcherEnabled(true);
|
||||
} else if (keyguardUserSwitcherView != null) {
|
||||
KeyguardUserSwitcherComponent userSwitcherComponent =
|
||||
mKeyguardUserSwitcherComponentFactory.build(keyguardUserSwitcherView);
|
||||
mKeyguardUserSwitcherController =
|
||||
userSwitcherComponent.getKeyguardUserSwitcherController();
|
||||
mKeyguardUserSwitcherController.init();
|
||||
mKeyguardStatusBar.setKeyguardUserSwitcherEnabled(true);
|
||||
mKeyguardStatusBarViewController.setKeyguardUserSwitcherEnabled(true);
|
||||
} else {
|
||||
mKeyguardStatusBar.setKeyguardUserSwitcherEnabled(false);
|
||||
mKeyguardStatusBarViewController.setKeyguardUserSwitcherEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2442,7 +2442,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
boolean qsVisible) {
|
||||
// Fancy clipping for quick settings
|
||||
int radius = mScrimCornerRadius;
|
||||
int statusBarClipTop = 0;
|
||||
boolean clipStatusView = false;
|
||||
if (!mShouldUseSplitNotificationShade) {
|
||||
// The padding on this area is large enough that we can use a cheaper clipping strategy
|
||||
@@ -2451,7 +2450,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
float screenCornerRadius = mRecordingController.isRecording() ? 0 : mScreenCornerRadius;
|
||||
radius = (int) MathUtils.lerp(screenCornerRadius, mScrimCornerRadius,
|
||||
Math.min(top / (float) mScrimCornerRadius, 1f));
|
||||
statusBarClipTop = top - mKeyguardStatusBar.getTop();
|
||||
}
|
||||
if (mQs != null) {
|
||||
float qsTranslation = 0;
|
||||
@@ -2486,8 +2484,13 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
mScrimController.setNotificationsBounds(left, top, right, bottom);
|
||||
}
|
||||
|
||||
if (mShouldUseSplitNotificationShade) {
|
||||
mKeyguardStatusBarViewController.setNoTopClipping();
|
||||
} else {
|
||||
mKeyguardStatusBarViewController.updateTopClipping(top);
|
||||
}
|
||||
|
||||
mScrimController.setScrimCornerRadius(radius);
|
||||
mKeyguardStatusBar.setTopClipping(statusBarClipTop);
|
||||
int nsslLeft = left - mNotificationStackScrollLayoutController.getLeft();
|
||||
int nsslRight = right - mNotificationStackScrollLayoutController.getLeft();
|
||||
int nsslTop = top - mNotificationStackScrollLayoutController.getTop();
|
||||
|
||||
@@ -17,11 +17,14 @@
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
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;
|
||||
|
||||
@@ -37,15 +40,14 @@ import com.android.systemui.statusbar.policy.UserInfoController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@TestableLooper.RunWithLooper
|
||||
public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private KeyguardStatusBarView mKeyguardStatusBarView;
|
||||
@Mock
|
||||
private ViewGroup mViewGroup;
|
||||
@Mock
|
||||
private CarrierTextController mCarrierTextController;
|
||||
@Mock
|
||||
@@ -63,15 +65,19 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private BatteryMeterViewController mBatteryMeterViewController;
|
||||
|
||||
private KeyguardStatusBarView mKeyguardStatusBarView;
|
||||
private KeyguardStatusBarViewController mController;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
when(mKeyguardStatusBarView.getResources()).thenReturn(mContext.getResources());
|
||||
when(mKeyguardStatusBarView.findViewById(R.id.statusIcons)).thenReturn(mViewGroup);
|
||||
when(mViewGroup.getContext()).thenReturn(mContext);
|
||||
allowTestableLooperAsMainThread();
|
||||
TestableLooper.get(this).runWithLooper(() -> {
|
||||
mKeyguardStatusBarView =
|
||||
(KeyguardStatusBarView) LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.keyguard_status_bar, null);
|
||||
});
|
||||
|
||||
mController = new KeyguardStatusBarViewController(
|
||||
mKeyguardStatusBarView,
|
||||
@@ -133,4 +139,27 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
|
||||
|
||||
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