mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Merge "Two panel home empty page removing logic change" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
701c76013c
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID;
|
||||
import static com.android.launcher3.WorkspaceLayoutManager.SECOND_SCREEN_ID;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
@@ -299,6 +300,11 @@ public class AddWorkspaceItemsTask extends BaseModelUpdateTask {
|
||||
IntSet screensToExclude = new IntSet();
|
||||
if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
|
||||
screensToExclude.add(FIRST_SCREEN_ID);
|
||||
|
||||
// On split display we don't want to add the new items onto the second screen.
|
||||
if (app.getInvariantDeviceProfile().isSplitDisplay) {
|
||||
screensToExclude.add(SECOND_SCREEN_ID);
|
||||
}
|
||||
}
|
||||
|
||||
for (int screen = 0; screen < screenCount; screen++) {
|
||||
|
||||
@@ -296,7 +296,7 @@ public class IntArray implements Cloneable, Iterable<Integer> {
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
removeIndex(--mNextIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user