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

Commit 69f37fd7 authored by Himanshu Gupta's avatar Himanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "Preventing DragAndDrop for PS apps." into main

parents e7575789 3ec66fb3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -34,3 +34,10 @@ flag {
    description: "This flag disables accessibility drag for Private Space Apps."
    bug: "289223923"
}

flag {
    name: "private_space_restrict_item_drag"
    namespace: "launcher_search"
    description: "This flag disables drag and drop for Private Space Items."
    bug: "289223923"
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_PRIVATE
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_PRIVATE_SPACE_SYS_APPS_DIVIDER;
import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_NOTHING;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_NOT_PINNABLE;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_PRIVATE_SPACE_INSTALL_APP;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
@@ -109,7 +110,7 @@ public class PrivateProfileManager extends UserProfileManager {
        itemInfo.bitmap = bitmapInfo;
        itemInfo.contentDescription = context.getResources().getString(
                com.android.launcher3.R.string.ps_add_button_content_description);
        itemInfo.runtimeStatusFlags |= FLAG_PRIVATE_SPACE_INSTALL_APP;
        itemInfo.runtimeStatusFlags |= FLAG_PRIVATE_SPACE_INSTALL_APP | FLAG_NOT_PINNABLE;

        BaseAllAppsAdapter.AdapterItem item = new BaseAllAppsAdapter.AdapterItem(VIEW_TYPE_ICON);
        item.itemInfo = itemInfo;
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.launcher3.dragndrop;

import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_NOT_PINNABLE;

import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -29,8 +31,10 @@ import androidx.annotation.Nullable;
import com.android.app.animation.Interpolators;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.Flags;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.ActivityContext;
@@ -221,6 +225,12 @@ public abstract class DragController<T extends ActivityContext>
        }
    }

    protected boolean isItemPinnable() {
        return !Flags.privateSpaceRestrictItemDrag()
                || !(mDragObject.dragInfo instanceof ItemInfoWithIcon itemInfoWithIcon)
                || (itemInfoWithIcon.runtimeStatusFlags & FLAG_NOT_PINNABLE) == 0;
    }

    public Optional<InstanceId> getLogInstanceId() {
        return Optional.ofNullable(mDragObject)
                .map(dragObject -> dragObject.logInstanceId);
+3 −2
Original line number Diff line number Diff line
@@ -149,9 +149,10 @@ public class LauncherDragController extends DragController<Launcher> {

        handleMoveEvent(mLastTouch.x, mLastTouch.y);

        if (!mActivity.isTouchInProgress() && options.simulatedDndStartPoint == null) {
        if (!isItemPinnable()
                || (!mActivity.isTouchInProgress() && options.simulatedDndStartPoint == null)) {
            // If it is an internal drag and the touch is already complete, cancel immediately
            MAIN_EXECUTOR.submit(this::cancelDrag);
            MAIN_EXECUTOR.post(this::cancelDrag);
        }
        return dragView;
    }
+10 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3.popup;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS;
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_NOT_PINNABLE;
import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;

@@ -44,6 +45,7 @@ import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.Flags;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
@@ -53,6 +55,7 @@ import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.dragndrop.DraggableView;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
@@ -204,17 +207,21 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
                .collect(Collectors.toList());
        container = (PopupContainerWithArrow) launcher.getLayoutInflater().inflate(
                R.layout.popup_container, launcher.getDragLayer(), false);
        container.configureForLauncher(launcher);
        container.configureForLauncher(launcher, item);
        container.populateAndShowRows(icon, deepShortcutCount, systemShortcuts);
        launcher.refreshAndBindWidgetsForPackageUser(PackageUserKey.fromItemInfo(item));
        container.requestFocus();
        return container;
    }

    private void configureForLauncher(Launcher launcher) {
    private void configureForLauncher(Launcher launcher, ItemInfo itemInfo) {
        addOnAttachStateChangeListener(new LauncherPopupLiveUpdateHandler(
                launcher, (PopupContainerWithArrow<Launcher>) this));
        if (!Flags.privateSpaceRestrictItemDrag()
                || !(itemInfo instanceof ItemInfoWithIcon itemInfoWithIcon)
                || (itemInfoWithIcon.runtimeStatusFlags & FLAG_NOT_PINNABLE) == 0) {
            mPopupItemDragHandler = new LauncherPopupItemDragHandler(launcher, this);
        }
        mAccessibilityDelegate = new ShortcutMenuAccessibilityDelegate(launcher);
        launcher.getDragController().addDragListener(this);
    }
Loading