mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 02:38:20 +00:00
Removing UI dependency from LauncherModel in case of 2-panel layout
Bug: 175939730 Bug: 192431856 Bug: 185515153 Test: Manual Change-Id: I8baa1cf9e5a8a04d5b8bc38c1f4b0755265cd8a9
This commit is contained in:
@@ -102,6 +102,7 @@ import com.android.launcher3.touch.WorkspaceTouchListener;
|
||||
import com.android.launcher3.util.EdgeEffectCompat;
|
||||
import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.IntSparseArrayMap;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.LauncherBindableItemsContainer;
|
||||
@@ -327,22 +328,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
setPageSpacing(Math.max(maxInsets, maxPadding));
|
||||
}
|
||||
|
||||
if (grid.isTwoPanels) {
|
||||
// Add left widget panel if it isn't already there
|
||||
if (!mWorkspaceScreens.containsKey(LEFT_PANEL_ID)) {
|
||||
int newCurrentPage = mCurrentPage + 1;
|
||||
bindAndInitLeftPanel();
|
||||
setCurrentPage(newCurrentPage);
|
||||
}
|
||||
} else {
|
||||
// Remove left widget panel if it is present
|
||||
if (mWorkspaceScreens.containsKey(LEFT_PANEL_ID)) {
|
||||
int newCurrentPage = mCurrentPage - 1;
|
||||
removeLeftPanel();
|
||||
setCurrentPage(newCurrentPage);
|
||||
}
|
||||
}
|
||||
|
||||
int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
|
||||
int paddingBottom = grid.cellLayoutBottomPaddingPx;
|
||||
int twoPanelLandscapeSidePadding = paddingLeftRight * 2;
|
||||
@@ -570,6 +555,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {
|
||||
return;
|
||||
}
|
||||
if (isTwoPanelEnabled()) {
|
||||
insertNewWorkspaceScreen(Workspace.LEFT_PANEL_ID, getChildCount());
|
||||
}
|
||||
|
||||
// Add the first page
|
||||
CellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, getChildCount());
|
||||
// Always add a QSB on the first screen.
|
||||
@@ -590,19 +579,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes and binds the left panel
|
||||
*/
|
||||
public void bindAndInitLeftPanel() {
|
||||
if (!FeatureFlags.QSB_ON_FIRST_SCREEN || !isTwoPanelEnabled()
|
||||
|| mWorkspaceScreens.containsKey(Workspace.LEFT_PANEL_ID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
insertNewWorkspaceScreen(Workspace.LEFT_PANEL_ID, getChildCount());
|
||||
mLauncher.getModelWriter().setLeftPanelShown(true);
|
||||
}
|
||||
|
||||
public void removeAllWorkspaceScreens() {
|
||||
// Disable all layout transitions before removing all pages to ensure that we don't get the
|
||||
// transition animations competing with us changing the scroll when we add pages
|
||||
@@ -624,7 +600,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
mLauncher.mHandler.removeCallbacksAndMessages(DeferredWidgetRefresh.class);
|
||||
|
||||
// Ensure that the first page is always present
|
||||
bindAndInitLeftPanel();
|
||||
bindAndInitFirstWorkspaceScreen(qsb);
|
||||
|
||||
// Re-enable the layout transitions
|
||||
@@ -645,18 +620,6 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
insertNewWorkspaceScreen(screenId, getChildCount());
|
||||
}
|
||||
|
||||
private void removeLeftPanel() {
|
||||
if (!mWorkspaceScreens.containsKey(LEFT_PANEL_ID)) {
|
||||
return;
|
||||
}
|
||||
mLauncher.getModelWriter().setLeftPanelShown(false);
|
||||
CellLayout leftPanel = mWorkspaceScreens.get(LEFT_PANEL_ID);
|
||||
mWorkspaceScreens.remove(LEFT_PANEL_ID);
|
||||
removeView(leftPanel);
|
||||
mScreenOrder.removeValue(LEFT_PANEL_ID);
|
||||
updatePageScrollValues();
|
||||
}
|
||||
|
||||
public CellLayout insertNewWorkspaceScreen(int screenId, int insertIndex) {
|
||||
if (mWorkspaceScreens.containsKey(screenId)) {
|
||||
throw new RuntimeException("Screen id " + screenId + " already exists!");
|
||||
@@ -829,6 +792,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
return indexOfChild(mWorkspaceScreens.get(screenId));
|
||||
}
|
||||
|
||||
public IntSet getCurrentPageScreenIds() {
|
||||
return IntSet.wrap(getScreenIdForPageIndex(getCurrentPage()));
|
||||
}
|
||||
|
||||
public int getScreenIdForPageIndex(int index) {
|
||||
if (0 <= index && index < mScreenOrder.size()) {
|
||||
return mScreenOrder.get(index);
|
||||
|
||||
Reference in New Issue
Block a user