Loading packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +0 −2 Original line number Diff line number Diff line Loading @@ -76,7 +76,6 @@ android:textSize="100dp" android:includeFontPadding="false" android:fontFamily="@font/clock" android:lineSpacingMultiplier=".7" android:typeface="monospace" android:elegantTextHeight="false" dozeWeight="200" Loading @@ -97,7 +96,6 @@ android:gravity="center_horizontal" android:textSize="@dimen/large_clock_text_size" android:includeFontPadding="false" android:lineSpacingMultiplier=".7" android:fontFamily="@font/clock" android:typeface="monospace" android:elegantTextHeight="false" Loading packages/SystemUI/res/values/dimens.xml +5 −0 Original line number Diff line number Diff line Loading @@ -688,6 +688,11 @@ <!-- The amount to shift the clocks during a small/large transition --> <dimen name="keyguard_clock_switch_y_shift">10dp</dimen> <!-- Default line spacing multiplier between hours and minutes of the keyguard clock --> <item name="keyguard_clock_line_spacing_scale" type="dimen" format="float">.7</item> <!-- Burmese line spacing multiplier between hours and minutes of the keyguard clock --> <item name="keyguard_clock_line_spacing_scale_burmese" type="dimen" format="float">1</item> <item name="scrim_behind_alpha" format="float" type="dimen">0.62</item> <!-- The minimum amount the user needs to swipe to go to the camera / phone. --> Loading packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java +55 −7 Original line number Diff line number Diff line Loading @@ -16,37 +16,72 @@ package com.android.keyguard; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Color; import android.graphics.Paint; import android.icu.text.NumberFormat; import android.util.MathUtils; import com.android.settingslib.Utils; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.util.ViewController; import java.util.Locale; import java.util.Objects; import java.util.TimeZone; /** * Controls the color of a GradientTextClock. * Controller for an AnimatableClockView. */ public class AnimatableClockController extends ViewController<AnimatableClockView> { private static final int FORMAT_NUMBER = 1234567890; private final StatusBarStateController mStatusBarStateController; private final int[] mDozingColors = new int[] {Color.WHITE, Color.WHITE}; private int[] mLockScreenColors = new int[2]; private final BroadcastDispatcher mBroadcastDispatcher; private final int mDozingColor = Color.WHITE; private int mLockScreenColor; private boolean mIsDozing; private Locale mLocale; private final NumberFormat mBurmeseNf = NumberFormat.getInstance(Locale.forLanguageTag("my")); private final String mBurmeseNumerals; private final float mBurmeseLineSpacing; private final float mDefaultLineSpacing; public AnimatableClockController( AnimatableClockView view, StatusBarStateController statusBarStateController) { StatusBarStateController statusBarStateController, BroadcastDispatcher broadcastDispatcher) { super(view); mStatusBarStateController = statusBarStateController; mIsDozing = mStatusBarStateController.isDozing(); mBroadcastDispatcher = broadcastDispatcher; mBurmeseNumerals = mBurmeseNf.format(FORMAT_NUMBER); mBurmeseLineSpacing = getContext().getResources().getFloat( R.dimen.keyguard_clock_line_spacing_scale_burmese); mDefaultLineSpacing = getContext().getResources().getFloat( R.dimen.keyguard_clock_line_spacing_scale); } private BroadcastReceiver mLocaleBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateLocale(); } }; @Override protected void onViewAttached() { updateLocale(); mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); mStatusBarStateController.addCallback(mStatusBarStateListener); mIsDozing = mStatusBarStateController.isDozing(); refreshTime(); Loading @@ -55,6 +90,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie @Override protected void onViewDetached() { mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver); mStatusBarStateController.removeCallback(mStatusBarStateListener); } Loading Loading @@ -84,11 +120,23 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie mView.refreshFormat(); } private void updateLocale() { Locale currLocale = Locale.getDefault(); if (!Objects.equals(currLocale, mLocale)) { mLocale = currLocale; NumberFormat nf = NumberFormat.getInstance(mLocale); if (nf.format(FORMAT_NUMBER).equals(mBurmeseNumerals)) { mView.setLineSpacingScale(mBurmeseLineSpacing); } else { mView.setLineSpacingScale(mDefaultLineSpacing); } } } private void initColors() { mLockScreenColors[0] = Utils.getColorAttrDefaultColor(getContext(), mLockScreenColor = Utils.getColorAttrDefaultColor(getContext(), com.android.systemui.R.attr.wallpaperTextColor); mLockScreenColors[1] = mLockScreenColors[0]; // same color mView.setColors(mDozingColors, mLockScreenColors); mView.setColors(mDozingColor, mLockScreenColor); mView.animateDoze(mIsDozing, false); } Loading packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java +18 −13 Original line number Diff line number Diff line Loading @@ -44,12 +44,13 @@ public class AnimatableClockView extends TextView { private final Calendar mTime = Calendar.getInstance(); private CharSequence mFormat; private CharSequence mDescFormat; private int[] mDozingColors; private int[] mLockScreenColors; private final int mDozingWeight; private final int mLockScreenWeight; private CharSequence mFormat; private CharSequence mDescFormat; private int mDozingColor; private int mLockScreenColor; private float mLineSpacingScale = 1f; private TextAnimator mTextAnimator = null; private Runnable mOnTextAnimatorInitialized; Loading Loading @@ -111,8 +112,7 @@ public class AnimatableClockView extends TextView { () -> { invalidate(); return Unit.INSTANCE; }, 2 /* number of lines (each can have a unique Paint) */); }); if (mOnTextAnimatorInitialized != null) { mOnTextAnimatorInitialized.run(); mOnTextAnimatorInitialized = null; Loading @@ -127,15 +127,20 @@ public class AnimatableClockView extends TextView { mTextAnimator.draw(canvas); } void setColors(int[] dozingColors, int[] lockScreenColors) { mDozingColors = dozingColors; mLockScreenColors = lockScreenColors; void setLineSpacingScale(float scale) { mLineSpacingScale = scale; setLineSpacing(0, mLineSpacingScale); } void setColors(int dozingColor, int lockScreenColor) { mDozingColor = dozingColor; mLockScreenColor = lockScreenColor; } void animateDoze(boolean isDozing, boolean animate) { setTextStyle(isDozing ? mDozingWeight : mLockScreenWeight /* weight */, -1, isDozing ? mDozingColors : mLockScreenColors, isDozing ? mDozingColor : mLockScreenColor, animate); } Loading @@ -152,15 +157,15 @@ public class AnimatableClockView extends TextView { private void setTextStyle( @IntRange(from = 0, to = 1000) int weight, @FloatRange(from = 0) float textSize, int[] colors, int color, boolean animate) { if (mTextAnimator != null) { mTextAnimator.setTextStyle(weight, textSize, colors, animate, ANIM_DURATION, null); mTextAnimator.setTextStyle(weight, textSize, color, animate, ANIM_DURATION, null); } else { // when the text animator is set, update its start values mOnTextAnimatorInitialized = () -> mTextAnimator.setTextStyle( weight, textSize, colors, false, ANIM_DURATION, null); weight, textSize, color, false, ANIM_DURATION, null); } } Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +9 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.widget.FrameLayout; import com.android.internal.colorextraction.ColorExtractor; import com.android.keyguard.clock.ClockManager; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.ClockPlugin; Loading Loading @@ -56,6 +57,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private final ClockManager mClockManager; private final KeyguardSliceViewController mKeyguardSliceViewController; private final NotificationIconAreaController mNotificationIconAreaController; private final BroadcastDispatcher mBroadcastDispatcher; /** * Gradient clock for usage when mode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL. Loading Loading @@ -101,7 +103,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS SysuiColorExtractor colorExtractor, ClockManager clockManager, KeyguardSliceViewController keyguardSliceViewController, NotificationIconAreaController notificationIconAreaController, ContentResolver contentResolver) { ContentResolver contentResolver, BroadcastDispatcher broadcastDispatcher) { super(keyguardClockSwitch); mResources = resources; mStatusBarStateController = statusBarStateController; Loading @@ -109,6 +112,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mClockManager = clockManager; mKeyguardSliceViewController = keyguardSliceViewController; mNotificationIconAreaController = notificationIconAreaController; mBroadcastDispatcher = broadcastDispatcher; mTimeFormat = Settings.System.getString(contentResolver, Settings.System.TIME_12_24); } Loading Loading @@ -231,12 +235,14 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mNewLockScreenClockViewController = new AnimatableClockController( mView.findViewById(R.id.animatable_clock_view), mStatusBarStateController); mStatusBarStateController, mBroadcastDispatcher); mNewLockScreenClockViewController.init(); mNewLockScreenLargeClockViewController = new AnimatableClockController( mView.findViewById(R.id.animatable_clock_view_large), mStatusBarStateController); mStatusBarStateController, mBroadcastDispatcher); mNewLockScreenLargeClockViewController.init(); } } else { Loading Loading
packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +0 −2 Original line number Diff line number Diff line Loading @@ -76,7 +76,6 @@ android:textSize="100dp" android:includeFontPadding="false" android:fontFamily="@font/clock" android:lineSpacingMultiplier=".7" android:typeface="monospace" android:elegantTextHeight="false" dozeWeight="200" Loading @@ -97,7 +96,6 @@ android:gravity="center_horizontal" android:textSize="@dimen/large_clock_text_size" android:includeFontPadding="false" android:lineSpacingMultiplier=".7" android:fontFamily="@font/clock" android:typeface="monospace" android:elegantTextHeight="false" Loading
packages/SystemUI/res/values/dimens.xml +5 −0 Original line number Diff line number Diff line Loading @@ -688,6 +688,11 @@ <!-- The amount to shift the clocks during a small/large transition --> <dimen name="keyguard_clock_switch_y_shift">10dp</dimen> <!-- Default line spacing multiplier between hours and minutes of the keyguard clock --> <item name="keyguard_clock_line_spacing_scale" type="dimen" format="float">.7</item> <!-- Burmese line spacing multiplier between hours and minutes of the keyguard clock --> <item name="keyguard_clock_line_spacing_scale_burmese" type="dimen" format="float">1</item> <item name="scrim_behind_alpha" format="float" type="dimen">0.62</item> <!-- The minimum amount the user needs to swipe to go to the camera / phone. --> Loading
packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java +55 −7 Original line number Diff line number Diff line Loading @@ -16,37 +16,72 @@ package com.android.keyguard; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Color; import android.graphics.Paint; import android.icu.text.NumberFormat; import android.util.MathUtils; import com.android.settingslib.Utils; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.util.ViewController; import java.util.Locale; import java.util.Objects; import java.util.TimeZone; /** * Controls the color of a GradientTextClock. * Controller for an AnimatableClockView. */ public class AnimatableClockController extends ViewController<AnimatableClockView> { private static final int FORMAT_NUMBER = 1234567890; private final StatusBarStateController mStatusBarStateController; private final int[] mDozingColors = new int[] {Color.WHITE, Color.WHITE}; private int[] mLockScreenColors = new int[2]; private final BroadcastDispatcher mBroadcastDispatcher; private final int mDozingColor = Color.WHITE; private int mLockScreenColor; private boolean mIsDozing; private Locale mLocale; private final NumberFormat mBurmeseNf = NumberFormat.getInstance(Locale.forLanguageTag("my")); private final String mBurmeseNumerals; private final float mBurmeseLineSpacing; private final float mDefaultLineSpacing; public AnimatableClockController( AnimatableClockView view, StatusBarStateController statusBarStateController) { StatusBarStateController statusBarStateController, BroadcastDispatcher broadcastDispatcher) { super(view); mStatusBarStateController = statusBarStateController; mIsDozing = mStatusBarStateController.isDozing(); mBroadcastDispatcher = broadcastDispatcher; mBurmeseNumerals = mBurmeseNf.format(FORMAT_NUMBER); mBurmeseLineSpacing = getContext().getResources().getFloat( R.dimen.keyguard_clock_line_spacing_scale_burmese); mDefaultLineSpacing = getContext().getResources().getFloat( R.dimen.keyguard_clock_line_spacing_scale); } private BroadcastReceiver mLocaleBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateLocale(); } }; @Override protected void onViewAttached() { updateLocale(); mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); mStatusBarStateController.addCallback(mStatusBarStateListener); mIsDozing = mStatusBarStateController.isDozing(); refreshTime(); Loading @@ -55,6 +90,7 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie @Override protected void onViewDetached() { mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver); mStatusBarStateController.removeCallback(mStatusBarStateListener); } Loading Loading @@ -84,11 +120,23 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie mView.refreshFormat(); } private void updateLocale() { Locale currLocale = Locale.getDefault(); if (!Objects.equals(currLocale, mLocale)) { mLocale = currLocale; NumberFormat nf = NumberFormat.getInstance(mLocale); if (nf.format(FORMAT_NUMBER).equals(mBurmeseNumerals)) { mView.setLineSpacingScale(mBurmeseLineSpacing); } else { mView.setLineSpacingScale(mDefaultLineSpacing); } } } private void initColors() { mLockScreenColors[0] = Utils.getColorAttrDefaultColor(getContext(), mLockScreenColor = Utils.getColorAttrDefaultColor(getContext(), com.android.systemui.R.attr.wallpaperTextColor); mLockScreenColors[1] = mLockScreenColors[0]; // same color mView.setColors(mDozingColors, mLockScreenColors); mView.setColors(mDozingColor, mLockScreenColor); mView.animateDoze(mIsDozing, false); } Loading
packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java +18 −13 Original line number Diff line number Diff line Loading @@ -44,12 +44,13 @@ public class AnimatableClockView extends TextView { private final Calendar mTime = Calendar.getInstance(); private CharSequence mFormat; private CharSequence mDescFormat; private int[] mDozingColors; private int[] mLockScreenColors; private final int mDozingWeight; private final int mLockScreenWeight; private CharSequence mFormat; private CharSequence mDescFormat; private int mDozingColor; private int mLockScreenColor; private float mLineSpacingScale = 1f; private TextAnimator mTextAnimator = null; private Runnable mOnTextAnimatorInitialized; Loading Loading @@ -111,8 +112,7 @@ public class AnimatableClockView extends TextView { () -> { invalidate(); return Unit.INSTANCE; }, 2 /* number of lines (each can have a unique Paint) */); }); if (mOnTextAnimatorInitialized != null) { mOnTextAnimatorInitialized.run(); mOnTextAnimatorInitialized = null; Loading @@ -127,15 +127,20 @@ public class AnimatableClockView extends TextView { mTextAnimator.draw(canvas); } void setColors(int[] dozingColors, int[] lockScreenColors) { mDozingColors = dozingColors; mLockScreenColors = lockScreenColors; void setLineSpacingScale(float scale) { mLineSpacingScale = scale; setLineSpacing(0, mLineSpacingScale); } void setColors(int dozingColor, int lockScreenColor) { mDozingColor = dozingColor; mLockScreenColor = lockScreenColor; } void animateDoze(boolean isDozing, boolean animate) { setTextStyle(isDozing ? mDozingWeight : mLockScreenWeight /* weight */, -1, isDozing ? mDozingColors : mLockScreenColors, isDozing ? mDozingColor : mLockScreenColor, animate); } Loading @@ -152,15 +157,15 @@ public class AnimatableClockView extends TextView { private void setTextStyle( @IntRange(from = 0, to = 1000) int weight, @FloatRange(from = 0) float textSize, int[] colors, int color, boolean animate) { if (mTextAnimator != null) { mTextAnimator.setTextStyle(weight, textSize, colors, animate, ANIM_DURATION, null); mTextAnimator.setTextStyle(weight, textSize, color, animate, ANIM_DURATION, null); } else { // when the text animator is set, update its start values mOnTextAnimatorInitialized = () -> mTextAnimator.setTextStyle( weight, textSize, colors, false, ANIM_DURATION, null); weight, textSize, color, false, ANIM_DURATION, null); } } Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +9 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.widget.FrameLayout; import com.android.internal.colorextraction.ColorExtractor; import com.android.keyguard.clock.ClockManager; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.ClockPlugin; Loading Loading @@ -56,6 +57,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private final ClockManager mClockManager; private final KeyguardSliceViewController mKeyguardSliceViewController; private final NotificationIconAreaController mNotificationIconAreaController; private final BroadcastDispatcher mBroadcastDispatcher; /** * Gradient clock for usage when mode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL. Loading Loading @@ -101,7 +103,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS SysuiColorExtractor colorExtractor, ClockManager clockManager, KeyguardSliceViewController keyguardSliceViewController, NotificationIconAreaController notificationIconAreaController, ContentResolver contentResolver) { ContentResolver contentResolver, BroadcastDispatcher broadcastDispatcher) { super(keyguardClockSwitch); mResources = resources; mStatusBarStateController = statusBarStateController; Loading @@ -109,6 +112,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mClockManager = clockManager; mKeyguardSliceViewController = keyguardSliceViewController; mNotificationIconAreaController = notificationIconAreaController; mBroadcastDispatcher = broadcastDispatcher; mTimeFormat = Settings.System.getString(contentResolver, Settings.System.TIME_12_24); } Loading Loading @@ -231,12 +235,14 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mNewLockScreenClockViewController = new AnimatableClockController( mView.findViewById(R.id.animatable_clock_view), mStatusBarStateController); mStatusBarStateController, mBroadcastDispatcher); mNewLockScreenClockViewController.init(); mNewLockScreenLargeClockViewController = new AnimatableClockController( mView.findViewById(R.id.animatable_clock_view_large), mStatusBarStateController); mStatusBarStateController, mBroadcastDispatcher); mNewLockScreenLargeClockViewController.init(); } } else { Loading