soul-browser/sources/java/com/google/android/material/internal/NavigationMenuItemView.java
KaKi87 550ddb0413
Decompile and recreate Soul Browser v1.4.85 with APK CI builds (#1)
* Decompile and recreate Soul Browser v1.4.85 with APK CI builds

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix CI build: include bundled google.jks and remove PR trigger

The apktool build failed in CI because app/unknown/.../google.jks was
excluded by the *.jks gitignore rule. Whitelist app-bundled JKS files
and commit the missing resource.

Also remove the redundant pull_request workflow trigger.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Change package ID to com.github.kaki87.soulbrowser

Rename the application ID so the rebuilt APK can be installed
alongside the original Soul Browser from Google Play.

- Update AndroidManifest package, permissions, providers, and actions
- Update R class references in smali (com/github/kaki87/soulbrowser/R)
- Update shortcuts.xml targetPackage
- Rename app label to "Soul Rebuild" for easy identification

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix install compatibility: remove split APK metadata and bundle native libs

The rebuilt APK still declared requiredSplitTypes and Play Store split
metadata, causing Android to reject standalone installs as incompatible.

- Remove requiredSplitTypes and split-related manifest meta-data
- Merge native libs from all ABI splits with uncompressed storage
- Page-align before signing for extractNativeLibs=false
- Add .so to apktool doNotCompress list

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix install failure: use apksigner v2/v3 and bundle arm64 native libs

Target SDK 36 requires APK Signature Scheme v2+, but jarsigner only
produces v1 signatures, causing Android to reject the install.

- Sign with apksigner (v1+v2+v3) instead of jarsigner
- Add arm64-v8a native libraries from universal Soul Browser 1.4.79
- Set extractNativeLibs=true for reliable sideload installs
- Commit stable debug keystore for consistent signatures across builds

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Add committed debug keystore for consistent APK signatures

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix startup crash: use original classes2.dex desugar libraries

Apktool recompiles smali_classes2 into a broken classes2.dex, causing
ClassNotFoundException for j$.com.android.tools.r8.a at ML Kit init.

Inject the original classes2.dex (Java 8+ desugar libs) after apktool
build instead of using the recompiled version.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix missing drawable resources from density split APKs

The base APK is an app bundle module; density-specific drawables like
seek_thumb_nor_b live in config.xhdpi.apk and were missing after rebuild,
causing Resources$NotFoundException at runtime.

- Merge non-9-patch resources from split APKs before apktool build
- Sync public.xml IDs from R smali only when backing files exist
- Add 713 density-specific resource IDs to public.xml

Co-authored-by: KaKi87 <KaKi87@pm.me>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-08-10 16:07:14 +02:00

253 lines
9.4 KiB
Java

package com.google.android.material.internal;
import android.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.CheckedTextView;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.annotation.Dimension;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.appcompat.view.menu.MenuItemImpl;
import androidx.appcompat.view.menu.MenuView;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.appcompat.widget.TooltipCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
@RestrictTo
/* loaded from: classes3.dex */
public class NavigationMenuItemView extends ForegroundLinearLayout implements MenuView.ItemView {
public static final int[] K = {R.attr.state_checked};
public boolean A;
public boolean B;
public final boolean C;
public final CheckedTextView D;
public FrameLayout E;
public MenuItemImpl F;
public ColorStateList G;
public boolean H;
public Drawable I;
public final AccessibilityDelegateCompat J;
public int z;
public NavigationMenuItemView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
super(context, attributeSet);
this.C = true;
AccessibilityDelegateCompat accessibilityDelegateCompat = new AccessibilityDelegateCompat() { // from class: com.google.android.material.internal.NavigationMenuItemView.1
@Override // androidx.core.view.AccessibilityDelegateCompat
public final void d(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
AccessibilityNodeInfo accessibilityNodeInfo = accessibilityNodeInfoCompat.f834a;
this.f760a.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfo);
accessibilityNodeInfo.setCheckable(NavigationMenuItemView.this.B);
}
};
this.J = accessibilityDelegateCompat;
setOrientation(0);
LayoutInflater.from(context).inflate(com.google.android.material.R.layout.design_navigation_menu_item, (ViewGroup) this, true);
setIconSize(context.getResources().getDimensionPixelSize(com.google.android.material.R.dimen.design_navigation_icon_size));
CheckedTextView checkedTextView = (CheckedTextView) findViewById(com.google.android.material.R.id.design_menu_item_text);
this.D = checkedTextView;
ViewCompat.z(checkedTextView, accessibilityDelegateCompat);
}
private void setActionView(@Nullable View view) {
if (view != null) {
if (this.E == null) {
this.E = (FrameLayout) ((ViewStub) findViewById(com.google.android.material.R.id.design_menu_item_action_area_stub)).inflate();
}
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
this.E.removeAllViews();
this.E.addView(view);
}
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public final void c(MenuItemImpl menuItemImpl) {
int i;
StateListDrawable stateListDrawable;
this.F = menuItemImpl;
int i2 = menuItemImpl.f179a;
if (i2 > 0) {
setId(i2);
}
if (menuItemImpl.isVisible()) {
i = 0;
} else {
i = 8;
}
setVisibility(i);
if (getBackground() == null) {
TypedValue typedValue = new TypedValue();
if (getContext().getTheme().resolveAttribute(androidx.appcompat.R.attr.colorControlHighlight, typedValue, true)) {
stateListDrawable = new StateListDrawable();
stateListDrawable.addState(K, new ColorDrawable(typedValue.data));
stateListDrawable.addState(ViewGroup.EMPTY_STATE_SET, new ColorDrawable(0));
} else {
stateListDrawable = null;
}
setBackground(stateListDrawable);
}
setCheckable(menuItemImpl.isCheckable());
setChecked(menuItemImpl.isChecked());
setEnabled(menuItemImpl.isEnabled());
setTitle(menuItemImpl.e);
setIcon(menuItemImpl.getIcon());
setActionView(menuItemImpl.getActionView());
setContentDescription(menuItemImpl.q);
TooltipCompat.a(this, menuItemImpl.r);
MenuItemImpl menuItemImpl2 = this.F;
CharSequence charSequence = menuItemImpl2.e;
CheckedTextView checkedTextView = this.D;
if (charSequence == null && menuItemImpl2.getIcon() == null && this.F.getActionView() != null) {
checkedTextView.setVisibility(8);
FrameLayout frameLayout = this.E;
if (frameLayout != null) {
LinearLayoutCompat.LayoutParams layoutParams = (LinearLayoutCompat.LayoutParams) frameLayout.getLayoutParams();
((LinearLayout.LayoutParams) layoutParams).width = -1;
this.E.setLayoutParams(layoutParams);
return;
}
return;
}
checkedTextView.setVisibility(0);
FrameLayout frameLayout2 = this.E;
if (frameLayout2 != null) {
LinearLayoutCompat.LayoutParams layoutParams2 = (LinearLayoutCompat.LayoutParams) frameLayout2.getLayoutParams();
((LinearLayout.LayoutParams) layoutParams2).width = -2;
this.E.setLayoutParams(layoutParams2);
}
}
@Override // androidx.appcompat.view.menu.MenuView.ItemView
public MenuItemImpl getItemData() {
return this.F;
}
@Override // android.view.ViewGroup, android.view.View
public final int[] onCreateDrawableState(int i) {
int[] onCreateDrawableState = super.onCreateDrawableState(i + 1);
MenuItemImpl menuItemImpl = this.F;
if (menuItemImpl != null && menuItemImpl.isCheckable() && this.F.isChecked()) {
View.mergeDrawableStates(onCreateDrawableState, K);
}
return onCreateDrawableState;
}
public void setCheckable(boolean z) {
refreshDrawableState();
if (this.B != z) {
this.B = z;
this.J.h(this.D, 2048);
}
}
public void setChecked(boolean z) {
int i;
refreshDrawableState();
CheckedTextView checkedTextView = this.D;
checkedTextView.setChecked(z);
Typeface typeface = checkedTextView.getTypeface();
if (z && this.C) {
i = 1;
} else {
i = 0;
}
checkedTextView.setTypeface(typeface, i);
}
public void setHorizontalPadding(int i) {
setPadding(i, getPaddingTop(), i, getPaddingBottom());
}
public void setIcon(@Nullable Drawable drawable) {
if (drawable != null) {
if (this.H) {
Drawable.ConstantState constantState = drawable.getConstantState();
if (constantState != null) {
drawable = constantState.newDrawable();
}
drawable = drawable.mutate();
drawable.setTintList(this.G);
}
int i = this.z;
drawable.setBounds(0, 0, i, i);
} else if (this.A) {
if (this.I == null) {
Resources resources = getResources();
int i2 = com.google.android.material.R.drawable.navigation_empty_icon;
Resources.Theme theme = getContext().getTheme();
ThreadLocal threadLocal = ResourcesCompat.f668a;
Drawable drawable2 = resources.getDrawable(i2, theme);
this.I = drawable2;
if (drawable2 != null) {
int i3 = this.z;
drawable2.setBounds(0, 0, i3, i3);
}
}
drawable = this.I;
}
this.D.setCompoundDrawablesRelative(drawable, null, null, null);
}
public void setIconPadding(int i) {
this.D.setCompoundDrawablePadding(i);
}
public void setIconSize(@Dimension int i) {
this.z = i;
}
public void setIconTintList(ColorStateList colorStateList) {
boolean z;
this.G = colorStateList;
if (colorStateList != null) {
z = true;
} else {
z = false;
}
this.H = z;
MenuItemImpl menuItemImpl = this.F;
if (menuItemImpl != null) {
setIcon(menuItemImpl.getIcon());
}
}
public void setMaxLines(int i) {
this.D.setMaxLines(i);
}
public void setNeedsEmptyIcon(boolean z) {
this.A = z;
}
public void setTextAppearance(int i) {
this.D.setTextAppearance(i);
}
public void setTextColor(ColorStateList colorStateList) {
this.D.setTextColor(colorStateList);
}
public void setTitle(CharSequence charSequence) {
this.D.setText(charSequence);
}
}