soul-browser/sources/java/android/support/v4/media/RatingCompat.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

313 lines
9.1 KiB
Java

package android.support.v4.media;
import android.annotation.SuppressLint;
import android.media.Rating;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import androidx.annotation.DoNotInline;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@SuppressLint({"BanParcelableUsage"})
/* loaded from: classes.dex */
public final class RatingCompat implements Parcelable {
public static final Parcelable.Creator<RatingCompat> CREATOR = new Parcelable.Creator<RatingCompat>() { // from class: android.support.v4.media.RatingCompat.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public RatingCompat createFromParcel(Parcel parcel) {
return new RatingCompat(parcel.readInt(), parcel.readFloat());
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public RatingCompat[] newArray(int i) {
return new RatingCompat[i];
}
};
public static final int RATING_3_STARS = 3;
public static final int RATING_4_STARS = 4;
public static final int RATING_5_STARS = 5;
public static final int RATING_HEART = 1;
public static final int RATING_NONE = 0;
private static final float RATING_NOT_RATED = -1.0f;
public static final int RATING_PERCENTAGE = 6;
public static final int RATING_THUMB_UP_DOWN = 2;
private static final String TAG = "Rating";
private Object mRatingObj;
private final int mRatingStyle;
private final float mRatingValue;
@RequiresApi
/* loaded from: classes.dex */
public static class Api19Impl {
private Api19Impl() {
}
@DoNotInline
public static float getPercentRating(Rating rating) {
return rating.getPercentRating();
}
@DoNotInline
public static int getRatingStyle(Rating rating) {
return rating.getRatingStyle();
}
@DoNotInline
public static float getStarRating(Rating rating) {
return rating.getStarRating();
}
@DoNotInline
public static boolean hasHeart(Rating rating) {
return rating.hasHeart();
}
@DoNotInline
public static boolean isRated(Rating rating) {
return rating.isRated();
}
@DoNotInline
public static boolean isThumbUp(Rating rating) {
return rating.isThumbUp();
}
@DoNotInline
public static Rating newHeartRating(boolean z) {
return Rating.newHeartRating(z);
}
@DoNotInline
public static Rating newPercentageRating(float f) {
return Rating.newPercentageRating(f);
}
@DoNotInline
public static Rating newStarRating(int i, float f) {
return Rating.newStarRating(i, f);
}
@DoNotInline
public static Rating newThumbRating(boolean z) {
return Rating.newThumbRating(z);
}
@DoNotInline
public static Rating newUnratedRating(int i) {
return Rating.newUnratedRating(i);
}
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo
/* loaded from: classes.dex */
public @interface StarStyle {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo
/* loaded from: classes.dex */
public @interface Style {
}
public RatingCompat(int i, float f) {
this.mRatingStyle = i;
this.mRatingValue = f;
}
public static RatingCompat fromRating(Object obj) {
RatingCompat ratingCompat = null;
if (obj != null) {
Rating rating = (Rating) obj;
int ratingStyle = Api19Impl.getRatingStyle(rating);
if (Api19Impl.isRated(rating)) {
switch (ratingStyle) {
case 1:
ratingCompat = newHeartRating(Api19Impl.hasHeart(rating));
break;
case 2:
ratingCompat = newThumbRating(Api19Impl.isThumbUp(rating));
break;
case 3:
case 4:
case 5:
ratingCompat = newStarRating(ratingStyle, Api19Impl.getStarRating(rating));
break;
case 6:
ratingCompat = newPercentageRating(Api19Impl.getPercentRating(rating));
break;
default:
return null;
}
} else {
ratingCompat = newUnratedRating(ratingStyle);
}
ratingCompat.mRatingObj = obj;
}
return ratingCompat;
}
public static RatingCompat newHeartRating(boolean z) {
float f;
if (z) {
f = 1.0f;
} else {
f = 0.0f;
}
return new RatingCompat(1, f);
}
public static RatingCompat newPercentageRating(float f) {
if (f >= 0.0f && f <= 100.0f) {
return new RatingCompat(6, f);
}
Log.e(TAG, "Invalid percentage-based rating value");
return null;
}
public static RatingCompat newStarRating(int i, float f) {
float f2;
if (i != 3) {
if (i != 4) {
if (i != 5) {
Log.e(TAG, "Invalid rating style (" + i + ") for a star rating");
return null;
}
f2 = 5.0f;
} else {
f2 = 4.0f;
}
} else {
f2 = 3.0f;
}
if (f >= 0.0f && f <= f2) {
return new RatingCompat(i, f);
}
Log.e(TAG, "Trying to set out of range star-based rating");
return null;
}
public static RatingCompat newThumbRating(boolean z) {
float f;
if (z) {
f = 1.0f;
} else {
f = 0.0f;
}
return new RatingCompat(2, f);
}
public static RatingCompat newUnratedRating(int i) {
switch (i) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return new RatingCompat(i, RATING_NOT_RATED);
default:
return null;
}
}
@Override // android.os.Parcelable
public int describeContents() {
return this.mRatingStyle;
}
public float getPercentRating() {
if (this.mRatingStyle == 6 && isRated()) {
return this.mRatingValue;
}
return RATING_NOT_RATED;
}
/* JADX WARN: Failed to find 'out' block for switch in B:6:0x000c. Please report as an issue. */
public Object getRating() {
if (this.mRatingObj == null) {
if (isRated()) {
int i = this.mRatingStyle;
switch (i) {
case 1:
this.mRatingObj = Api19Impl.newHeartRating(hasHeart());
break;
case 2:
this.mRatingObj = Api19Impl.newThumbRating(isThumbUp());
break;
case 3:
case 4:
case 5:
this.mRatingObj = Api19Impl.newStarRating(i, getStarRating());
break;
case 6:
this.mRatingObj = Api19Impl.newPercentageRating(getPercentRating());
break;
default:
return null;
}
} else {
this.mRatingObj = Api19Impl.newUnratedRating(this.mRatingStyle);
}
}
return this.mRatingObj;
}
public int getRatingStyle() {
return this.mRatingStyle;
}
public float getStarRating() {
int i = this.mRatingStyle;
if ((i == 3 || i == 4 || i == 5) && isRated()) {
return this.mRatingValue;
}
return RATING_NOT_RATED;
}
public boolean hasHeart() {
if (this.mRatingStyle != 1 || this.mRatingValue != 1.0f) {
return false;
}
return true;
}
public boolean isRated() {
if (this.mRatingValue >= 0.0f) {
return true;
}
return false;
}
public boolean isThumbUp() {
if (this.mRatingStyle != 2 || this.mRatingValue != 1.0f) {
return false;
}
return true;
}
public String toString() {
String valueOf;
StringBuilder sb = new StringBuilder("Rating:style=");
sb.append(this.mRatingStyle);
sb.append(" rating=");
float f = this.mRatingValue;
if (f < 0.0f) {
valueOf = "unrated";
} else {
valueOf = String.valueOf(f);
}
sb.append(valueOf);
return sb.toString();
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.mRatingStyle);
parcel.writeFloat(this.mRatingValue);
}
}