soul-browser/sources/java/com/google/android/material/internal/ForegroundLinearLayout.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

173 lines
5.7 KiB
Java

package com.google.android.material.internal;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.appcompat.widget.LinearLayoutCompat;
import com.google.android.material.R;
@RestrictTo
/* loaded from: classes3.dex */
public class ForegroundLinearLayout extends LinearLayoutCompat {
public Drawable t;
public final Rect u;
public final Rect v;
public int w;
public final boolean x;
public boolean y;
public ForegroundLinearLayout(Context context, AttributeSet attributeSet) {
super(context, attributeSet, 0);
this.u = new Rect();
this.v = new Rect();
this.w = 119;
this.x = true;
this.y = false;
int[] iArr = R.styleable.ForegroundLinearLayout;
ThemeEnforcement.a(context, attributeSet, 0, 0);
ThemeEnforcement.b(context, attributeSet, iArr, 0, 0, new int[0]);
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr, 0, 0);
this.w = obtainStyledAttributes.getInt(R.styleable.ForegroundLinearLayout_android_foregroundGravity, this.w);
Drawable drawable = obtainStyledAttributes.getDrawable(R.styleable.ForegroundLinearLayout_android_foreground);
if (drawable != null) {
setForeground(drawable);
}
this.x = obtainStyledAttributes.getBoolean(R.styleable.ForegroundLinearLayout_foregroundInsidePadding, true);
obtainStyledAttributes.recycle();
}
@Override // android.view.View
public final void draw(Canvas canvas) {
super.draw(canvas);
Drawable drawable = this.t;
if (drawable != null) {
if (this.y) {
this.y = false;
int right = getRight() - getLeft();
int bottom = getBottom() - getTop();
boolean z = this.x;
Rect rect = this.u;
if (z) {
rect.set(0, 0, right, bottom);
} else {
rect.set(getPaddingLeft(), getPaddingTop(), right - getPaddingRight(), bottom - getPaddingBottom());
}
int i = this.w;
int intrinsicWidth = drawable.getIntrinsicWidth();
int intrinsicHeight = drawable.getIntrinsicHeight();
Rect rect2 = this.v;
Gravity.apply(i, intrinsicWidth, intrinsicHeight, rect, rect2);
drawable.setBounds(rect2);
}
drawable.draw(canvas);
}
}
@Override // android.view.View
public final void drawableHotspotChanged(float f, float f2) {
super.drawableHotspotChanged(f, f2);
Drawable drawable = this.t;
if (drawable != null) {
drawable.setHotspot(f, f2);
}
}
@Override // android.view.ViewGroup, android.view.View
public final void drawableStateChanged() {
super.drawableStateChanged();
Drawable drawable = this.t;
if (drawable != null && drawable.isStateful()) {
this.t.setState(getDrawableState());
}
}
@Override // android.view.View
@Nullable
public Drawable getForeground() {
return this.t;
}
@Override // android.view.View
public int getForegroundGravity() {
return this.w;
}
@Override // android.view.ViewGroup, android.view.View
public final void jumpDrawablesToCurrentState() {
super.jumpDrawablesToCurrentState();
Drawable drawable = this.t;
if (drawable != null) {
drawable.jumpToCurrentState();
}
}
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup, android.view.View
public final void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
this.y = z | this.y;
}
@Override // android.view.View
public final void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
this.y = true;
}
@Override // android.view.View
public void setForeground(@Nullable Drawable drawable) {
Drawable drawable2 = this.t;
if (drawable2 != drawable) {
if (drawable2 != null) {
drawable2.setCallback(null);
unscheduleDrawable(this.t);
}
this.t = drawable;
this.y = true;
if (drawable != null) {
setWillNotDraw(false);
drawable.setCallback(this);
if (drawable.isStateful()) {
drawable.setState(getDrawableState());
}
if (this.w == 119) {
drawable.getPadding(new Rect());
}
} else {
setWillNotDraw(true);
}
requestLayout();
invalidate();
}
}
@Override // android.view.View
public void setForegroundGravity(int i) {
if (this.w != i) {
if ((8388615 & i) == 0) {
i |= 8388611;
}
if ((i & 112) == 0) {
i |= 48;
}
this.w = i;
if (i == 119 && this.t != null) {
this.t.getPadding(new Rect());
}
requestLayout();
}
}
@Override // android.view.View
public final boolean verifyDrawable(Drawable drawable) {
if (!super.verifyDrawable(drawable) && drawable != this.t) {
return false;
}
return true;
}
}