From eaa65cb08fd650e8bb1a99a34057e19ce399ecef Mon Sep 17 00:00:00 2001 From: Navid Date: Thu, 18 Jul 2024 20:28:24 -0400 Subject: [PATCH 1/4] Retire allow OB1 initiate bonding --- .../dexdrip/services/Ob1G5CollectionService.java | 2 +- .../dexdrip/utilitymodels/IdempotentMigrations.java | 1 + app/src/main/res/xml/pref_data_source.xml | 6 ------ 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java b/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java index 2c843592e..ccfa545f5 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java @@ -1785,7 +1785,7 @@ public void instantCreateBondIfAllowed() { private boolean getInitiateBondingFlag() { - return Pref.getBoolean("ob1_initiate_bonding_flag", true); + return true; // There is no reason not to initiate bonding } diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/IdempotentMigrations.java b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/IdempotentMigrations.java index a9803735e..65c0c5776 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/IdempotentMigrations.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/IdempotentMigrations.java @@ -151,6 +151,7 @@ private static void legacySettingsFix() { Pref.setBoolean("always_get_new_keys", true); Pref.setBoolean("run_ble_scan_constantly", false); Pref.setBoolean("run_G5_ble_tasks_on_uithread", false); + Pref.setBoolean("ob1_initiate_bonding_flag", true); } private static void legacySettingsMoveLanguageFromNoToNb() { // Check if the user's language preference is set to "no" diff --git a/app/src/main/res/xml/pref_data_source.xml b/app/src/main/res/xml/pref_data_source.xml index 07ef37e6e..b5495d3fe 100644 --- a/app/src/main/res/xml/pref_data_source.xml +++ b/app/src/main/res/xml/pref_data_source.xml @@ -400,12 +400,6 @@ android:key="ob1_special_pairing_workaround" android:summary="Some Samsung devices can have an error where they lose the pairing information. This attempts to work around the issue." android:title="@string/special_pairing_workaround" /> - Date: Sat, 20 Jul 2024 14:50:58 +0100 Subject: [PATCH 2/4] fix missing timestamp on ongoing BG notification --- .../com/eveningoutpost/dexdrip/utilitymodels/Notifications.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/Notifications.java b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/Notifications.java index 12500de83..ce7d28e1e 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/Notifications.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/Notifications.java @@ -651,6 +651,8 @@ public synchronized Notification createOngoingNotification(BgGraphBuilder bgGrap if (lastReading != null) { b.setWhen(lastReading.timestamp); + b.setShowWhen(true); + final SpannableString deltaString = new SpannableString("Delta: " + ((dg != null) ? (dg.spannableString(dg.unitized_delta + (dg.from_plugin ? " "+context.getString(R.string.p_in_circle) : ""))) : bgGraphBuilder.unitizedDeltaString(true, true))); From 4aceda11cca8bb6640a5e1079a531607c79bdfea Mon Sep 17 00:00:00 2001 From: Navid Date: Sat, 3 Aug 2024 23:53:31 -0400 Subject: [PATCH 3/4] Sensor expiry alert resolution increased to 1 decimal point --- .../eveningoutpost/dexdrip/alert/SensorExpiry.java | 3 ++- .../java/com/eveningoutpost/dexdrip/models/JoH.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java b/app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java index dcd1f455d..2c8c5334e 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java @@ -3,6 +3,7 @@ import static com.eveningoutpost.dexdrip.models.JoH.cancelNotification; import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalar; import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalarNatural; +import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalarNaturalp1; import static com.eveningoutpost.dexdrip.models.JoH.showNotification; import static com.eveningoutpost.dexdrip.models.JoH.tsl; import static com.eveningoutpost.dexdrip.utilitymodels.Constants.SENSORY_EXPIRY_NOTIFICATION_ID; @@ -41,7 +42,7 @@ public SensorExpiry() { @Override public boolean activate() { - val expiry = niceTimeScalarNatural(SensorDays.get().getRemainingSensorPeriodInMs()); + val expiry = niceTimeScalarNaturalp1(SensorDays.get().getRemainingSensorPeriodInMs()); val notificationId = SENSORY_EXPIRY_NOTIFICATION_ID; cancelNotification(notificationId); val expireMsg = String.format("Sensor will expire in %s", expiry); // TODO i18n and format string diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java b/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java index 584cea0e3..86dfbad1e 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java @@ -809,7 +809,7 @@ public static String niceTimeScalar(double t, int digits) { } - public static String niceTimeScalarNatural(long t) { + public static String niceTimeScalarNatural(long t) { // Shows the integer part only if (t > 3000000) t = t + 10000; // round up by 10 seconds if nearly an hour if ((t > Constants.DAY_IN_MS) && (t < Constants.WEEK_IN_MS * 2)) { final SimpleDateFormat df = new SimpleDateFormat("EEEE", Locale.getDefault()); @@ -820,6 +820,17 @@ public static String niceTimeScalarNatural(long t) { } } + public static String niceTimeScalarNaturalp1(long t) { // Rounds down to 1 decimal point. + if (t > 3000000) t = t + 10000; // round up by 10 seconds if nearly an hour + if ((t > Constants.DAY_IN_MS) && (t < Constants.WEEK_IN_MS * 2)) { + final SimpleDateFormat df = new SimpleDateFormat("EEEE", Locale.getDefault()); + final String day = df.format(new Date(JoH.tsl() + t)); + return ((t > Constants.WEEK_IN_MS) ? "next " : "") + day; + } else { + return niceTimeScalar(t, 1); + } + } + public static String niceTimeScalarRedux(long t) { return niceTimeScalar(t).replaceFirst("^1 ", ""); } From 50c3b7c0f0c3094967346f15c400db264af37cbf Mon Sep 17 00:00:00 2001 From: Navid Date: Sun, 4 Aug 2024 00:41:33 -0400 Subject: [PATCH 4/4] Cleanup --- .../dexdrip/alert/SensorExpiry.java | 3 +-- .../com/eveningoutpost/dexdrip/models/JoH.java | 15 ++++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java b/app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java index 2c8c5334e..f7271a52c 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java @@ -3,7 +3,6 @@ import static com.eveningoutpost.dexdrip.models.JoH.cancelNotification; import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalar; import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalarNatural; -import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalarNaturalp1; import static com.eveningoutpost.dexdrip.models.JoH.showNotification; import static com.eveningoutpost.dexdrip.models.JoH.tsl; import static com.eveningoutpost.dexdrip.utilitymodels.Constants.SENSORY_EXPIRY_NOTIFICATION_ID; @@ -42,7 +41,7 @@ public SensorExpiry() { @Override public boolean activate() { - val expiry = niceTimeScalarNaturalp1(SensorDays.get().getRemainingSensorPeriodInMs()); + val expiry = niceTimeScalarNatural(SensorDays.get().getRemainingSensorPeriodInMs(), 1); val notificationId = SENSORY_EXPIRY_NOTIFICATION_ID; cancelNotification(notificationId); val expireMsg = String.format("Sensor will expire in %s", expiry); // TODO i18n and format string diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java b/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java index 86dfbad1e..84114994d 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java @@ -809,25 +809,18 @@ public static String niceTimeScalar(double t, int digits) { } - public static String niceTimeScalarNatural(long t) { // Shows the integer part only - if (t > 3000000) t = t + 10000; // round up by 10 seconds if nearly an hour - if ((t > Constants.DAY_IN_MS) && (t < Constants.WEEK_IN_MS * 2)) { - final SimpleDateFormat df = new SimpleDateFormat("EEEE", Locale.getDefault()); - final String day = df.format(new Date(JoH.tsl() + t)); - return ((t > Constants.WEEK_IN_MS) ? "next " : "") + day; - } else { - return niceTimeScalar(t); - } + public static String niceTimeScalarNatural(long t) { // Shows the integer part only when less than 1 day. + return niceTimeScalarNatural(t, 0); } - public static String niceTimeScalarNaturalp1(long t) { // Rounds down to 1 decimal point. + public static String niceTimeScalarNatural(long t, int h_digits) { // Rounds down to the defined number of decimal points when less than 1 day. if (t > 3000000) t = t + 10000; // round up by 10 seconds if nearly an hour if ((t > Constants.DAY_IN_MS) && (t < Constants.WEEK_IN_MS * 2)) { final SimpleDateFormat df = new SimpleDateFormat("EEEE", Locale.getDefault()); final String day = df.format(new Date(JoH.tsl() + t)); return ((t > Constants.WEEK_IN_MS) ? "next " : "") + day; } else { - return niceTimeScalar(t, 1); + return niceTimeScalar(t, h_digits); } }