Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Navid200 committed Oct 29, 2024
1 parent d00302d commit 11710eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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.utilitymodels.Constants.SECOND_IN_MS;
import static com.eveningoutpost.dexdrip.utils.Preferences.handleUnitsChange;
import static com.eveningoutpost.dexdrip.xdrip.gs;

import android.Manifest;
Expand Down Expand Up @@ -386,9 +385,6 @@ protected void onCreate(Bundle savedInstanceState) {
setVolumeControlStream(AudioManager.STREAM_MUSIC);

checkedeula = checkEula();
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 based on the selected unit
}

binding = ActivityHomeBinding.inflate(getLayoutInflater());
binding.setVs(homeShelf);
Expand Down
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,6 +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 @@ -758,7 +759,7 @@ 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 ? Double.parseDouble(stringValue) : Double.parseDouble(stringValue) * Constants.MMOLL_TO_MGDL;
double submissionMgdl = domgdl ? tolerantParseDouble(stringValue) : tolerantParseDouble(stringValue) * Constants.MMOLL_TO_MGDL;
if (submissionMgdl > MAX_GLUCOSE_INPUT || submissionMgdl < MIN_GLUCOSE_INPUT) {
JoH.static_toast_long("The value must be between " + unitsConvert2Disp(domgdl, MIN_GLUCOSE_INPUT) + " and " + unitsConvert2Disp(domgdl, MAX_GLUCOSE_INPUT));
return false;
Expand Down

0 comments on commit 11710eb

Please sign in to comment.