|
18 | 18 |
|
19 | 19 | import android.annotation.NonNull;
|
20 | 20 | import android.annotation.Nullable;
|
| 21 | +import android.app.AppGlobals; |
21 | 22 | import android.compat.annotation.UnsupportedAppUsage;
|
22 | 23 | import android.content.BroadcastReceiver;
|
23 | 24 | import android.content.Context;
|
|
61 | 62 | @Deprecated
|
62 | 63 | public class AnalogClock extends View {
|
63 | 64 | private static final String LOG_TAG = "AnalogClock";
|
| 65 | + |
64 | 66 | /** How many times per second that the seconds hand advances. */
|
65 |
| - private static final long SECONDS_HAND_FPS = 30; |
| 67 | + private final int mSecondsHandFps; |
66 | 68 |
|
67 | 69 | private Clock mClock;
|
68 | 70 | @Nullable
|
@@ -106,6 +108,10 @@ public AnalogClock(Context context, AttributeSet attrs, int defStyleAttr) {
|
106 | 108 | public AnalogClock(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
107 | 109 | super(context, attrs, defStyleAttr, defStyleRes);
|
108 | 110 |
|
| 111 | + mSecondsHandFps = AppGlobals.getIntCoreSetting( |
| 112 | + WidgetFlags.KEY_ANALOG_CLOCK_SECONDS_HAND_FPS, |
| 113 | + WidgetFlags.ANALOG_CLOCK_SECONDS_HAND_FPS_DEFAULT); |
| 114 | + |
109 | 115 | final TypedArray a = context.obtainStyledAttributes(
|
110 | 116 | attrs, com.android.internal.R.styleable.AnalogClock, defStyleAttr, defStyleRes);
|
111 | 117 | saveAttributeDataForStyleable(context, com.android.internal.R.styleable.AnalogClock,
|
@@ -743,7 +749,7 @@ private void onTimeChanged(LocalTime localTime, long nowMillis) {
|
743 | 749 | // n positions between two given numbers, where n is the number of ticks per second. This
|
744 | 750 | // ensures the second hand advances by a consistent distance despite our handler callbacks
|
745 | 751 | // occurring at inconsistent frequencies.
|
746 |
| - mSeconds = Math.round(rawSeconds * SECONDS_HAND_FPS) / (float) SECONDS_HAND_FPS; |
| 752 | + mSeconds = Math.round(rawSeconds * mSecondsHandFps) / (float) mSecondsHandFps; |
747 | 753 | mMinutes = localTime.getMinute() + mSeconds / 60.0f;
|
748 | 754 | mHour = localTime.getHour() + mMinutes / 60.0f;
|
749 | 755 | mChanged = true;
|
@@ -781,7 +787,7 @@ public void run() {
|
781 | 787 | // How many milliseconds through the second we currently are.
|
782 | 788 | long millisOfSecond = Duration.ofNanos(localTime.getNano()).toMillis();
|
783 | 789 | // How many milliseconds there are between tick positions for the seconds hand.
|
784 |
| - double millisPerTick = 1000 / (double) SECONDS_HAND_FPS; |
| 790 | + double millisPerTick = 1000 / (double) mSecondsHandFps; |
785 | 791 | // How many milliseconds we are past the last tick position.
|
786 | 792 | long millisPastLastTick = Math.round(millisOfSecond % millisPerTick);
|
787 | 793 | // How many milliseconds there are until the next tick position.
|
|
0 commit comments