Skip to content

Commit

Permalink
QS Transparency: Remove parameterized condition from hook method
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed Sep 15, 2023
1 parent c29c9ae commit 657f8fb
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
import static com.drdisagree.iconify.common.Preferences.QSALPHA_LEVEL;
import static com.drdisagree.iconify.common.Preferences.QS_TRANSPARENCY_SWITCH;
import static com.drdisagree.iconify.config.XPrefs.Xprefs;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedBridge.hookAllMethods;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.findField;
import static de.robv.android.xposed.XposedHelpers.getObjectField;

import android.content.Context;
import android.view.View;

import com.drdisagree.iconify.xposed.ModPack;

Expand Down Expand Up @@ -42,26 +41,27 @@ public void updatePrefs(String... Key) {
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpParam) {
if (!lpParam.packageName.equals(SYSTEMUI_PACKAGE)) return;

final Class<?> ScrimController = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.ScrimController", lpParam.classLoader);
final Class<?> ScrimControllerClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.ScrimController", lpParam.classLoader);

findAndHookMethod(ScrimController, "updateScrimColor", View.class, Integer.TYPE, Float.TYPE, new XC_MethodHook() {
hookAllMethods(ScrimControllerClass, "updateScrimColor", new XC_MethodHook() {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!qsTransparencyActive && !onlyNotifTransparencyActive) return;

int alphaIndex = param.args[2] instanceof Float ? 2 : 1;
String scrimState = getObjectField(param.thisObject, "mState").toString();

if (scrimState.equals("KEYGUARD")) {
param.args[2] = 0.0f;
param.args[alphaIndex] = 0.0f;
} else if (scrimState.contains("BOUNCER")) {
param.args[2] = (Float) param.args[2] * keyguard_alpha;
param.args[alphaIndex] = (Float) param.args[alphaIndex] * keyguard_alpha;
} else {
String scrimName = "unknown_scrim";

if (findField(ScrimController, "mScrimInFront").get(param.thisObject).equals(param.args[0])) {
if (findField(ScrimControllerClass, "mScrimInFront").get(param.thisObject).equals(param.args[0])) {
scrimName = "front_scrim";
} else if (findField(ScrimController, "mScrimBehind").get(param.thisObject).equals(param.args[0])) {
} else if (findField(ScrimControllerClass, "mScrimBehind").get(param.thisObject).equals(param.args[0])) {
scrimName = "behind_scrim";
} else if (findField(ScrimController, "mNotificationsScrim").get(param.thisObject).equals(param.args[0])) {
} else if (findField(ScrimControllerClass, "mNotificationsScrim").get(param.thisObject).equals(param.args[0])) {
scrimName = "notifications_scrim";
}

Expand All @@ -71,7 +71,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
break;
}
case "notifications_scrim":
param.args[2] = (Float) param.args[2] * alpha;
param.args[alphaIndex] = (Float) param.args[alphaIndex] * alpha;
break;
default:
break;
Expand Down

0 comments on commit 657f8fb

Please sign in to comment.