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

182 lines
6.7 KiB
Java

package androidx.recyclerview.widget;
import android.graphics.PointF;
import android.util.DisplayMetrics;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
/* loaded from: classes.dex */
public class PagerSnapHelper extends SnapHelper {
public OrientationHelper d;
public OrientationHelper e;
public static int h(View view, OrientationHelper orientationHelper) {
return ((orientationHelper.c(view) / 2) + orientationHelper.e(view)) - ((orientationHelper.l() / 2) + orientationHelper.k());
}
public static View i(RecyclerView.LayoutManager layoutManager, OrientationHelper orientationHelper) {
int x = layoutManager.x();
View view = null;
if (x == 0) {
return null;
}
int l = (orientationHelper.l() / 2) + orientationHelper.k();
int i = Integer.MAX_VALUE;
for (int i2 = 0; i2 < x; i2++) {
View w = layoutManager.w(i2);
int abs = Math.abs(((orientationHelper.c(w) / 2) + orientationHelper.e(w)) - l);
if (abs < i) {
view = w;
i = abs;
}
}
return view;
}
@Override // androidx.recyclerview.widget.SnapHelper
public final int[] c(RecyclerView.LayoutManager layoutManager, View view) {
int[] iArr = new int[2];
if (layoutManager.f()) {
iArr[0] = h(view, j(layoutManager));
} else {
iArr[0] = 0;
}
if (layoutManager.g()) {
iArr[1] = h(view, k(layoutManager));
return iArr;
}
iArr[1] = 0;
return iArr;
}
@Override // androidx.recyclerview.widget.SnapHelper
public final RecyclerView.SmoothScroller d(RecyclerView.LayoutManager layoutManager) {
if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider)) {
return null;
}
return new LinearSmoothScroller(this.f1591a.getContext()) { // from class: androidx.recyclerview.widget.PagerSnapHelper.1
@Override // androidx.recyclerview.widget.LinearSmoothScroller, androidx.recyclerview.widget.RecyclerView.SmoothScroller
public final void e(View view, RecyclerView.SmoothScroller.Action action) {
PagerSnapHelper pagerSnapHelper = PagerSnapHelper.this;
int[] c2 = pagerSnapHelper.c(pagerSnapHelper.f1591a.getLayoutManager(), view);
int i = c2[0];
int i2 = c2[1];
int ceil = (int) Math.ceil(k(Math.max(Math.abs(i), Math.abs(i2))) / 0.3356d);
if (ceil > 0) {
action.f1584a = i;
action.b = i2;
action.f1585c = ceil;
action.e = this.j;
action.f = true;
}
}
@Override // androidx.recyclerview.widget.LinearSmoothScroller
public final float j(DisplayMetrics displayMetrics) {
return 100.0f / displayMetrics.densityDpi;
}
@Override // androidx.recyclerview.widget.LinearSmoothScroller
public final int k(int i) {
return Math.min(100, super.k(i));
}
};
}
@Override // androidx.recyclerview.widget.SnapHelper
public View e(RecyclerView.LayoutManager layoutManager) {
if (layoutManager.g()) {
return i(layoutManager, k(layoutManager));
}
if (layoutManager.f()) {
return i(layoutManager, j(layoutManager));
}
return null;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // androidx.recyclerview.widget.SnapHelper
public final int f(RecyclerView.LayoutManager layoutManager, int i, int i2) {
OrientationHelper orientationHelper;
boolean z;
PointF a2;
int H = layoutManager.H();
if (H != 0) {
View view = null;
if (layoutManager.g()) {
orientationHelper = k(layoutManager);
} else if (layoutManager.f()) {
orientationHelper = j(layoutManager);
} else {
orientationHelper = null;
}
if (orientationHelper != null) {
int x = layoutManager.x();
boolean z2 = false;
int i3 = Integer.MAX_VALUE;
int i4 = Integer.MIN_VALUE;
View view2 = null;
for (int i5 = 0; i5 < x; i5++) {
View w = layoutManager.w(i5);
if (w != null) {
int h = h(w, orientationHelper);
if (h <= 0 && h > i4) {
view2 = w;
i4 = h;
}
if (h >= 0 && h < i3) {
view = w;
i3 = h;
}
}
}
int i6 = 1;
if (!layoutManager.f() ? i2 > 0 : i > 0) {
z = true;
} else {
z = false;
}
if (z && view != null) {
return RecyclerView.LayoutManager.N(view);
}
if (!z && view2 != null) {
return RecyclerView.LayoutManager.N(view2);
}
if (z) {
view = view2;
}
if (view != null) {
int N = RecyclerView.LayoutManager.N(view);
int H2 = layoutManager.H();
if ((layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) && (a2 = ((RecyclerView.SmoothScroller.ScrollVectorProvider) layoutManager).a(H2 - 1)) != null && (a2.x < 0.0f || a2.y < 0.0f)) {
z2 = true;
}
if (z2 == z) {
i6 = -1;
}
int i7 = N + i6;
if (i7 >= 0 && i7 < H) {
return i7;
}
}
}
}
return -1;
}
public final OrientationHelper j(RecyclerView.LayoutManager layoutManager) {
OrientationHelper orientationHelper = this.e;
if (orientationHelper == null || orientationHelper.f1551a != layoutManager) {
this.e = new OrientationHelper(layoutManager);
}
return this.e;
}
public final OrientationHelper k(RecyclerView.LayoutManager layoutManager) {
OrientationHelper orientationHelper = this.d;
if (orientationHelper == null || orientationHelper.f1551a != layoutManager) {
this.d = new OrientationHelper(layoutManager);
}
return this.d;
}
}