soul-browser/sources/java/androidx/fragment/app/DialogFragment.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

525 lines
19 KiB
Java

package androidx.fragment.app;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import androidx.activity.ComponentDialog;
import androidx.annotation.CallSuper;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.StyleRes;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;
import androidx.lifecycle.runtime.R;
import kotlin.jvm.internal.Intrinsics;
/* loaded from: classes.dex */
public class DialogFragment extends Fragment implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
private static final String SAVED_BACK_STACK_ID = "android:backStackId";
private static final String SAVED_CANCELABLE = "android:cancelable";
private static final String SAVED_DIALOG_STATE_TAG = "android:savedDialogState";
private static final String SAVED_INTERNAL_DIALOG_SHOWING = "android:dialogShowing";
private static final String SAVED_SHOWS_DIALOG = "android:showsDialog";
private static final String SAVED_STYLE = "android:style";
private static final String SAVED_THEME = "android:theme";
public static final int STYLE_NORMAL = 0;
public static final int STYLE_NO_FRAME = 2;
public static final int STYLE_NO_INPUT = 3;
public static final int STYLE_NO_TITLE = 1;
private boolean mCreatingDialog;
@Nullable
private Dialog mDialog;
private boolean mDismissed;
private Handler mHandler;
private boolean mShownByMe;
private boolean mViewDestroyed;
private Runnable mDismissRunnable = new Runnable() { // from class: androidx.fragment.app.DialogFragment.1
@Override // java.lang.Runnable
public final void run() {
DialogFragment dialogFragment = DialogFragment.this;
dialogFragment.mOnDismissListener.onDismiss(dialogFragment.mDialog);
}
};
private DialogInterface.OnCancelListener mOnCancelListener = new DialogInterface.OnCancelListener() { // from class: androidx.fragment.app.DialogFragment.2
@Override // android.content.DialogInterface.OnCancelListener
public final void onCancel(DialogInterface dialogInterface) {
DialogFragment dialogFragment = DialogFragment.this;
if (dialogFragment.mDialog != null) {
dialogFragment.onCancel(dialogFragment.mDialog);
}
}
};
private DialogInterface.OnDismissListener mOnDismissListener = new DialogInterface.OnDismissListener() { // from class: androidx.fragment.app.DialogFragment.3
@Override // android.content.DialogInterface.OnDismissListener
public final void onDismiss(DialogInterface dialogInterface) {
DialogFragment dialogFragment = DialogFragment.this;
if (dialogFragment.mDialog != null) {
dialogFragment.onDismiss(dialogFragment.mDialog);
}
}
};
private int mStyle = 0;
private int mTheme = 0;
private boolean mCancelable = true;
private boolean mShowsDialog = true;
private int mBackStackId = -1;
private Observer<LifecycleOwner> mObserver = new Observer<LifecycleOwner>() { // from class: androidx.fragment.app.DialogFragment.4
@Override // androidx.lifecycle.Observer
public final void a(Object obj) {
if (((LifecycleOwner) obj) != null) {
DialogFragment dialogFragment = DialogFragment.this;
if (dialogFragment.mShowsDialog) {
View requireView = dialogFragment.requireView();
if (requireView.getParent() == null) {
if (dialogFragment.mDialog != null) {
if (FragmentManager.J(3)) {
Log.d("FragmentManager", "DialogFragment " + this + " setting the content view on " + dialogFragment.mDialog);
}
dialogFragment.mDialog.setContentView(requireView);
return;
}
return;
}
throw new IllegalStateException("DialogFragment can not be attached to a container view");
}
}
}
};
private boolean mDialogCreated = false;
@Override // androidx.fragment.app.Fragment
@NonNull
public FragmentContainer createFragmentContainer() {
final FragmentContainer createFragmentContainer = super.createFragmentContainer();
return new FragmentContainer() { // from class: androidx.fragment.app.DialogFragment.5
@Override // androidx.fragment.app.FragmentContainer
public final View b(int i) {
FragmentContainer fragmentContainer = createFragmentContainer;
if (fragmentContainer.c()) {
return fragmentContainer.b(i);
}
return DialogFragment.this.onFindViewById(i);
}
@Override // androidx.fragment.app.FragmentContainer
public final boolean c() {
if (!createFragmentContainer.c() && !DialogFragment.this.onHasView()) {
return false;
}
return true;
}
};
}
public void dismiss() {
f(false, false, false);
}
public void dismissAllowingStateLoss() {
f(true, false, false);
}
@MainThread
public void dismissNow() {
f(false, false, true);
}
public final void f(boolean z, boolean z2, boolean z3) {
if (this.mDismissed) {
return;
}
this.mDismissed = true;
this.mShownByMe = false;
Dialog dialog = this.mDialog;
if (dialog != null) {
dialog.setOnDismissListener(null);
this.mDialog.dismiss();
if (!z2) {
if (Looper.myLooper() == this.mHandler.getLooper()) {
onDismiss(this.mDialog);
} else {
this.mHandler.post(this.mDismissRunnable);
}
}
}
this.mViewDestroyed = true;
if (this.mBackStackId >= 0) {
if (z3) {
FragmentManager parentFragmentManager = getParentFragmentManager();
int i = this.mBackStackId;
if (i >= 0) {
parentFragmentManager.R(i, 1);
} else {
parentFragmentManager.getClass();
throw new IllegalArgumentException(android.support.v4.media.a.e(i, "Bad id: "));
}
} else {
FragmentManager parentFragmentManager2 = getParentFragmentManager();
int i2 = this.mBackStackId;
parentFragmentManager2.getClass();
if (i2 >= 0) {
parentFragmentManager2.w(new FragmentManager.PopBackStackState(i2), z);
} else {
throw new IllegalArgumentException(android.support.v4.media.a.e(i2, "Bad id: "));
}
}
this.mBackStackId = -1;
return;
}
FragmentManager parentFragmentManager3 = getParentFragmentManager();
parentFragmentManager3.getClass();
BackStackRecord backStackRecord = new BackStackRecord(parentFragmentManager3);
backStackRecord.o = true;
backStackRecord.g(this);
if (z3) {
backStackRecord.e();
} else if (z) {
backStackRecord.i(true);
} else {
backStackRecord.i(false);
}
}
@Nullable
public Dialog getDialog() {
return this.mDialog;
}
public boolean getShowsDialog() {
return this.mShowsDialog;
}
@StyleRes
public int getTheme() {
return this.mTheme;
}
public boolean isCancelable() {
return this.mCancelable;
}
@Override // androidx.fragment.app.Fragment
@MainThread
@Deprecated
public void onActivityCreated(@Nullable Bundle bundle) {
super.onActivityCreated(bundle);
}
@Override // androidx.fragment.app.Fragment
@MainThread
public void onAttach(@NonNull Context context) {
super.onAttach(context);
getViewLifecycleOwnerLiveData().e(this.mObserver);
if (!this.mShownByMe) {
this.mDismissed = false;
}
}
public void onCancel(DialogInterface dialogInterface) {
}
@Override // androidx.fragment.app.Fragment
@MainThread
public void onCreate(@Nullable Bundle bundle) {
boolean z;
super.onCreate(bundle);
this.mHandler = new Handler();
if (this.mContainerId == 0) {
z = true;
} else {
z = false;
}
this.mShowsDialog = z;
if (bundle != null) {
this.mStyle = bundle.getInt(SAVED_STYLE, 0);
this.mTheme = bundle.getInt(SAVED_THEME, 0);
this.mCancelable = bundle.getBoolean(SAVED_CANCELABLE, true);
this.mShowsDialog = bundle.getBoolean(SAVED_SHOWS_DIALOG, this.mShowsDialog);
this.mBackStackId = bundle.getInt(SAVED_BACK_STACK_ID, -1);
}
}
public Dialog onCreateDialog(Bundle bundle) {
if (FragmentManager.J(3)) {
Log.d("FragmentManager", "onCreateDialog called for DialogFragment " + this);
}
return new ComponentDialog(requireContext(), getTheme());
}
@Override // androidx.fragment.app.Fragment
@MainThread
public void onDestroyView() {
super.onDestroyView();
Dialog dialog = this.mDialog;
if (dialog != null) {
this.mViewDestroyed = true;
dialog.setOnDismissListener(null);
this.mDialog.dismiss();
if (!this.mDismissed) {
onDismiss(this.mDialog);
}
this.mDialog = null;
this.mDialogCreated = false;
}
}
@Override // androidx.fragment.app.Fragment
@MainThread
public void onDetach() {
super.onDetach();
if (!this.mShownByMe && !this.mDismissed) {
this.mDismissed = true;
}
getViewLifecycleOwnerLiveData().h(this.mObserver);
}
@Override // android.content.DialogInterface.OnDismissListener
@CallSuper
public void onDismiss(@NonNull DialogInterface dialogInterface) {
if (!this.mViewDestroyed) {
if (FragmentManager.J(3)) {
Log.d("FragmentManager", "onDismiss called for DialogFragment " + this);
}
f(true, true, false);
}
}
@Nullable
public View onFindViewById(int i) {
Dialog dialog = this.mDialog;
if (dialog != null) {
return dialog.findViewById(i);
}
return null;
}
@Override // androidx.fragment.app.Fragment
@NonNull
public LayoutInflater onGetLayoutInflater(@Nullable Bundle bundle) {
LayoutInflater onGetLayoutInflater = super.onGetLayoutInflater(bundle);
boolean z = this.mShowsDialog;
if (z && !this.mCreatingDialog) {
if (z && !this.mDialogCreated) {
try {
this.mCreatingDialog = true;
Dialog onCreateDialog = onCreateDialog(bundle);
this.mDialog = onCreateDialog;
if (this.mShowsDialog) {
setupDialog(onCreateDialog, this.mStyle);
Context context = getContext();
if (context instanceof Activity) {
this.mDialog.setOwnerActivity((Activity) context);
}
this.mDialog.setCancelable(this.mCancelable);
this.mDialog.setOnCancelListener(this.mOnCancelListener);
this.mDialog.setOnDismissListener(this.mOnDismissListener);
this.mDialogCreated = true;
} else {
this.mDialog = null;
}
this.mCreatingDialog = false;
} catch (Throwable th) {
this.mCreatingDialog = false;
throw th;
}
}
if (FragmentManager.J(2)) {
Log.d("FragmentManager", "get layout inflater for DialogFragment " + this + " from dialog context");
}
Dialog dialog = this.mDialog;
if (dialog != null) {
return onGetLayoutInflater.cloneInContext(dialog.getContext());
}
} else if (FragmentManager.J(2)) {
String str = "getting layout inflater for DialogFragment " + this;
if (!this.mShowsDialog) {
Log.d("FragmentManager", "mShowsDialog = false: " + str);
return onGetLayoutInflater;
}
Log.d("FragmentManager", "mCreatingDialog = true: " + str);
}
return onGetLayoutInflater;
}
public boolean onHasView() {
return this.mDialogCreated;
}
@Override // androidx.fragment.app.Fragment
@MainThread
public void onSaveInstanceState(@NonNull Bundle bundle) {
Dialog dialog = this.mDialog;
if (dialog != null) {
Bundle onSaveInstanceState = dialog.onSaveInstanceState();
onSaveInstanceState.putBoolean(SAVED_INTERNAL_DIALOG_SHOWING, false);
bundle.putBundle(SAVED_DIALOG_STATE_TAG, onSaveInstanceState);
}
int i = this.mStyle;
if (i != 0) {
bundle.putInt(SAVED_STYLE, i);
}
int i2 = this.mTheme;
if (i2 != 0) {
bundle.putInt(SAVED_THEME, i2);
}
boolean z = this.mCancelable;
if (!z) {
bundle.putBoolean(SAVED_CANCELABLE, z);
}
boolean z2 = this.mShowsDialog;
if (!z2) {
bundle.putBoolean(SAVED_SHOWS_DIALOG, z2);
}
int i3 = this.mBackStackId;
if (i3 != -1) {
bundle.putInt(SAVED_BACK_STACK_ID, i3);
}
}
@Override // androidx.fragment.app.Fragment
@MainThread
public void onStart() {
super.onStart();
Dialog dialog = this.mDialog;
if (dialog != null) {
this.mViewDestroyed = false;
dialog.show();
View decorView = this.mDialog.getWindow().getDecorView();
Intrinsics.checkNotNullParameter(decorView, "<this>");
decorView.setTag(R.id.view_tree_lifecycle_owner, this);
Intrinsics.checkNotNullParameter(decorView, "<this>");
decorView.setTag(androidx.lifecycle.viewmodel.R.id.view_tree_view_model_store_owner, this);
Intrinsics.checkNotNullParameter(decorView, "<this>");
decorView.setTag(androidx.savedstate.R.id.view_tree_saved_state_registry_owner, this);
}
}
@Override // androidx.fragment.app.Fragment
@MainThread
public void onStop() {
super.onStop();
Dialog dialog = this.mDialog;
if (dialog != null) {
dialog.hide();
}
}
@Override // androidx.fragment.app.Fragment
@MainThread
public void onViewStateRestored(@Nullable Bundle bundle) {
Bundle bundle2;
super.onViewStateRestored(bundle);
if (this.mDialog != null && bundle != null && (bundle2 = bundle.getBundle(SAVED_DIALOG_STATE_TAG)) != null) {
this.mDialog.onRestoreInstanceState(bundle2);
}
}
@Override // androidx.fragment.app.Fragment
public void performCreateView(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
Bundle bundle2;
super.performCreateView(layoutInflater, viewGroup, bundle);
if (this.mView == null && this.mDialog != null && bundle != null && (bundle2 = bundle.getBundle(SAVED_DIALOG_STATE_TAG)) != null) {
this.mDialog.onRestoreInstanceState(bundle2);
}
}
@NonNull
public final ComponentDialog requireComponentDialog() {
Dialog requireDialog = requireDialog();
if (requireDialog instanceof ComponentDialog) {
return (ComponentDialog) requireDialog;
}
throw new IllegalStateException("DialogFragment " + this + " did not return a ComponentDialog instance from requireDialog(). The actual Dialog is " + requireDialog);
}
@NonNull
public final Dialog requireDialog() {
Dialog dialog = getDialog();
if (dialog != null) {
return dialog;
}
throw new IllegalStateException("DialogFragment " + this + " does not have a Dialog.");
}
public void setCancelable(boolean z) {
this.mCancelable = z;
Dialog dialog = this.mDialog;
if (dialog != null) {
dialog.setCancelable(z);
}
}
public void setShowsDialog(boolean z) {
this.mShowsDialog = z;
}
public void setStyle(int i, @StyleRes int i2) {
if (FragmentManager.J(2)) {
Log.d("FragmentManager", "Setting style and theme for DialogFragment " + this + " to " + i + ", " + i2);
}
this.mStyle = i;
if (i == 2 || i == 3) {
this.mTheme = android.R.style.Theme.Panel;
}
if (i2 != 0) {
this.mTheme = i2;
}
}
@RestrictTo
public void setupDialog(@NonNull Dialog dialog, int i) {
if (i != 1 && i != 2) {
if (i != 3) {
return;
}
Window window = dialog.getWindow();
if (window != null) {
window.addFlags(24);
}
}
dialog.requestWindowFeature(1);
}
public void show(FragmentManager fragmentManager, String str) {
this.mDismissed = false;
this.mShownByMe = true;
fragmentManager.getClass();
BackStackRecord backStackRecord = new BackStackRecord(fragmentManager);
backStackRecord.o = true;
backStackRecord.f(0, this, str, 1);
backStackRecord.i(false);
}
public void showNow(@NonNull FragmentManager fragmentManager, @Nullable String str) {
this.mDismissed = false;
this.mShownByMe = true;
fragmentManager.getClass();
BackStackRecord backStackRecord = new BackStackRecord(fragmentManager);
backStackRecord.o = true;
backStackRecord.f(0, this, str, 1);
backStackRecord.e();
}
public int show(@NonNull FragmentTransaction fragmentTransaction, @Nullable String str) {
this.mDismissed = false;
this.mShownByMe = true;
fragmentTransaction.f(0, this, str, 1);
this.mViewDestroyed = false;
int c2 = fragmentTransaction.c();
this.mBackStackId = c2;
return c2;
}
}