Commit 95814aa2 authored by Arnau Vàzquez's avatar Arnau Vàzquez
Browse files

Merge branch 'pwa-support' into 'master'

Improved PWA support

See merge request e/apps/BlissLauncher!45
parents 682f1e74 44bf8496
Pipeline #65515 passed with stage
in 6 minutes and 36 seconds
......@@ -43,6 +43,8 @@
<uses-permission android:name="lineageos.permission.READ_WEATHER" />
<!-- LineageOS specific permissions END -->
<uses-permission android:name="foundation.e.pwaplayer.provider.READ_WRITE"/>
<application
android:name=".BlissLauncher"
android:hardwareAccelerated="true"
......
......@@ -39,6 +39,7 @@ import android.os.UserManager;
import android.provider.Settings;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.DragEvent;
import android.view.Gravity;
......@@ -1977,12 +1978,16 @@ public class LauncherActivity extends AppCompatActivity implements
startActivity(i);
}
} else if (launcherItem.itemType == Constants.ITEM_TYPE_SHORTCUT) {
AlertDialog dialog =new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom))
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom))
.setTitle(launcherItem.title)
.setMessage(R.string.uninstall_shortcut_dialog)
.setPositiveButton(R.string.ok, (dialog1, which) -> {
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) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment