Skip to content

Commit

Permalink
CHANGELOG: Added Launcher Layout modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed May 19, 2024
1 parent a2b38ea commit fc00e90
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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" -> {
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,26 +8,19 @@
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;
import android.util.AttributeSet;
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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@

<!-- Launcher Mods -->
<string name="launcher_intro_title">Launcher Options requires Launcher Restart.\nTap on menu to restart.</string>
<string name="launcher_layout">Home Layout</string>
<string name="launcher_edit_layout">Edit home layout</string>
<string name="launcher_columns">Home Columns</string>
<string name="launcher_rows">Home Rows</string>
<string name="launcher_folder_layout">Folder layout</string>
<string name="launcher_folder_edit_layout">Edit layout</string>
<string name="launcher_folder_columns">Columns</string>
Expand Down
34 changes: 34 additions & 0 deletions app/src/main/res/xml/launcher_mods.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,40 @@
android:title="@string/launcher_intro_title"
search:ignore="true"/>

<PreferenceCategory
app:iconSpaceReserved="false"
android:title="@string/launcher_layout">

<SwitchPreferenceCompat
android:key="rearrange_home"
app:iconSpaceReserved="false"
android:title="@string/launcher_edit_layout"
android:summaryOff="@string/general_off"
android:summaryOn="@string/general_on"
android:defaultValue="false"/>

<it.dhd.oxygencustomizer.customprefs.SliderPreference
android:key="launcher_max_columns"
app:iconSpaceReserved="false"
android:title="@string/launcher_columns"
app:minVal="4"
app:maxVal="8"
app:tickInterval="1"
app:defaultValue="4"
android:dependency="rearrange_home"/>

<it.dhd.oxygencustomizer.customprefs.SliderPreference
android:key="launcher_max_rows"
app:iconSpaceReserved="false"
android:title="@string/launcher_rows"
app:minVal="3"
app:maxVal="10"
app:tickInterval="1"
app:defaultValue="4"
android:dependency="rearrange_home"/>

</PreferenceCategory>

<PreferenceCategory
app:iconSpaceReserved="false"
android:title="@string/launcher_folder_layout">
Expand Down

0 comments on commit fc00e90

Please sign in to comment.