mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 13:26:50 +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);
|
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) {
|
public static void setLanguage(String lang) {
|
||||||
if (lang.equals("default")) {
|
if (lang.equals("default")) {
|
||||||
language = Resources.getSystem().getConfiguration().locale;
|
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);
|
Button addDeviceButtonDebug = findViewById(R.id.addDeviceButtonDebug);
|
||||||
addDeviceButtonDebug.setOnClickListener(new View.OnClickListener() {
|
addDeviceButtonDebug.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -94,6 +94,8 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
prefs.getPreferences().edit().remove(MiBandConst.PREF_MIBAND_ADDRESS).apply();
|
prefs.getPreferences().edit().remove(MiBandConst.PREF_MIBAND_ADDRESS).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GBApplication.deleteDeviceSpecificSharedPrefs(gbDevice.getAddress());
|
||||||
|
|
||||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
||||||
DaoSession session = dbHandler.getDaoSession();
|
DaoSession session = dbHandler.getDaoSession();
|
||||||
Device device = DBHelper.findDevice(gbDevice, session);
|
Device device = DBHelper.findDevice(gbDevice, session);
|
||||||
|
@ -217,6 +217,14 @@
|
|||||||
grid:layout_gravity="fill_horizontal"
|
grid:layout_gravity="fill_horizontal"
|
||||||
android:text="Add test device manually" />
|
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>
|
</androidx.gridlayout.widget.GridLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
Loading…
Reference in New Issue
Block a user