77import android .text .TextUtils ;
88import android .view .Gravity ;
99import android .view .View ;
10+ import android .view .ViewGroup ;
1011import android .view .ViewStub ;
1112import android .widget .LinearLayout ;
1213import android .widget .TextView ;
@@ -105,7 +106,7 @@ public MethodHook(boolean showName, boolean showBio, String typeArchive) {
105106 protected void afterHookedMethod (MethodHookParam param ) throws Throwable {
106107 var homeActivity = (Activity ) param .thisObject ;
107108 var actionbar = XposedHelpers .callMethod (homeActivity , "getSupportActionBar" );
108- var toolbar = homeActivity .findViewById (Utils .getID ("toolbar" , "id" ));
109+ var toolbar = ( ViewGroup ) homeActivity .findViewById (Utils .getID ("toolbar" , "id" ));
109110 var logo = toolbar .findViewById (Utils .getID ("toolbar_logo" , "id" ));
110111 var name = WppCore .getMyName ();
111112 var bio = WppCore .getMyBio ();
@@ -132,11 +133,11 @@ public void onMultiClick(View v) {
132133 }
133134
134135 if (!showBio && !showName ) return ;
136+ var parent = (ViewGroup ) logo .getParent ();
135137
136- if (!(logo . getParent () instanceof LinearLayout parent ) ) {
138+ if (!(parent instanceof LinearLayout ) && logo . getVisibility () == View . VISIBLE ) {
137139 var methods = Arrays .stream (actionbar .getClass ().getDeclaredMethods ()).filter (m -> m .getParameterCount () == 1 && m .getParameterTypes ()[0 ] == CharSequence .class ).toArray (Method []::new );
138140
139-
140141 if (showName ) {
141142 methods [1 ].invoke (actionbar , name );
142143 }
@@ -159,19 +160,42 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
159160 param .args [0 ] = name ;
160161 }
161162 if (logo instanceof ViewStub stub ) {
162- stub .setLayoutParams (new LinearLayout .LayoutParams (1 , 1 ));
163+ var layoutParams = stub .getLayoutParams ();
164+ layoutParams .width = 1 ;
165+ layoutParams .height = 200 ;
166+ stub .setLayoutParams (layoutParams );
163167 }
164168 }
165169 });
166170
167171 return ;
168172 }
173+ LinearLayout layout ;
174+ if (parent instanceof LinearLayout ) {
175+ layout = (LinearLayout ) parent ;
176+ } else {
177+ layout = new LinearLayout (homeActivity );
178+ layout .setOrientation (LinearLayout .VERTICAL );
179+ toolbar .removeAllViews ();
180+ parent .addView (layout , 0 );
181+ var clazzWDS = XposedHelpers .findClass ("com.whatsapp.wds.components.topbar.WDSToolbar" , homeActivity .getClassLoader ());
182+ if (clazzWDS .isInstance (toolbar )) {
183+ XposedHelpers .callMethod (toolbar , "setTitle" , (CharSequence ) null );
184+ XposedHelpers .findAndHookMethod (clazzWDS , "setTitle" , CharSequence .class , new XC_MethodHook () {
185+ @ Override
186+ protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
187+ if (param .thisObject != toolbar ) return ;
188+ param .setResult (null );
189+ }
190+ });
191+ }
192+ }
169193 var mTitle = new TextView (homeActivity );
170194 mTitle .setText (showName ? name : "WhatsApp" );
171195 mTitle .setLayoutParams (new LinearLayout .LayoutParams (LinearLayout .LayoutParams .WRAP_CONTENT , LinearLayout .LayoutParams .MATCH_PARENT , 1f ));
172196 mTitle .setTextSize (18f );
173197 mTitle .setTextColor (DesignUtils .getPrimaryTextColor ());
174- parent .addView (mTitle );
198+ layout .addView (mTitle );
175199 if (showBio ) {
176200 TextView mSubtitle = new TextView (homeActivity );
177201 mSubtitle .setLayoutParams (new LinearLayout .LayoutParams (LinearLayout .LayoutParams .WRAP_CONTENT , LinearLayout .LayoutParams .MATCH_PARENT ));
@@ -182,7 +206,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
182206 mSubtitle .setEllipsize (TextUtils .TruncateAt .MARQUEE );
183207 mSubtitle .setSingleLine ();
184208 mSubtitle .setSelected (true );
185- parent .addView (mSubtitle );
209+ layout .addView (mSubtitle );
186210 } else {
187211 mTitle .setGravity (Gravity .CENTER );
188212 }
0 commit comments