Merge "Update spacing/layout of LS clock"
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml
index d339ae9..7816d62 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml
@@ -67,20 +67,18 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
- android:layout_marginBottom="24dp"
android:visibility="gone">
<com.android.keyguard.AnimatableClockView
android:id="@+id/animatable_clock_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:gravity="right"
android:textSize="80dp"
android:letterSpacing="0.02"
android:lineSpacingMultiplier=".8"
android:includeFontPadding="false"
android:fontFamily="@font/clock"
android:typeface="monospace"
- android:format12Hour="hh\nmm"
- android:format24Hour="HH\nmm"
android:elegantTextHeight="false"
/>
</FrameLayout>
diff --git a/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java b/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java
index 692e401..3157a5a 100644
--- a/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java
+++ b/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java
@@ -17,6 +17,8 @@
package com.android.keyguard;
import android.graphics.Color;
+import android.graphics.Paint;
+import android.util.MathUtils;
import com.android.settingslib.Utils;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -54,6 +56,11 @@
mStatusBarStateController.removeCallback(mStatusBarStateListener);
}
+ float getClockTextTopPadding() {
+ Paint.FontMetrics fm = mView.getPaint().getFontMetrics();
+ return MathUtils.abs(fm.ascent - fm.top);
+ }
+
/**
* Updates the time for this view.
*/
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
index 4d8fdf3..d731840 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
@@ -232,6 +232,11 @@
}
}
+ float getClockTextTopPadding() {
+ Paint.FontMetrics fm = mClockView.getPaint().getFontMetrics();
+ return fm.ascent - fm.top;
+ }
+
/**
* Set container for big clock face appearing behind NSSL and KeyguardStatusView.
*/
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index 775ebf4..6c69534 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -239,6 +239,15 @@
mView.setFormat24Hour(Patterns.sClockView24);
}
+ float getClockTextTopPadding() {
+ if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1
+ && mNewLockScreenClockViewController != null) {
+ return mNewLockScreenClockViewController.getClockTextTopPadding();
+ }
+
+ return mView.getClockTextTopPadding();
+ }
+
private void updateAodIcons() {
NotificationIconContainer nic = (NotificationIconContainer)
mView.findViewById(
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
index a9c06ed..a32cd14 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceView.java
@@ -154,12 +154,7 @@
public void updateLockScreenMode(int mode) {
mLockScreenMode = mode;
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
- // add top padding to better align with top of clock
- final int topPadding = (int) TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP,
- 20,
- getResources().getDisplayMetrics());
- mTitle.setPaddingRelative(0, topPadding, 0, 0);
+ mTitle.setPaddingRelative(0, 0, 0, 0);
mTitle.setGravity(Gravity.START);
setGravity(Gravity.START);
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) getLayoutParams();
@@ -524,9 +519,9 @@
.getDimension(R.dimen.widget_horizontal_padding) / 2;
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
// orientation is vertical, so add padding to top & bottom
- setPadding(0, padding, 0, padding * (hasText ? 1 : -1));
+ setPadding(0, padding, 0, hasText ? padding : 0);
} else {
- // oreintation is horizontal, so add padding to left & right
+ // orientation is horizontal, so add padding to left & right
setPadding(padding, 0, padding * (hasText ? 1 : -1), 0);
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java
index 02b18b2..1b0a7fa 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java
@@ -26,6 +26,7 @@
import android.util.Log;
import android.view.Display;
import android.view.View;
+import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
@@ -148,6 +149,12 @@
KeyguardSliceViewController.this.hashCode()));
}
+ void updateTopMargin(float clockTopTextPadding) {
+ ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mView.getLayoutParams();
+ lp.topMargin = (int) clockTopTextPadding;
+ mView.setLayoutParams(lp);
+ }
+
/**
* Updates the lockscreen mode which may change the layout of the keyguard slice view.
*/
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java
index cc7b832..dcb306e 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java
@@ -297,6 +297,15 @@
mLockScreenMode = mode;
mKeyguardClockSwitchController.updateLockScreenMode(mode);
mKeyguardSliceViewController.updateLockScreenMode(mode);
+ if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
+ // align the top of keyguard_status_area with the top of the clock text instead
+ // of the top of the view
+ mKeyguardSliceViewController.updateTopMargin(
+ mKeyguardClockSwitchController.getClockTextTopPadding());
+ } else {
+ // reset margin
+ mKeyguardSliceViewController.updateTopMargin(0);
+ }
updateAodIcons();
}
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 5c225e5..7508dcb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
@@ -256,10 +256,9 @@
// TODO(b/12836565) - prototyping only adjustment
if (mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL) {
- // This will keep the clock at the top for AOD
- return (int) (clockY + burnInPreventionOffsetY() + mEmptyDragAmount);
+ // This will keep the clock at the top
+ clockYDark = (int) (clockY + burnInPreventionOffsetY());
}
-
return (int) (MathUtils.lerp(clockY, clockYDark, darkAmount) + mEmptyDragAmount);
}
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 193c963..c936e82 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -221,6 +221,7 @@
@Override
public void onLockScreenModeChanged(int mode) {
+ mLockScreenMode = mode;
mClockPositionAlgorithm.onLockScreenModeChanged(mode);
}
@@ -472,6 +473,8 @@
private int mOldLayoutDirection;
private NotificationShelfController mNotificationShelfController;
+ private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
+
private View.AccessibilityDelegate mAccessibilityDelegate = new View.AccessibilityDelegate() {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
@@ -872,8 +875,10 @@
mNotificationStackScrollLayoutController.getIntrinsicContentHeight(),
getExpandedFraction(),
totalHeight,
- (int) (mKeyguardStatusViewController.getHeight()
- - mShelfHeight / 2.0f - mDarkIconSize / 2.0f),
+ mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1
+ ? mKeyguardStatusViewController.getHeight()
+ : (int) (mKeyguardStatusViewController.getHeight()
+ - mShelfHeight / 2.0f - mDarkIconSize / 2.0f),
clockPreferredY, hasCustomClock(),
hasVisibleNotifications, mInterpolatedDarkAmount, mEmptyDragAmount,
bypassEnabled, getUnlockedStackScrollerPadding(),