Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Aug 7, 2024
2 parents 9b89039 + f0ba4ed commit f96d4e5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public SensorExpiry() {

@Override
public boolean activate() {
val expiry = niceTimeScalarNatural(SensorDays.get().getRemainingSensorPeriodInMs());
val expiry = niceTimeScalarNatural(SensorDays.get().getRemainingSensorPeriodInMs(), 1);
val notificationId = SENSORY_EXPIRY_NOTIFICATION_ID;
cancelNotification(notificationId);
val expireMsg = String.format("Sensor will expire in %s", expiry); // TODO i18n and format string
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,14 +809,18 @@ public static String niceTimeScalar(double t, int digits) {
}


public static String niceTimeScalarNatural(long t) {
public static String niceTimeScalarNatural(long t) { // Shows the integer part only when less than 1 day.
return niceTimeScalarNatural(t, 0);
}

public static String niceTimeScalarNatural(long t, int h_digits) { // Rounds down to the defined number of decimal points when less than 1 day.
if (t > 3000000) t = t + 10000; // round up by 10 seconds if nearly an hour
if ((t > Constants.DAY_IN_MS) && (t < Constants.WEEK_IN_MS * 2)) {
final SimpleDateFormat df = new SimpleDateFormat("EEEE", Locale.getDefault());
final String day = df.format(new Date(JoH.tsl() + t));
return ((t > Constants.WEEK_IN_MS) ? "next " : "") + day;
} else {
return niceTimeScalar(t);
return niceTimeScalar(t, h_digits);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ public void instantCreateBondIfAllowed() {


private boolean getInitiateBondingFlag() {
return Pref.getBoolean("ob1_initiate_bonding_flag", true);
return true; // There is no reason not to initiate bonding
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private static void legacySettingsFix() {
Pref.setBoolean("always_get_new_keys", true);
Pref.setBoolean("run_ble_scan_constantly", false);
Pref.setBoolean("run_G5_ble_tasks_on_uithread", false);
Pref.setBoolean("ob1_initiate_bonding_flag", true);
}
private static void legacySettingsMoveLanguageFromNoToNb() {
// Check if the user's language preference is set to "no"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ public synchronized Notification createOngoingNotification(BgGraphBuilder bgGrap
if (lastReading != null) {

b.setWhen(lastReading.timestamp);
b.setShowWhen(true);

final SpannableString deltaString = new SpannableString("Delta: " + ((dg != null) ? (dg.spannableString(dg.unitized_delta + (dg.from_plugin ? " "+context.getString(R.string.p_in_circle) : "")))
: bgGraphBuilder.unitizedDeltaString(true, true)));

Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/xml/pref_data_source.xml
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,6 @@
android:key="ob1_special_pairing_workaround"
android:summary="Some Samsung devices can have an error where they lose the pairing information. This attempts to work around the issue."
android:title="@string/special_pairing_workaround" />
<CheckBoxPreference
android:defaultValue="true"
android:key="ob1_initiate_bonding_flag"
android:summary="@string/summary_ob1_initiate_bonding_flag"
android:title="@string/title_ob1_initiate_bonding_flag"
/>
<EditTextPreference
android:defaultValue=""
android:inputType="number"
Expand Down

0 comments on commit f96d4e5

Please sign in to comment.