soul-browser/sources/java/com/mycompany/app/view/MySwitchView.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

172 lines
5.6 KiB
Java

package com.mycompany.app.view;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.widget.FrameLayout;
import com.mycompany.app.main.MainApp;
import com.mycompany.app.main.MainUtil;
import com.mycompany.app.soulbrowser.R;
/* loaded from: classes3.dex */
public class MySwitchView extends FrameLayout {
/* renamed from: c, reason: collision with root package name */
public boolean f19008c;
public final boolean f;
public boolean g;
public View h;
public View i;
public Drawable j;
public Drawable k;
public Drawable l;
public Drawable m;
public final int n;
public MySwitchView(Context context) {
super(context);
this.f = MainUtil.O5(context);
this.f19008c = false;
int round = Math.round(MainUtil.G(context, 32.0f));
int round2 = Math.round(MainUtil.G(context, 18.0f));
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(round, round2);
layoutParams.gravity = 17;
View view = new View(context);
this.h = view;
addView(view, layoutParams);
int round3 = round2 - Math.round(MainUtil.G(context, 4.0f));
int round4 = Math.round(((MainApp.g1 - round) + r2) / 2.0f);
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(round3, round3);
layoutParams2.gravity = 8388627;
layoutParams2.setMarginStart(round4);
View view2 = new View(context);
this.i = view2;
addView(view2, layoutParams2);
this.n = Math.round((round - r2) / 2.0f);
c();
}
private Drawable getThumbDrawable() {
if (this.f19008c) {
return this.l;
}
return this.m;
}
private Drawable getTrackDrawable() {
if (this.f19008c) {
return this.j;
}
return this.k;
}
private void setAppearance(boolean z) {
if (z) {
Drawable background = this.h.getBackground();
if (background != null) {
if (background instanceof TransitionDrawable) {
background = ((TransitionDrawable) background).getDrawable(1);
}
TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[]{background, getTrackDrawable()});
transitionDrawable.setCrossFadeEnabled(true);
this.h.setBackground(transitionDrawable);
transitionDrawable.startTransition(150);
} else {
this.h.setBackground(getTrackDrawable());
}
} else {
this.h.setBackground(getTrackDrawable());
}
if (z) {
Drawable background2 = this.i.getBackground();
if (background2 != null) {
if (background2 instanceof TransitionDrawable) {
background2 = ((TransitionDrawable) background2).getDrawable(1);
}
TransitionDrawable transitionDrawable2 = new TransitionDrawable(new Drawable[]{background2, getThumbDrawable()});
transitionDrawable2.setCrossFadeEnabled(true);
this.i.setBackground(transitionDrawable2);
transitionDrawable2.startTransition(150);
return;
}
this.i.setBackground(getThumbDrawable());
return;
}
this.i.setBackground(getThumbDrawable());
}
public final void a() {
this.h = null;
this.i = null;
this.j = null;
this.k = null;
this.l = null;
this.m = null;
}
public final void b(boolean z, boolean z2) {
int i;
if (this.i != null) {
if (this.f19008c == z && this.g == this.f) {
return;
}
this.f19008c = z;
this.g = this.f;
setAppearance(z2);
if (this.f) {
i = -this.n;
} else {
i = this.n;
}
this.i.animate().cancel();
float f = 0.0f;
if (z2) {
ViewPropertyAnimator animate = this.i.animate();
if (this.f19008c) {
f = i;
}
animate.translationX(f).setDuration(150L).start();
return;
}
View view = this.i;
if (this.f19008c) {
f = i;
}
view.setTranslationX(f);
}
}
public final void c() {
if (this.h == null) {
return;
}
Context context = getContext();
if (MainApp.K1) {
this.j = MainUtil.S(context, R.drawable.switc_track_on_dark);
this.k = MainUtil.S(context, R.drawable.switc_track_off_dark);
this.l = MainUtil.S(context, R.drawable.switc_thumb_on_dark);
this.m = MainUtil.S(context, R.drawable.switc_thumb_off_dark);
} else {
this.j = MainUtil.S(context, R.drawable.switc_track_on_bright);
this.k = MainUtil.S(context, R.drawable.switc_track_off_bright);
this.l = MainUtil.S(context, R.drawable.switc_thumb_on_bright);
this.m = MainUtil.S(context, R.drawable.switc_thumb_off_bright);
}
this.h.setBackground(getTrackDrawable());
this.i.setBackground(getThumbDrawable());
}
@Override // android.view.View
public void setEnabled(boolean z) {
float f;
super.setEnabled(z);
if (z) {
f = 1.0f;
} else {
f = 0.4f;
}
setAlpha(f);
}
}