Loading packages/SystemUI/res-keyguard/font/clock.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ** ** Copyright 2020, 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. */ --> <!-- ** AOD/LockScreen Clock font. ** Should include all numeric glyphs in all supported locales. ** Recommended: font with variable width to support AOD => LS animations --> <font-family xmlns:android="http://schemas.android.com/apk/res/android"> <!-- TODO (b/171376810): switch this font with a variable width clock font for AOSP --> <font android:typeface="monospace" android:font="@*android:string/config_headlineFontFamily" /> </font-family> No newline at end of file packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ android:letterSpacing="0.02" android:lineSpacingMultiplier=".8" android:includeFontPadding="false" android:fontFamily="sans-serif" android:fontFamily="@font/clock" android:typeface="monospace" android:format12Hour="hh\nmm" android:format24Hour="HH\nmm" Loading packages/SystemUI/src/com/android/keyguard/GradientTextClock.java +1 −1 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ public class GradientTextClock extends TextClock { @Override public void refreshTime() { updatePaint(); super.refreshTime(); } Loading @@ -77,6 +76,7 @@ public class GradientTextClock extends TextClock { public void setGradientColors(int[] colors) { mGradientColors = colors; updatePaint(); } public void setColorPositions(float[] positions) { Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +8 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import android.transition.TransitionValues; import android.util.AttributeSet; import android.util.Log; import android.util.MathUtils; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; Loading Loading @@ -149,6 +150,11 @@ public class KeyguardClockSwitch extends RelativeLayout { mKeyguardStatusArea.getLayoutParams(); if (mode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) { final int startEndPadding = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 12, getResources().getDisplayMetrics()); setPaddingRelative(startEndPadding, 0, startEndPadding, 0); mSmallClockFrame.setVisibility(GONE); mNewLockscreenClockFrame.setVisibility(VISIBLE); mNewLockscreenClockViewController.init(); Loading @@ -157,6 +163,7 @@ public class KeyguardClockSwitch extends RelativeLayout { statusAreaLP.addRule(RelativeLayout.LEFT_OF, R.id.new_lockscreen_clock_view); statusAreaLP.addRule(RelativeLayout.ALIGN_PARENT_START); } else { setPaddingRelative(0, 0, 0, 0); mSmallClockFrame.setVisibility(VISIBLE); mNewLockscreenClockFrame.setVisibility(GONE); Loading Loading @@ -298,6 +305,7 @@ public class KeyguardClockSwitch extends RelativeLayout { if (mClockPlugin != null) { mClockPlugin.setDarkAmount(darkAmount); } mNewLockscreenClockViewController.setDarkAmount(darkAmount); updateBigClockAlpha(); } Loading packages/SystemUI/src/com/android/keyguard/TimeBasedColorsClockController.java +49 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ package com.android.keyguard; import android.util.MathUtils; import com.android.internal.graphics.ColorUtils; import com.android.settingslib.Utils; import com.android.systemui.R; import com.android.systemui.util.ViewController; import java.util.Calendar; Loading @@ -28,6 +33,13 @@ public class TimeBasedColorsClockController extends ViewController<GradientTextC private final int[] mGradientColors = new int[3]; private final float[] mPositions = new float[3]; /** * 0 = fully awake * between 0 and 1 = transitioning between awake and doze * 1 = fully in doze */ private float mDarkAmount = 0f; public TimeBasedColorsClockController(GradientTextClock view) { super(view); } Loading @@ -46,14 +58,29 @@ public class TimeBasedColorsClockController extends ViewController<GradientTextC * Updates the time for this view. Also updates any color changes. */ public void refreshTime(long timeInMillis) { Calendar now = new GregorianCalendar(); now.setTimeInMillis(timeInMillis); updateColors(now); updatePositions(now); updateColors(timeInMillis); updatePositions(timeInMillis); mView.refreshTime(); } private int getTimeIndex(Calendar now) { /** * Set the amount (ratio) that the device has transitioned to doze. * * @param darkAmount Amount of transition to doze: 1f for doze and 0f for awake. */ public void setDarkAmount(float darkAmount) { mDarkAmount = darkAmount; // TODO: (b/170228350) currently this relayouts throughout the animation; // eventually this should use new Text APIs to animate the variable font weight refreshTime(System.currentTimeMillis()); int weight = (int) MathUtils.lerp(200, 400, 1f - darkAmount); mView.setFontVariationSettings("'wght' " + weight); } private int getTimeIndex(long timeInMillis) { Calendar now = getCalendar(timeInMillis); int hour = now.get(Calendar.HOUR_OF_DAY); // 0 - 23 if (hour < mTimes[0]) { return mTimes.length - 1; Loading @@ -68,16 +95,22 @@ public class TimeBasedColorsClockController extends ViewController<GradientTextC return mTimes.length - 1; } private void updateColors(Calendar now) { final int index = getTimeIndex(now); private void updateColors(long timeInMillis) { final int index = getTimeIndex(timeInMillis); final int wallpaperTextColor = Utils.getColorAttrDefaultColor(mView.getContext(), R.attr.wallpaperTextColor); for (int i = 0; i < mGradientColors.length; i++) { mGradientColors[i] = COLORS[index][i]; // wallpaperTextColor on LS when mDarkAmount = 0f // full color on AOD when mDarkAmount = 1f mGradientColors[i] = ColorUtils.blendARGB(wallpaperTextColor, COLORS[index][i], mDarkAmount); } mView.setGradientColors(mGradientColors); } private void updatePositions(Calendar now) { final int index = getTimeIndex(now); private void updatePositions(long timeInMillis) { Calendar now = getCalendar(timeInMillis); final int index = getTimeIndex(timeInMillis); final Calendar startTime = new GregorianCalendar(); startTime.setTimeInMillis(now.getTimeInMillis()); Loading Loading @@ -108,6 +141,12 @@ public class TimeBasedColorsClockController extends ViewController<GradientTextC mView.setColorPositions(mPositions); } private Calendar getCalendar(long timeInMillis) { Calendar now = new GregorianCalendar(); now.setTimeInMillis(timeInMillis); return now; } private static final int[] SUNRISE = new int[] {0xFF6F75AA, 0xFFAFF0FF, 0xFFFFDEBF}; private static final int[] DAY = new int[] {0xFF9BD8FB, 0xFFD7F5FF, 0xFFFFF278}; private static final int[] NIGHT = new int[] {0xFF333D5E, 0xFFC5A1D6, 0xFF907359}; Loading Loading
packages/SystemUI/res-keyguard/font/clock.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ** ** Copyright 2020, 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. */ --> <!-- ** AOD/LockScreen Clock font. ** Should include all numeric glyphs in all supported locales. ** Recommended: font with variable width to support AOD => LS animations --> <font-family xmlns:android="http://schemas.android.com/apk/res/android"> <!-- TODO (b/171376810): switch this font with a variable width clock font for AOSP --> <font android:typeface="monospace" android:font="@*android:string/config_headlineFontFamily" /> </font-family> No newline at end of file
packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ android:letterSpacing="0.02" android:lineSpacingMultiplier=".8" android:includeFontPadding="false" android:fontFamily="sans-serif" android:fontFamily="@font/clock" android:typeface="monospace" android:format12Hour="hh\nmm" android:format24Hour="HH\nmm" Loading
packages/SystemUI/src/com/android/keyguard/GradientTextClock.java +1 −1 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ public class GradientTextClock extends TextClock { @Override public void refreshTime() { updatePaint(); super.refreshTime(); } Loading @@ -77,6 +76,7 @@ public class GradientTextClock extends TextClock { public void setGradientColors(int[] colors) { mGradientColors = colors; updatePaint(); } public void setColorPositions(float[] positions) { Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +8 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import android.transition.TransitionValues; import android.util.AttributeSet; import android.util.Log; import android.util.MathUtils; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; Loading Loading @@ -149,6 +150,11 @@ public class KeyguardClockSwitch extends RelativeLayout { mKeyguardStatusArea.getLayoutParams(); if (mode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) { final int startEndPadding = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 12, getResources().getDisplayMetrics()); setPaddingRelative(startEndPadding, 0, startEndPadding, 0); mSmallClockFrame.setVisibility(GONE); mNewLockscreenClockFrame.setVisibility(VISIBLE); mNewLockscreenClockViewController.init(); Loading @@ -157,6 +163,7 @@ public class KeyguardClockSwitch extends RelativeLayout { statusAreaLP.addRule(RelativeLayout.LEFT_OF, R.id.new_lockscreen_clock_view); statusAreaLP.addRule(RelativeLayout.ALIGN_PARENT_START); } else { setPaddingRelative(0, 0, 0, 0); mSmallClockFrame.setVisibility(VISIBLE); mNewLockscreenClockFrame.setVisibility(GONE); Loading Loading @@ -298,6 +305,7 @@ public class KeyguardClockSwitch extends RelativeLayout { if (mClockPlugin != null) { mClockPlugin.setDarkAmount(darkAmount); } mNewLockscreenClockViewController.setDarkAmount(darkAmount); updateBigClockAlpha(); } Loading
packages/SystemUI/src/com/android/keyguard/TimeBasedColorsClockController.java +49 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ package com.android.keyguard; import android.util.MathUtils; import com.android.internal.graphics.ColorUtils; import com.android.settingslib.Utils; import com.android.systemui.R; import com.android.systemui.util.ViewController; import java.util.Calendar; Loading @@ -28,6 +33,13 @@ public class TimeBasedColorsClockController extends ViewController<GradientTextC private final int[] mGradientColors = new int[3]; private final float[] mPositions = new float[3]; /** * 0 = fully awake * between 0 and 1 = transitioning between awake and doze * 1 = fully in doze */ private float mDarkAmount = 0f; public TimeBasedColorsClockController(GradientTextClock view) { super(view); } Loading @@ -46,14 +58,29 @@ public class TimeBasedColorsClockController extends ViewController<GradientTextC * Updates the time for this view. Also updates any color changes. */ public void refreshTime(long timeInMillis) { Calendar now = new GregorianCalendar(); now.setTimeInMillis(timeInMillis); updateColors(now); updatePositions(now); updateColors(timeInMillis); updatePositions(timeInMillis); mView.refreshTime(); } private int getTimeIndex(Calendar now) { /** * Set the amount (ratio) that the device has transitioned to doze. * * @param darkAmount Amount of transition to doze: 1f for doze and 0f for awake. */ public void setDarkAmount(float darkAmount) { mDarkAmount = darkAmount; // TODO: (b/170228350) currently this relayouts throughout the animation; // eventually this should use new Text APIs to animate the variable font weight refreshTime(System.currentTimeMillis()); int weight = (int) MathUtils.lerp(200, 400, 1f - darkAmount); mView.setFontVariationSettings("'wght' " + weight); } private int getTimeIndex(long timeInMillis) { Calendar now = getCalendar(timeInMillis); int hour = now.get(Calendar.HOUR_OF_DAY); // 0 - 23 if (hour < mTimes[0]) { return mTimes.length - 1; Loading @@ -68,16 +95,22 @@ public class TimeBasedColorsClockController extends ViewController<GradientTextC return mTimes.length - 1; } private void updateColors(Calendar now) { final int index = getTimeIndex(now); private void updateColors(long timeInMillis) { final int index = getTimeIndex(timeInMillis); final int wallpaperTextColor = Utils.getColorAttrDefaultColor(mView.getContext(), R.attr.wallpaperTextColor); for (int i = 0; i < mGradientColors.length; i++) { mGradientColors[i] = COLORS[index][i]; // wallpaperTextColor on LS when mDarkAmount = 0f // full color on AOD when mDarkAmount = 1f mGradientColors[i] = ColorUtils.blendARGB(wallpaperTextColor, COLORS[index][i], mDarkAmount); } mView.setGradientColors(mGradientColors); } private void updatePositions(Calendar now) { final int index = getTimeIndex(now); private void updatePositions(long timeInMillis) { Calendar now = getCalendar(timeInMillis); final int index = getTimeIndex(timeInMillis); final Calendar startTime = new GregorianCalendar(); startTime.setTimeInMillis(now.getTimeInMillis()); Loading Loading @@ -108,6 +141,12 @@ public class TimeBasedColorsClockController extends ViewController<GradientTextC mView.setColorPositions(mPositions); } private Calendar getCalendar(long timeInMillis) { Calendar now = new GregorianCalendar(); now.setTimeInMillis(timeInMillis); return now; } private static final int[] SUNRISE = new int[] {0xFF6F75AA, 0xFFAFF0FF, 0xFFFFDEBF}; private static final int[] DAY = new int[] {0xFF9BD8FB, 0xFFD7F5FF, 0xFFFFF278}; private static final int[] NIGHT = new int[] {0xFF333D5E, 0xFFC5A1D6, 0xFF907359}; Loading