Skip to content

Commit

Permalink
Merge pull request #180 from NightscoutFoundation/master
Browse files Browse the repository at this point in the history
downstream sync
  • Loading branch information
gruoner authored Jun 1, 2024
2 parents 645e8b4 + 27de713 commit fea0ad9
Show file tree
Hide file tree
Showing 73 changed files with 985 additions and 189 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ android {

defaultConfig {
applicationId "com.eveningoutpost.dexdrip"
minSdkVersion 23
minSdkVersion 24
// increasing target SDK version can cause compatibility issues with Android 7+
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 23
targetSdkVersion 24
// change versionCode only when downgrade should be prevented
// eg, when data structures are incompatible
versionCode 1603091400
Expand Down Expand Up @@ -216,7 +216,7 @@ android {
// set minSdkVersion to 21 or higher. When using Android Studio 2.3 or higher,
// the build automatically avoids legacy multidex when deploying to a device running
// API level 21 or higher—regardless of what you set as your minSdkVersion.
minSdkVersion 23
minSdkVersion 24
versionNameSuffix "-dev"
buildConfigField "int", "buildVersion", "2021010100"
buildConfigField "String", "buildUUID", "\"0f79a60a-5616-99be-8eb1-a430edcfd9fd\""
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<provider
android:name=".receiver.InfoContentProvider"
android:authorities="${applicationId}.contentprovider"
android:enabled="true"
android:exported="true">
</provider>

<activity
android:name=".Home"
Expand Down
26 changes: 14 additions & 12 deletions app/src/main/java/com/eveningoutpost/dexdrip/EditAlertActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.eveningoutpost.dexdrip.models.AlertType;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.UserError.Log;
import com.eveningoutpost.dexdrip.ui.dialog.GenericConfirmDialog;
import com.eveningoutpost.dexdrip.utilitymodels.AlertPlayer;
import com.eveningoutpost.dexdrip.utilitymodels.BgGraphBuilder;
import com.eveningoutpost.dexdrip.utilitymodels.Constants;
Expand Down Expand Up @@ -565,19 +566,20 @@ public void onClick(View v) {

buttonRemove.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {


if (uuid == null) {
Log.wtf(TAG, "Error remove pressed, while we were adding an alert");
} else {
AlertType.remove_alert(uuid);
startWatchUpdaterService(mContext, WatchUpdaterService.ACTION_SYNC_ALERTTYPE, TAG);
}
Intent returnIntent = new Intent();
setResult(RESULT_OK,returnIntent);
finish();
GenericConfirmDialog.show(EditAlertActivity.this, gs(R.string.are_you_sure), gs(R.string.you_cannot_undo_delete_alert),
() -> { // This, which deletes the alert, will only be executed after confirmation
if (uuid == null) {
Log.wtf(TAG, "Error remove pressed, while we were adding an alert");
} else {
AlertType.remove_alert(uuid);
startWatchUpdaterService(mContext, WatchUpdaterService.ACTION_SYNC_ALERTTYPE, TAG);
}
Intent returnIntent = new Intent();
setResult(RESULT_OK, returnIntent);
finish();
}
);
}

});

buttonTest.setOnClickListener(new View.OnClickListener() {
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/eveningoutpost/dexdrip/GcmActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.eveningoutpost.dexdrip.utils.CipherUtils;
import com.eveningoutpost.dexdrip.utils.DisplayQRCode;
import com.eveningoutpost.dexdrip.utils.SdcardImportExport;
import com.eveningoutpost.dexdrip.watch.thinjam.BlueJayEntry;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.gcm.GoogleCloudMessaging;
Expand Down Expand Up @@ -864,9 +865,11 @@ public void onReceive(Context context, Intent intent) {
xdrip.getAppContext().startService(intent);
} else {
cease_all_activity = true;
final String msg = "ERROR: Connecting to Google Services - check google login or reboot?";
JoH.static_toast_long(msg);
Home.toaststaticnext(msg);
if (!BlueJayEntry.isNative()) {
final String msg = "ERROR: Connecting to Google Services - check google login or reboot?";
JoH.static_toast_long(msg);
Home.toaststaticnext(msg);
}
}
}

Expand Down Expand Up @@ -998,6 +1001,7 @@ static Boolean checkPlayServices(Context context, Activity activity) {
if (resultCode != ConnectionResult.SUCCESS) {
try {
if (apiAvailability.isUserResolvableError(resultCode)) {
if (resultCode == 3 && BlueJayEntry.isNative()) return false;
if (activity != null) {
apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
Expand Down
18 changes: 14 additions & 4 deletions app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ public void toggleStepsVisibility(View v) {
}

public void sourceWizardButtonClick(View v) {
SourceWizard.start(this, true);
SourceWizard.start(Home.this, true);
}

private long whichTimeLocked() {
Expand Down Expand Up @@ -2296,8 +2296,12 @@ private void setHoursViewPort(final String source) {
break;
}

float ideal_hours_to_show = DEFAULT_CHART_HOURS + bgGraphBuilder.getPredictivehours();
// always show at least the ideal number of hours if locked or auto
// always show at least the ideal number of hours
float ideal_hours_to_show = DEFAULT_CHART_HOURS;
// ... and rescale to accommodate predictions if not locked
if (! homeShelf.get("time_locked_always")) {
ideal_hours_to_show += bgGraphBuilder.getPredictivehours();
}
float hours_to_show = exactHoursSpecified ? hours : Math.max(hours, ideal_hours_to_show);

UserError.Log.d(TAG, "VIEWPORT " + source + " moveviewport in setHours: asked " + hours + " vs auto " + ideal_hours_to_show + " = " + hours_to_show + " full chart width: " + bgGraphBuilder.hoursShownOnChart());
Expand All @@ -2308,6 +2312,12 @@ private void setHoursViewPort(final String source) {
holdViewport.top = maxViewPort.top;
holdViewport.bottom = maxViewPort.bottom;

// if locked, center display on current bg values, not predictions
if (homeShelf.get("time_locked_always")) {
holdViewport.left -= hour_width * bgGraphBuilder.getPredictivehours();
holdViewport.right -= hour_width * bgGraphBuilder.getPredictivehours();
}

if (d) {
UserError.Log.d(TAG, "HOLD VIEWPORT " + holdViewport);
UserError.Log.d(TAG, "MAX VIEWPORT " + maxViewPort);
Expand Down Expand Up @@ -2647,7 +2657,7 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final Context context = this;
builder.setTitle(getString(R.string.start_sensor) + "?");
builder.setMessage(String.format(gs(R.string.start_sensor_confirmation), DexCollectionType.getDexCollectionType().toString()));
builder.setMessage(String.format(gs(R.string.start_sensor_confirmation), DexCollectionType.getBestCollectorHardwareName()));
builder.setNegativeButton(gs(R.string.change_settings), (dialog, which) -> {
dialog.dismiss();
startActivity(new Intent(context, Preferences.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.LibreBlock;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.receiver.InfoContentProvider;
import com.eveningoutpost.dexdrip.sharemodels.BgUploader;
import com.eveningoutpost.dexdrip.sharemodels.models.ShareUploadPayload;
import com.eveningoutpost.dexdrip.utilitymodels.Inevitable;
Expand Down Expand Up @@ -58,6 +59,7 @@ public static void newBgReading(BgReading bgReading, boolean is_follower) {
sendToBlueJay();
sendToRemoteBlueJay();
Notifications.start();
InfoContentProvider.ping("bg");
uploadToShare(bgReading, is_follower);
textToSpeech(bgReading, null);
LibreBlock.UpdateBgVal(bgReading.timestamp, bgReading.calculated_value);
Expand Down Expand Up @@ -87,6 +89,7 @@ public static void newExternalStatus(boolean receivedLocally) {
GcmActivity.push_external_status_update(JoH.tsl(), statusLine);

}
InfoContentProvider.ping("status");
}

}
Expand Down
25 changes: 15 additions & 10 deletions app/src/main/java/com/eveningoutpost/dexdrip/StartNewSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,22 @@ public class StartNewSensor extends ActivityWithMenu {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!Sensor.isActive()) {
JoH.fixActionBar(this);
setContentView(R.layout.activity_start_new_sensor);
button = (Button) findViewById(R.id.startNewSensor);
//dp = (DatePicker)findViewById(R.id.datePicker);
//tp = (TimePicker)findViewById(R.id.timePicker);
addListenerOnButton();
} else {
Intent intent = new Intent(this, StopSensor.class);
startActivity(intent);
if (DexCollectionType.getBestCollectorHardwareName().equals("G7")) {
JoH.static_toast_long(getString(R.string.g7_should_start_automatically));
finish();
} else {
if (!Sensor.isActive()) {
JoH.fixActionBar(this);
setContentView(R.layout.activity_start_new_sensor);
button = (Button) findViewById(R.id.startNewSensor);
//dp = (DatePicker)findViewById(R.id.datePicker);
//tp = (TimePicker)findViewById(R.id.timePicker);
addListenerOnButton();
} else {
Intent intent = new Intent(this, StopSensor.class);
startActivity(intent);
finish();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.R;
import com.eveningoutpost.dexdrip.receiver.InfoContentProvider;
import com.eveningoutpost.dexdrip.utilitymodels.Inevitable;
import com.eveningoutpost.dexdrip.utilitymodels.PrefsViewImpl;
import com.eveningoutpost.dexdrip.databinding.ActivityBackupPickerBinding;
Expand Down Expand Up @@ -193,7 +194,7 @@ public synchronized void restoreNow() {
status(getString(R.string.nothing_to_restore_please_select));
} else {
Runnable restoreRunnable = () -> GenericConfirmDialog.show(BackupActivity.this, getString(R.string.are_you_really_sure_question), getString(R.string.restoring_backup_will_erase_warning), () -> restoreNowReal());
if (metaData.sourceDevice.equals(cleanPhoneName())) {
if (metaData.sourceDevice != null && metaData.sourceDevice.equals(cleanPhoneName())) {
restoreRunnable.run();
} else {
GenericConfirmDialog.show(BackupActivity.this, getString(R.string.backup_source_confirm), getString(R.string.this_backup_looks_like_came_from_different_format_string, metaData.sourceDevice), restoreRunnable);
Expand All @@ -212,6 +213,7 @@ private synchronized void restoreNowReal() {
if (metaData.exception != null) {
status(getString(R.string.error_exclamation) + " " + metaData.exception);
}
InfoContentProvider.ping("pref");
} finally {
idle.set(true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eveningoutpost.dexdrip.g5model;

import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.services.G5CollectionService;

import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -50,4 +51,9 @@ public Integer getPredictedGlucose() {
return null; // stub
}

public long getRealTimestamp() {
return JoH.tsl(); // default behavior is received now
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public static void store(final String transmitterId, final long when) {
UserError.Log.d(TAG, "Sync time updated to: " + JoH.dateTimeText(when));
}

public static void store(final String transmitterId, final long when, final long last_conection_time, final long last_glucose_processed) {
final long latency = (last_glucose_processed - last_conection_time);
UserError.Log.d(TAG, "Update time from glucose rx glucose: " + JoH.dateTimeText(when) + " latency:" + latency + " ms");
if (latency < 8000) { // roughly half preempt
store(transmitterId, when);
} else {
UserError.Log.e(TAG, "Refusing to update stored timestamp due to excessive processing latency: " + latency + "ms");
}
}

public static void clear(final String transmitterId) {
if (PersistentStore.getLong(DEX_SYNC_STORE + transmitterId) > 0) {
UserError.Log.e(TAG, "Clearing stored timing sync information for: " + transmitterId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public Long getRealSessionStartTime() {
return null;
}

@Override
public long getRealTimestamp() {
return JoH.tsl() - (age * Constants.SECOND_IN_MS);
}

public String getRealSessionStartTimeString() {
val t = getRealSessionStartTime();
if (t != null) {
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", "44.192.105.72");
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", "32.192.106.0", "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
Loading

0 comments on commit fea0ad9

Please sign in to comment.