mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-10-06 13:20:30 +02:00
Remove dynamic shortcut when deleting device
This commit is contained in:
parent
1d4c85b732
commit
2636dd85f1
@ -923,10 +923,11 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
try {
|
try {
|
||||||
DeviceCoordinator coordinator = device.getDeviceCoordinator();
|
DeviceCoordinator coordinator = device.getDeviceCoordinator();
|
||||||
if (coordinator != null) {
|
|
||||||
coordinator.deleteDevice(device);
|
coordinator.deleteDevice(device);
|
||||||
}
|
|
||||||
DeviceHelper.getInstance().removeBond(device);
|
DeviceHelper.getInstance().removeBond(device);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
removeDynamicShortcut(device);
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
GB.toast(context, context.getString(R.string.error_deleting_device, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex);
|
GB.toast(context, context.getString(R.string.error_deleting_device, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex);
|
||||||
} finally {
|
} finally {
|
||||||
@ -1461,6 +1462,13 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.R)
|
||||||
|
void removeDynamicShortcut(GBDevice device) {
|
||||||
|
final ShortcutManager shortcutManager = (ShortcutManager) context.getApplicationContext().getSystemService(Context.SHORTCUT_SERVICE);
|
||||||
|
|
||||||
|
shortcutManager.removeDynamicShortcuts(Collections.singletonList(device.getAddress()));
|
||||||
|
}
|
||||||
|
|
||||||
private static class GBDeviceDiffUtil extends DiffUtil.ItemCallback<GBDevice> {
|
private static class GBDeviceDiffUtil extends DiffUtil.ItemCallback<GBDevice> {
|
||||||
@Override
|
@Override
|
||||||
public boolean areItemsTheSame(@NonNull GBDevice oldItem, @NonNull GBDevice newItem) {
|
public boolean areItemsTheSame(@NonNull GBDevice oldItem, @NonNull GBDevice newItem) {
|
||||||
|
Loading…
Reference in New Issue
Block a user