mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 18:45:49 +01:00
Remove device specific preferences upon device removal. Also add this option to the Debug screen.
This commit is contained in:
parent
47b9e94858
commit
d6b5140519
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -217,6 +217,14 @@
|
||||
grid:layout_gravity="fill_horizontal"
|
||||
android:text="Add test device manually" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/removeDevicePreferences"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Remove device preferences"
|
||||
grid:layout_columnSpan="2"
|
||||
grid:layout_gravity="fill_horizontal" />
|
||||
|
||||
</androidx.gridlayout.widget.GridLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
Loading…
Reference in New Issue
Block a user