From 362c580cccc8c390bce87ab91dfeaf4cbfe9a0a5 Mon Sep 17 00:00:00 2001 From: Dev4Mod Date: Mon, 13 Jan 2025 21:27:56 -0300 Subject: [PATCH] fix bug in CustomToolbar Signed-off-by: Dev4Mod --- .../features/customization/CustomToolbar.java | 104 +++++------------- 1 file changed, 28 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomToolbar.java b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomToolbar.java index 0bd7b2ff..b305cc78 100644 --- a/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomToolbar.java +++ b/app/src/main/java/com/wmods/wppenhacer/xposed/features/customization/CustomToolbar.java @@ -4,12 +4,8 @@ import android.app.Activity; import android.content.Intent; import android.os.Bundle; -import android.text.TextUtils; -import android.view.Gravity; import android.view.View; import android.view.ViewGroup; -import android.view.ViewStub; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -18,7 +14,7 @@ import com.wmods.wppenhacer.xposed.core.Feature; import com.wmods.wppenhacer.xposed.core.WppCore; import com.wmods.wppenhacer.xposed.core.devkit.Unobfuscator; -import com.wmods.wppenhacer.xposed.utils.DesignUtils; +import com.wmods.wppenhacer.xposed.features.general.Others; import com.wmods.wppenhacer.xposed.utils.ReflectionUtils; import com.wmods.wppenhacer.xposed.utils.ResId; import com.wmods.wppenhacer.xposed.utils.Utils; @@ -50,6 +46,8 @@ public void doHook() throws Exception { var typeArchive = prefs.getString("typearchive", "0"); var methodHook = new MethodHook(showName, showBio, typeArchive); XposedHelpers.findAndHookMethod("com.whatsapp.HomeActivity", classLoader, "onCreate", Bundle.class, methodHook); + Others.propsBoolean.put(6481, false); + Others.propsBoolean.put(5353, true); expirationAboutInfo(); } @@ -133,84 +131,38 @@ public void onMultiClick(View v) { } if (!showBio && !showName) return; - var parent = (ViewGroup) logo.getParent(); - if (!(parent instanceof LinearLayout) && logo.getVisibility() == View.VISIBLE) { - var methods = Arrays.stream(actionbar.getClass().getDeclaredMethods()).filter(m -> m.getParameterCount() == 1 && m.getParameterTypes()[0] == CharSequence.class).toArray(Method[]::new); + var methods = Arrays.stream(actionbar.getClass().getDeclaredMethods()).filter(m -> m.getParameterCount() == 1 && m.getParameterTypes()[0] == CharSequence.class).toArray(Method[]::new); - if (showName) { - methods[1].invoke(actionbar, name); - } + if (showName) { + methods[1].invoke(actionbar, name); + } - if (showBio) { - methods[0].invoke(actionbar, bio); - } + if (showBio) { + methods[0].invoke(actionbar, bio); + } - XposedBridge.hookMethod(methods[1], new XC_MethodHook() { - @Override - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - var name = WppCore.getMyName(); - var bio = WppCore.getMyBio(); - if (showBio && (param.args[0] == "" || param.args[0] == "WhatsApp")) { - ReflectionUtils.callMethod(methods[0], param.thisObject, bio); - } else { - ReflectionUtils.callMethod(methods[0], param.thisObject, ""); - } - if (showName && (param.args[0] == "" || param.args[0] == "WhatsApp")) { - param.args[0] = name; - } - if (logo instanceof ViewStub stub) { - var layoutParams = stub.getLayoutParams(); - layoutParams.width = 1; - layoutParams.height = 200; - stub.setLayoutParams(layoutParams); - } + XposedBridge.hookMethod(methods[1], new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + var name = WppCore.getMyName(); + var bio = WppCore.getMyBio(); + if (showBio && (param.args[0] == "" || param.args[0] == "WhatsApp")) { + ReflectionUtils.callMethod(methods[0], param.thisObject, bio); + } else { + ReflectionUtils.callMethod(methods[0], param.thisObject, ""); + } + if (showName && (param.args[0] == "" || param.args[0] == "WhatsApp")) { + param.args[0] = name; } - }); - return; - } - LinearLayout layout; - if (parent instanceof LinearLayout) { - layout = (LinearLayout) parent; - } else { - layout = new LinearLayout(homeActivity); - layout.setOrientation(LinearLayout.VERTICAL); - toolbar.removeAllViews(); - parent.addView(layout, 0); - var clazzWDS = XposedHelpers.findClass("com.whatsapp.wds.components.topbar.WDSToolbar", homeActivity.getClassLoader()); - if (clazzWDS.isInstance(toolbar)) { - XposedHelpers.callMethod(toolbar, "setTitle", (CharSequence) null); - XposedHelpers.findAndHookMethod(clazzWDS, "setTitle", CharSequence.class, new XC_MethodHook() { - @Override - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - if (param.thisObject != toolbar) return; - param.setResult(null); - } - }); + var layoutParams = logo.getLayoutParams(); + layoutParams.width = 1; + layoutParams.height = 1; + logo.setLayoutParams(layoutParams); + } - } - var mTitle = new TextView(homeActivity); - mTitle.setText(showName ? name : "WhatsApp"); - mTitle.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); - mTitle.setTextSize(18f); - mTitle.setTextColor(DesignUtils.getPrimaryTextColor()); - layout.addView(mTitle); - if (showBio) { - TextView mSubtitle = new TextView(homeActivity); - mSubtitle.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); - mSubtitle.setText(bio); - mSubtitle.setTextSize(12f); - mSubtitle.setTextColor(DesignUtils.getPrimaryTextColor()); - mSubtitle.setMarqueeRepeatLimit(-1); - mSubtitle.setEllipsize(TextUtils.TruncateAt.MARQUEE); - mSubtitle.setSingleLine(); - mSubtitle.setSelected(true); - layout.addView(mSubtitle); - } else { - mTitle.setGravity(Gravity.CENTER); - } - parent.removeView(logo); + }); } } }