Skip to content

Commit

Permalink
add color to reset to default colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev4Mod committed May 2, 2024
1 parent 29f2e71 commit cb86c6c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1290,4 +1290,10 @@ public static Method loadSendStickerMethod(ClassLoader loader) throws Exception
if (method == null) throw new RuntimeException("SendSticker method not found");
return method;
}

public static Method loadStkMethod(ClassLoader loader) throws Exception {
var method = dexkit.findMethod(new FindMethod().matcher(new MethodMatcher().name("setDateWrapperBackground")));
if (method.isEmpty()) throw new RuntimeException("Stk method not found");
return method.get(0).getMethodInstance(loader);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;

import androidx.annotation.NonNull;
Expand All @@ -29,46 +31,44 @@ public void doHook() throws Exception {

var bubbleRightColor = prefs.getInt("bubble_right", 0);

var balloon = DesignUtils.getDrawableByName(Unobfuscator.BUBBLE_COLORS_BALLOON_OUTGOING_NORMAL);
balloon.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable(Unobfuscator.BUBBLE_COLORS_BALLOON_OUTGOING_NORMAL, balloon);
// Right

var balloonExt = DesignUtils.getDrawableByName(Unobfuscator.BUBBLE_COLORS_BALLOON_OUTGOING_NORMAL_EXT);
balloonExt.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable(Unobfuscator.BUBBLE_COLORS_BALLOON_OUTGOING_NORMAL_EXT, balloonExt);
if (bubbleRightColor!= 0) {

var balloonFrame = DesignUtils.getDrawableByName("balloon_outgoing_frame");
balloonFrame.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable("balloon_outgoing_frame", balloonFrame);
replaceColor(Unobfuscator.BUBBLE_COLORS_BALLOON_OUTGOING_NORMAL, bubbleRightColor);

var balloonPressed = DesignUtils.getDrawableByName("balloon_outgoing_pressed");
balloonPressed.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable("balloon_outgoing_pressed", balloonPressed);
replaceColor(Unobfuscator.BUBBLE_COLORS_BALLOON_OUTGOING_NORMAL_EXT, bubbleRightColor);

var balloonSticker = DesignUtils.getDrawableByName("balloon_outgoing_normal_stkr");
balloonSticker.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable("balloon_outgoing_normal_stkr", balloonSticker);
replaceColor("balloon_outgoing_frame", bubbleRightColor);

replaceColor("balloon_outgoing_pressed", bubbleRightColor);

var balloonLeft = DesignUtils.getDrawableByName(Unobfuscator.BUBBLE_COLORS_BALLOON_INCOMING_NORMAL);
balloonLeft.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable(Unobfuscator.BUBBLE_COLORS_BALLOON_INCOMING_NORMAL, balloonLeft);
replaceColor("balloon_outgoing_pressed_ext", bubbleRightColor);

var balloonExtLeft = DesignUtils.getDrawableByName(Unobfuscator.BUBBLE_COLORS_BALLOON_INCOMING_NORMAL_EXT);
balloonExtLeft.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable(Unobfuscator.BUBBLE_COLORS_BALLOON_INCOMING_NORMAL_EXT, balloonExtLeft);
replaceColor("balloon_outgoing_normal_stkr", bubbleRightColor);

var balloonFrameLeft = DesignUtils.getDrawableByName("balloon_incoming_frame");
balloonFrameLeft.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable("balloon_incoming_frame", balloonFrameLeft);
replaceColor("balloon_outgoing_normal_stkr_tinted", bubbleRightColor);
}

// Left

if (bubbleLeftColor != 0) {

replaceColor(Unobfuscator.BUBBLE_COLORS_BALLOON_INCOMING_NORMAL, bubbleLeftColor);

replaceColor(Unobfuscator.BUBBLE_COLORS_BALLOON_INCOMING_NORMAL_EXT, bubbleLeftColor);

replaceColor("balloon_incoming_frame", bubbleLeftColor);

var balloonPressedLeft = DesignUtils.getDrawableByName("balloon_incoming_pressed");
balloonPressedLeft.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable("balloon_incoming_pressed", balloonPressedLeft);
replaceColor("balloon_incoming_pressed", bubbleLeftColor);

var balloonStickerLeft = DesignUtils.getDrawableByName("balloon_incoming_normal_stkr");
balloonStickerLeft.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable("balloon_incoming_normal_stkr", balloonStickerLeft);
replaceColor("balloon_incoming_pressed_ext", bubbleLeftColor);

replaceColor("balloon_incoming_normal_stkr", bubbleLeftColor);

replaceColor("balloon_incoming_normal_stkr_tinted", bubbleLeftColor);

}


var methods = Unobfuscator.loadNineDrawableMethods(loader);
Expand All @@ -79,14 +79,21 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
var draw = (NinePatchDrawable) param.getResult();
var right = (boolean) param.args[3];
if (right) {
if (bubbleRightColor == 0) return;
draw.setColorFilter(new PorterDuffColorFilter(bubbleRightColor, PorterDuff.Mode.SRC_IN));
} else {
if (bubbleLeftColor == 0) return;
draw.setColorFilter(new PorterDuffColorFilter(bubbleLeftColor, PorterDuff.Mode.SRC_IN));
}
}
});
}
}

private static void replaceColor(String drawableName, int color) {
var drawable = DesignUtils.getDrawableByName(drawableName);
drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
DesignUtils.setReplacementDrawable(drawableName, drawable);
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public void doHook() throws Exception {
logDebug("customDrawable3: " + customDrawable3.getName());


var primaryColorInt = prefs.getInt("primary_color", 0xFF000000);
var secondaryColorInt = prefs.getInt("secondary_color", 0xFF000000);
var backgroundColorInt = prefs.getInt("background_color", 0xFF000000);
var primaryColorInt = prefs.getInt("primary_color", 0);
var secondaryColorInt = prefs.getInt("secondary_color", 0);
var backgroundColorInt = prefs.getInt("background_color", 0);

var primaryColor = String.format("#%08X", primaryColorInt);
var secondaryColor = String.format("#%08X", secondaryColorInt);
var backgroundColor = String.format("#%08X", backgroundColorInt);
var primaryColor = primaryColorInt == 0 ? "0" : String.format("#%08X", primaryColorInt);
var secondaryColor = secondaryColorInt == 0 ? "0" : String.format("#%08X", secondaryColorInt);
var backgroundColor = backgroundColorInt == 0 ? "0" : String.format("#%08X", backgroundColorInt);

for (var c : colors.keySet()) {
if (!primaryColor.equals("0")) {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/fragment_customization.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@
app:key="primary_color"
app:cpv_showAlphaSlider="true"
app:dependency="changecolor"
app:summary="Set color #00000000 to default color"
app:title="@string/primary_color" />

<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
app:key="secondary_color"
app:cpv_showAlphaSlider="true"
app:dependency="changecolor"
app:summary="Set color #00000000 to default color"
app:title="@string/secondary_color" />

<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
app:key="background_color"
app:dependency="changecolor"
app:cpv_showAlphaSlider="true"
app:summary="Set color #00000000 to default color"
app:title="@string/background_color" />

</PreferenceCategory>
Expand All @@ -49,12 +52,14 @@
app:key="bubble_left"
app:cpv_showAlphaSlider="true"
app:dependency="bubble_color"
app:summary="Set color #00000000 to default color"
app:title="@string/bubble_left" />

<com.jaredrummler.android.colorpicker.ColorPreferenceCompat
app:key="bubble_right"
app:dependency="bubble_color"
app:cpv_showAlphaSlider="true"
app:summary="Set color #00000000 to default color"
app:title="@string/bubble_right" />
</PreferenceCategory>

Expand Down

0 comments on commit cb86c6c

Please sign in to comment.