From 50537471f4672696911cf2242ccd959db95834dd Mon Sep 17 00:00:00 2001 From: Navid Date: Fri, 21 Apr 2023 10:04:43 -0400 Subject: [PATCH 1/2] Refactoring to models --- .../java/com/eveningoutpost/dexdrip/Home.java | 29 ++++++++++++------- .../dexdrip/StartNewSensor.java | 2 +- app/src/main/res/values/strings.xml | 1 + 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/Home.java b/app/src/main/java/com/eveningoutpost/dexdrip/Home.java index 0eaf637893..4a1e8a5c41 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/Home.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/Home.java @@ -4,6 +4,7 @@ import static com.eveningoutpost.dexdrip.models.JoH.msSince; import static com.eveningoutpost.dexdrip.models.JoH.quietratelimit; import static com.eveningoutpost.dexdrip.models.JoH.tsl; +import static com.eveningoutpost.dexdrip.services.Ob1G5CollectionService.getTransmitterID; import static com.eveningoutpost.dexdrip.utilitymodels.ColorCache.X; import static com.eveningoutpost.dexdrip.utilitymodels.ColorCache.getCol; import static com.eveningoutpost.dexdrip.utilitymodels.Constants.DAY_IN_MS; @@ -67,6 +68,7 @@ import android.widget.TextView; import android.widget.Toast; +import com.eveningoutpost.dexdrip.g5model.DexTimeKeeper; import com.eveningoutpost.dexdrip.g5model.Ob1G5StateMachine; import com.eveningoutpost.dexdrip.g5model.SensorDays; import com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.util.HexDump; @@ -1123,7 +1125,7 @@ public void cloudBackup(MenuItem x) { } public void crowdTranslate(MenuItem x) { - // startActivity(new Intent(this, LanguageEditor.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); + // startActivity(new Intent(this, LanguageEditor.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.com/project/xdrip")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } @@ -2174,7 +2176,7 @@ public static boolean hasLibreblock() { if (!has_libreblock_set) setHasLibreblock(); return has_libreblock; } - + public static boolean get_is_libre_whole_house_collector() { return Pref.getBooleanDefaultFalse("libre_whole_house_collector"); } @@ -2302,10 +2304,10 @@ private void setHoursViewPort(final String source) { holdViewport.top = maxViewPort.top; holdViewport.bottom = maxViewPort.bottom; - if (d) { - UserError.Log.d(TAG, "HOLD VIEWPORT " + holdViewport); - UserError.Log.d(TAG, "MAX VIEWPORT " + maxViewPort); - } + if (d) { + UserError.Log.d(TAG, "HOLD VIEWPORT " + holdViewport); + UserError.Log.d(TAG, "MAX VIEWPORT " + maxViewPort); + } chart.setCurrentViewport(holdViewport); @@ -2386,8 +2388,8 @@ private void updateCurrentBgInfo(final String source) { } if (reset_viewport) { reset_viewport = false; - // holdViewport.set(0, 0, 0, 0); - // if (chart != null) chart.setZoomType(ZoomType.HORIZONTAL); + // holdViewport.set(0, 0, 0, 0); + // if (chart != null) chart.setZoomType(ZoomType.HORIZONTAL); // TODO above reset viewport thing seems defunct now } setupCharts(source); @@ -2614,7 +2616,13 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not } if (!isSensorActive) { - notificationText.setText(R.string.now_start_your_sensor); + // Define a variable (notConnectedToG6Yet) that is only true if G6 has been selected and transmitter days is unknown. + boolean notConnectedToG6Yet = Pref.getBooleanDefaultFalse("using_g6") && DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1; + if (notConnectedToG6Yet) { // Only if G6 has been selected and transmitter days is unknown. + notificationText.setText(R.string.wait_to_connect); + } else { // Only if G6 is not selected or G6 transmitter days is known. + notificationText.setText(R.string.now_start_your_sensor); + } if ((dialog == null) || (!dialog.isShowing())) { if (!Experience.gotData() && Experience.backupAvailable() && JoH.ratelimit("restore-backup-prompt", 10)) { @@ -2630,7 +2638,8 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not dialog = builder.create(); dialog.show(); } else { - if (!Experience.gotData() && !QuickSettingsDialogs.isDialogShowing() && JoH.ratelimit("start-sensor_prompt", 20)) { + if (!Experience.gotData() && !QuickSettingsDialogs.isDialogShowing() && !notConnectedToG6Yet && JoH.ratelimit("start-sensor_prompt", 20)) { + // Show the dialog only if there is no data, and there is no dialog, and G6 is not selected or G6 is connected, and the rate limit is satisfied. final AlertDialog.Builder builder = new AlertDialog.Builder(this); final Context context = this; builder.setTitle(getString(R.string.start_sensor) + "?"); diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/StartNewSensor.java b/app/src/main/java/com/eveningoutpost/dexdrip/StartNewSensor.java index b290706e11..37c08ef96a 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/StartNewSensor.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/StartNewSensor.java @@ -242,7 +242,7 @@ public static void startSensorForTime(long startTime) { LibreAlarmReceiver.clearSensorStats(); // TODO this is just a timer and could be confusing - consider removing this notification - // JoH.scheduleNotification(xdrip.getAppContext(), "Sensor should be ready", xdrip.getAppContext().getString(R.string.please_enter_two_calibrations_to_get_started), 60 * 130, Home.SENSOR_READY_ID); + // JoH.scheduleNotification(xdrip.getAppContext(), "Sensor should be ready", xdrip.getAppContext().getString(R.string.please_enter_two_calibrations_to_get_started), 60 * 130, Home.SENSOR_READY_ID); // Add treatment entry in db Treatments.sensorStart(startTime, "Started by xDrip"); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d3078b4893..fadfc25e3a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1809,6 +1809,7 @@ Adjust y axis maximum Choose yMin for when there are no smaller readings. Choose yMax for when there are no greater readings. + Verify settings and wait for connectivity. Close Advanced settings for Libre 2 Show raw values in graph From acc64c026e1464dc80a6c46b75823dcecbe7f6d4 Mon Sep 17 00:00:00 2001 From: Navid Date: Fri, 5 May 2023 00:01:53 -0400 Subject: [PATCH 2/2] Conclusively detecting native G6 --- app/src/main/java/com/eveningoutpost/dexdrip/Home.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/Home.java b/app/src/main/java/com/eveningoutpost/dexdrip/Home.java index 4a1e8a5c41..d5c89e4307 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/Home.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/Home.java @@ -159,6 +159,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.internal.bind.DateTypeAdapter; +import static com.eveningoutpost.dexdrip.utils.DexCollectionType.DexcomG5; import java.io.ByteArrayOutputStream; import java.io.File; @@ -2616,8 +2617,8 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not } if (!isSensorActive) { - // Define a variable (notConnectedToG6Yet) that is only true if G6 has been selected and transmitter days is unknown. - boolean notConnectedToG6Yet = Pref.getBooleanDefaultFalse("using_g6") && DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1; + // Define a variable (notConnectedToG6Yet) that is only true if Native G6 is chosen, but, transmitter days is unknown. + boolean notConnectedToG6Yet = DexCollectionType.getDexCollectionType() == DexcomG5 && Pref.getBooleanDefaultFalse("ob1_g5_use_transmitter_alg") && Pref.getBooleanDefaultFalse("using_g6") && DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1; if (notConnectedToG6Yet) { // Only if G6 has been selected and transmitter days is unknown. notificationText.setText(R.string.wait_to_connect); } else { // Only if G6 is not selected or G6 transmitter days is known.