AOD/LS - Large clock adjustments

For smaller displays and/or displays set to use a larger size/font,
the large clock would display too far down on the screen. Remove some
padding, and use variable sizes for the font depending on the
available height.

Fixes: 176474531
Test: manual, testing multiple display sizes and burn-in testing
Change-Id: I865ea965d83ae25ea9b53f6aacd37492ddc21930
This commit is contained in:
Matt Pietal
2021-01-07 13:54:15 -05:00
parent 47fcbd746c
commit aa568bbd38
6 changed files with 50 additions and 6 deletions

View File

@@ -89,7 +89,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/keyguard_status_area"
android:paddingTop="20dp"
android:visibility="gone">
<com.android.keyguard.AnimatableClockView
android:id="@+id/animatable_clock_view_large"
@@ -97,7 +96,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textSize="200dp"
android:textSize="@dimen/large_clock_text_size"
android:letterSpacing="0.02"
android:lineSpacingMultiplier=".8"
android:includeFontPadding="false"

View File

@@ -0,0 +1,20 @@
<!--
~ 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>
<!-- Large clock maximum font size (dp is intentional, to prevent any further scaling) -->
<dimen name="large_clock_text_size">170dp</dimen>
</resources>

View File

@@ -17,4 +17,7 @@
<resources>
<!-- Minimum margin between clock and top of screen or ambient indication -->
<dimen name="keyguard_clock_top_margin">76dp</dimen>
</resources>
<!-- Large clock maximum font size (dp is intentional, to prevent any further scaling) -->
<dimen name="large_clock_text_size">200dp</dimen>
</resources>

View File

@@ -1041,6 +1041,13 @@
burn-in on AOD. -->
<dimen name="burn_in_prevention_offset_y">50dp</dimen>
<!-- The maximum offset in either direction that elements are moved vertically to prevent
burn-in on AOD. -->
<dimen name="burn_in_prevention_offset_y_large_clock">42dp</dimen>
<!-- Large clock maximum font size (dp is intentional, to prevent any further scaling) -->
<dimen name="large_clock_text_size">150dp</dimen>
<!-- The maximum offset in either direction that icons move to prevent burn-in on AOD. -->
<dimen name="default_burn_in_prevention_offset">15dp</dimen>

View File

@@ -23,6 +23,7 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextClock;
import android.widget.TextView;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.keyguard.dagger.KeyguardStatusViewScope;
@@ -143,6 +144,10 @@ public class KeyguardClockSwitch extends RelativeLayout {
setTextSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources()
.getDimensionPixelSize(R.dimen.widget_big_font_size));
((TextView) mNewLockscreenLargeClockFrame.getChildAt(0))
.setTextSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources()
.getDimensionPixelSize(R.dimen.large_clock_text_size));
mClockSwitchYAmount = mContext.getResources().getDimensionPixelSize(
R.dimen.keyguard_clock_switch_y_shift);
}
@@ -374,7 +379,6 @@ public class KeyguardClockSwitch extends RelativeLayout {
if (hasVisibleNotifications == mHasVisibleNotifications) {
return;
}
animateClockChange(!hasVisibleNotifications);
mHasVisibleNotifications = hasVisibleNotifications;

View File

@@ -111,6 +111,11 @@ public class KeyguardClockPositionAlgorithm {
*/
private int mBurnInPreventionOffsetY;
/**
* Burn-in prevention y translation for large clock layouts.
*/
private int mBurnInPreventionOffsetYLargeClock;
/**
* Doze/AOD transition amount.
*/
@@ -156,6 +161,8 @@ public class KeyguardClockPositionAlgorithm {
R.dimen.burn_in_prevention_offset_x);
mBurnInPreventionOffsetY = res.getDimensionPixelSize(
R.dimen.burn_in_prevention_offset_y);
mBurnInPreventionOffsetYLargeClock = res.getDimensionPixelSize(
R.dimen.burn_in_prevention_offset_y_large_clock);
}
/**
@@ -287,8 +294,12 @@ public class KeyguardClockPositionAlgorithm {
}
private float burnInPreventionOffsetY() {
return getBurnInOffset(mBurnInPreventionOffsetY * 2, false /* xAxis */)
- mBurnInPreventionOffsetY;
int offset = mBurnInPreventionOffsetY;
if (mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL) {
offset = mBurnInPreventionOffsetYLargeClock;
}
return getBurnInOffset(offset * 2, false /* xAxis */) - offset;
}
private float burnInPreventionOffsetX() {