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

Commit 45bad725 authored by Sebastián Franco's avatar Sebastián Franco Committed by Android (Google) Code Review
Browse files

Merge "Refactoring FolderPagedView to make it more testable" into main

parents 1c1547f5 c794aca6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import static com.android.launcher3.LauncherState.SPRING_LOADED;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
import static com.android.launcher3.config.FeatureFlags.MULTI_SELECT_EDIT_MODE;
import static com.android.launcher3.folder.FolderGridOrganizer.createFolderGridOrganizer;
import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.HIDE;
import static com.android.launcher3.logging.KeyboardStateManager.KeyboardState.SHOW;
import static com.android.launcher3.logging.StatsLogManager.EventEnum;
@@ -188,7 +189,6 @@ import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.dragndrop.LauncherDragController;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderGridOrganizer;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
@@ -816,7 +816,7 @@ public class Launcher extends StatefulActivity<LauncherState>
            View collectionIcon = getWorkspace().getHomescreenIconByItemId(info.container);
            if (collectionIcon instanceof FolderIcon folderIcon
                    && collectionIcon.getTag() instanceof FolderInfo) {
                if (new FolderGridOrganizer(getDeviceProfile())
                if (createFolderGridOrganizer(getDeviceProfile())
                        .setFolderInfo((FolderInfo) folderIcon.getTag())
                        .isItemInPreview(info.rank)) {
                    folderIcon.invalidate();
+3 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static com.android.launcher3.LauncherState.EDIT_MODE;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
import static com.android.launcher3.config.FeatureFlags.ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS;
import static com.android.launcher3.folder.FolderGridOrganizer.createFolderGridOrganizer;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_LABEL_UPDATED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED;
import static com.android.launcher3.testing.shared.TestProtocol.FOLDER_OPENED_MESSAGE;
@@ -1106,7 +1107,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
    }

    private void updateItemLocationsInDatabaseBatch(boolean isBind) {
        FolderGridOrganizer verifier = new FolderGridOrganizer(
        FolderGridOrganizer verifier = createFolderGridOrganizer(
                mActivityContext.getDeviceProfile()).setFolderInfo(mInfo);

        ArrayList<ItemInfo> items = new ArrayList<>();
@@ -1404,7 +1405,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo

    @Override
    public void onAdd(ItemInfo item, int rank) {
        FolderGridOrganizer verifier = new FolderGridOrganizer(
        FolderGridOrganizer verifier = createFolderGridOrganizer(
                mActivityContext.getDeviceProfile()).setFolderInfo(mInfo);
        verifier.updateRankAndPos(item, rank);
        mLauncherDelegate.getModelWriter().addOrMoveItemInDatabase(item, mInfo.id, 0, item.cellX,
+2 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.view.View.ALPHA;
import static com.android.launcher3.BubbleTextView.TEXT_ALPHA_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW;
import static com.android.launcher3.folder.FolderGridOrganizer.createFolderGridOrganizer;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -99,7 +100,7 @@ public class FolderAnimationManager {

        mContext = folder.getContext();
        mDeviceProfile = folder.mActivityContext.getDeviceProfile();
        mPreviewVerifier = new FolderGridOrganizer(mDeviceProfile);
        mPreviewVerifier = createFolderGridOrganizer(mDeviceProfile);

        mIsOpening = isOpening;

+10 −3
Original line number Diff line number Diff line
@@ -47,12 +47,19 @@ public class FolderGridOrganizer {
    /**
     * Note: must call {@link #setFolderInfo(FolderInfo)} manually for verifier to work.
     */
    public FolderGridOrganizer(DeviceProfile profile) {
        mMaxCountX = profile.numFolderColumns;
        mMaxCountY = profile.numFolderRows;
    public FolderGridOrganizer(int maxCountX, int maxCountY) {
        mMaxCountX = maxCountX;
        mMaxCountY = maxCountY;
        mMaxItemsPerPage = mMaxCountX * mMaxCountY;
    }

    /**
     * Creates a FolderGridOrganizer for the given DeviceProfile
     */
    public static FolderGridOrganizer createFolderGridOrganizer(DeviceProfile profile) {
        return new FolderGridOrganizer(profile.numFolderColumns, profile.numFolderRows);
    }

    /**
     * Updates the organizer with the provided folder info
     */
+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3.folder;
import static com.android.launcher3.Flags.enableCursorHoverStates;
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ICON_OVERLAP_FACTOR;
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW;
import static com.android.launcher3.folder.FolderGridOrganizer.createFolderGridOrganizer;
import static com.android.launcher3.folder.PreviewItemManager.INITIAL_ITEM_ANIMATION_DURATION;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_AUTO_LABELED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_AUTO_LABELING_SKIPPED_EMPTY_PRIMARY;
@@ -223,7 +224,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel

        icon.setAccessibilityDelegate(activity.getAccessibilityDelegate());

        icon.mPreviewVerifier = new FolderGridOrganizer(activity.getDeviceProfile());
        icon.mPreviewVerifier = createFolderGridOrganizer(activity.getDeviceProfile());
        icon.mPreviewVerifier.setFolderInfo(folderInfo);
        icon.updatePreviewItems(false);

Loading