mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 03:16:51 +01:00
Display device name to delete, and use different API to delete device
This commit is contained in:
parent
b890242c4f
commit
2e7fb57172
@ -301,6 +301,7 @@ public class ControlCenter extends GBActivity {
|
||||
case R.id.controlcenter_delete_device:
|
||||
if (selectedDevice != null) {
|
||||
if (confirmDeleteDevice(selectedDevice)) {
|
||||
deleteDevice(selectedDevice);
|
||||
selectedDevice = null;
|
||||
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
|
||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(refreshIntent);
|
||||
@ -355,12 +356,11 @@ public class ControlCenter extends GBActivity {
|
||||
final boolean[] result = new boolean[1];
|
||||
new AlertDialog.Builder(this)
|
||||
.setCancelable(true)
|
||||
.setTitle(R.string.controlcenter_delete_device)
|
||||
.setTitle(getString(R.string.controlcenter_delete_device_name, gbDevice.getName()))
|
||||
.setMessage(R.string.controlcenter_delete_device_dialogmessage)
|
||||
.setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
deleteDevice(gbDevice);
|
||||
result[0] = true;
|
||||
}
|
||||
})
|
||||
@ -381,7 +381,7 @@ public class ControlCenter extends GBActivity {
|
||||
}
|
||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
||||
DaoSession session = dbHandler.getDaoSession();
|
||||
Device device = DBHelper.findDevice(gbDevice, session);
|
||||
Device device = DBHelper.getDevice(gbDevice, session);
|
||||
if (device != null) {
|
||||
long deviceId = device.getId();
|
||||
QueryBuilder qb;
|
||||
@ -406,8 +406,7 @@ public class ControlCenter extends GBActivity {
|
||||
}
|
||||
qb = session.getDeviceAttributesDao().queryBuilder();
|
||||
qb.where(DeviceAttributesDao.Properties.DeviceId.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities();
|
||||
qb = session.getDeviceDao().queryBuilder();
|
||||
qb.where(DeviceDao.Properties.Id.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities();
|
||||
session.getDeviceDao().delete(device);
|
||||
} else {
|
||||
LOG.warn("device not found while deleting");
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
<string name="controlcenter_take_screenshot">Take Screenshot</string>
|
||||
<string name="controlcenter_disconnect">Disconnect</string>
|
||||
<string name="controlcenter_delete_device">Delete Device</string>
|
||||
<string name="controlcenter_delete_device_name">Delete %1$s</string>
|
||||
<string name="controlcenter_delete_device_dialogmessage">This will delete the device and all associated data!</string>
|
||||
|
||||
<string name="title_activity_debug">Debug</string>
|
||||
|
Loading…
Reference in New Issue
Block a user