mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 10:18:20 +00:00
Add option to allow empty home screen pages
This commit is contained in:
@@ -42,6 +42,7 @@ import android.app.WallpaperManager;
|
||||
import android.appwidget.AppWidgetHostView;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
@@ -117,6 +118,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import ch.deletescape.lawnchair.sharedprefs.LawnchairPreferences;
|
||||
|
||||
/**
|
||||
* The workspace is a wide area with a wallpaper and a finite number of pages.
|
||||
* Each page contains a number of icons, folders or widgets the user can
|
||||
@@ -255,6 +258,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
private final StatsLogManager mStatsLogManager;
|
||||
|
||||
// Lawnchair: Create boolean to indicate if empty pages are allowed.
|
||||
Boolean emptyScreensAllowed;
|
||||
|
||||
/**
|
||||
* Used to inflate the Workspace from XML.
|
||||
*
|
||||
@@ -288,6 +294,12 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
setMotionEventSplittingEnabled(true);
|
||||
setOnTouchListener(new WorkspaceTouchListener(mLauncher, this));
|
||||
mStatsLogManager = StatsLogManager.newInstance(context);
|
||||
|
||||
// Lawnchair: Get instance of `SharedPreferences`, assign value to `emptyScreensAllowed`.
|
||||
SharedPreferences prefs = LawnchairPreferences.Companion.getInstance(getContext());
|
||||
if (prefs != null) {
|
||||
emptyScreensAllowed = prefs.getBoolean(LawnchairPreferences.ALLOW_EMPTY_PAGES, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -621,6 +633,12 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
}
|
||||
|
||||
if (hasExtraEmptyScreen() || mScreenOrder.size() == 0) return;
|
||||
|
||||
// Lawnchair: Stop execution if empty pages are allowed.
|
||||
if (emptyScreensAllowed) {
|
||||
return;
|
||||
}
|
||||
|
||||
int finalScreenId = mScreenOrder.get(mScreenOrder.size() - 1);
|
||||
|
||||
CellLayout finalScreen = mWorkspaceScreens.get(finalScreenId);
|
||||
@@ -741,6 +759,11 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
return;
|
||||
}
|
||||
|
||||
// Lawnchair: Stop execution if empty pages are allowed.
|
||||
if (emptyScreensAllowed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPageInTransition()) {
|
||||
mStripScreensOnPageStopMoving = true;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user