Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rvictorr committed Jul 25, 2017
1 parent b7923f2 commit c51382e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,20 @@ 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);
contentView.setViewVisibility(R.id.progress_container, View.VISIBLE);
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;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}
Expand All @@ -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(
Expand Down

0 comments on commit c51382e

Please sign in to comment.