mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 09:56:49 +00:00
Handle visibility of AddDesktopButton for overview/quickswitch
This change introduces mDisallowScrollToAddDesk to handle the visibility of AddDesktopButton in overview/quickswitch. In overview, set its scroll as the first task; in quick switch, set its scroll out range of [minScroll, maxScroll]. Bug: 398036110 Flag: com.android.window.flags.enable_multiple_desktops_frontend Flag: com.android.window.flags.enable_multiple_desktops_backend Test: manual quick switch Change-Id: I5fada0c4c5bccc5572b458da9970e3524087508d
This commit is contained in:
@@ -302,6 +302,7 @@ public class FallbackRecentsView<CONTAINER_TYPE extends Context & RecentsViewCon
|
||||
if (enabled) {
|
||||
RecentsState state = mContainer.getStateManager().getState();
|
||||
setDisallowScrollToClearAll(!state.hasClearAllButton());
|
||||
setDisallowScrollToAddDesk(!state.hasAddDeskButton());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
||||
import static android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY;
|
||||
|
||||
import static com.android.launcher3.LauncherState.CLEAR_ALL_BUTTON;
|
||||
import static com.android.launcher3.LauncherState.ADD_DESK_BUTTON;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
|
||||
@@ -198,7 +199,10 @@ public class LauncherRecentsView extends RecentsView<QuickstepLauncher, Launcher
|
||||
LauncherState state = getStateManager().getState();
|
||||
boolean hasClearAllButton = (state.getVisibleElements(mContainer)
|
||||
& CLEAR_ALL_BUTTON) != 0;
|
||||
boolean hasAddDeskButton = (state.getVisibleElements(mContainer)
|
||||
& ADD_DESK_BUTTON) != 0;
|
||||
setDisallowScrollToClearAll(!hasClearAllButton);
|
||||
setDisallowScrollToAddDesk(!hasAddDeskButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -586,6 +586,8 @@ public abstract class RecentsView<
|
||||
private final TaskOverlayFactory mTaskOverlayFactory;
|
||||
|
||||
protected boolean mDisallowScrollToClearAll;
|
||||
// True if it is not allowed to scroll to [AddDesktopButton].
|
||||
protected boolean mDisallowScrollToAddDesk;
|
||||
private boolean mOverlayEnabled;
|
||||
protected boolean mFreezeViewVisibility;
|
||||
private boolean mOverviewGridEnabled;
|
||||
@@ -6164,6 +6166,17 @@ public abstract class RecentsView<
|
||||
updateMinAndMaxScrollX();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Update the value of [mDisallowScrollToAddDesk]
|
||||
*/
|
||||
public void setDisallowScrollToAddDesk(boolean disallowScrollToAddDesk) {
|
||||
if (mDisallowScrollToAddDesk != disallowScrollToAddDesk) {
|
||||
mDisallowScrollToAddDesk = disallowScrollToAddDesk;
|
||||
updateMinAndMaxScrollX();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates page scroll synchronously after measure and layout child views.
|
||||
@@ -6309,7 +6322,20 @@ public abstract class RecentsView<
|
||||
if (addDesktopButtonIndex >= 0 && addDesktopButtonIndex < outPageScrolls.length) {
|
||||
int firstViewIndex = getFirstViewIndex();
|
||||
if (firstViewIndex >= 0 && firstViewIndex < outPageScrolls.length) {
|
||||
outPageScrolls[addDesktopButtonIndex] = outPageScrolls[firstViewIndex];
|
||||
// If we can scroll to [AddDesktopButton], make its page scroll equal to
|
||||
// the first [TaskView]. Otherwise, make its page scroll out of range of
|
||||
// [minScroll, maxScroll].
|
||||
if (!mDisallowScrollToAddDesk) {
|
||||
outPageScrolls[addDesktopButtonIndex] = outPageScrolls[firstViewIndex];
|
||||
} else {
|
||||
outPageScrolls[addDesktopButtonIndex] =
|
||||
outPageScrolls[firstViewIndex] + (mIsRtl ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "getPageScrolls - addDesktopButtonScroll: "
|
||||
+ outPageScrolls[addDesktopButtonIndex]);
|
||||
}
|
||||
}
|
||||
if (DEBUG) {
|
||||
|
||||
Reference in New Issue
Block a user