Skip to content

Commit

Permalink
Settings shortcut: get tint from OP Colors
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed May 1, 2024
1 parent a005066 commit 378ee35
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static de.robv.android.xposed.XposedBridge.hookAllConstructors;
import static de.robv.android.xposed.XposedBridge.hookAllMethods;
import static de.robv.android.xposed.XposedHelpers.callMethod;
import static de.robv.android.xposed.XposedHelpers.callStaticMethod;
import static de.robv.android.xposed.XposedHelpers.findAndHookConstructor;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.getObjectField;
Expand All @@ -12,6 +13,7 @@

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
Expand Down Expand Up @@ -81,7 +83,8 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
}
});

Class<?> COUITintUtil = findClass("com.coui.appcompat.tintimageview.COUITintUtil", lpparam.classLoader);
Class<?> ThemeUtils = findClass("com.oplus.settings.utils.ThemeUtils", lpparam.classLoader);
hookAllMethods(TopLevelSettingsClass, "onCreateAdapter", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Expand All @@ -92,10 +95,17 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

Object mWallpaperCategory = callMethod(param.args[0], "findPreference", "notification_settings_category");

Drawable OCIcon = ResourcesCompat.getDrawable(ResourceManager.modRes,
R.drawable.pref_icon,
mContext.getTheme());
Drawable tinted;
try {
tinted = (Drawable) callStaticMethod(ThemeUtils, "getApplyCOUITintDrawable", c, OCIcon, true);
} catch (Throwable t) {
tinted = OCIcon;
}
callMethod(OCPreference, "setIcon",
ResourcesCompat.getDrawable(ResourceManager.modRes,
R.drawable.pref_icon,
mContext.getTheme()));
tinted);
callMethod(OCPreference, "setTitle", "Oxygen Customizer");
callMethod(OCPreference, "setOrder", 1);
callMethod(OCPreference, "setKey", "oxygen_customizer");
Expand All @@ -105,6 +115,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}



@Override
public boolean listensTo(String packageName) {
return packageName.equals(this.packageName);
Expand Down

0 comments on commit 378ee35

Please sign in to comment.