11package com .wmods .wppenhacer .xposed .features .others ;
22
3+ import android .graphics .drawable .ColorDrawable ;
34import android .os .Bundle ;
45import android .view .View ;
56import android .widget .EditText ;
1112import com .wmods .wppenhacer .xposed .core .WppCore ;
1213import com .wmods .wppenhacer .xposed .core .devkit .Unobfuscator ;
1314import com .wmods .wppenhacer .xposed .utils .ReflectionUtils ;
15+ import com .wmods .wppenhacer .xposed .utils .ResId ;
1416import com .wmods .wppenhacer .xposed .utils .Utils ;
1517
1618import java .lang .reflect .Field ;
2325
2426public class TextStatusComposer extends Feature {
2527 private static final AtomicReference <ColorData > colorData = new AtomicReference <>();
28+ private static final AtomicReference <Object > textComposerModel = new AtomicReference <>();
2629
2730 public TextStatusComposer (@ NonNull ClassLoader classLoader , @ NonNull XSharedPreferences preferences ) {
2831 super (classLoader , preferences );
@@ -34,6 +37,27 @@ public void doHook() throws Throwable {
3437
3538 var setColorTextComposer = Unobfuscator .loadTextStatusComposer (classLoader );
3639 log ("setColorTextComposer: " + Unobfuscator .getMethodDescriptor (setColorTextComposer ));
40+
41+ if (setColorTextComposer != null ) {
42+ XposedBridge .hookAllConstructors (setColorTextComposer .getDeclaringClass (), new XC_MethodHook () {
43+ @ Override
44+ protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
45+ textComposerModel .set (param .thisObject );
46+ }
47+ });
48+ var arrMethod = ReflectionUtils .findMethodUsingFilter (setColorTextComposer .getDeclaringClass (), method -> method .getParameterCount () == 1 && method .getParameterTypes ()[0 ] == int .class && method .getReturnType () == int .class );
49+ XposedBridge .hookMethod (arrMethod , new XC_MethodHook () {
50+ @ Override
51+ protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
52+ try {
53+ param .setResult (XposedBridge .invokeOriginalMethod (param .method , param .thisObject , param .args ));
54+ } catch (Exception e ) {
55+ param .setResult (ResId .string .app_name );
56+ }
57+ }
58+ });
59+ }
60+
3761 var clazz = XposedHelpers .findClass ("com.whatsapp.statuscomposer.composer.TextStatusComposerFragment" , classLoader );
3862 var methodOnCreate = ReflectionUtils .findMethodUsingFilter (clazz , method -> method .getParameterCount () == 2 && method .getParameterTypes ()[0 ] == Bundle .class && method .getParameterTypes ()[1 ] == View .class );
3963 XposedBridge .hookMethod (methodOnCreate ,
@@ -49,9 +73,17 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
4973 pickerColor .setOnLongClickListener (v -> {
5074 var dialog = new SimpleColorPickerDialog (activity , color -> {
5175 try {
52- Field fieldInt = ReflectionUtils .findFieldUsingFilter (param .thisObject .getClass (), field -> field .getType () == int .class );
53- fieldInt .setInt (param .thisObject , color );
54- ReflectionUtils .callMethod (setColorTextComposer , null , param .thisObject );
76+ if (setColorTextComposer != null ) {
77+ var mInstance = textComposerModel .get ();
78+ ReflectionUtils .callMethod (setColorTextComposer , mInstance , color );
79+ } else {
80+ Field fieldInt = ReflectionUtils .getFieldByType (param .thisObject .getClass (), int .class );
81+ fieldInt .setInt (param .thisObject , color );
82+ }
83+ activity .getWindow ().setBackgroundDrawable (new ColorDrawable (color ));
84+ var controls = viewRoot .findViewById (Utils .getID ("controls" , "id" ));
85+ controls .setBackgroundColor (color );
86+
5587 } catch (Exception e ) {
5688 log (e );
5789 }
0 commit comments