From 88698576a2ba7920bddfdc943b96c074625290ec Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 8 Aug 2016 10:08:30 +0200 Subject: [PATCH] plusminis edit shows toast when hit limit --- .../nightscout/utils/PlusMinusEditText.java | 21 +++++++++++++++---- .../info/nightscout/utils/ToastUtils.java | 2 +- app/src/main/res/values-cs/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/utils/PlusMinusEditText.java b/app/src/main/java/info/nightscout/utils/PlusMinusEditText.java index 6faf77ffa8..249e5c5312 100644 --- a/app/src/main/java/info/nightscout/utils/PlusMinusEditText.java +++ b/app/src/main/java/info/nightscout/utils/PlusMinusEditText.java @@ -17,6 +17,9 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; + /** * Created by mike on 28.06.2016. */ @@ -109,13 +112,21 @@ public class PlusMinusEditText implements View.OnKeyListener, private void inc() { value += step; - if (value > maxValue) value = maxValue; + if (value > maxValue) { + value = maxValue; + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit)); + stopUpdating(); + } updateEditText(); } private void dec() { value -= step; - if (value < minValue) value = minValue; + if (value < minValue) { + value = minValue; + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.youareonallowedlimit)); + stopUpdating(); + } updateEditText(); } @@ -137,8 +148,10 @@ public class PlusMinusEditText implements View.OnKeyListener, } private void stopUpdating() { - mUpdater.shutdownNow(); - mUpdater = null; + if (mUpdater != null) { + mUpdater.shutdownNow(); + mUpdater = null; + } } @Override diff --git a/app/src/main/java/info/nightscout/utils/ToastUtils.java b/app/src/main/java/info/nightscout/utils/ToastUtils.java index 704022a9c2..dba4fb4202 100644 --- a/app/src/main/java/info/nightscout/utils/ToastUtils.java +++ b/app/src/main/java/info/nightscout/utils/ToastUtils.java @@ -27,7 +27,7 @@ public class ToastUtils { playSound(ctx, soundID); } - public static void playSound(final Context ctx, final int soundID) { + private static void playSound(final Context ctx, final int soundID) { final MediaPlayer soundMP = MediaPlayer.create(ctx, soundID); soundMP.start(); soundMP.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index a04e3843f0..356bad438d 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -299,4 +299,5 @@ Jeden týden úspěšného používání s běžným příjmem sacharidů Upravit bazály a koeficinty, když bude potřeba a povolit automatickou detekci citlivosti na inzulín Povolit další fukce pro běžné používání jako AMA + Dosaženo limitu \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index eb2b2eab1e..70a02b8ec3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -301,5 +301,6 @@ Adjust basals and ratios if needed, and then enable auto-sens 1 week successful daytime looping with regular carb entry Enabling additional features for daytime use, such as advanced meal assist + You reached allowed limit