soul-browser/sources/java/androidx/appcompat/widget/MenuPopupWindow.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

201 lines
7.4 KiB
Java

package androidx.appcompat.widget;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.transition.Transition;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.widget.HeaderViewListAdapter;
import android.widget.ListAdapter;
import android.widget.PopupWindow;
import androidx.annotation.DoNotInline;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.appcompat.view.menu.ListMenuItemView;
import androidx.appcompat.view.menu.MenuAdapter;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.view.menu.MenuItemImpl;
import java.lang.reflect.Method;
@RestrictTo
/* loaded from: classes.dex */
public class MenuPopupWindow extends ListPopupWindow implements MenuItemHoverListener {
public static final Method I;
public MenuItemHoverListener H;
@RequiresApi
/* loaded from: classes.dex */
public static class Api23Impl {
@DoNotInline
public static void a(PopupWindow popupWindow, Transition transition) {
popupWindow.setEnterTransition(transition);
}
@DoNotInline
public static void b(PopupWindow popupWindow, Transition transition) {
popupWindow.setExitTransition(transition);
}
}
@RequiresApi
/* loaded from: classes.dex */
public static class Api29Impl {
@DoNotInline
public static void a(PopupWindow popupWindow, boolean z) {
popupWindow.setTouchModal(z);
}
}
@RestrictTo
/* loaded from: classes.dex */
public static class MenuDropDownListView extends DropDownListView {
public final int q;
public final int r;
public MenuItemHoverListener s;
public MenuItemImpl t;
public MenuDropDownListView(Context context, boolean z) {
super(context, z);
if (1 == context.getResources().getConfiguration().getLayoutDirection()) {
this.q = 21;
this.r = 22;
} else {
this.q = 22;
this.r = 21;
}
}
@Override // androidx.appcompat.widget.DropDownListView, android.view.View
public final boolean onHoverEvent(MotionEvent motionEvent) {
MenuAdapter menuAdapter;
int i;
MenuItemImpl menuItemImpl;
int pointToPosition;
int i2;
if (this.s != null) {
ListAdapter adapter = getAdapter();
if (adapter instanceof HeaderViewListAdapter) {
HeaderViewListAdapter headerViewListAdapter = (HeaderViewListAdapter) adapter;
i = headerViewListAdapter.getHeadersCount();
menuAdapter = (MenuAdapter) headerViewListAdapter.getWrappedAdapter();
} else {
menuAdapter = (MenuAdapter) adapter;
i = 0;
}
if (motionEvent.getAction() != 10 && (pointToPosition = pointToPosition((int) motionEvent.getX(), (int) motionEvent.getY())) != -1 && (i2 = pointToPosition - i) >= 0 && i2 < menuAdapter.getCount()) {
menuItemImpl = menuAdapter.getItem(i2);
} else {
menuItemImpl = null;
}
MenuItemImpl menuItemImpl2 = this.t;
if (menuItemImpl2 != menuItemImpl) {
MenuBuilder menuBuilder = menuAdapter.f175c;
if (menuItemImpl2 != null) {
this.s.g(menuBuilder, menuItemImpl2);
}
this.t = menuItemImpl;
if (menuItemImpl != null) {
this.s.d(menuBuilder, menuItemImpl);
}
}
}
return super.onHoverEvent(motionEvent);
}
@Override // android.widget.ListView, android.widget.AbsListView, android.view.View, android.view.KeyEvent.Callback
public final boolean onKeyDown(int i, KeyEvent keyEvent) {
MenuAdapter menuAdapter;
ListMenuItemView listMenuItemView = (ListMenuItemView) getSelectedView();
if (listMenuItemView != null && i == this.q) {
if (listMenuItemView.isEnabled() && listMenuItemView.getItemData().hasSubMenu()) {
performItemClick(listMenuItemView, getSelectedItemPosition(), getSelectedItemId());
}
return true;
}
if (listMenuItemView != null && i == this.r) {
setSelection(-1);
ListAdapter adapter = getAdapter();
if (adapter instanceof HeaderViewListAdapter) {
menuAdapter = (MenuAdapter) ((HeaderViewListAdapter) adapter).getWrappedAdapter();
} else {
menuAdapter = (MenuAdapter) adapter;
}
menuAdapter.f175c.c(false);
return true;
}
return super.onKeyDown(i, keyEvent);
}
public void setHoverListener(MenuItemHoverListener menuItemHoverListener) {
this.s = menuItemHoverListener;
}
@Override // androidx.appcompat.widget.DropDownListView, android.widget.AbsListView
public /* bridge */ /* synthetic */ void setSelector(Drawable drawable) {
super.setSelector(drawable);
}
}
static {
try {
if (Build.VERSION.SDK_INT <= 28) {
I = PopupWindow.class.getDeclaredMethod("setTouchModal", Boolean.TYPE);
}
} catch (NoSuchMethodException unused) {
Log.i("MenuPopupWindow", "Could not find method setTouchModal() on PopupWindow. Oh well.");
}
}
@Override // androidx.appcompat.widget.MenuItemHoverListener
public final void d(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
MenuItemHoverListener menuItemHoverListener = this.H;
if (menuItemHoverListener != null) {
menuItemHoverListener.d(menuBuilder, menuItemImpl);
}
}
@Override // androidx.appcompat.widget.MenuItemHoverListener
public final void g(MenuBuilder menuBuilder, MenuItem menuItem) {
MenuItemHoverListener menuItemHoverListener = this.H;
if (menuItemHoverListener != null) {
menuItemHoverListener.g(menuBuilder, menuItem);
}
}
@Override // androidx.appcompat.widget.ListPopupWindow
public final DropDownListView q(Context context, boolean z) {
MenuDropDownListView menuDropDownListView = new MenuDropDownListView(context, z);
menuDropDownListView.setHoverListener(this);
return menuDropDownListView;
}
public final void s() {
Api23Impl.a(this.D, null);
}
public final void t() {
Api23Impl.b(this.D, null);
}
public final void u() {
int i = Build.VERSION.SDK_INT;
PopupWindow popupWindow = this.D;
if (i <= 28) {
Method method = I;
if (method != null) {
try {
method.invoke(popupWindow, Boolean.FALSE);
return;
} catch (Exception unused) {
Log.i("MenuPopupWindow", "Could not invoke setTouchModal() on PopupWindow. Oh well.");
return;
}
}
return;
}
Api29Impl.a(popupWindow, false);
}
}