44import static com .wmods .wppenhacer .utils .IColors .backgroundColors ;
55import static com .wmods .wppenhacer .utils .IColors .primaryColors ;
66import static com .wmods .wppenhacer .utils .IColors .secondaryColors ;
7- import static de .robv .android .xposed .XposedHelpers .findAndHookMethod ;
87
98import android .Manifest ;
109import android .app .Activity ;
1110import android .content .pm .PackageManager ;
1211import android .content .res .AssetManager ;
1312import android .content .res .ColorStateList ;
14- import android .graphics .Paint ;
1513import android .graphics .drawable .Drawable ;
1614import android .os .Bundle ;
1715import android .util .TypedValue ;
1816import android .view .View ;
1917import android .view .ViewGroup ;
2018import android .widget .FrameLayout ;
21- import android .widget .TextView ;
2219
2320import androidx .annotation .NonNull ;
2421import androidx .core .content .ContextCompat ;
@@ -48,7 +45,7 @@ public class CustomThemeV2 extends Feature {
4845 private HashMap <String , String > navAlpha ;
4946 private HashMap <String , String > toolbarAlpha ;
5047 private Properties properties ;
51- private View mMainContainer ;
48+ private ViewGroup mContent ;
5249
5350 public CustomThemeV2 (@ NonNull ClassLoader classLoader , @ NonNull XSharedPreferences preferences ) {
5451 super (classLoader , preferences );
@@ -104,10 +101,6 @@ private void hookWallpaper() throws Exception {
104101
105102 toolbarAlpha = new HashMap <>(IColors .colors );
106103
107- // Corrigir cor verde na barra de ferramentas
108- var colorOrig = "#ff1b8755" ;
109- var color = toolbarAlpha .get (colorOrig );
110- if (Objects .equals (colorOrig , color )) toolbarAlpha .put (colorOrig , "#ffffffff" );
111104 var wallpaperToolbarAlpha = customWallpaper ? prefs .getInt ("wallpaper_alpha_toolbar" , 30 ) : Utils .tryParseInt (properties .getProperty ("wallpaper_alpha_toolbar" ), 30 );
112105 replaceTransparency (toolbarAlpha , (100 - wallpaperToolbarAlpha ) / 100.0f );
113106 }
@@ -130,14 +123,14 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
130123 WppCore .addListenerActivity ((activity , type ) -> {
131124 var isHome = homeClass .isInstance (activity );
132125 if (WppCore .ActivityChangeState .ChangeType .RESUMED == type && isHome ) {
133- mMainContainer = activity .findViewById (android .R .id .content );
134- if (mMainContainer != null ) {
135- replaceColors (mMainContainer , wallAlpha );
126+ mContent = activity .findViewById (android .R .id .content );
127+ if (mContent != null ) {
128+ replaceColors (mContent , wallAlpha );
136129 }
137130 } else if (WppCore .ActivityChangeState .ChangeType .CREATED == type && !isHome &&
138- !activity .getClass ().getSimpleName ().equals ("QuickContactActivity" )) {
139- if (mMainContainer != null ) {
140- replaceColors (mMainContainer , revertWallAlpha );
131+ !activity .getClass ().getSimpleName ().equals ("QuickContactActivity" ) && ! DesignUtils . isNightMode () ) {
132+ if (mContent != null ) {
133+ replaceColors (mContent , revertWallAlpha );
141134 }
142135 }
143136 });
@@ -181,6 +174,12 @@ public void hookColors() throws Throwable {
181174 backgroundColor = backgroundColorInt == 0 ? "0" : IColors .toString (backgroundColorInt );
182175 }
183176
177+ // Passa as cores de fundo para as cores secundárias no tema claro
178+ if (!DesignUtils .isNightMode ()) {
179+ secondaryColors .clear ();
180+ secondaryColors .putAll (backgroundColors );
181+ backgroundColors .clear ();
182+ }
184183
185184 if (prefs .getBoolean ("changecolor" , false ) || Objects .equals (properties .getProperty ("change_colors" ), "true" )) {
186185
@@ -205,24 +204,21 @@ public void hookColors() throws Throwable {
205204
206205 if (!DesignUtils .isNightMode ()) {
207206 backgroundColors .clear ();
207+ backgroundColors .put ("#ff1b8755" , "#ffffffff" );
208208 backgroundColors .put ("#ffffffff" , "#ffffffff" );
209209 backgroundColors .put ("ffffff" , "ffffff" );
210210 }
211211
212212 XposedBridge .hookAllMethods (AssetManager .class , "getResourceValue" , new XC_MethodHook () {
213213 @ Override
214214 protected void afterHookedMethod (MethodHookParam param ) throws Throwable {
215- var id = (int ) param .args [0 ];
216-
217215 var typedValue = (TypedValue ) param .args [2 ];
218- if ((id >= 0x7f060000 && id <= 0x7f06ffff ) || (id >= 0x01010000 && id <= 0x0101ffff )) {
219- if (typedValue .type >= TypedValue .TYPE_FIRST_INT
220- && typedValue .type <= TypedValue .TYPE_LAST_INT ) {
221- if (typedValue .data == 0 ) return ;
222- typedValue .data = IColors .getFromIntColor (typedValue .data , IColors .colors );
223- }
216+ if (typedValue .type >= TypedValue .TYPE_FIRST_INT
217+ && typedValue .type <= TypedValue .TYPE_LAST_INT ) {
218+ if (typedValue .data == 0 ) return ;
219+ if (checkNotApplyColor (typedValue .data )) return ;
220+ typedValue .data = IColors .getFromIntColor (typedValue .data , IColors .colors );
224221 }
225-
226222 }
227223 });
228224
@@ -247,9 +243,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
247243 }
248244 });
249245
250- var intBgHook = new IntBgColorHook ();
251- findAndHookMethod (Paint .class , "setColor" , int .class , intBgHook );
252- findAndHookMethod (TextView .class , "setTextColor" , int .class , intBgHook );
253246 }
254247
255248 private void replaceTransparency (HashMap <String , String > wallpaperColors , float mAlpha ) {
@@ -294,31 +287,12 @@ private static int getOriginalColor(String sColor) {
294287 return resultColor ;
295288 }
296289
297- public static class IntBgColorHook extends XC_MethodHook {
298-
299-
300- @ Override
301- protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
302- var color = (int ) param .args [0 ];
303- var sColor = IColors .toString (color );
304-
305- if (param .thisObject instanceof TextView textView ) {
306- var id = Utils .getID ("conversations_row_message_count" , "id" );
307- if (textView .getId () == id ) {
308- param .args [0 ] = IColors .parseColor ("#ff" + sColor .substring (sColor .length () == 9 ? 3 : 1 ));
309- return ;
310- }
311- } else if (param .thisObject instanceof Paint ) {
312- if (ReflectionUtils .isCalledFromStrings ("getValue" ) && !ReflectionUtils .isCalledFromStrings ("android.view" )) {
313- var resultColor = getOriginalColor (sColor );
314- if (resultColor != -1 ) {
315- param .args [0 ] = resultColor ;
316- return ;
317- }
318- }
319- }
320- param .args [0 ] = IColors .getFromIntColor (color , IColors .colors );
290+ private boolean checkNotApplyColor (int color ) {
291+ var activity = WppCore .getCurrentActivity ();
292+ if (activity != null && activity .getClass ().getSimpleName ().equals ("Conversation" ) && ReflectionUtils .isCalledFromStrings ("getValue" ) && !ReflectionUtils .isCalledFromStrings ("android.view" )) {
293+ return color != 0xff12181c ;
321294 }
295+ return false ;
322296 }
323297
324298 @ NonNull
0 commit comments