diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java index d4a16570b..7cd53320c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java @@ -952,6 +952,14 @@ public class GBApplication extends Application { return context.getSharedPreferences("devicesettings_" + deviceIdentifier, Context.MODE_PRIVATE); } + public static void deleteDeviceSpecificSharedPrefs(String deviceIdentifier) { + if (deviceIdentifier == null || deviceIdentifier.isEmpty()) { + return; + } + context.getSharedPreferences("devicesettings_" + deviceIdentifier, Context.MODE_PRIVATE).edit().clear().apply(); + } + + public static void setLanguage(String lang) { if (lang.equals("default")) { language = Resources.getSystem().getConfiguration().locale; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java index a1d79bd10..3c035d893 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java @@ -397,6 +397,17 @@ public class DebugActivity extends AbstractGBActivity { } }); + Button removeDevicePreferencesButton = findViewById(R.id.removeDevicePreferences); + removeDevicePreferencesButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Context context = getApplicationContext(); + GBApplication gbApp = (GBApplication) context; + final GBDevice device = gbApp.getDeviceManager().getSelectedDevice(); + GBApplication.deleteDeviceSpecificSharedPrefs(device.getAddress()); + } + }); + Button addDeviceButtonDebug = findViewById(R.id.addDeviceButtonDebug); addDeviceButtonDebug.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java index 2e01af38d..086329378 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java @@ -94,6 +94,8 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator { prefs.getPreferences().edit().remove(MiBandConst.PREF_MIBAND_ADDRESS).apply(); } + GBApplication.deleteDeviceSpecificSharedPrefs(gbDevice.getAddress()); + try (DBHandler dbHandler = GBApplication.acquireDB()) { DaoSession session = dbHandler.getDaoSession(); Device device = DBHelper.findDevice(gbDevice, session); diff --git a/app/src/main/res/layout/activity_debug.xml b/app/src/main/res/layout/activity_debug.xml index db7232e54..bd7c24b7b 100644 --- a/app/src/main/res/layout/activity_debug.xml +++ b/app/src/main/res/layout/activity_debug.xml @@ -217,6 +217,14 @@ grid:layout_gravity="fill_horizontal" android:text="Add test device manually" /> +