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

162 lines
5.3 KiB
Java

package androidx.recyclerview.widget;
import android.graphics.PointF;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import kotlin.jvm.internal.IntCompanionObject;
/* loaded from: classes.dex */
public class LinearSnapHelper extends SnapHelper {
public OrientationHelper d;
public OrientationHelper e;
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()) {
OrientationHelper j = j(layoutManager);
iArr[0] = ((j.c(view) / 2) + j.e(view)) - ((j.l() / 2) + j.k());
} else {
iArr[0] = 0;
}
if (layoutManager.g()) {
OrientationHelper k = k(layoutManager);
iArr[1] = ((k.c(view) / 2) + k.e(view)) - ((k.l() / 2) + k.k());
return iArr;
}
iArr[1] = 0;
return iArr;
}
@Override // androidx.recyclerview.widget.SnapHelper
public final 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) {
int H;
View e;
int N;
int i3;
PointF a2;
int i4;
int i5;
if ((layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider) && (H = layoutManager.H()) != 0 && (e = e(layoutManager)) != null && (N = RecyclerView.LayoutManager.N(e)) != -1 && (a2 = ((RecyclerView.SmoothScroller.ScrollVectorProvider) layoutManager).a(H - 1)) != null) {
int i6 = 0;
if (layoutManager.f()) {
i4 = h(layoutManager, j(layoutManager), i, 0);
if (a2.x < 0.0f) {
i4 = -i4;
}
} else {
i4 = 0;
}
if (layoutManager.g()) {
i5 = h(layoutManager, k(layoutManager), 0, i2);
if (a2.y < 0.0f) {
i5 = -i5;
}
} else {
i5 = 0;
}
if (layoutManager.g()) {
i4 = i5;
}
if (i4 != 0) {
int i7 = N + i4;
if (i7 >= 0) {
i6 = i7;
}
if (i6 >= H) {
return i3;
}
return i6;
}
}
return -1;
}
public final int h(RecyclerView.LayoutManager layoutManager, OrientationHelper orientationHelper, int i, int i2) {
int i3;
this.b.fling(0, 0, i, i2, IntCompanionObject.MIN_VALUE, Integer.MAX_VALUE, IntCompanionObject.MIN_VALUE, Integer.MAX_VALUE);
int[] iArr = {this.b.getFinalX(), this.b.getFinalY()};
int x = layoutManager.x();
float f = 1.0f;
if (x != 0) {
View view = null;
int i4 = Integer.MIN_VALUE;
int i5 = Integer.MAX_VALUE;
View view2 = null;
for (int i6 = 0; i6 < x; i6++) {
View w = layoutManager.w(i6);
int N = RecyclerView.LayoutManager.N(w);
if (N != -1) {
if (N < i5) {
view = w;
i5 = N;
}
if (N > i4) {
view2 = w;
i4 = N;
}
}
}
if (view != null && view2 != null) {
int max = Math.max(orientationHelper.b(view), orientationHelper.b(view2)) - Math.min(orientationHelper.e(view), orientationHelper.e(view2));
if (max != 0) {
f = (max * 1.0f) / ((i4 - i5) + 1);
}
}
}
if (f <= 0.0f) {
return 0;
}
if (Math.abs(iArr[0]) > Math.abs(iArr[1])) {
i3 = iArr[0];
} else {
i3 = iArr[1];
}
return Math.round(i3 / f);
}
public final OrientationHelper j(RecyclerView.LayoutManager layoutManager) {
if (this.e.f1551a != layoutManager) {
this.e = new OrientationHelper(layoutManager);
}
return this.e;
}
public final OrientationHelper k(RecyclerView.LayoutManager layoutManager) {
if (this.d.f1551a != layoutManager) {
this.d = new OrientationHelper(layoutManager);
}
return this.d;
}
}