diff options
8 files changed, 106 insertions, 34 deletions
diff --git a/packages/SystemUI/res/values-sw600dp-land/config.xml b/packages/SystemUI/res/values-sw600dp-land/config.xml index 040df865bfe5..362e18d785ac 100644 --- a/packages/SystemUI/res/values-sw600dp-land/config.xml +++ b/packages/SystemUI/res/values-sw600dp-land/config.xml @@ -33,5 +33,4 @@ <!-- Notifications are sized to match the width of two (of 4) qs tiles in landscape. --> <bool name="config_skinnyNotifsInLandscape">false</bool> - <dimen name="keyguard_indication_margin_bottom">25dp</dimen> </resources> diff --git a/packages/SystemUI/res/values-sw600dp-land/dimens.xml b/packages/SystemUI/res/values-sw600dp-land/dimens.xml new file mode 100644 index 000000000000..3cfe05638032 --- /dev/null +++ b/packages/SystemUI/res/values-sw600dp-land/dimens.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + * 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. +*/ +--> +<resources> + + <!-- keyguard--> + <dimen name="keyguard_indication_margin_bottom">25dp</dimen> + <dimen name="ambient_indication_margin_bottom">115dp</dimen> + <dimen name="lock_icon_margin_bottom">60dp</dimen> + + <!-- margin from keyguard status bar to clock. For split shade it should be + keyguard_split_shade_top_margin - status_bar_header_height_keyguard = 8dp --> + <dimen name="keyguard_clock_top_margin">8dp</dimen> +</resources> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index e5ea3688ec0d..3b3dc3899f33 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -753,6 +753,9 @@ <!-- Minimum distance the user has to drag down to go to the full shade. --> <dimen name="keyguard_drag_down_min_distance">100dp</dimen> + <!-- The margin from the top of the screen to notifications and keyguard status view in + split shade on keyguard--> + <dimen name="keyguard_split_shade_top_margin">68dp</dimen> <!-- The margin between the status view and the notifications on Keyguard.--> <dimen name="keyguard_status_view_bottom_margin">20dp</dimen> <!-- Minimum margin between clock and status bar --> @@ -935,7 +938,9 @@ <dimen name="keyguard_lock_padding">20dp</dimen> <dimen name="keyguard_indication_margin_bottom">32dp</dimen> - <dimen name="lock_icon_margin_bottom">98dp</dimen> + <dimen name="lock_icon_margin_bottom">110dp</dimen> + <dimen name="ambient_indication_margin_bottom">71dp</dimen> + <!-- The text size for battery level --> <dimen name="battery_level_text_size">12sp</dimen> diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index c7be3ce01c54..88476398e09d 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -43,6 +43,7 @@ import android.view.GestureDetector.SimpleOnGestureListener; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; @@ -85,7 +86,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme private static final float sDefaultDensity = (float) DisplayMetrics.DENSITY_DEVICE_STABLE / (float) DisplayMetrics.DENSITY_DEFAULT; private static final int sLockIconRadiusPx = (int) (sDefaultDensity * 36); - private static final float sDistAboveKgBottomAreaPx = sDefaultDensity * 12; private static final AudioAttributes VIBRATION_SONIFICATION_ATTRIBUTES = new AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) @@ -126,7 +126,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme private boolean mUdfpsSupported; private float mHeightPixels; private float mWidthPixels; - private int mBottomPadding; // in pixels + private int mBottomPaddingPx; private boolean mShowUnlockIcon; private boolean mShowLockIcon; @@ -347,11 +347,11 @@ public class LockIconViewController extends ViewController<LockIconView> impleme } private void updateConfiguration() { - final DisplayMetrics metrics = mView.getContext().getResources().getDisplayMetrics(); - mWidthPixels = metrics.widthPixels; - mHeightPixels = metrics.heightPixels; - mBottomPadding = mView.getContext().getResources().getDimensionPixelSize( - R.dimen.lock_icon_margin_bottom); + WindowManager windowManager = getContext().getSystemService(WindowManager.class); + Rect bounds = windowManager.getCurrentWindowMetrics().getBounds(); + mWidthPixels = bounds.right; + mHeightPixels = bounds.bottom; + mBottomPaddingPx = getResources().getDimensionPixelSize(R.dimen.lock_icon_margin_bottom); mUnlockedLabel = mView.getContext().getResources().getString( R.string.accessibility_unlock_button); @@ -370,8 +370,8 @@ public class LockIconViewController extends ViewController<LockIconView> impleme } else { mView.setCenterLocation( new PointF(mWidthPixels / 2, - mHeightPixels - mBottomPadding - sDistAboveKgBottomAreaPx - - sLockIconRadiusPx), sLockIconRadiusPx); + mHeightPixels - mBottomPaddingPx - sLockIconRadiusPx), + sLockIconRadiusPx); } mView.getHitRect(mSensorTouchLocation); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java index 4f3bbdbff030..7ca8652e1b3c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -57,21 +57,6 @@ public class KeyguardClockPositionAlgorithm { private int mUserSwitchPreferredY; /** - * Whether or not there is a custom clock face on keyguard. - */ - private boolean mHasCustomClock; - - /** - * Whether or not the NSSL contains any visible notifications. - */ - private boolean mHasVisibleNotifs; - - /** - * Height of notification stack: Sum of height of each notification. - */ - private int mNotificationStackHeight; - - /** * Minimum top margin to avoid overlap with status bar, lock icon, or multi-user switcher * avatar. */ @@ -88,6 +73,16 @@ public class KeyguardClockPositionAlgorithm { private int mContainerTopPadding; /** + * Top margin of notifications introduced by presence of split shade header / status bar + */ + private int mSplitShadeTopNotificationsMargin; + + /** + * Target margin for notifications and clock from the top of the screen in split shade + */ + private int mSplitShadeTargetTopMargin; + + /** * @see NotificationPanelViewController#getExpandedFraction() */ private float mPanelExpansion; @@ -152,6 +147,10 @@ public class KeyguardClockPositionAlgorithm { public void loadDimens(Resources res) { mStatusViewBottomMargin = res.getDimensionPixelSize( R.dimen.keyguard_status_view_bottom_margin); + mSplitShadeTopNotificationsMargin = + res.getDimensionPixelSize(R.dimen.split_shade_header_height); + mSplitShadeTargetTopMargin = + res.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin); mContainerTopPadding = res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); @@ -214,7 +213,7 @@ public class KeyguardClockPositionAlgorithm { if (mBypassEnabled) { return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount); } else if (mIsSplitShade) { - return clockYPosition; + return Math.max(0, clockYPosition - mSplitShadeTopNotificationsMargin); } else { return clockYPosition + mKeyguardStatusHeight; } @@ -224,14 +223,18 @@ public class KeyguardClockPositionAlgorithm { if (mBypassEnabled) { return mUnlockedStackScrollerPadding; } else if (mIsSplitShade) { - return mMinTopMargin; + return Math.max(mSplitShadeTargetTopMargin, mMinTopMargin); } else { return mMinTopMargin + mKeyguardStatusHeight; } } private int getExpandedPreferredClockY() { - return mMinTopMargin + mUserSwitchHeight; + if (mIsSplitShade) { + return Math.max(mSplitShadeTargetTopMargin, mMinTopMargin); + } else { + return mMinTopMargin; + } } public int getLockscreenStatusViewHeight() { 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 32659e416535..dedd6daf49a6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -3558,7 +3558,12 @@ public class NotificationPanelViewController extends PanelViewController { mNotificationStackScrollLayoutController.setPulsing(pulsing, animatePulse); } - public void setAmbientIndicationBottomPadding(int ambientIndicationBottomPadding) { + public void setAmbientIndicationTop(int ambientIndicationTop, boolean ambientTextVisible) { + int ambientIndicationBottomPadding = 0; + if (ambientTextVisible) { + int stackBottom = mNotificationStackScrollLayoutController.getView().getBottom(); + ambientIndicationBottomPadding = stackBottom - ambientIndicationTop; + } if (mAmbientIndicationBottomPadding != ambientIndicationBottomPadding) { mAmbientIndicationBottomPadding = ambientIndicationBottomPadding; updateMaxDisplayedNotifications(true); diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java index d64319b278b4..e01583e1cb1e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java @@ -32,6 +32,7 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; import android.graphics.PointF; +import android.graphics.Rect; import android.graphics.drawable.AnimatedStateListDrawable; import android.hardware.biometrics.BiometricSourceType; import android.hardware.biometrics.SensorLocationInternal; @@ -39,10 +40,10 @@ import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; import android.os.Vibrator; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; -import android.util.DisplayMetrics; import android.util.Pair; import android.view.LayoutInflater; import android.view.View; +import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; import androidx.test.filters.SmallTest; @@ -70,6 +71,7 @@ import com.airbnb.lottie.LottieAnimationView; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Answers; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; @@ -88,7 +90,7 @@ public class LockIconViewControllerTest extends SysuiTestCase { private @Mock AnimatedStateListDrawable mIconDrawable; private @Mock Context mContext; private @Mock Resources mResources; - private @Mock DisplayMetrics mDisplayMetrics; + private @Mock(answer = Answers.RETURNS_DEEP_STUBS) WindowManager mWindowManager; private @Mock StatusBarStateController mStatusBarStateController; private @Mock KeyguardUpdateMonitor mKeyguardUpdateMonitor; private @Mock KeyguardViewController mKeyguardViewController; @@ -137,7 +139,9 @@ public class LockIconViewControllerTest extends SysuiTestCase { when(mLockIconView.getContext()).thenReturn(mContext); when(mLockIconView.findViewById(R.layout.udfps_aod_lock_icon)).thenReturn(mAodFp); when(mContext.getResources()).thenReturn(mResources); - when(mResources.getDisplayMetrics()).thenReturn(mDisplayMetrics); + when(mContext.getSystemService(WindowManager.class)).thenReturn(mWindowManager); + Rect windowBounds = new Rect(0, 0, 800, 1200); + when(mWindowManager.getCurrentWindowMetrics().getBounds()).thenReturn(windowBounds); when(mResources.getString(R.string.accessibility_unlock_button)).thenReturn(UNLOCKED_LABEL); when(mResources.getDrawable(anyInt(), any())).thenReturn(mIconDrawable); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java index 624bedc30be9..11826954baee 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java @@ -263,6 +263,34 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test + public void clockPositionedDependingOnMarginInSplitShade() { + when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)) + .thenReturn(400); + mClockPositionAlgorithm.loadDimens(mResources); + givenLockScreen(); + mIsSplitShade = true; + // WHEN the position algorithm is run + positionClock(); + + assertThat(mClockPosition.clockY).isEqualTo(400); + } + + @Test + public void notifPaddingMakesUpToFullMarginInSplitShade() { + when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)) + .thenReturn(100); + when(mResources.getDimensionPixelSize(R.dimen.split_shade_header_height)) + .thenReturn(70); + mClockPositionAlgorithm.loadDimens(mResources); + givenLockScreen(); + mIsSplitShade = true; + // WHEN the position algorithm is run + positionClock(); + // THEN the notif padding makes up lacking margin (margin - header height = 30). + assertThat(mClockPosition.stackScrollerPadding).isEqualTo(30); + } + + @Test public void notifPaddingExpandedAlignedWithClockInSplitShadeMode() { givenLockScreen(); mIsSplitShade = true; @@ -271,7 +299,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { positionClock(); // THEN the padding DOESN'T adjust for keyguard status height. assertThat(mClockPosition.stackScrollerPaddingExpanded) - .isEqualTo(mClockPosition.clockYFullyDozing); + .isEqualTo(mClockPosition.clockY); } @Test |