From 44bf8496d21f336b035d742c645b287a6055b624 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Mon, 29 Jun 2020 17:04:27 +0530 Subject: [PATCH] Delete pwa from Provider when shortcut is deleted --- app/src/main/AndroidManifest.xml | 2 ++ .../features/launcher/LauncherActivity.java | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index abc340ba90..fc2935bc72 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,6 +43,8 @@ + + { - DeepShortcutManager.getInstance(this).unpinShortcut(ShortcutKey.fromItem((ShortcutItem) launcherItem)); - removeShortcutView((ShortcutItem) launcherItem, blissFrameLayout); + ShortcutItem shortcut = (ShortcutItem) launcherItem; + DeepShortcutManager.getInstance(this).unpinShortcut(ShortcutKey.fromItem(shortcut)); + if (DeepShortcutManager.getInstance(this).wasLastCallSuccess()) { + deleteShortcutFromProvider(shortcut.id); + removeShortcutView(shortcut, blissFrameLayout); + } }) .setNegativeButton(R.string.cancel, null) .setIcon(launcherItem.icon) @@ -2000,6 +2005,12 @@ public class LauncherActivity extends AppCompatActivity implements blissFrameLayout.addView(imageView, layoutParams); } + private void deleteShortcutFromProvider(String id) { + ContentResolver resolver = getContentResolver(); + int count = resolver.delete(Uri.parse("content://foundation.e.pwaplayer.provider/pwa"), null, new String[]{id}); + Log.d("LauncherActivity", "Items deleted from pwa provider: " + count); + } + private void removeShortcutView(ShortcutItem shortcutItem, BlissFrameLayout blissFrameLayout) { DatabaseManager.getManager(this).removeLauncherItem(shortcutItem.id); if (mFolderWindowContainer.getVisibility() == View.VISIBLE) { -- GitLab