Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 318c0048 authored by Dan Sandler's avatar Dan Sandler
Browse files

AnalogClock: Allow subclasses to override the "now" instant.

Allows you to use the (deprecated) AnalogClock widget to
display times other than the current system clock time.

While we're at it, update the AnalogClock widget assets to
contemporary vector drawables.

Bug: 177962166
Test: atest AnalogClockTest
Change-Id: I69e9e89b8f42030e910086ee79bb5a447a00bb84
parent 1e67f861
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -740,8 +740,22 @@ public class AnalogClock extends View {
        }
    }

    private void onTimeChanged() {
        Instant now = mClock.instant();
    /**
     * Return the current Instant to be used for drawing the clockface. Protected to allow
     * subclasses to override this to show a different time from the system clock.
     *
     * @return the Instant to be shown on the clockface
     * @hide
     */
    protected Instant now() {
        return mClock.instant();
    }

    /**
     * @hide
     */
    protected void onTimeChanged() {
        Instant now = now();
        onTimeChanged(now.atZone(mClock.getZone()).toLocalTime(), now.toEpochMilli());
    }

@@ -789,7 +803,7 @@ public class AnalogClock extends View {
                return;
            }

            Instant now = mClock.instant();
            Instant now = now();
            ZonedDateTime zonedDateTime = now.atZone(mClock.getZone());
            LocalTime localTime = zonedDateTime.toLocalTime();

−10.3 KiB
Loading image diff...
−2.14 KiB
Loading image diff...
−2.46 KiB
Loading image diff...
−3.01 KiB
Loading image diff...
Loading