Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed May 22, 2024
2 parents 76398bd + 5aee479 commit 52a73fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 12 additions & 2 deletions app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,14 @@ public static synchronized Treatments create(final double carbs, final double in
}

public static synchronized Treatments create(final double carbs, final double insulinSum, final List<InsulinInjection> insulin, long timestamp, String suggested_uuid) {
// if treatment more than 1 minutes in the future
final long future_seconds = (timestamp - JoH.tsl()) / 1000;
// if treatment more than 1 hour in the future
if (future_seconds > (60 * 60)) {
JoH.static_toast_long("Refusing to create a treatement more than 1 hours in the future!");
return null;
}
if ((future_seconds > 60) && (future_seconds < 86400) && ((carbs > 0) || (insulinSum > 0))) {
// if treatment more than 3 minutes in the future
if ((future_seconds > (3 * 60)) && (future_seconds < 86400) && ((carbs > 0) || (insulinSum > 0))) {
final Context context = xdrip.getAppContext();
JoH.scheduleNotification(context, "Treatment Reminder", "@" + JoH.hourMinuteString(timestamp) + " : "
+ carbs + " g " + context.getString(R.string.carbs) + " / "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public static boolean isSamsung() {
return Build.MANUFACTURER.toLowerCase().contains("samsung")
|| Build.MANUFACTURER.toLowerCase().contains("xiaomi")
|| Build.MANUFACTURER.toLowerCase().contains("oneplus") // experimental test
|| Build.MANUFACTURER.toLowerCase().contains("oppo"); // experimental test
|| Build.MANUFACTURER.toLowerCase().contains("oppo") // experimental test
|| Build.MANUFACTURER.toLowerCase().contains("huawei"); // experimental test
}

}

0 comments on commit 52a73fc

Please sign in to comment.