@@ -213,19 +213,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
213
213
214
214
// insert app key
215
215
ViewGroup vRot , navButtons ;
216
- LinearLayout .LayoutParams lp ;
217
216
218
217
// insert app key in rot0 view
219
218
vRot = (ViewGroup ) ((ViewGroup ) param .thisObject ).findViewById (
220
219
mResources .getIdentifier ("rot0" , "id" , PACKAGE_NAME ));
221
220
if (vRot != null ) {
222
221
KeyButtonView appKey = new KeyButtonView (context );
223
- lp = new LinearLayout .LayoutParams (
224
- (int ) TypedValue .applyDimension (TypedValue .COMPLEX_UNIT_DIP , 40 ,
225
- mResources .getDisplayMetrics ()),
226
- LinearLayout .LayoutParams .MATCH_PARENT );
227
- lp .weight = 0 ;
228
- appKey .setLayoutParams (lp );
229
222
appKey .setScaleType (ScaleType .FIT_CENTER );
230
223
appKey .setClickable (true );
231
224
appKey .setImageDrawable (gbRes .getDrawable (R .drawable .ic_sysbar_apps ));
@@ -240,19 +233,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
240
233
mResources .getIdentifier ("rot90" , "id" , PACKAGE_NAME ));
241
234
if (vRot != null ) {
242
235
KeyButtonView appKey = new KeyButtonView (context );
243
- if (Utils .isPhoneUI (context )) {
244
- lp = new LinearLayout .LayoutParams (
245
- LinearLayout .LayoutParams .MATCH_PARENT ,
246
- (int ) TypedValue .applyDimension (TypedValue .COMPLEX_UNIT_DIP , 40 ,
247
- mResources .getDisplayMetrics ()));
248
- } else {
249
- lp = new LinearLayout .LayoutParams (
250
- (int ) TypedValue .applyDimension (TypedValue .COMPLEX_UNIT_DIP , 40 ,
251
- mResources .getDisplayMetrics ()),
252
- LinearLayout .LayoutParams .MATCH_PARENT );
253
- }
254
- lp .weight = 0 ;
255
- appKey .setLayoutParams (lp );
256
236
appKey .setClickable (true );
257
237
appKey .setImageDrawable (gbRes .getDrawable (R .drawable .ic_sysbar_apps ));
258
238
appKey .setOnClickListener (mAppKeyOnClickListener );
@@ -297,6 +277,10 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
297
277
298
278
private static void prepareNavbarViewInfo (ViewGroup navButtons , int index , KeyButtonView appView ) {
299
279
try {
280
+ final int size = (int ) TypedValue .applyDimension (TypedValue .COMPLEX_UNIT_DIP ,
281
+ 40 , navButtons .getResources ().getDisplayMetrics ());
282
+ if (DEBUG ) log ("App key view minimum size=" + size );
283
+
300
284
mNavbarViewInfo [index ] = new NavbarViewInfo ();
301
285
mNavbarViewInfo [index ].navButtons = navButtons ;
302
286
mNavbarViewInfo [index ].appLauncherView = appView ;
@@ -313,6 +297,47 @@ private static void prepareNavbarViewInfo(ViewGroup navButtons, int index, KeyBu
313
297
}
314
298
}
315
299
mNavbarViewInfo [index ].position = searchPosition ;
300
+
301
+ // determine app key layout
302
+ LinearLayout .LayoutParams lp = null ;
303
+ if (mNavbarViewInfo [index ].originalView != null ) {
304
+ // determine layout from layout of placeholder view we found
305
+ ViewGroup .LayoutParams ovlp = mNavbarViewInfo [index ].originalView .getLayoutParams ();
306
+ if (DEBUG ) log ("originalView: lpWidth=" + ovlp .width + "; lpHeight=" + ovlp .height );
307
+ if (ovlp .width >= 0 ) {
308
+ lp = new LinearLayout .LayoutParams (size , LinearLayout .LayoutParams .MATCH_PARENT , 0 );
309
+ } else if (ovlp .height >= 0 ) {
310
+ lp = new LinearLayout .LayoutParams (LinearLayout .LayoutParams .MATCH_PARENT , size , 0 );
311
+ } else {
312
+ log ("Weird layout of placeholder view detected" );
313
+ }
314
+ } else {
315
+ // determine layout from Back key
316
+ final int resId = navButtons .getResources ().getIdentifier ("back" , "id" , PACKAGE_NAME );
317
+ if (resId != 0 ) {
318
+ View back = navButtons .findViewById (resId );
319
+ if (back != null ) {
320
+ ViewGroup .LayoutParams blp = back .getLayoutParams ();
321
+ if (blp .width >= 0 ) {
322
+ lp = new LinearLayout .LayoutParams (size , LinearLayout .LayoutParams .MATCH_PARENT , 0 );
323
+ } else if (blp .height >= 0 ) {
324
+ lp = new LinearLayout .LayoutParams (LinearLayout .LayoutParams .MATCH_PARENT , size , 0 );
325
+ } else {
326
+ log ("Weird layout of back button view detected" );
327
+ }
328
+ } else {
329
+ log ("Could not find back button view" );
330
+ }
331
+ } else {
332
+ log ("Could not find back button resource ID" );
333
+ }
334
+ }
335
+ // worst case scenario (should never happen, but just to make sure)
336
+ if (lp == null ) {
337
+ lp = new LinearLayout .LayoutParams (size , size , 0 );
338
+ }
339
+ if (DEBUG ) log ("appView: lpWidth=" + lp .width + "; lpHeight=" + lp .height );
340
+ mNavbarViewInfo [index ].appLauncherView .setLayoutParams (lp );
316
341
} catch (Throwable t ) {
317
342
log ("Error preparing NavbarViewInfo: " + t .getMessage ());
318
343
}
0 commit comments