mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 18:06:48 +00:00
Two panel & two page swipe & currentPage fixes
- Pagespacing set to 0 to have similar design to figma - Added padding to left side of left panel and right side of right panel to match figma - getPageScrolls changed to support two page scrolling - validateNewPage changed so that only even indexed pages can be switched to - getPageWidthSize added for measurements, it returns half screen width when two panel is active - onMeasure changed to use getPageWidthSize - panelCount has been increased from 1 to 2 when two panel is active - add feature flag for two panel home - shouldConsumeTouch changed so not only currentpage is checked but currentpage+1 screen as well - add one more extra check for setDropLayoutForDragObject for currentpage + 2, next to right panel - using new grid option for two panel home screen Test: manual Bug: 174464115 Change-Id: I1bad7eecc67f65fb833608744a5aa5aca65373b4
This commit is contained in:
@@ -312,7 +312,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
// Increase our bottom insets so we don't overlap with the taskbar.
|
||||
mInsets.bottom += grid.nonOverlappingTaskbarInset;
|
||||
|
||||
if (mWorkspaceFadeInAdjacentScreens) {
|
||||
if (isTwoPanelEnabled()) {
|
||||
setPageSpacing(0); // we have two pages and we don't want any spacing
|
||||
} else if (mWorkspaceFadeInAdjacentScreens) {
|
||||
// In landscape mode the page spacing is set to the default.
|
||||
setPageSpacing(grid.edgeMarginPx);
|
||||
} else {
|
||||
@@ -324,12 +326,30 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
setPageSpacing(Math.max(maxInsets, maxPadding));
|
||||
}
|
||||
|
||||
|
||||
int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
|
||||
int paddingBottom = grid.cellLayoutBottomPaddingPx;
|
||||
int twoPanelLandscapeSidePadding = paddingLeftRight * 2;
|
||||
int twoPanelPortraitSidePadding = paddingLeftRight / 2;
|
||||
|
||||
int panelCount = getPanelCount();
|
||||
for (int i = mWorkspaceScreens.size() - 1; i >= 0; i--) {
|
||||
mWorkspaceScreens.valueAt(i)
|
||||
.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
|
||||
int paddingLeft = paddingLeftRight;
|
||||
int paddingRight = paddingLeftRight;
|
||||
if (panelCount > 1) {
|
||||
if (i % panelCount == 0) { // left side panel
|
||||
paddingLeft = grid.isLandscape ? twoPanelLandscapeSidePadding
|
||||
: twoPanelPortraitSidePadding;
|
||||
paddingRight = 0;
|
||||
} else if (i % panelCount == panelCount - 1) { // right side panel
|
||||
paddingLeft = 0;
|
||||
paddingRight = grid.isLandscape ? twoPanelLandscapeSidePadding
|
||||
: twoPanelPortraitSidePadding;
|
||||
} else { // middle panel
|
||||
paddingLeft = 0;
|
||||
paddingRight = 0;
|
||||
}
|
||||
}
|
||||
mWorkspaceScreens.valueAt(i).setPadding(paddingLeft, 0, paddingRight, paddingBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +465,15 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
.log(LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED);
|
||||
}
|
||||
|
||||
private boolean isTwoPanelEnabled() {
|
||||
return mLauncher.mDeviceProfile.isTablet && FeatureFlags.ENABLE_TWO_PANEL_HOME.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPanelCount() {
|
||||
return isTwoPanelEnabled() ? 2 : super.getPanelCount();
|
||||
}
|
||||
|
||||
public void deferRemoveExtraEmptyScreen() {
|
||||
mDeferRemoveExtraEmptyScreen = true;
|
||||
}
|
||||
@@ -832,7 +861,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
private boolean shouldConsumeTouch(View v) {
|
||||
return !workspaceIconsCanBeDragged()
|
||||
|| (!workspaceInModalState() && indexOfChild(v) != mCurrentPage);
|
||||
|| (!workspaceInModalState() && !isVisible(v));
|
||||
}
|
||||
|
||||
public boolean isSwitchingState() {
|
||||
@@ -2259,19 +2288,27 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
int nextPage = getNextPage();
|
||||
if (layout == null && !isPageInTransition()) {
|
||||
// Check if the item is dragged over left page
|
||||
// Check if the item is dragged over currentPage - 1 page
|
||||
mTempTouchCoordinates[0] = Math.min(centerX, d.x);
|
||||
mTempTouchCoordinates[1] = d.y;
|
||||
layout = verifyInsidePage(nextPage + (mIsRtl ? 1 : -1), mTempTouchCoordinates);
|
||||
}
|
||||
|
||||
if (layout == null && !isPageInTransition()) {
|
||||
// Check if the item is dragged over right page
|
||||
// Check if the item is dragged over currentPage + 1 page
|
||||
mTempTouchCoordinates[0] = Math.max(centerX, d.x);
|
||||
mTempTouchCoordinates[1] = d.y;
|
||||
layout = verifyInsidePage(nextPage + (mIsRtl ? -1 : 1), mTempTouchCoordinates);
|
||||
}
|
||||
|
||||
// If two panel is enabled, users can also drag items to currentPage + 2
|
||||
if (isTwoPanelEnabled() && layout == null && !isPageInTransition()) {
|
||||
// Check if the item is dragged over currentPage + 2 page
|
||||
mTempTouchCoordinates[0] = Math.max(centerX, d.x);
|
||||
mTempTouchCoordinates[1] = d.y;
|
||||
layout = verifyInsidePage(nextPage + (mIsRtl ? -2 : 2), mTempTouchCoordinates);
|
||||
}
|
||||
|
||||
// Always pick the current page.
|
||||
if (layout == null && nextPage >= 0 && nextPage < getPageCount()) {
|
||||
layout = (CellLayout) getChildAt(nextPage);
|
||||
|
||||
Reference in New Issue
Block a user