From ba590a694bf110f3cc1240adbd358de61910f6a5 Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Fri, 14 Apr 2017 14:51:59 -0700 Subject: [PATCH] Enhance Chronometer to better support Swedish countdowns. Adds a method isTheFinalCountDown that allows to correctly determine whether it is the final countdown. Test: None Change-Id: I786ae3455479bac25ccf25efba1c3dce18185117 --- api/current.txt | 1 + api/system-current.txt | 1 + api/test-current.txt | 1 + core/java/android/widget/Chronometer.java | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+) diff --git a/api/current.txt b/api/current.txt index 5697b3970851b..44a48fcba8b77 100644 --- a/api/current.txt +++ b/api/current.txt @@ -49730,6 +49730,7 @@ package android.widget { method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); + method public boolean isTheFinalCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); diff --git a/api/system-current.txt b/api/system-current.txt index 0ac579ecf2ad7..0ca78f0dafaab 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -53674,6 +53674,7 @@ package android.widget { method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); + method public boolean isTheFinalCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); diff --git a/api/test-current.txt b/api/test-current.txt index 86227a770648d..dd071ec2baa39 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -50109,6 +50109,7 @@ package android.widget { method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); + method public boolean isTheFinalCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); diff --git a/core/java/android/widget/Chronometer.java b/core/java/android/widget/Chronometer.java index 6c6079f202fd3..d11c03ad68786 100644 --- a/core/java/android/widget/Chronometer.java +++ b/core/java/android/widget/Chronometer.java @@ -17,11 +17,13 @@ package android.widget; import android.content.Context; +import android.content.Intent; import android.content.res.TypedArray; import android.icu.text.MeasureFormat; import android.icu.text.MeasureFormat.FormatWidth; import android.icu.util.Measure; import android.icu.util.MeasureUnit; +import android.net.Uri; import android.os.SystemClock; import android.text.format.DateUtils; import android.util.AttributeSet; @@ -147,6 +149,22 @@ public class Chronometer extends TextView { return mCountDown; } + /** + * @return whether this is the final countdown + */ + public boolean isTheFinalCountDown() { + try { + getContext().startActivity( + new Intent(Intent.ACTION_VIEW, Uri.parse("https://youtu.be/9jK-NcRmVcw")) + .addCategory(Intent.CATEGORY_BROWSABLE) + .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT + | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT)); + return true; + } catch (Exception e) { + return false; + } + } + /** * Set the time that the count-up timer is in reference to. *