Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15706f85 authored by Yash Garg's avatar Yash Garg 💬 Committed by Mohammed Althaf T
Browse files

feat(pwa): allow applounge to place shortcuts directly

parent b2e409a9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
/*
 * Copyright © MURENA SAS 2023.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 */
package foundation.e.bliss.utils

object BlissConstants {
    const val APPS_PACKAGE = "foundation.e.apps"
}
+19 −3
Original line number Diff line number Diff line
@@ -84,8 +84,11 @@ import com.android.launcher3.widget.WidgetImageView;
import com.android.launcher3.widget.WidgetManagerHelper;
import com.android.launcher3.widget.WidgetSections;

import java.util.Objects;
import java.util.function.Supplier;

import foundation.e.bliss.utils.BlissConstants;

/**
 * Activity to show pin widget dialog.
 */
@@ -151,6 +154,11 @@ public class AddItemActivity extends BaseActivity
        switch (mRequest.getRequestType()) {
            case PinItemRequest.REQUEST_TYPE_SHORTCUT:
                targetApp = setupShortcut();
                if (Objects.requireNonNull(mRequest.getShortcutInfo())
                        .getPackage().equals(BlissConstants.APPS_PACKAGE)) {
                    onPlaceAutomaticallyClick();
                    return;
                }
                break;
            case PinItemRequest.REQUEST_TYPE_APPWIDGET:
                targetApp = setupWidget();
@@ -334,10 +342,14 @@ public class AddItemActivity extends BaseActivity
        mSlideInView.close(/* animate= */ true);
    }

    public void onPlaceAutomaticallyClick(View v) {
        onPlaceAutomaticallyClick();
    }

    /**
     * Called when place-automatically button is clicked.
     */
    public void onPlaceAutomaticallyClick(View v) {
    public void onPlaceAutomaticallyClick() {
        if (mRequest.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT) {
            ShortcutInfo shortcutInfo = mRequest.getShortcutInfo();
            ItemInstallQueue.INSTANCE.get(this).queueItem(shortcutInfo);
@@ -348,7 +360,9 @@ public class AddItemActivity extends BaseActivity
                label = shortcutInfo.getShortLabel();
            }
            sendWidgetAddedToScreenAccessibilityEvent(label.toString());
            if (mSlideInView != null) {
                mSlideInView.close(/* animate= */ true);
            }
            return;
        }

@@ -373,8 +387,10 @@ public class AddItemActivity extends BaseActivity
        mWidgetOptions.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
        mRequest.accept(mWidgetOptions);
        logCommand(LAUNCHER_ADD_EXTERNAL_ITEM_PLACED_AUTOMATICALLY);
        if (mSlideInView != null) {
            mSlideInView.close(/* animate= */ true);
        }
    }

    @Override
    public void onDestroy() {