mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-09 03:37:03 +01: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) {
|
||||
try {
|
||||
DeviceCoordinator coordinator = device.getDeviceCoordinator();
|
||||
if (coordinator != null) {
|
||||
coordinator.deleteDevice(device);
|
||||
}
|
||||
coordinator.deleteDevice(device);
|
||||
DeviceHelper.getInstance().removeBond(device);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
removeDynamicShortcut(device);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
GB.toast(context, context.getString(R.string.error_deleting_device, ex.getMessage()), Toast.LENGTH_LONG, GB.ERROR, ex);
|
||||
} 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> {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull GBDevice oldItem, @NonNull GBDevice newItem) {
|
||||
|
Loading…
Reference in New Issue
Block a user