Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent High threshold fix #3734

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/prod/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should not be in the PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing it right now

"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.eveningoutpost.dexdrip",
"variantName": "prodRelease",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1603091400,
"versionName": "11710ebe5-Navid_2024_10_15b-2024.10.30",
"outputFile": "app-prod-release.apk"
}
],
"elementType": "File"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.eveningoutpost.dexdrip.utilitymodels;

import static com.eveningoutpost.dexdrip.utils.Preferences.handleUnitsChange;

import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
Expand Down Expand Up @@ -60,6 +62,9 @@ public void performAll() {
IncompatibleApps.notifyAboutIncompatibleApps();
CompatibleApps.notifyAboutCompatibleApps();
legacySettingsMoveLanguageFromNoToNb();
if (!Pref.getString("units", "mgdl").equals("mgdl")) { // Only if the selected unit is mmol/L
handleUnitsChange(null, "mmol", null); // Trigger the correction of values (defaults) if needed
}

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.eveningoutpost.dexdrip.utils;

import static com.eveningoutpost.dexdrip.EditAlertActivity.unitsConvert2Disp;
import static com.eveningoutpost.dexdrip.models.JoH.tolerantParseDouble;
import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getBestCollectorHardwareName;
import static com.eveningoutpost.dexdrip.xdrip.gs;

Expand Down Expand Up @@ -188,6 +190,8 @@ public class Preferences extends BasePreferenceActivity implements SearchPrefere
private volatile String scanFormat = null; // The format of the scan
private volatile String scanContents = null; // Text content of the scan coming either from camera or file
private volatile byte[] scanRawBytes = null; // Raw bytes of the scan
private static final double MIN_GLUCOSE_INPUT = 40; // The smallest input glucose value xDrip accepts
private static final double MAX_GLUCOSE_INPUT = 400; // The largest input glucose value xDrip accepts

private void refreshFragments() {
refreshFragments(null);
Expand Down Expand Up @@ -755,6 +759,11 @@ public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (isNumeric(stringValue)) {
final boolean domgdl = Pref.getString("units", "mgdl").equals("mgdl"); // Identify which unit is chosen
double submissionMgdl = domgdl ? tolerantParseDouble(stringValue) : tolerantParseDouble(stringValue) * Constants.MMOLL_TO_MGDL;
if (submissionMgdl > MAX_GLUCOSE_INPUT || submissionMgdl < MIN_GLUCOSE_INPUT) {
JoH.static_toast_long(xdrip.gs(R.string.the_value_must_be_between_space) + unitsConvert2Disp(domgdl, MIN_GLUCOSE_INPUT) + xdrip.gs(R.string.space_and_space) + unitsConvert2Disp(domgdl, MAX_GLUCOSE_INPUT));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For good localization you shouldn't be building the string yourself with concatenation. Instead use a format string. See how xdrip_software_changed_format is handled for an example.

return false;
}
preference.setSummary(stringValue + " " + (domgdl ? "mg/dl" : "mmol/l")); // Set the summary to show the value followed by the chosen unit
return true;
}
Expand Down Expand Up @@ -1009,7 +1018,11 @@ private static void bindPreferenceSummaryToValueAndEnsureNumeric(Preference pref
.getString(preference.getKey(), ""));
}

private static void bindPreferenceSummaryToUnitizedValueAndEnsureNumeric(Preference preference) { // Use this to show the value as well as the corresponding glucose unit as the summary
private static void bindPreferenceSummaryToUnitizedValueAndEnsureNumeric(Preference preference) { // Use this to:
// 1- show the value as summary;
// 2- amend the value in summary with the corresponding glucose unit;
// 3- reject inputs outside the 40-400 mg/dL range.

preference.setOnPreferenceChangeListener(sBindNumericUnitizedPreferenceSummaryToValueListener);
sBindNumericUnitizedPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@
<string name="persistent_high_alert">Persistent High Alert</string>
<string name="persistent_high_alert_enable">Enable</string>
<string name="title_persistent_high_threshold">Threshold</string>
<string name="the_value_must_be_between_space">"The value must be between "</string>
<string name="space_and_space">" and "</string>
<string name="forecasted_low_alert">Forecasted Low Alert</string>
<string name="extrapolate_data_to_try_to_predict_lows">Extrapolate data to try to predict lows</string>
<string name="alarm_at_forecasted_low_mins">Alarm at Forecasted Low mins</string>
Expand Down
Loading