From 184cf0e4aa7c693a286753eced6e6c1c598083ea Mon Sep 17 00:00:00 2001 From: DrDisagree Date: Tue, 10 Oct 2023 18:28:14 +0600 Subject: [PATCH] Use enhanced switch case --- .../iconify/xposed/mods/QSLightThemeA12.java | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSLightThemeA12.java b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSLightThemeA12.java index e0f8da6d9..0cf886815 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSLightThemeA12.java +++ b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSLightThemeA12.java @@ -195,30 +195,28 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { for (Object constant : constants) { String enumVal = constant.toString(); switch (enumVal) { - case "KEYGUARD": - findAndHookMethod(constant.getClass(), "prepare", ScrimStateEnum, new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - if (!lightQSHeaderEnabled) return; - - boolean mClipQsScrim = (boolean) getObjectField(param.thisObject, "mClipQsScrim"); - if (mClipQsScrim) { - callMethod(param.thisObject, "updateScrimColor", getObjectField(param.thisObject, "mScrimBehind"), 1f, Color.TRANSPARENT); + case "KEYGUARD" -> + findAndHookMethod(constant.getClass(), "prepare", ScrimStateEnum, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + if (!lightQSHeaderEnabled) return; + + boolean mClipQsScrim = (boolean) getObjectField(param.thisObject, "mClipQsScrim"); + if (mClipQsScrim) { + callMethod(param.thisObject, "updateScrimColor", getObjectField(param.thisObject, "mScrimBehind"), 1f, Color.TRANSPARENT); + } } - } - }); - break; - case "BOUNCER": - findAndHookMethod(constant.getClass(), "prepare", ScrimStateEnum, new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - if (!lightQSHeaderEnabled) return; - - setObjectField(param.thisObject, "mBehindTint", Color.TRANSPARENT); - } - }); - break; - case "SHADE_LOCKED": + }); + case "BOUNCER" -> + findAndHookMethod(constant.getClass(), "prepare", ScrimStateEnum, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + if (!lightQSHeaderEnabled) return; + + setObjectField(param.thisObject, "mBehindTint", Color.TRANSPARENT); + } + }); + case "SHADE_LOCKED" -> { hookAllMethods(constant.getClass(), "prepare", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { @@ -239,20 +237,18 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { param.setResult(Color.TRANSPARENT); } }); - break; - - case "UNLOCKED": - findAndHookMethod(constant.getClass(), "prepare", ScrimStateEnum, new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - if (!lightQSHeaderEnabled) return; + } + case "UNLOCKED" -> + findAndHookMethod(constant.getClass(), "prepare", ScrimStateEnum, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + if (!lightQSHeaderEnabled) return; - setObjectField(param.thisObject, "mBehindTint", Color.TRANSPARENT); + setObjectField(param.thisObject, "mBehindTint", Color.TRANSPARENT); - callMethod(param.thisObject, "updateScrimColor", getObjectField(param.thisObject, "mScrimBehind"), 1f, Color.TRANSPARENT); - } - }); - break; + callMethod(param.thisObject, "updateScrimColor", getObjectField(param.thisObject, "mScrimBehind"), 1f, Color.TRANSPARENT); + } + }); } } } catch (Throwable throwable) {