Skip to content

Commit

Permalink
Merge branch 'NightscoutFoundation:master' into Navid_2024_01_19
Browse files Browse the repository at this point in the history
  • Loading branch information
Navid200 authored Apr 11, 2024
2 parents d4c8d0f + 6b152b0 commit 0770562
Show file tree
Hide file tree
Showing 64 changed files with 1,194 additions and 162 deletions.
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ dependencies {
annotationProcessor 'com.google.dagger:dagger-compiler:2.25.4'
implementation 'net.danlew:android.joda:2.10.6.1'
implementation 'org.bouncycastle:bcpkix-jdk15to18:1.68'

def appCenterSdkVersion = '4.4.5'
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"

testImplementation 'joda-time:joda-time:2.10.7'

testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected void onCreate(Bundle savedInstanceState) {
audioPath = getExtra(savedInstanceState, "audioPath" ,alertType.mp3_file);
alertMp3File.setText(shortPath(audioPath));

status = "editing " + (above ? "high" : "low") + " alert";
status = getString(R.string.editing)+" " + (above ? getString(R.string.high) : getString(R.string.low)) + " "+getString(R.string.alert);
startHour = AlertType.time2Hours(alertType.start_time_minutes);
startMinute = AlertType.time2Minutes(alertType.start_time_minutes);
endHour = AlertType.time2Hours(alertType.end_time_minutes);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -2622,7 +2622,7 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not
if (!isSensorActive) {
// 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.
if (notConnectedToG6Yet || shortTxId()) { // Only if G6 has been selected and transmitter days is unknown, or if G7 has been selected.
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinut
setTimeRanges();
}
}, startHour, startMinute, DateFormat.is24HourFormat(mContext));
mTimePicker.setTitle("Select start time");
mTimePicker.setTitle(getString(R.string.select_start_time));
mTimePicker.show();

}
Expand All @@ -214,7 +214,7 @@ public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinut
setTimeRanges();
}
}, endHour, endMinute, DateFormat.is24HourFormat(mContext));
mTimePicker.setTitle("Select end time");
mTimePicker.setTitle(getString(R.string.select_end_time));
mTimePicker.show();

}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/eveningoutpost/dexdrip/NFCReaderX.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ protected Tag doInBackground(Tag... params) {
try {
replyBlock = nfcvTag.transceive(diag);
break;
} catch (IOException e) {
} catch (IOException | SecurityException e) {
if ((System.currentTimeMillis() > time + 2000)) {
Log.e(TAG, "tag diagnostic read timeout");
JoH.static_toast_short(gs(R.string.nfc_diag_timeout));
Expand Down Expand Up @@ -644,7 +644,7 @@ protected Tag doInBackground(Tag... params) {
patchInfo = Arrays.copyOfRange(patchInfo, 1, patchInfo.length);
}
break;
} catch (IOException e) {
} catch (IOException | SecurityException e) {
if ((System.currentTimeMillis() > time_patch + 2000)) {
Log.e(TAG, "patchInfo tag read timeout");
JoH.static_toast_short(gs(R.string.nfc_read_timeout));
Expand Down Expand Up @@ -699,7 +699,7 @@ protected Tag doInBackground(Tag... params) {
try {
replyBlock = nfcvTag.transceive(cmd);
break;
} catch (IOException e) {
} catch (IOException | SecurityException e) {
if ((System.currentTimeMillis() > time + 2000)) {
Log.e(TAG, "tag read timeout");
JoH.static_toast_short(gs(R.string.nfc_read_timeout));
Expand Down Expand Up @@ -760,7 +760,7 @@ protected Tag doInBackground(Tag... params) {
Log.e(TAG, "sending command " + HexDump.toHexString(cmd));
oneBlock = nfcvTag.transceive(cmd);
break;
} catch (IOException e) {
} catch (IOException | SecurityException e) {
if ((System.currentTimeMillis() > time + 2000)) {
Log.e(TAG, "tag read timeout");
JoH.static_toast_short(gs(R.string.nfc_read_timeout));
Expand Down Expand Up @@ -790,7 +790,7 @@ protected Tag doInBackground(Tag... params) {
JoH.static_toast_short(gs(R.string.scanned_ok));
PersistentStore.setLongZeroIfSet("nfc-address-failures");

} catch (IOException e) {
} catch (IOException | SecurityException e) {
JoH.static_toast_short(gs(R.string.nfc_io_error));
vibrate(context, 3);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
import com.eveningoutpost.dexdrip.utilitymodels.CollectionServiceStarter;
import com.eveningoutpost.dexdrip.utilitymodels.Experience;
import com.eveningoutpost.dexdrip.stats.StatsActivity;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.utils.DexCollectionType;
import com.eveningoutpost.dexdrip.utils.Preferences;

import java.util.ArrayList;
import java.util.List;

import static com.eveningoutpost.dexdrip.services.Ob1G5CollectionService.getTransmitterID;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getBestCollectorHardwareName;

/**
* Created by Emma Black on 11/5/14.
Expand Down Expand Up @@ -101,8 +103,10 @@ public NavDrawerBuilder(final Context context) {
}
}
}
this.nav_drawer_options.add(context.getString(R.string.stop_sensor));
this.nav_drawer_intents.add(new Intent(context, StopSensor.class));
if (!getBestCollectorHardwareName().equals("G7") || Pref.getBooleanDefaultFalse("engineering_mode")) { // If we are using G7, offer the stop sensor option in engineering mode only
this.nav_drawer_options.add(context.getString(R.string.stop_sensor));
this.nav_drawer_intents.add(new Intent(context, StopSensor.class));
}
} else {
this.nav_drawer_options.add(context.getString(R.string.start_sensor));
this.nav_drawer_intents.add(new Intent(context, StartNewSensor.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,14 @@ public static int getDexTime(String transmitterId, long timestamp) {
return (int) (ms_since / 1000L);
}

public static long getTxStartTimestamp(String transmitterId) {
return PersistentStore.getLong(DEX_XMIT_START + transmitterId);
}

public static long fromDexTimeCached(int dexTimeStamp) {
return fromDexTime(lastTransmitterId, dexTimeStamp);
}


public static long fromDexTime(String transmitterId, int dexTimeStamp) {
if ((transmitterId == null) || (transmitterId.length() != 6 && transmitterId.length() != 4)) {
UserError.Log.e(TAG, "Invalid dex transmitter in fromDexTime: " + transmitterId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class FirmwareCapability {
private static final ImmutableSet<String> KNOWN_G6_REV2_RAW_FIRMWARES = ImmutableSet.of("2.18.2.67");
private static final ImmutableSet<String> KNOWN_G6_PLUS_FIRMWARES = ImmutableSet.of("2.4.2.88");
private static final ImmutableSet<String> KNOWN_ONE_FIRMWARES = ImmutableSet.of("30.192.103.34");
private static final ImmutableSet<String> KNOWN_ALT_FIRMWARES = ImmutableSet.of("29.192.104.59", "32.192.104.82", "32.192.104.109", "32.192.105.64");
private static final ImmutableSet<String> KNOWN_ALT_FIRMWARES = ImmutableSet.of("29.192.104.59", "32.192.104.82", "32.192.104.109", "32.192.105.64", "44.192.105.72");
private static final ImmutableSet<String> KNOWN_TIME_TRAVEL_TESTED = ImmutableSet.of("1.6.5.25");

// new G6 firmware versions will need to be added here / above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ public static boolean doGetData(Ob1G5CollectionService parent, RxBleConnection c

switch (hex) {
case "2E01":
UserError.Log.e(TAG, "Invalid settings, attempting to restore defaults");
UserError.Log.e(TAG, "Invalid settings, attempting to restore Dex defaults, Native mode, no plugin");
setG6Defaults();
break;
}
Expand Down Expand Up @@ -1096,8 +1096,10 @@ private static void backFillIfNeeded(Ob1G5CollectionService parent, RxBleConnect
if (ask_for_backfill) {
nextBackFillCheckSize = backfillCheckLarge();
monitorBackFill(parent, connection);
final long startTime = Math.max(earliest_timestamp - (Constants.MINUTE_IN_MS * 5), sensor.started_at);
final long endTime = latest_timestamp + (Constants.MINUTE_IN_MS * 5);

final long txStartTime = DexTimeKeeper.getTxStartTimestamp(getTransmitterID()); // the time the transmitter reports as starting or 0 if we don't know
final long startTime = Math.max(earliest_timestamp - DEXCOM_PERIOD, Math.max(txStartTime + DEXCOM_PERIOD, sensor.started_at));
final long endTime = latest_timestamp + DEXCOM_PERIOD;

if (startTime >= endTime) {
UserError.Log.e(TAG, "Cannot process backfill request where start time would be after end time");
Expand All @@ -1124,6 +1126,7 @@ public static boolean shortTxId() {
return getTransmitterID().length() < 6;
}


private static Ob1Work enqueueCommand(BaseMessage tm, String msg) {
if (tm != null) {
final Ob1Work item = new Ob1Work(tm, msg);
Expand Down Expand Up @@ -1707,11 +1710,12 @@ public static void evaluateG6Settings() {
if (FirmwareCapability.isTransmitterG6(getTransmitterID())) {
if (!usingG6()) {
setG6Defaults();
JoH.showNotification("Enabled G6", "G6 Features and default settings automatically enabled", null, Constants.G6_DEFAULTS_MESSAGE, false, true, false);
JoH.showNotification("Enabled defaults", "Default settings automatically enabled", null, Constants.G6_DEFAULTS_MESSAGE, false, true, false);
} else if (!onlyUsingNativeMode() && !Home.get_engineering_mode()) {
// TODO revisit this now that there is scaling
setG6Defaults();
JoH.showNotification("Enabled G6", "G6 Native mode enabled", null, Constants.G6_DEFAULTS_MESSAGE, false, true, false);
UserError.Log.uel(TAG, "Dex Native mode enabled. For your device, non-native mode is either not possible or not recommended.");
JoH.showNotification("Enabled Native", "Native mode enabled", null, Constants.G6_DEFAULTS_MESSAGE, false, true, false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.eveningoutpost.dexdrip.models.Sensor;
import com.eveningoutpost.dexdrip.R;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.utilitymodels.Constants;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.utilitymodels.StatusItem.Highlight;
Expand All @@ -32,6 +31,7 @@
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.HOUR_IN_MS;
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.MINUTE_IN_MS;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.None;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getBestCollectorHardwareName;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getDexCollectionType;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.hasDexcomRaw;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.hasLibre;
Expand Down Expand Up @@ -103,7 +103,7 @@ public static SensorDays get(DexCollectionType type, final String tx_id) {
ths.warmupMs = 2 * HOUR_IN_MS;
}

if (FirmwareCapability.isDeviceG7(getTransmitterID())) { // If using a G7
if (getBestCollectorHardwareName().equals("G7")) { // If using a G7
ths.period = DAY_IN_MS * 10 + HOUR_IN_MS * 12; // The device lasts 10.5 days.
ths.warmupMs = 30 * MINUTE_IN_MS; // The warmup time is 30 minutes.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,7 @@ public static boolean trendingToAlertEnd(Context context, boolean above) {
return false;
}

// TODO: Should we add documentation to address possible misbehavior in case of 1-minute readings?
if(above == false) {
// This is a low alert, we should be going up
if((latest.get(0).calculated_value - latest.get(1).calculated_value > 4) ||
Expand All @@ -2049,8 +2050,8 @@ public static boolean trendingToAlertEnd(Context context, boolean above) {
}
} else {
// This is a high alert we should be heading down
if((latest.get(1).calculated_value - latest.get(0).calculated_value > 4) ||
(latest.get(2).calculated_value - latest.get(0).calculated_value > 10)) {
if((latest.get(1).calculated_value - latest.get(0).calculated_value > 1) ||
(latest.get(2).calculated_value - latest.get(0).calculated_value > 2)) {
Log.d(TAG_ALERT, "trendingToAlertEnd returning true for high alert");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ private synchronized void stopDiscover() {
}

private boolean isScanMatch(final String this_address, final String historical_address, final String this_name, final String search_name) {
if (search_name == null && (this_address.equalsIgnoreCase(historical_address) || this_name == null || (emptyString(historical_address) && this_name.startsWith("DXCM")))) {
if (search_name == null && (this_address.equalsIgnoreCase(historical_address) || this_name == null || (emptyString(historical_address) && this_name.startsWith("DXCM")) || (emptyString(historical_address) && this_name.startsWith("DX02")))) {
return !inFailureTally(this_address);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class UiBasedCollector extends NotificationListenerService {
coOptedPackages.add("com.dexcom.g6.region3.mgdl");
coOptedPackages.add("com.dexcom.dexcomone");
coOptedPackages.add("com.dexcom.g7");
coOptedPackages.add("com.dexcom.d1plus");
coOptedPackages.add("com.camdiab.fx_alert.mmoll");
coOptedPackages.add("com.camdiab.fx_alert.mgdl");
coOptedPackages.add("com.camdiab.fx_alert.hx.mmoll");
Expand All @@ -87,11 +88,14 @@ public class UiBasedCollector extends NotificationListenerService {
coOptedPackages.add("com.medtronic.diabetes.guardianconnect.us");
coOptedPackages.add("com.medtronic.diabetes.minimedmobile.eu");
coOptedPackages.add("com.medtronic.diabetes.minimedmobile.us");
coOptedPackages.add("com.medtronic.diabetes.simplera.eu");
coOptedPackages.add("com.senseonics.gen12androidapp");
coOptedPackages.add("com.senseonics.androidapp");

coOptedPackagesAll.add("com.dexcom.dexcomone");
coOptedPackagesAll.add("com.dexcom.d1plus");
coOptedPackagesAll.add("com.medtronic.diabetes.guardian");
coOptedPackagesAll.add("com.medtronic.diabetes.simplera.eu");
coOptedPackagesAll.add("com.senseonics.gen12androidapp");
coOptedPackagesAll.add("com.senseonics.androidapp");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public interface MicroStatus {

boolean xmitterBattery();


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Created by jamorham on 29/09/2017.
*/

import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getBestCollectorHardwareName;

import androidx.databinding.BaseObservable;

import com.eveningoutpost.dexdrip.utils.DexCollectionType;
Expand All @@ -28,12 +30,13 @@ public String gs(String id) {
}

@Override
public boolean bluetooth() {
return DexCollectionType.hasBluetooth();
public boolean bluetooth() { // Dexcom with Bluetooth except G7
return DexCollectionType.hasBluetooth() && !getBestCollectorHardwareName().equals("G7");
}

@Override
public boolean xmitterBattery() {
return DexCollectionType.usesClassicTransmitterBattery();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class BgSparklineBuilder {
protected boolean useSmallDots = true;
protected boolean useTinyDots = false;
protected boolean showFiltered = false;

protected Integer useSpecificDotSize = null;
protected int backgroundColor = Color.TRANSPARENT;
protected final static int SCALE_TRIGGER = 84;

Expand Down Expand Up @@ -123,6 +125,11 @@ public BgSparklineBuilder setSmallDots() {

public BgSparklineBuilder setTinyDots() { return this.setTinyDots(true); }

public BgSparklineBuilder setDotSize(int size) {
this.useSpecificDotSize = size;
return this;
}

public BgSparklineBuilder setBackgroundColor(int color)
{
this.backgroundColor = color;
Expand Down Expand Up @@ -213,6 +220,10 @@ public Bitmap build() {
for(Line line: lines)
line.setPointRadius(1);
}
if (useSpecificDotSize != null) {
for(Line line: lines)
line.setPointRadius(useSpecificDotSize);
}
LineChartData lineData = new LineChartData(lines);
if (showAxes) {
if (height<=SCALE_TRIGGER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void performAll() {
legacySettingsFix();
IncompatibleApps.notifyAboutIncompatibleApps();
CompatibleApps.notifyAboutCompatibleApps();
legacySettingsMoveLanguageFromNoToNb();

}

Expand Down Expand Up @@ -149,5 +150,11 @@ private static void legacySettingsFix() {
Pref.setBoolean("always_unbond_G5", false);
Pref.setBoolean("always_get_new_keys", true);
}

private static void legacySettingsMoveLanguageFromNoToNb() {
// Check if the user's language preference is set to "no"
if ("no".equals(Pref.getString("forced_language", ""))) {
// Update the language preference to "nb"
Pref.setString("forced_language", "nb");
}
}
}
Loading

0 comments on commit 0770562

Please sign in to comment.