mirror of
https://github.com/markusfisch/PieLauncher.git
synced 2026-03-13 09:01:30 +08:00
Only replace menu ArrayList for secondary menu
Instead of the whole `CanvasPieMenu` instance, which can be the same for the primary and secondary menu. Should there be a need to have two separate `CanvasPieMenu` instances, we can always rollback this change.
This commit is contained in:
@@ -77,8 +77,8 @@ public class Apps {
|
||||
public static final boolean HAS_LAUNCHER_APP =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
|
||||
public final CanvasPieMenu<Apps.AppIcon> piePrimary = new CanvasPieMenu<>();
|
||||
public final CanvasPieMenu<Apps.AppIcon> pieSecondary = new CanvasPieMenu<>();
|
||||
public final ArrayList<Apps.AppIcon> menuPrimary = new ArrayList<>();
|
||||
public final ArrayList<Apps.AppIcon> menuSecondary = new ArrayList<>();
|
||||
public final HiddenAppsStorage hiddenAppsStorage = new HiddenAppsStorage();
|
||||
|
||||
private final Handler handler = new Handler(Looper.getMainLooper());
|
||||
@@ -174,8 +174,8 @@ public class Apps {
|
||||
}
|
||||
|
||||
public void store(Context context) {
|
||||
MenuStorage.store(context, MENU_PRIMARY, piePrimary.icons);
|
||||
MenuStorage.store(context, MENU_SECONDARY, pieSecondary.icons);
|
||||
MenuStorage.store(context, MENU_PRIMARY, menuPrimary);
|
||||
MenuStorage.store(context, MENU_SECONDARY, menuSecondary);
|
||||
hiddenAppsStorage.store(context);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class Apps {
|
||||
}
|
||||
}
|
||||
if (prefs.excludePie()) {
|
||||
list.removeAll(new HashSet<>(piePrimary.icons));
|
||||
list.removeAll(new HashSet<>(menuPrimary));
|
||||
}
|
||||
} else {
|
||||
int item = prefs.getSearchParameter();
|
||||
@@ -270,9 +270,9 @@ public class Apps {
|
||||
hiddenAppsStorage.removeAndStore(appContext, packageName);
|
||||
handler.post(() -> {
|
||||
removePackageFromApps(apps, packageName, userHandle);
|
||||
removePackageFromPieMenu(piePrimary.icons, packageName,
|
||||
removePackageFromPieMenu(menuPrimary, packageName,
|
||||
userHandle);
|
||||
removePackageFromPieMenu(pieSecondary.icons, packageName,
|
||||
removePackageFromPieMenu(menuSecondary, packageName,
|
||||
userHandle);
|
||||
propagateUpdate();
|
||||
});
|
||||
@@ -329,10 +329,10 @@ public class Apps {
|
||||
handler.post(() -> {
|
||||
apps.clear();
|
||||
apps.putAll(newApps);
|
||||
piePrimary.icons.clear();
|
||||
piePrimary.icons.addAll(newIcons);
|
||||
pieSecondary.icons.clear();
|
||||
pieSecondary.icons.addAll(newIconsAlt);
|
||||
menuPrimary.clear();
|
||||
menuPrimary.addAll(newIcons);
|
||||
menuSecondary.clear();
|
||||
menuSecondary.addAll(newIconsAlt);
|
||||
indexing = false;
|
||||
propagateUpdate();
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ public class PieMenu<T extends PieMenu.Icon> {
|
||||
public int y;
|
||||
}
|
||||
|
||||
public final ArrayList<T> icons = new ArrayList<>();
|
||||
public ArrayList<T> icons = new ArrayList<>();
|
||||
|
||||
private int selectedIcon = -1;
|
||||
private int centerX = -1;
|
||||
|
||||
@@ -72,10 +72,11 @@ public class AppPieView extends View {
|
||||
private static final int MODE_LIST = 1;
|
||||
private static final int MODE_EDIT = 2;
|
||||
|
||||
private final CanvasPieMenu<Apps.AppIcon> menuPrimary =
|
||||
PieLauncherApp.apps.piePrimary;
|
||||
private final CanvasPieMenu<Apps.AppIcon> menuSecondary =
|
||||
PieLauncherApp.apps.pieSecondary;
|
||||
private final CanvasPieMenu<Apps.AppIcon> pieMenu = new CanvasPieMenu<>();
|
||||
private final ArrayList<Apps.AppIcon> menuPrimary =
|
||||
PieLauncherApp.apps.menuPrimary;
|
||||
private final ArrayList<Apps.AppIcon> menuSecondary =
|
||||
PieLauncherApp.apps.menuSecondary;
|
||||
private final Fade fadePie = new Fade();
|
||||
private final Fade fadeList = new Fade();
|
||||
private final Fade fadeEdit = new Fade();
|
||||
@@ -129,7 +130,6 @@ public class AppPieView extends View {
|
||||
private final float textOffset;
|
||||
private final float touchSlopSq;
|
||||
|
||||
private CanvasPieMenu<Apps.AppIcon> pieMenu = menuPrimary;
|
||||
private Window window;
|
||||
private RenderNode pieRenderNode;
|
||||
private RenderNode listRenderNode;
|
||||
@@ -189,6 +189,7 @@ public class AppPieView extends View {
|
||||
dp = dm.density;
|
||||
float sp = dm.scaledDensity;
|
||||
|
||||
pieMenu.icons = menuPrimary;
|
||||
controlsPadding = Math.round(80f * dp);
|
||||
listPadding = Math.round(16f * dp);
|
||||
searchInputHeight = Math.round(112f * dp);
|
||||
@@ -1216,10 +1217,9 @@ public class AppPieView extends View {
|
||||
} else if (contains(iconCenterRect, touch)) {
|
||||
if (grabbedIcon == null) {
|
||||
if (prefs.splitPieEnabled()) {
|
||||
pieMenu = pieMenu == menuPrimary
|
||||
? menuSecondary
|
||||
: menuPrimary;
|
||||
centerIcons(pieMenu.icons);
|
||||
swapMenus(pieMenu.icons == menuPrimary);
|
||||
centerSmoothCoordinatesAt(pieMenu.icons,
|
||||
viewWidth >> 1, viewHeight >> 1);
|
||||
updateSplitPieIcon();
|
||||
invalidate();
|
||||
} else {
|
||||
@@ -1266,14 +1266,6 @@ public class AppPieView extends View {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void centerIcons(ArrayList<Apps.AppIcon> icons) {
|
||||
int centerX = viewWidth >> 1;
|
||||
int centerY = viewHeight >> 1;
|
||||
for (Apps.AppIcon ic : icons) {
|
||||
ic.setStartPosition(centerX, centerY);
|
||||
}
|
||||
}
|
||||
|
||||
private void launchApp(Context context, Apps.AppIcon appIcon) {
|
||||
launchingIcon = appIcon;
|
||||
PieLauncherApp.apps.launchApp(context, appIcon);
|
||||
@@ -1295,6 +1287,13 @@ public class AppPieView extends View {
|
||||
pieMenu.icons.addAll(backup);
|
||||
}
|
||||
|
||||
private static void centerSmoothCoordinatesAt(
|
||||
ArrayList<Apps.AppIcon> icons, int centerX, int centerY) {
|
||||
for (Apps.AppIcon ic : icons) {
|
||||
ic.setStartPosition(centerX, centerY);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean sameOrder(
|
||||
List<? extends PieMenu.Icon> a,
|
||||
List<? extends PieMenu.Icon> b) {
|
||||
@@ -1409,7 +1408,7 @@ public class AppPieView extends View {
|
||||
}
|
||||
|
||||
private int getDrawableForSplitPie() {
|
||||
return pieMenu == menuSecondary
|
||||
return pieMenu.icons == menuSecondary
|
||||
? R.drawable.ic_screen_upper
|
||||
: R.drawable.ic_screen_lower;
|
||||
}
|
||||
@@ -1426,11 +1425,17 @@ public class AppPieView extends View {
|
||||
}
|
||||
|
||||
private void selectMenu(int x, int y) {
|
||||
pieMenu = (viewWidth > viewHeight
|
||||
swapMenus(viewWidth > viewHeight
|
||||
? x < viewWidth >> 1
|
||||
: y < viewHeight >> 1)
|
||||
? menuSecondary
|
||||
: menuPrimary;
|
||||
: y < viewHeight >> 1);
|
||||
}
|
||||
|
||||
private void swapMenus() {
|
||||
swapMenus(pieMenu.icons == menuPrimary);
|
||||
}
|
||||
|
||||
private void swapMenus(boolean isPrimary) {
|
||||
pieMenu.icons = isPrimary ? menuSecondary : menuPrimary;
|
||||
}
|
||||
|
||||
private void setCenter(int x, int y) {
|
||||
|
||||
Reference in New Issue
Block a user