Skip to content

Commit

Permalink
Merge pull request #2757 from Navid200/Navid_2023_03_30
Browse files Browse the repository at this point in the history
Don't ask user to start G6 before connectivity
  • Loading branch information
jamorham authored Jun 24, 2023
2 parents d46b342 + acc64c0 commit 67340c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
30 changes: 20 additions & 10 deletions app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -157,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;
Expand Down Expand Up @@ -1123,7 +1126,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));
}

Expand Down Expand Up @@ -2174,7 +2177,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");
}
Expand Down Expand Up @@ -2302,10 +2305,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);

Expand Down Expand Up @@ -2386,8 +2389,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);
Expand Down Expand Up @@ -2614,7 +2617,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 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.
notificationText.setText(R.string.now_start_your_sensor);
}

if ((dialog == null) || (!dialog.isShowing())) {
if (!Experience.gotData() && Experience.backupAvailable() && JoH.ratelimit("restore-backup-prompt", 10)) {
Expand All @@ -2630,7 +2639,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) + "?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,7 @@
<string name="title_ymax">Adjust y axis maximum</string>
<string name="summary_ymin">Choose yMin for when there are no smaller readings.</string>
<string name="summary_ymax">Choose yMax for when there are no greater readings.</string>
<string name="wait_to_connect">Verify settings and wait for connectivity.</string>
<string name="close">Close</string>
<string name="title_advanced_settings_4_Lib2">Advanced settings for Libre 2</string>
<string name="title_Lib2_show_raw_values">Show raw values in graph</string>
Expand Down

0 comments on commit 67340c4

Please sign in to comment.