From 3a72a11e1738060994daa6c23fe6cc27075ad9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Sun, 30 Oct 2022 09:37:42 +0000 Subject: [PATCH] Debug Activity: Add confirmation dialog before removing device preferences --- .../activities/DebugActivity.java | 19 +++++++++++++------ app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 15 insertions(+), 6 deletions(-) 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 dc03ce80e..7b983be07 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java @@ -478,12 +478,19 @@ public class DebugActivity extends AbstractGBActivity { removeDevicePreferencesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Context context = getApplicationContext(); - GBApplication gbApp = (GBApplication) context; - List devices = gbApp.getDeviceManager().getSelectedDevices(); - for(GBDevice device : devices){ - GBApplication.deleteDeviceSpecificSharedPrefs(device.getAddress()); - } + new AlertDialog.Builder(DebugActivity.this) + .setCancelable(true) + .setTitle(R.string.debugactivity_confirm_remove_device_preferences_title) + .setMessage(R.string.debugactivity_confirm_remove_device_preferences) + .setPositiveButton(R.string.ok, (dialog, which) -> { + final GBApplication gbApp = (GBApplication) getApplicationContext(); + final List devices = gbApp.getDeviceManager().getSelectedDevices(); + for(final GBDevice device : devices){ + GBApplication.deleteDeviceSpecificSharedPrefs(device.getAddress()); + } + }) + .setNegativeButton(R.string.Cancel, (dialog, which) -> {}) + .show(); } }); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4246016cc..b24177797 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -95,6 +95,8 @@ Debug Really factory reset? Doing a factory reset will delete all data from the connected device (if supported). Xiaomi/Huami devices also change Bluetooth MAC address, so they appear as a new devices to Gadgetbridge. + Remove device preferences? + This will reset the device preferences for all connected devices. Are you sure? App Manager Apps in cache