mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05: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:
|
case R.id.controlcenter_delete_device:
|
||||||
if (selectedDevice != null) {
|
if (selectedDevice != null) {
|
||||||
if (confirmDeleteDevice(selectedDevice)) {
|
if (confirmDeleteDevice(selectedDevice)) {
|
||||||
|
deleteDevice(selectedDevice);
|
||||||
selectedDevice = null;
|
selectedDevice = null;
|
||||||
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
|
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
|
||||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(refreshIntent);
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(refreshIntent);
|
||||||
@ -355,12 +356,11 @@ public class ControlCenter extends GBActivity {
|
|||||||
final boolean[] result = new boolean[1];
|
final boolean[] result = new boolean[1];
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setCancelable(true)
|
.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)
|
.setMessage(R.string.controlcenter_delete_device_dialogmessage)
|
||||||
.setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.Delete, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
deleteDevice(gbDevice);
|
|
||||||
result[0] = true;
|
result[0] = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -381,7 +381,7 @@ public class ControlCenter extends GBActivity {
|
|||||||
}
|
}
|
||||||
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.getDevice(gbDevice, session);
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
long deviceId = device.getId();
|
long deviceId = device.getId();
|
||||||
QueryBuilder qb;
|
QueryBuilder qb;
|
||||||
@ -406,8 +406,7 @@ public class ControlCenter extends GBActivity {
|
|||||||
}
|
}
|
||||||
qb = session.getDeviceAttributesDao().queryBuilder();
|
qb = session.getDeviceAttributesDao().queryBuilder();
|
||||||
qb.where(DeviceAttributesDao.Properties.DeviceId.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities();
|
qb.where(DeviceAttributesDao.Properties.DeviceId.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities();
|
||||||
qb = session.getDeviceDao().queryBuilder();
|
session.getDeviceDao().delete(device);
|
||||||
qb.where(DeviceDao.Properties.Id.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities();
|
|
||||||
} else {
|
} else {
|
||||||
LOG.warn("device not found while deleting");
|
LOG.warn("device not found while deleting");
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<string name="controlcenter_take_screenshot">Take Screenshot</string>
|
<string name="controlcenter_take_screenshot">Take Screenshot</string>
|
||||||
<string name="controlcenter_disconnect">Disconnect</string>
|
<string name="controlcenter_disconnect">Disconnect</string>
|
||||||
<string name="controlcenter_delete_device">Delete Device</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="controlcenter_delete_device_dialogmessage">This will delete the device and all associated data!</string>
|
||||||
|
|
||||||
<string name="title_activity_debug">Debug</string>
|
<string name="title_activity_debug">Debug</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user