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

Commit 701c7601 authored by András Klöczl's avatar András Klöczl Committed by Android (Google) Code Review
Browse files

Merge "Two panel home empty page removing logic change" into sc-v2-dev

parents da7fe8ce 8c574de9
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -2186,6 +2186,24 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
    }

    private void bindAddScreens(IntArray orderedScreenIds) {
        if (mDeviceProfile.isTwoPanels) {
            // Some empty pages might have been removed while the phone was in a single panel
            // mode, so we want to add those empty pages back.
            IntSet screenIds = IntSet.wrap(orderedScreenIds);
            for (int i = 0; i < orderedScreenIds.size(); i++) {
                int screenId = orderedScreenIds.get(i);
                // Don't add the page pair if the page is the last one and if the pair is on the
                // right, because that would cause a bug when adding new pages.
                // TODO: (b/196376162) remove this when the new screen id logic is fixed for two
                //  panel in Workspace::commitExtraEmptyScreen
                if (i == orderedScreenIds.size() - 1 && screenId % 2 == 0) {
                    continue;
                }
                screenIds.add(mWorkspace.getPagePair(screenId));
            }
            orderedScreenIds = screenIds.getArray();
        }

        int count = orderedScreenIds.size();
        for (int i = 0; i < count; i++) {
            int screenId = orderedScreenIds.get(i);
@@ -2193,7 +2211,6 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
                // No need to bind the first screen, as its always bound.
                continue;
            }

            mWorkspace.insertNewWorkspaceScreenBeforeEmptyScreen(screenId);
        }
    }
+32 −0
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverla

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -800,6 +801,21 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
        return mScreenOrder;
    }

    /**
     * Returns the page that is shown together with the given page when two panel is enabled.
     * @throws IllegalStateException if called while two panel home isn't enabled.
     */
    public int getPagePair(int page) {
        if (!isTwoPanelEnabled()) {
            throw new IllegalStateException("Two panel home isn't enabled.");
        }
        if (page % 2 == 0) {
            return page + 1;
        } else {
            return page - 1;
        }
    }

    public void stripEmptyScreens() {
        if (mLauncher.isWorkspaceLoading()) {
            // Don't strip empty screens if the workspace is still loading.
@@ -825,6 +841,22 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
            }
        }

        // When two panel home is enabled we only remove an empty page if both visible pages are
        // empty.
        if (isTwoPanelEnabled()) {
            // We go through all the pages that were marked as removable and check their page pair
            Iterator<Integer> removeScreensIterator = removeScreens.iterator();
            while (removeScreensIterator.hasNext()) {
                int pageToRemove = removeScreensIterator.next();
                int pagePair = getPagePair(pageToRemove);
                if (!removeScreens.contains(pagePair)) {
                    // The page pair isn't empty so we want to remove the current page from the
                    // removable pages' collection
                    removeScreensIterator.remove();
                }
            }
        }

        // We enforce at least one page to add new items to. In the case that we remove the last
        // such screen, we convert the last screen to the empty screen
        int minScreens = 1;
+2 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ public interface WorkspaceLayoutManager {
    int EXTRA_EMPTY_SCREEN_ID = -201;
    // The is the first screen. It is always present, even if its empty.
    int FIRST_SCREEN_ID = 0;
    // This is the second page. On two panel home it is always present, even if its empty.
    int SECOND_SCREEN_ID = 1;

    /**
     * At bind time, we use the rank (screenId) to compute x and y for hotseat items.
+2 −1
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.WorkspaceLayoutManager;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.FolderIcon;
@@ -279,7 +280,7 @@ public class LauncherPreviewRenderer extends ContextWrapper
                    mDp.workspacePadding.top,
                    mDp.workspacePadding.right + mDp.cellLayoutPaddingLeftRightPx,
                    mDp.workspacePadding.bottom);
            mWorkspaceScreens.put(PreviewSurfaceRenderer.SECOND_SCREEN_ID, rightPanel);
            mWorkspaceScreens.put(Workspace.SECOND_SCREEN_ID, rightPanel);
        }

        if (Utilities.ATLEAST_S) {
+1 −4
Original line number Diff line number Diff line
@@ -66,9 +66,6 @@ public class PreviewSurfaceRenderer {

    private static final int FADE_IN_ANIMATION_DURATION = 200;

    // The is the second screen. It is always present in two panel, even if its empty.
    static final int SECOND_SCREEN_ID = 1;

    private static final String KEY_HOST_TOKEN = "host_token";
    private static final String KEY_VIEW_WIDTH = "width";
    private static final String KEY_VIEW_HEIGHT = "height";
@@ -172,7 +169,7 @@ public class PreviewSurfaceRenderer {
                            + LauncherSettings.Favorites.CONTAINER_HOTSEAT;
                    if (deviceProfile.isTwoPanels) {
                        query += " or " + LauncherSettings.Favorites.SCREEN + " = "
                                + SECOND_SCREEN_ID;
                                + Workspace.SECOND_SCREEN_ID;
                    }
                    loadWorkspace(new ArrayList<>(), LauncherSettings.Favorites.PREVIEW_CONTENT_URI,
                            query);
Loading