diff --git a/app/src/main/java/tk/wasdennnoch/androidn_ify/systemui/notifications/NotificationHooks.java b/app/src/main/java/tk/wasdennnoch/androidn_ify/systemui/notifications/NotificationHooks.java index 76390779..f2fda0e5 100644 --- a/app/src/main/java/tk/wasdennnoch/androidn_ify/systemui/notifications/NotificationHooks.java +++ b/app/src/main/java/tk/wasdennnoch/androidn_ify/systemui/notifications/NotificationHooks.java @@ -517,6 +517,7 @@ private static String loadHeaderAppName(Context context, Bundle extras) { private static boolean handleProgressBar(boolean hasProgress, RemoteViews contentView, Object builder, Resources res) { final int max = XposedHelpers.getIntField(builder, "mProgressMax"); final boolean ind = XposedHelpers.getBooleanField(builder, "mProgressIndeterminate"); + int progressId = res.getIdentifier("progress", "id", PACKAGE_ANDROID); if (hasProgress && (max != 0 || ind)) { CharSequence text = (CharSequence) XposedHelpers.getObjectField(builder, "mContentText"); contentView.setTextViewText(R.id.text_line_1, text); @@ -524,12 +525,12 @@ private static boolean handleProgressBar(boolean hasProgress, RemoteViews conten contentView.setViewVisibility(R.id.text_line_1, View.VISIBLE); contentView.setViewVisibility(res.getIdentifier("line3", "id", PACKAGE_ANDROID), View.GONE); XposedHelpers.callMethod(contentView, "setProgressBackgroundTintList", - res.getIdentifier("progress", "id", PACKAGE_ANDROID), ColorStateList.valueOf(res.getColor( + progressId, ColorStateList.valueOf(res.getColor( res.getIdentifier("notification_progress_background_color", "color", PACKAGE_ANDROID)))); if (XposedHelpers.getIntField(builder, "mColor") != COLOR_DEFAULT) { ColorStateList colorStateList = ColorStateList.valueOf((int) XposedHelpers.callMethod(builder, "resolveColor")); - XposedHelpers.callMethod(contentView, "setProgressTintList", res.getIdentifier("progress", "id", PACKAGE_ANDROID), colorStateList); - XposedHelpers.callMethod(contentView, "setProgressIndeterminateTintList", res.getIdentifier("progress", "id", PACKAGE_ANDROID), + XposedHelpers.callMethod(contentView, "setProgressTintList", progressId, colorStateList); + XposedHelpers.callMethod(contentView, "setProgressIndeterminateTintList", progressId, colorStateList); } return true; @@ -702,10 +703,10 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { @Override protected Object replaceHookedMethod(MethodHookParam param) throws Throwable { Object builder = param.thisObject; + Context context = (Context) XposedHelpers.getObjectField(builder, "mContext"); int mColor = XposedHelpers.getIntField(builder, "mColor"); - if (mColor != 0) return NotificationColorUtil.resolveContrastColor((Context)XposedHelpers.getObjectField(builder, "mContext"), - (int)XposedHelpers.getObjectField(builder, "mColor")); // App specified color in notification builder - Context context = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext"); + if (mColor != 0) return NotificationColorUtil.resolveContrastColor(context, + mColor); // App specified color in notification builder if (mAccentColor == 0) { //noinspection deprecation mAccentColor = context.getResources().getColor(context.getResources().getIdentifier("notification_icon_bg_color", "color", PACKAGE_ANDROID)); diff --git a/app/src/main/java/tk/wasdennnoch/androidn_ify/systemui/notifications/NotificationPanelHooks.java b/app/src/main/java/tk/wasdennnoch/androidn_ify/systemui/notifications/NotificationPanelHooks.java index 1bc522cd..e30d73f3 100644 --- a/app/src/main/java/tk/wasdennnoch/androidn_ify/systemui/notifications/NotificationPanelHooks.java +++ b/app/src/main/java/tk/wasdennnoch/androidn_ify/systemui/notifications/NotificationPanelHooks.java @@ -17,6 +17,7 @@ import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XC_MethodReplacement; +import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedHelpers; import tk.wasdennnoch.androidn_ify.R; import tk.wasdennnoch.androidn_ify.XposedHook; @@ -197,14 +198,18 @@ public static void hook(ClassLoader classLoader) { classPanelView = XposedHelpers.findClass(CLASS_PANEL_VIEW, classLoader); if (ConfigUtils.M) { - XposedHelpers.findAndHookMethod(classPanelView, "expand", instantExpand); - XposedHelpers.findAndHookMethod(classPanelView, "instantExpand", new XC_MethodHook() { - @Override - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - mAnimate = false; - } - }); - XposedHelpers.findAndHookMethod(classPanelView, "instantExpand", instantExpand); + try { + XposedBridge.hookAllMethods(classPanelView, "expand", instantExpand); + XposedBridge.hookAllMethods(classPanelView, "instantExpand", new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + mAnimate = false; + } + }); + XposedBridge.hookAllMethods(classPanelView, "instantExpand", instantExpand); + } catch (Throwable t) { + XposedHook.logE(TAG, "Error in PanelView hooks", t); + } } if (ConfigUtils.qs().header) { // Although this is the notification panel everything here is header-related (mainly QS editor) diff --git a/app/src/main/java/tk/wasdennnoch/androidn_ify/utils/NotificationColorUtil.java b/app/src/main/java/tk/wasdennnoch/androidn_ify/utils/NotificationColorUtil.java index 2bf4536e..1470286d 100644 --- a/app/src/main/java/tk/wasdennnoch/androidn_ify/utils/NotificationColorUtil.java +++ b/app/src/main/java/tk/wasdennnoch/androidn_ify/utils/NotificationColorUtil.java @@ -56,8 +56,6 @@ public class NotificationColorUtil { private static final int TYPE_BITMAP = 1; private static final int TYPE_RESOURCE = 2; - private static ResourceUtils res; - private static final Object sLock = new Object(); private static NotificationColorUtil sInstance; @@ -77,9 +75,9 @@ public static NotificationColorUtil getInstance(Context context) { } private NotificationColorUtil(Context context) { + ResourceUtils res = ResourceUtils.getInstance(context); mGrayscaleIconMaxSize = res.getResources().getDimensionPixelSize( R.dimen.notification_large_icon_width); - res = ResourceUtils.getInstance(context); } /** @@ -167,7 +165,7 @@ public boolean isGrayscaleIcon(Context context, Icon icon) { * @return True if the bitmap is grayscale; false if it is color or too large to examine. */ public boolean isGrayscaleIcon(Context context, int drawableResId) { - res = ResourceUtils.getInstance(context); + ResourceUtils res = ResourceUtils.getInstance(context); if (drawableResId != 0) { try { return isGrayscaleIcon(res.getDrawable(drawableResId)); @@ -311,7 +309,7 @@ public static String contrastChange(int colorOld, int colorNew, int bg) { * Resolves {@param color} to an actual color if it is {@link Notification#COLOR_DEFAULT} */ public static int resolveColor(Context context, int color) { - res = ResourceUtils.getInstance(context); + ResourceUtils res = ResourceUtils.getInstance(context); if (color == Notification.COLOR_DEFAULT) { return res.getColor(R.color.notification_default_color); } @@ -326,7 +324,7 @@ public static int resolveColor(Context context, int color) { * @return a color of the same hue with enough contrast against the backgrounds. */ public static int resolveContrastColor(Context context, int notificationColor) { - res = ResourceUtils.getInstance(context); + ResourceUtils res = ResourceUtils.getInstance(context); final int resolvedColor = resolveColor(context, notificationColor); final int actionBg = res.getColor(