From fc00e909a4b99314e6b47be2a2467932724571fa Mon Sep 17 00:00:00 2001 From: DHD2280 Date: Sun, 19 May 2024 13:58:32 +0200 Subject: [PATCH] CHANGELOG: Added Launcher Layout modifications --- .../utils/PreferenceHelper.java | 5 +++ .../xposed/hooks/launcher/Launcher.java | 44 ++++++++++++++----- app/src/main/res/values/strings.xml | 4 ++ app/src/main/res/xml/launcher_mods.xml | 34 ++++++++++++++ 4 files changed, 76 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java index 175760668..4e282b06f 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java @@ -168,6 +168,9 @@ public static boolean isVisible(String key) { case "drawer_columns" -> { return instance.mPreferences.getBoolean("rearrange_drawer", false); } + case "launcher_max_columns", "launcher_max_rows" -> { + return instance.mPreferences.getBoolean("rearrange_home", false); + } // Statusbar Prefs case "statusbar_top_padding", "statusbarPaddings" -> { @@ -621,6 +624,8 @@ public static String getSummary(Context fragmentCompat, @NonNull String key) { case "folder_columns" -> String.valueOf(instance.mPreferences.getSliderInt("folder_columns", 3)); case "folder_rows" -> String.valueOf(instance.mPreferences.getSliderInt("folder_rows", 3)); case "drawer_columns" -> String.valueOf(instance.mPreferences.getSliderInt("drawer_columns", 4)); + case "launcher_max_columns" -> String.valueOf(instance.mPreferences.getSliderInt("launcher_max_columns", 5)); + case "launcher_max_rows" -> String.valueOf(instance.mPreferences.getSliderInt("launcher_max_rows", 6)); // Header Image case "qs_header_image_alpha" -> String.valueOf(instance.mPreferences.getSliderInt("qs_header_image_alpha", 255)); diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/launcher/Launcher.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/launcher/Launcher.java index 362e041a9..42f168f48 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/launcher/Launcher.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/launcher/Launcher.java @@ -1,6 +1,5 @@ package it.dhd.oxygencustomizer.xposed.hooks.launcher; -import static android.content.Context.RECEIVER_EXPORTED; import static de.robv.android.xposed.XposedBridge.hookAllMethods; import static de.robv.android.xposed.XposedBridge.log; import static de.robv.android.xposed.XposedHelpers.callMethod; @@ -9,17 +8,12 @@ import static de.robv.android.xposed.XposedHelpers.findClass; import static de.robv.android.xposed.XposedHelpers.getIntField; import static de.robv.android.xposed.XposedHelpers.getObjectField; +import static de.robv.android.xposed.XposedHelpers.setObjectField; import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs; -import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.ColorFilter; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.Settings; @@ -27,8 +21,6 @@ import android.view.MotionEvent; import android.view.View; -import androidx.core.graphics.ColorUtils; - import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; import de.robv.android.xposed.callbacks.XC_LoadPackage; @@ -38,10 +30,11 @@ public class Launcher extends XposedMods { private static final String listenPackage = Constants.Packages.LAUNCHER; - + private static final String TAG = "OxygenCustomizer - Launcher: "; private int mFolderRows, mFolderColumns, mDrawerColumns; - private boolean mFolderRearrange = false, mFolderPreview = false, mDrawerRearrange = false, mOpenAppDetails; + private boolean mRearrangeHome = false, mFolderRearrange = false, mFolderPreview = false, mDrawerRearrange = false, mOpenAppDetails; private boolean mRemoveFolderPagination = false, mRemoveHomePagination = false; + private int mMaxRows = 6, mMaxColumns = 4; public Launcher(Context context) { super(context); @@ -54,6 +47,9 @@ public void updatePrefs(String... Key) { mFolderRows = Xprefs.getSliderInt("folder_rows", 3); mFolderColumns = Xprefs.getSliderInt("folder_columns", 3); mDrawerColumns = Xprefs.getSliderInt("drawer_columns", 4); + mMaxRows = Xprefs.getSliderInt("launcher_max_rows", 6); + mMaxColumns = Xprefs.getSliderInt("launcher_max_columns", 5); + mRearrangeHome = Xprefs.getBoolean("rearrange_home", false); mFolderRearrange = Xprefs.getBoolean("rearrange_folder", true); mFolderPreview = Xprefs.getBoolean("rearrange_preview", true); mDrawerRearrange = Xprefs.getBoolean("rearrange_drawer", true); @@ -148,6 +144,32 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { }); } catch (Throwable ignored) {} + try { + Class UiConfig = findClass("com.android.launcher.UiConfig", lpparam.classLoader); + hookAllMethods(UiConfig, "isSupportLayout", new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (mRearrangeHome) param.setResult(true); + } + }); + + Class ToggleBarLayoutAdapter = findClass("com.android.launcher.togglebar.adapter.ToggleBarLayoutAdapter", lpparam.classLoader); + hookAllMethods(ToggleBarLayoutAdapter, "initToggleBarLayoutConfigs", new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (!mRearrangeHome) return; + int[] mMinMaxRows = (int[]) getObjectField(param.thisObject, "MIN_MAX_ROW"); + int[] mMinMaxColumns = (int[]) getObjectField(param.thisObject, "MIN_MAX_COLUMN"); + mMinMaxRows[1] = mMaxRows; + mMinMaxColumns[1] = mMaxColumns; + setObjectField(param.thisObject, "MIN_MAX_ROW", mMinMaxRows); + setObjectField(param.thisObject, "MIN_MAX_COLUMN", mMinMaxColumns); + } + }); + } catch (Throwable t) { + log(TAG + "Error in Launcher Layout " + t); + } + } class ClickListener implements View.OnLongClickListener { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 55e9951e1..d49dc1ec6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -504,6 +504,10 @@ Launcher Options requires Launcher Restart.\nTap on menu to restart. + Home Layout + Edit home layout + Home Columns + Home Rows Folder layout Edit layout Columns diff --git a/app/src/main/res/xml/launcher_mods.xml b/app/src/main/res/xml/launcher_mods.xml index b9c1ae647..6516c5859 100644 --- a/app/src/main/res/xml/launcher_mods.xml +++ b/app/src/main/res/xml/launcher_mods.xml @@ -10,6 +10,40 @@ android:title="@string/launcher_intro_title" search:ignore="true"/> + + + + + + + + + +