Skip to content

Commit

Permalink
OB1: make setting always enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Jul 16, 2023
1 parent 4ca4b00 commit 23ccbd1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void performAll() {
AlertType.fixUpTable();
UserNotification.updateDB();
JoH.clearCache();
legacySettingsFix();
IncompatibleApps.notifyAboutIncompatibleApps();
CompatibleApps.notifyAboutCompatibleApps();

Expand Down Expand Up @@ -141,4 +142,9 @@ public static void migrateOOP2CalibrationPreferences() {
}
}

// Force legacy settings to be at their recommended values
private static void legacySettingsFix() {
Pref.setBoolean("use_ob1_g5_collector_service", true);
}

}
86 changes: 41 additions & 45 deletions app/src/main/java/com/eveningoutpost/dexdrip/utils/Preferences.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.eveningoutpost.dexdrip.utils;

import static com.eveningoutpost.dexdrip.xdrip.gs;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
Expand Down Expand Up @@ -47,28 +49,45 @@
import com.bytehamster.lib.preferencesearch.SearchPreferenceResult;
import com.bytehamster.lib.preferencesearch.SearchPreferenceResultListener;
import com.eveningoutpost.dexdrip.BasePreferenceActivity;
import com.eveningoutpost.dexdrip.g5model.DexSyncKeeper;
import com.eveningoutpost.dexdrip.g5model.Ob1G5StateMachine;
import com.eveningoutpost.dexdrip.GcmActivity;
import com.eveningoutpost.dexdrip.Home;
import com.eveningoutpost.dexdrip.NFCReaderX;
import com.eveningoutpost.dexdrip.ParakeetHelper;
import com.eveningoutpost.dexdrip.R;
import com.eveningoutpost.dexdrip.WidgetUpdateService;
import com.eveningoutpost.dexdrip.alert.Registry;
import com.eveningoutpost.dexdrip.calibrations.PluggableCalibration;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.CareLinkFollowService;
import com.eveningoutpost.dexdrip.cgm.nsfollow.NightscoutFollow;
import com.eveningoutpost.dexdrip.cgm.sharefollow.ShareFollowService;
import com.eveningoutpost.dexdrip.cgm.webfollow.Cpref;
import com.eveningoutpost.dexdrip.g5model.DexSyncKeeper;
import com.eveningoutpost.dexdrip.g5model.Ob1G5StateMachine;
import com.eveningoutpost.dexdrip.healthconnect.HealthConnectEntry;
import com.eveningoutpost.dexdrip.healthconnect.HealthGamut;
import com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry;
import com.eveningoutpost.dexdrip.models.DesertSync;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.Profile;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.models.UserError.ExtraLogTags;
import com.eveningoutpost.dexdrip.models.UserError.Log;
import com.eveningoutpost.dexdrip.models.UserNotification;
import com.eveningoutpost.dexdrip.NFCReaderX;
import com.eveningoutpost.dexdrip.ParakeetHelper;
import com.eveningoutpost.dexdrip.R;
import com.eveningoutpost.dexdrip.alert.Registry;
import com.eveningoutpost.dexdrip.plugin.Dialog;
import com.eveningoutpost.dexdrip.profileeditor.ProfileEditor;
import com.eveningoutpost.dexdrip.services.ActivityRecognizedService;
import com.eveningoutpost.dexdrip.services.BluetoothGlucoseMeter;
import com.eveningoutpost.dexdrip.services.DexCollectionService;
import com.eveningoutpost.dexdrip.services.G5BaseService;
import com.eveningoutpost.dexdrip.services.Ob1G5CollectionService;
import com.eveningoutpost.dexdrip.services.PlusSyncService;
import com.eveningoutpost.dexdrip.services.UiBasedCollector;
import com.eveningoutpost.dexdrip.services.broadcastservice.BroadcastService;
import com.eveningoutpost.dexdrip.tidepool.AuthFlowOut;
import com.eveningoutpost.dexdrip.tidepool.TidepoolUploader;
import com.eveningoutpost.dexdrip.tidepool.UploadChunk;
import com.eveningoutpost.dexdrip.ui.LockScreenWallPaper;
import com.eveningoutpost.dexdrip.ui.dialog.GenericConfirmDialog;
import com.eveningoutpost.dexdrip.utilitymodels.BgGraphBuilder;
import com.eveningoutpost.dexdrip.utilitymodels.CollectionServiceStarter;
import com.eveningoutpost.dexdrip.utilitymodels.Constants;
Expand All @@ -87,22 +106,6 @@
import com.eveningoutpost.dexdrip.utilitymodels.pebble.watchface.InstallPebbleTrendClayWatchFace;
import com.eveningoutpost.dexdrip.utilitymodels.pebble.watchface.InstallPebbleTrendWatchFace;
import com.eveningoutpost.dexdrip.utilitymodels.pebble.watchface.InstallPebbleWatchFace;
import com.eveningoutpost.dexdrip.WidgetUpdateService;
import com.eveningoutpost.dexdrip.calibrations.PluggableCalibration;
import com.eveningoutpost.dexdrip.cgm.nsfollow.NightscoutFollow;
import com.eveningoutpost.dexdrip.cgm.sharefollow.ShareFollowService;
import com.eveningoutpost.dexdrip.cgm.webfollow.Cpref;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.CareLinkFollowService;
import com.eveningoutpost.dexdrip.healthconnect.HealthConnectEntry;
import com.eveningoutpost.dexdrip.healthconnect.HealthGamut;
import com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry;
import com.eveningoutpost.dexdrip.plugin.Dialog;
import com.eveningoutpost.dexdrip.profileeditor.ProfileEditor;
import com.eveningoutpost.dexdrip.tidepool.AuthFlowOut;
import com.eveningoutpost.dexdrip.tidepool.TidepoolUploader;
import com.eveningoutpost.dexdrip.tidepool.UploadChunk;
import com.eveningoutpost.dexdrip.ui.LockScreenWallPaper;
import com.eveningoutpost.dexdrip.ui.dialog.GenericConfirmDialog;
import com.eveningoutpost.dexdrip.utils.framework.IncomingCallsReceiver;
import com.eveningoutpost.dexdrip.watch.lefun.LeFunEntry;
import com.eveningoutpost.dexdrip.watch.miband.MiBand;
Expand All @@ -112,7 +115,6 @@
import com.eveningoutpost.dexdrip.watch.thinjam.BlueJayAdapter;
import com.eveningoutpost.dexdrip.watch.thinjam.BlueJayEntry;
import com.eveningoutpost.dexdrip.wearintegration.Amazfitservice;
import com.eveningoutpost.dexdrip.services.broadcastservice.BroadcastService;
import com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService;
import com.eveningoutpost.dexdrip.webservices.XdripWebService;
import com.eveningoutpost.dexdrip.xDripWidget;
Expand All @@ -135,8 +137,6 @@
import lombok.Setter;
import lombok.val;

import static com.eveningoutpost.dexdrip.xdrip.gs;

/**
* A {@link PreferenceActivity} that presents a set of application settings. On
* handset devices, settings are presented as a single list. On tablets,
Expand Down Expand Up @@ -1135,24 +1135,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
//
}

findPreference("use_ob1_g5_collector_service").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
//
}
CollectionServiceStarter.restartCollectionService(xdrip.getAppContext());
}
}).start();

return true;
}
});

final Preference profile_carb_absorption_default = findPreference("profile_carb_absorption_default");
profile_carb_absorption_default.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
Expand Down Expand Up @@ -2468,11 +2450,25 @@ public void run() {
return true;
}
});

removeLegacyPreferences();
jumpToScreen(jumpTo);
}

public static void checkReadPermission(final Activity activity) {
private void removeLegacyPreferences() {
// removePreferenceFromCategory("use_ob1_g5_collector_service", "ob1_options");
}

private void removePreferenceFromCategory(final String preference, final String category) {
try {
final Preference pref = findPreference(preference);
final PreferenceGroup cat = (PreferenceGroup) findPreference(category);
cat.removePreference(pref);
} catch (Exception e) {
UserError.Log.e(TAG, "Exception removing preference " + preference + " from " + category + " " + e);
}
}

public static void checkReadPermission(final Activity activity) {

// TODO call log permission - especially for Android 9+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Expand Down
12 changes: 1 addition & 11 deletions app/src/main/res/xml/pref_data_source.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,9 @@
<PreferenceCategory
android:key="ob1_options"
android:title="@string/title_ob1_options">

<CheckBoxPreference
android:defaultValue="true"
android:key="use_ob1_g5_collector_service"
android:summary="@string/summary_use_ob1_g5_collector_service"
android:title="@string/title_use_ob1_g5_collector_service" />
<CheckBoxPreference
android:defaultValue="true"
android:dependency="use_ob1_g5_collector_service"
android:key="ob1_g5_use_transmitter_alg"
android:summary="@string/summary_ob1_g5_use_transmitter_alg"
android:title="@string/title_ob1_g5_use_transmitter_alg"
Expand Down Expand Up @@ -357,7 +352,6 @@
android:title="@string/title_ob1_g5_fallback_to_xdrip" />
<CheckBoxPreference
android:defaultValue="false"
android:dependency="use_ob1_g5_collector_service"
android:key="ob1_minimize_scanning"
android:summary="@string/summary_ob1_minimize_scanning"
android:title="@string/title_ob1_minimize_scanning" />
Expand All @@ -370,26 +364,22 @@
android:title="Avoid Scanning" />
<CheckBoxPreference
android:defaultValue="false"
android:dependency="use_ob1_g5_collector_service"
android:key="using_g6"
android:summary="@string/summary_using_g6"
android:title="@string/title_using_g6" />
<CheckBoxPreference
android:defaultValue="false"
android:key="ob1_g5_allow_resetbond"
android:dependency="use_ob1_g5_collector_service"
android:summary="@string/summary_ob1_g5_allow_resetbond"
android:title="@string/title_ob1_g5_allow_resetbond" />
<CheckBoxPreference
android:defaultValue="false"
android:key="ob1_special_pairing_workaround"
android:dependency="use_ob1_g5_collector_service"
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:dependency="use_ob1_g5_collector_service"
android:summary="@string/summary_ob1_initiate_bonding_flag"
android:title="@string/title_ob1_initiate_bonding_flag"
/>
Expand Down

0 comments on commit 23ccbd1

Please sign in to comment.