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

Commit 81c23aac authored by Selim Cinek's avatar Selim Cinek
Browse files

Added convenience methods to use chronometer countdown methods

Bug: 27343480
Change-Id: Iea4d0259ba8c3ab91fec5ee04ea4b39e5dd988bf
parent cb24ab8e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4906,6 +4906,7 @@ package android.app {
    field public static final int DEFAULT_VIBRATE = 2; // 0x2
    field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri";
    field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText";
    field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown";
    field public static final java.lang.String EXTRA_COMPACT_ACTIONS = "android.compactActions";
    field public static final java.lang.String EXTRA_INFO_TEXT = "android.infoText";
    field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon";
@@ -5057,6 +5058,7 @@ package android.app {
    method public android.app.Notification.Builder setActions(android.app.Notification.Action...);
    method public android.app.Notification.Builder setAutoCancel(boolean);
    method public android.app.Notification.Builder setCategory(java.lang.String);
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setColor(int);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
@@ -47165,6 +47167,7 @@ package android.widget {
    method public void setChar(int, java.lang.String, char);
    method public void setCharSequence(int, java.lang.String, java.lang.CharSequence);
    method public void setChronometer(int, long, java.lang.String, boolean);
    method public void setChronometerCountsDown(int, boolean);
    method public void setContentDescription(int, java.lang.CharSequence);
    method public void setDisplayedChild(int, int);
    method public void setDouble(int, java.lang.String, double);
+3 −0
Original line number Diff line number Diff line
@@ -5038,6 +5038,7 @@ package android.app {
    field public static final int DEFAULT_VIBRATE = 2; // 0x2
    field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri";
    field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText";
    field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown";
    field public static final java.lang.String EXTRA_COMPACT_ACTIONS = "android.compactActions";
    field public static final java.lang.String EXTRA_INFO_TEXT = "android.infoText";
    field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon";
@@ -5189,6 +5190,7 @@ package android.app {
    method public android.app.Notification.Builder setActions(android.app.Notification.Action...);
    method public android.app.Notification.Builder setAutoCancel(boolean);
    method public android.app.Notification.Builder setCategory(java.lang.String);
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setColor(int);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
@@ -50266,6 +50268,7 @@ package android.widget {
    method public void setChar(int, java.lang.String, char);
    method public void setCharSequence(int, java.lang.String, java.lang.CharSequence);
    method public void setChronometer(int, long, java.lang.String, boolean);
    method public void setChronometerCountsDown(int, boolean);
    method public void setContentDescription(int, java.lang.CharSequence);
    method public void setDisplayedChild(int, int);
    method public void setDouble(int, java.lang.String, double);
+3 −0
Original line number Diff line number Diff line
@@ -4906,6 +4906,7 @@ package android.app {
    field public static final int DEFAULT_VIBRATE = 2; // 0x2
    field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri";
    field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText";
    field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown";
    field public static final java.lang.String EXTRA_COMPACT_ACTIONS = "android.compactActions";
    field public static final java.lang.String EXTRA_INFO_TEXT = "android.infoText";
    field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon";
@@ -5057,6 +5058,7 @@ package android.app {
    method public android.app.Notification.Builder setActions(android.app.Notification.Action...);
    method public android.app.Notification.Builder setAutoCancel(boolean);
    method public android.app.Notification.Builder setCategory(java.lang.String);
    method public android.app.Notification.Builder setChronometerCountsDown(boolean);
    method public android.app.Notification.Builder setColor(int);
    method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews);
    method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence);
@@ -47182,6 +47184,7 @@ package android.widget {
    method public void setChar(int, java.lang.String, char);
    method public void setCharSequence(int, java.lang.String, java.lang.CharSequence);
    method public void setChronometer(int, long, java.lang.String, boolean);
    method public void setChronometerCountsDown(int, boolean);
    method public void setContentDescription(int, java.lang.CharSequence);
    method public void setDisplayedChild(int, int);
    method public void setDouble(int, java.lang.String, double);
+27 −0
Original line number Diff line number Diff line
@@ -822,6 +822,12 @@ public class Notification implements Parcelable
     */
    public static final String EXTRA_SHOW_CHRONOMETER = "android.showChronometer";

    /**
     * {@link #extras} key: whether the chronometer set on the notification should count down
     * instead of counting up. Is only relevant if key {@link #EXTRA_SHOW_CHRONOMETER} is present.
     */
    public static final String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown";

    /**
     * {@link #extras} key: whether {@link #when} should be shown,
     * as supplied to {@link Builder#setShowWhen(boolean)}.
@@ -2158,14 +2164,31 @@ public class Notification implements Parcelable
         *
         * Useful when showing an elapsed time (like an ongoing phone call).
         *
         * The counter can also be set to count down to <code>when</code> when using
         * {@link #setChronometerCountsDown(boolean)}.
         *
         * @see android.widget.Chronometer
         * @see Notification#when
         * @see #setChronometerCountsDown(boolean)
         */
        public Builder setUsesChronometer(boolean b) {
            mN.extras.putBoolean(EXTRA_SHOW_CHRONOMETER, b);
            return this;
        }

        /**
         * Sets the Chronometer to count down instead of counting up.
         *
         * <p>This is only relevant if {@link #setUsesChronometer(boolean)} has been set to true.
         * If it isn't set the chronometer will count up.
         *
         * @see #setUsesChronometer(boolean)
         */
        public Builder setChronometerCountsDown(boolean countsDown) {
            mN.extras.putBoolean(EXTRA_CHRONOMETER_COUNTS_DOWN, countsDown);
            return this;
        }

        /**
         * Set the small icon resource, which will be used to represent the notification in the
         * status bar.
@@ -3097,6 +3120,8 @@ public class Notification implements Parcelable
                    contentView.setLong(R.id.chronometer, "setBase",
                            mN.when + (SystemClock.elapsedRealtime() - System.currentTimeMillis()));
                    contentView.setBoolean(R.id.chronometer, "setStarted", true);
                    boolean countsDown = mN.extras.getBoolean(EXTRA_CHRONOMETER_COUNTS_DOWN);
                    contentView.setChronometerCountsDown(R.id.chronometer, countsDown);
                } else {
                    contentView.setViewVisibility(R.id.time, View.VISIBLE);
                    contentView.setLong(R.id.time, "setTime", mN.when);
@@ -3328,6 +3353,8 @@ public class Notification implements Parcelable
                    savedBundle.getBoolean(EXTRA_SHOW_WHEN));
            publicExtras.putBoolean(EXTRA_SHOW_CHRONOMETER,
                    savedBundle.getBoolean(EXTRA_SHOW_CHRONOMETER));
            publicExtras.putBoolean(EXTRA_CHRONOMETER_COUNTS_DOWN,
                    savedBundle.getBoolean(EXTRA_CHRONOMETER_COUNTS_DOWN));
            publicExtras.putCharSequence(EXTRA_TITLE,
                    mContext.getString(R.string.notification_hidden_text));
            mN.extras = publicExtras;
+14 −0
Original line number Diff line number Diff line
@@ -2556,6 +2556,8 @@ public class RemoteViews implements Parcelable, Filter {
     * @param format The Chronometer format string, or null to
     *               simply display the timer value.
     * @param started True if you want the clock to be started, false if not.
     *
     * @see #setChronometerCountsDown(int, boolean)
     */
    public void setChronometer(int viewId, long base, String format, boolean started) {
        setLong(viewId, "setBase", base);
@@ -2563,6 +2565,18 @@ public class RemoteViews implements Parcelable, Filter {
        setBoolean(viewId, "setStarted", started);
    }

    /**
     * Equivalent to calling {@link Chronometer#setCountDown(boolean) Chronometer.setCountDown} on
     * the chronometer with the given viewId.
     *
     * @param viewId The id of the {@link Chronometer} to change
     * @param isCountDown True if you want the chronometer to count down to base instead of
     *                    counting up.
     */
    public void setChronometerCountsDown(int viewId, boolean isCountDown) {
        setBoolean(viewId, "setCountDown", isCountDown);
    }

    /**
     * Equivalent to calling {@link ProgressBar#setMax ProgressBar.setMax},
     * {@link ProgressBar#setProgress ProgressBar.setProgress}, and