Skip to content

Commit eaf6c37

Browse files
committed
Merge branch 'NightscoutFoundation-master'
2 parents 387971e + c276952 commit eaf6c37

57 files changed

Lines changed: 813 additions & 378 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/prod/release/output.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/src/main/java/com/eveningoutpost/dexdrip/GcmActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,11 @@ private static synchronized String sendMessageNow(String identity, String action
742742
return "";
743743
}
744744

745+
if (!Home.get_master_or_follower()) {
746+
UserError.Log.d(TAG, "Refusing to send sync message as we are neither master or follower for action: " + action);
747+
return "";
748+
}
749+
745750
final Bundle data = new Bundle();
746751
data.putString("action", action);
747752
data.putString("identity", identity);

app/src/main/java/com/eveningoutpost/dexdrip/Home.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3519,7 +3519,7 @@ public void showNoteTextInputDialog(View myitem, final long timestamp, final dou
35193519

35203520
if (treatment_text.length() > 0) {
35213521
// display snackbar of the snackbar
3522-
final View.OnClickListener mOnClickListener = v -> Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE, Long.toString(timestamp), Double.toString(position));
3522+
final View.OnClickListener mOnClickListener = v -> Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE, Long.toString(timestamp), "-1"); // Let's not enter a y position to avoid having to worry about BG units
35233523
Home.snackBar(R.string.add_note, getString(R.string.added) + ": " + treatment_text, mOnClickListener, mActivity);
35243524
}
35253525

app/src/main/java/com/eveningoutpost/dexdrip/ImportDatabaseActivity.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -282,23 +282,22 @@ protected String doInBackground(Void... args) {
282282

283283
if (dbFile.getAbsolutePath().endsWith(".zip")) {
284284
// uncompress first
285-
try {
286-
final FileInputStream fileInputStream = new FileInputStream(dbFile.getAbsolutePath());
287-
final ZipInputStream zip_stream = new ZipInputStream(new BufferedInputStream(fileInputStream));
285+
try (final FileInputStream fileInputStream = new FileInputStream(dbFile.getAbsolutePath());
286+
final ZipInputStream zip_stream = new ZipInputStream(new BufferedInputStream(fileInputStream))) {
288287
ZipEntry zipEntry = zip_stream.getNextEntry();
289288
if ((zipEntry != null) && zipEntry.isDirectory())
290289
zipEntry = zip_stream.getNextEntry();
291290
if (zipEntry != null) {
292291
String filename = zipEntry.getName();
293292
if (filename.endsWith(".sqlite")) {
294293
String output_filename = dbFile.getAbsolutePath().replaceFirst(".zip$", ".sqlite");
295-
FileOutputStream fout = new FileOutputStream(output_filename);
296-
byte[] buffer = new byte[4096];
297-
int count = 0;
298-
while ((count = zip_stream.read(buffer)) != -1) {
299-
fout.write(buffer, 0, count);
294+
try (FileOutputStream fout = new FileOutputStream(output_filename)) {
295+
byte[] buffer = new byte[4096];
296+
int count;
297+
while ((count = zip_stream.read(buffer)) != -1) {
298+
fout.write(buffer, 0, count);
299+
}
300300
}
301-
fout.close();
302301
dbFile = new File(output_filename);
303302
delete_file = dbFile;
304303
Log.d(TAG, "New filename: " + output_filename);
@@ -314,9 +313,6 @@ protected String doInBackground(Void... args) {
314313
return msg;
315314
}
316315

317-
zip_stream.close();
318-
fileInputStream.close();
319-
320316
} catch (IOException e) {
321317
String msg = "Could not open file";
322318
JoH.static_toast_long(msg);

app/src/main/java/com/eveningoutpost/dexdrip/MegaStatus.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,7 @@ private void populateSectionList() {
169169
addAsection(G4_STATUS, "Bluetooth Collector Status");
170170
}
171171
if (dexCollectionType.equals(DexcomG5)) {
172-
if (Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
173-
addAsection(G5_STATUS, "G6/Dex1/G7/1+ Collector/Transmitter Status");
174-
} else {
175-
addAsection(G5_STATUS, "G5 Collector and Transmitter Status");
176-
}
172+
addAsection(G5_STATUS, "Dex Collector/Transmitter Status");
177173
} else if (dexCollectionType.equals(Medtrum)) {
178174
addAsection(MEDTRUM_STATUS, "Medtrum A6 Status");
179175
}

app/src/main/java/com/eveningoutpost/dexdrip/StartNewSensor.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static com.eveningoutpost.dexdrip.Home.startWatchUpdaterService;
44
import static com.eveningoutpost.dexdrip.models.BgReading.AGE_ADJUSTMENT_TIME;
55
import static com.eveningoutpost.dexdrip.services.Ob1G5CollectionService.getTransmitterID;
6+
import static com.eveningoutpost.dexdrip.ui.dialog.QuickSettingsDialogs.FINISH_ACTIVITY_ON_DIALOG_DISMISS;
67
import static com.eveningoutpost.dexdrip.xdrip.gs;
78

89
import android.app.Activity;
@@ -13,7 +14,7 @@
1314
import android.os.Build;
1415
import android.os.Bundle;
1516
import androidx.annotation.NonNull;
16-
import android.view.View;
17+
1718
import android.widget.Button;
1819
import android.widget.Toast;
1920

@@ -28,14 +29,14 @@
2829
import com.eveningoutpost.dexdrip.models.UserError.Log;
2930
import com.eveningoutpost.dexdrip.services.Ob1G5CollectionService;
3031
import com.eveningoutpost.dexdrip.utilitymodels.CollectionServiceStarter;
31-
import com.eveningoutpost.dexdrip.utilitymodels.Experience;
3232
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
3333
import com.eveningoutpost.dexdrip.profileeditor.DatePickerFragment;
3434
import com.eveningoutpost.dexdrip.profileeditor.ProfileAdapter;
3535
import com.eveningoutpost.dexdrip.profileeditor.TimePickerFragment;
3636
import com.eveningoutpost.dexdrip.ui.dialog.G6CalibrationCodeDialog;
3737
import com.eveningoutpost.dexdrip.ui.dialog.G6EndOfLifeDialog;
3838
import com.eveningoutpost.dexdrip.utils.ActivityWithMenu;
39+
import com.eveningoutpost.dexdrip.utils.DexCollectionHelper;
3940
import com.eveningoutpost.dexdrip.utils.DexCollectionType;
4041
import com.eveningoutpost.dexdrip.utils.LocationHelper;
4142
import com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService;
@@ -58,17 +59,23 @@ public class StartNewSensor extends ActivityWithMenu {
5859
return DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID());
5960
}
6061

62+
private void activitySetupView() {
63+
JoH.fixActionBar(this);
64+
setContentView(R.layout.activity_start_new_sensor);
65+
button = findViewById(R.id.startNewSensor);
66+
}
67+
6168
@Override
6269
protected void onCreate(Bundle savedInstanceState) {
6370
super.onCreate(savedInstanceState);
64-
if (DexCollectionType.getBestCollectorHardwareName().equals("G7")) {
65-
JoH.static_toast_long(getString(R.string.g7_should_start_automatically));
66-
finish();
71+
if (DexCollectionType.isG7()) {
72+
//JoH.static_toast_long(getString(R.string.g7_should_start_automatically));
73+
activitySetupView();
74+
getIntent().putExtra(FINISH_ACTIVITY_ON_DIALOG_DISMISS, true);
75+
DexCollectionHelper.assistance(this, DexCollectionType.DexcomG5);
6776
} else {
6877
if (!Sensor.isActive()) {
69-
JoH.fixActionBar(this);
70-
setContentView(R.layout.activity_start_new_sensor);
71-
button = (Button) findViewById(R.id.startNewSensor);
78+
activitySetupView();
7279
//dp = (DatePicker)findViewById(R.id.datePicker);
7380
//tp = (TimePicker)findViewById(R.id.timePicker);
7481
addListenerOnButton();
@@ -88,18 +95,16 @@ public String getMenuName() {
8895
public void addListenerOnButton() {
8996
button = (Button) findViewById(R.id.startNewSensor);
9097

91-
button.setOnClickListener(new View.OnClickListener() {
92-
public void onClick(View v) {
98+
button.setOnClickListener(v -> {
9399

94-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && DexCollectionType.hasBluetooth()) {
95-
if (!LocationHelper.locationPermission(StartNewSensor.this)) {
96-
LocationHelper.requestLocationForBluetooth(StartNewSensor.this);
97-
} else {
98-
sensorButtonClick();
99-
}
100+
if (DexCollectionType.hasBluetooth()) {
101+
if (!LocationHelper.locationPermission(StartNewSensor.this)) {
102+
LocationHelper.requestLocationForBluetooth(StartNewSensor.this);
100103
} else {
101104
sensorButtonClick();
102105
}
106+
} else {
107+
sensorButtonClick();
103108
}
104109
});
105110
}

app/src/main/java/com/eveningoutpost/dexdrip/alert/Registry.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.eveningoutpost.dexdrip.alert;
22

3+
import static com.eveningoutpost.dexdrip.utilitymodels.UpdateActivity.AUTO_UPDATE_PREFS_NAME;
4+
35
import android.content.SharedPreferences;
46

57
import com.eveningoutpost.dexdrip.models.UserError.Log;
@@ -36,6 +38,9 @@ public static void refresh() {
3638
if (Pref.getBooleanDefaultFalse("alert_raise_for_sensor_expiry")) {
3739
registry.add(new SensorExpiry());
3840
}
41+
if (Pref.getBoolean(AUTO_UPDATE_PREFS_NAME, true)) {
42+
registry.add(new UpdateAvailable());
43+
}
3944
// addGlucoseAlerts();
4045
// sort();
4146
}

app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public boolean activate() {
4646
val expiry = niceTimeScalarNatural(SensorDays.get().getRemainingSensorPeriodInMs(), 1);
4747
val notificationId = SENSORY_EXPIRY_NOTIFICATION_ID;
4848
cancelNotification(notificationId);
49-
val expireMsg = String.format(xdrip.getAppContext().getString(R.string.sensor_will_expire_in) + " %s", expiry); // TODO i18n and format string
50-
showNotification(xdrip.getAppContext().getString(R.string.sensor_expiring), expireMsg, null, notificationId, null, true, true, null, null, null, true);
49+
val expireMsg = xdrip.gs(R.string.sensor_will_expire_in, expiry);
50+
showNotification(xdrip.gs(R.string.sensor_expiring), expireMsg, null, notificationId, null, true, true, null, null, null, true);
5151
Treatments.create_note("Warning: " + expireMsg, tsl()); // TODO i18n but note classifier also needs updating for that
5252
return true;
5353
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.eveningoutpost.dexdrip.alert;
2+
3+
import static com.eveningoutpost.dexdrip.models.JoH.cancelNotification;
4+
import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalar;
5+
import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalarNatural;
6+
import static com.eveningoutpost.dexdrip.models.JoH.showNotification;
7+
import static com.eveningoutpost.dexdrip.models.JoH.tsl;
8+
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.SENSORY_EXPIRY_NOTIFICATION_ID;
9+
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.XDRIP_UPDATE_NOTIFICATION_ID;
10+
import static com.eveningoutpost.dexdrip.utilitymodels.UpdateActivity.AUTO_UPDATE_PREFS_NAME;
11+
12+
import android.app.PendingIntent;
13+
import android.content.Intent;
14+
15+
import com.eveningoutpost.dexdrip.R;
16+
import com.eveningoutpost.dexdrip.g5model.SensorDays;
17+
import com.eveningoutpost.dexdrip.models.JoH;
18+
import com.eveningoutpost.dexdrip.models.Treatments;
19+
import com.eveningoutpost.dexdrip.models.UserError;
20+
import com.eveningoutpost.dexdrip.models.UserError.Log;
21+
import com.eveningoutpost.dexdrip.utilitymodels.Constants;
22+
import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore;
23+
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
24+
import com.eveningoutpost.dexdrip.utilitymodels.UpdateActivity;
25+
import com.eveningoutpost.dexdrip.xdrip;
26+
27+
import lombok.val;
28+
29+
/**
30+
* JamOrHam
31+
* <p>
32+
* Update available alert. Triggers when an update has been flagged as available
33+
*/
34+
35+
public class UpdateAvailable extends BaseAlert {
36+
37+
private static final String TAG = UpdateAvailable.class.getSimpleName();
38+
39+
public static final String XDRIP_UPDATE_NOTIFICATION_PENDING = "xdrip-update-notification-pending";
40+
public static final String XDRIP_UPDATE_RATELIMIT = "xdrip-update-notification-ratelimit";
41+
42+
public UpdateAvailable() {
43+
super("Update Available", When.ChargeChange, When.ScreenOn);
44+
}
45+
46+
@Override
47+
public boolean activate() {
48+
val context = xdrip.getAppContext();
49+
val notificationId = XDRIP_UPDATE_NOTIFICATION_ID;
50+
cancelNotification(notificationId);
51+
52+
val intent = new Intent(context, UpdateActivity.class);
53+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
54+
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
55+
56+
val channel = Pref.getString("update_channel", "beta"); // get the current update channel
57+
showNotification(xdrip.gs(R.string.xdrip_update), xdrip.gs(R.string.a_new_version_on_channel_1_s_is_available, channel), pendingIntent, notificationId, null, true, true, null, null, null, false);
58+
return true;
59+
}
60+
61+
@Override
62+
public boolean isMet() {
63+
return PersistentStore.getBoolean(XDRIP_UPDATE_NOTIFICATION_PENDING, false)
64+
&& Pref.getBoolean(AUTO_UPDATE_PREFS_NAME, true)
65+
&& JoH.pratelimit(XDRIP_UPDATE_RATELIMIT, 86400 * 6); // only once per 6 days
66+
}
67+
68+
}

app/src/main/java/com/eveningoutpost/dexdrip/cgm/nsfollow/BaseCallback.java

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)