diff options
author | Matt Pietal <mpietal@google.com> | 2021-03-18 10:22:27 -0400 |
---|---|---|
committer | Matt Pietal <mpietal@google.com> | 2021-03-18 10:25:43 -0400 |
commit | 04aeeebc991787bbe9276ecbe706e0f663b3cc00 (patch) | |
tree | 2ba5283339361d1af554f621b29c85819734e0c2 /packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java | |
parent | 4cdcf4126512c23f7c414066ac5df302db1843f5 (diff) |
Clock and padding updates
Single line clock for the small clock only. Align padding to specs
Bug: 172360102
Test: manual
Change-Id: I2d1a3f20f23886166a67ca40bf6d8e703eff3298
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java b/packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java index 64b3d7356d3c..c918d9871a7d 100644 --- a/packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java +++ b/packages/SystemUI/src/com/android/keyguard/AnimatableClockView.java @@ -38,8 +38,10 @@ import kotlin.Unit; * The time's text color is a gradient that changes its colors based on its controller. */ public class AnimatableClockView extends TextView { - private static final CharSequence FORMAT_12_HOUR = "hh\nmm"; - private static final CharSequence FORMAT_24_HOUR = "HH\nmm"; + private static final CharSequence DOUBLE_LINE_FORMAT_12_HOUR = "hh\nmm"; + private static final CharSequence DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm"; + private static final CharSequence SINGLE_LINE_FORMAT_12_HOUR = "h:mm"; + private static final CharSequence SINGLE_LINE_FORMAT_24_HOUR = "H:mm"; private static final long ANIM_DURATION = 300; private final Calendar mTime = Calendar.getInstance(); @@ -55,6 +57,8 @@ public class AnimatableClockView extends TextView { private TextAnimator mTextAnimator = null; private Runnable mOnTextAnimatorInitialized; + private boolean mIsSingleLine; + public AnimatableClockView(Context context) { this(context, null, 0, 0); } @@ -78,6 +82,15 @@ public class AnimatableClockView extends TextView { } finally { ta.recycle(); } + + ta = context.obtainStyledAttributes( + attrs, android.R.styleable.TextView, defStyleAttr, defStyleRes); + try { + mIsSingleLine = ta.getBoolean(android.R.styleable.TextView_singleLine, false); + } finally { + ta.recycle(); + } + refreshFormat(); } @@ -171,7 +184,16 @@ public class AnimatableClockView extends TextView { void refreshFormat() { final boolean use24HourFormat = DateFormat.is24HourFormat(getContext()); - mFormat = use24HourFormat ? FORMAT_24_HOUR : FORMAT_12_HOUR; + if (mIsSingleLine && use24HourFormat) { + mFormat = SINGLE_LINE_FORMAT_24_HOUR; + } else if (!mIsSingleLine && use24HourFormat) { + mFormat = DOUBLE_LINE_FORMAT_24_HOUR; + } else if (mIsSingleLine && !use24HourFormat) { + mFormat = SINGLE_LINE_FORMAT_12_HOUR; + } else { + mFormat = DOUBLE_LINE_FORMAT_12_HOUR; + } + mDescFormat = getBestDateTimePattern(getContext(), use24HourFormat ? "Hm" : "hm"); refreshTime(); } |