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

Commit c2538d74 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Add originalView of the menu to SystemShortcut

Split from home animation needs to originate from the app icon instead of the menu item icon. This can be useful for other animations in the future.

Bug: 226395821
Test: N/A
Change-Id: If45d80e347ba275bd550b6acd6ad81b319e753a3
parent b5d7744c
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -77,11 +77,12 @@ public final class AppSharing {
        return FileProvider.getUriForFile(context, authority, pathFile, displayName);
    }

    private SystemShortcut<Launcher> getShortcut(Launcher launcher, ItemInfo info) {
    private SystemShortcut<Launcher> getShortcut(Launcher launcher, ItemInfo info,
            View originalView) {
        if (TextUtils.isEmpty(mSharingComponent)) {
            return null;
        }
        return new Share(launcher, info);
        return new Share(launcher, info, originalView);
    }

    /**
@@ -104,8 +105,9 @@ public final class AppSharing {
        private final PopupDataProvider mPopupDataProvider;
        private final boolean mSharingEnabledForUser;

        public Share(Launcher target, ItemInfo itemInfo) {
            super(R.drawable.ic_share, R.string.app_share_drop_target_label, target, itemInfo);
        public Share(Launcher target, ItemInfo itemInfo, View originalView) {
            super(R.drawable.ic_share, R.string.app_share_drop_target_label, target, itemInfo,
                    originalView);
            mPopupDataProvider = target.getPopupDataProvider();

            mSharingEnabledForUser = bluetoothSharingEnabled(target);
@@ -200,6 +202,7 @@ public final class AppSharing {
    /**
     * Shortcut factory for generating the Share App button
     */
    public static final SystemShortcut.Factory<Launcher> SHORTCUT_FACTORY = (launcher, itemInfo) ->
            (new AppSharing(launcher)).getShortcut(launcher, itemInfo);
    public static final SystemShortcut.Factory<Launcher> SHORTCUT_FACTORY =
            (launcher, itemInfo, originalView) ->
                    (new AppSharing(launcher)).getShortcut(launcher, itemInfo, originalView);
}
+4 −4
Original line number Diff line number Diff line
@@ -409,11 +409,11 @@ public class HotseatPredictionController implements DragController.DragListener,
    @Nullable
    @Override
    public SystemShortcut<QuickstepLauncher> getShortcut(QuickstepLauncher activity,
            ItemInfo itemInfo) {
            ItemInfo itemInfo, View originalView) {
        if (itemInfo.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
            return null;
        }
        return new PinPrediction(activity, itemInfo);
        return new PinPrediction(activity, itemInfo, originalView);
    }

    private void preparePredictionInfo(WorkspaceItemInfo itemInfo, int rank) {
@@ -498,9 +498,9 @@ public class HotseatPredictionController implements DragController.DragListener,

    private class PinPrediction extends SystemShortcut<QuickstepLauncher> {

        private PinPrediction(QuickstepLauncher target, ItemInfo itemInfo) {
        private PinPrediction(QuickstepLauncher target, ItemInfo itemInfo, View originalView) {
            super(R.drawable.ic_pin, R.string.pin_prediction, target,
                    itemInfo);
                    itemInfo, originalView);
        }

        @Override
+6 −5
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.UserHandle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import android.view.View;

import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
@@ -193,7 +194,7 @@ public final class WellbeingModel extends BgObjectWithLooper {

    @MainThread
    private SystemShortcut getShortcutForApp(String packageName, int userId,
            BaseDraggingActivity activity, ItemInfo info) {
            BaseDraggingActivity activity, ItemInfo info, View originalView) {
        Preconditions.assertUIThread();
        // Work profile apps are not recognized by digital wellbeing.
        if (userId != UserHandle.myUserId()) {
@@ -217,7 +218,7 @@ public final class WellbeingModel extends BgObjectWithLooper {
                        "getShortcutForApp [" + packageName + "]: action: '" + action.getTitle()
                                + "'");
            }
            return new RemoteActionShortcut(action, activity, info);
            return new RemoteActionShortcut(action, activity, info, originalView);
        }
    }

@@ -378,8 +379,8 @@ public final class WellbeingModel extends BgObjectWithLooper {
     * Shortcut factory for generating wellbeing action
     */
    public static final SystemShortcut.Factory<BaseDraggingActivity> SHORTCUT_FACTORY =
            (activity, info) -> (info.getTargetComponent() == null) ? null : INSTANCE.get(activity)
                    .getShortcutForApp(
            (activity, info, originalView) -> (info.getTargetComponent() == null) ? null
                    : INSTANCE.get(activity).getShortcutForApp(
                            info.getTargetComponent().getPackageName(), info.user.getIdentifier(),
                            activity, info);
                            activity, info, originalView);
}
+5 −4
Original line number Diff line number Diff line
@@ -34,8 +34,9 @@ public interface QuickstepSystemShortcut {

    static SystemShortcut.Factory<BaseQuickstepLauncher> getSplitSelectShortcutByPosition(
            SplitPositionOption position) {
        return (activity, itemInfo) -> new QuickstepSystemShortcut.SplitSelectSystemShortcut(
                activity, itemInfo, position);
        return (activity, itemInfo, originalView) ->
                new QuickstepSystemShortcut.SplitSelectSystemShortcut(activity, itemInfo,
                        originalView, position);
    }

    class SplitSelectSystemShortcut extends SystemShortcut<BaseQuickstepLauncher> {
@@ -43,8 +44,8 @@ public interface QuickstepSystemShortcut {
        private final SplitPositionOption mPosition;

        public SplitSelectSystemShortcut(BaseQuickstepLauncher launcher, ItemInfo itemInfo,
                SplitPositionOption position) {
            super(position.iconResId, position.textResId, launcher, itemInfo);
                View originalView, SplitPositionOption position) {
            super(position.iconResId, position.textResId, launcher, itemInfo, originalView);

            mPosition = position;
        }
+5 −4
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
                mPopupDataProvider.getNotificationKeysForItem(item),
                // TODO (b/198438631): add support for INSTALL shortcut factory
                getSystemShortcuts()
                        .map(s -> s.getShortcut(context, item))
                        .map(s -> s.getShortcut(context, item, icon))
                        .filter(Objects::nonNull)
                        .collect(Collectors.toList()));
        container.requestFocus();
@@ -242,7 +242,8 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
     */
    private SystemShortcut.Factory<BaseTaskbarContext> createSplitShortcutFactory(
            SplitPositionOption position) {
        return (context, itemInfo) -> new TaskbarSplitShortcut(context, itemInfo, position);
        return (context, itemInfo, originalView) -> new TaskbarSplitShortcut(context, itemInfo,
                originalView, position);
    }

     /**
@@ -253,9 +254,9 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba
    private static class TaskbarSplitShortcut extends SystemShortcut<BaseTaskbarContext> {
        private final SplitPositionOption mPosition;

        TaskbarSplitShortcut(BaseTaskbarContext context, ItemInfo itemInfo,
        TaskbarSplitShortcut(BaseTaskbarContext context, ItemInfo itemInfo, View originalView,
                SplitPositionOption position) {
            super(position.iconResId, position.textResId, context, itemInfo);
            super(position.iconResId, position.textResId, context, itemInfo, originalView);
            mPosition = position;
        }

Loading