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

632 lines
21 KiB
Java

package com.google.android.material.internal;
import android.animation.TimeInterpolator;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.Build;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import androidx.annotation.RestrictTo;
import androidx.core.math.MathUtils;
import androidx.core.text.TextDirectionHeuristicCompat;
import androidx.core.text.TextDirectionHeuristicsCompat;
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.internal.StaticLayoutBuilderCompat;
import com.google.android.material.resources.CancelableFontCallback;
import com.google.android.material.resources.TextAppearance;
import com.google.android.material.resources.TypefaceUtils;
import com.google.android.material.textfield.TextInputLayout;
@RestrictTo
/* loaded from: classes3.dex */
public final class CollapsingTextHelper {
public CharSequence B;
public CharSequence C;
public boolean D;
public float F;
public float G;
public float H;
public float I;
public float J;
public int K;
public int L;
public int[] M;
public boolean N;
public final TextPaint O;
public final TextPaint P;
public TimeInterpolator Q;
public TimeInterpolator R;
public float S;
public float T;
public float U;
public ColorStateList V;
public float W;
public float X;
public float Y;
public StaticLayout Z;
/* renamed from: a, reason: collision with root package name */
public final TextInputLayout f11807a;
public float a0;
public float b;
public float b0;
/* renamed from: c, reason: collision with root package name */
public final Rect f11808c;
public float c0;
public final Rect d;
public CharSequence d0;
public final RectF e;
public ColorStateList j;
public ColorStateList k;
public boolean k0;
public int l;
public float m;
public float n;
public float o;
public float p;
public float q;
public float r;
public Typeface s;
public Typeface t;
public Typeface u;
public Typeface v;
public Typeface w;
public Typeface x;
public Typeface y;
public CancelableFontCallback z;
public int f = 16;
public int g = 16;
public float h = 15.0f;
public float i = 15.0f;
public final TextUtils.TruncateAt A = TextUtils.TruncateAt.END;
public final boolean E = true;
public int e0 = 1;
public int f0 = 1;
public final float g0 = 1.0f;
public final int h0 = 1;
public int i0 = -1;
public int j0 = -1;
/* renamed from: com.google.android.material.internal.CollapsingTextHelper$2, reason: invalid class name */
/* loaded from: classes3.dex */
class AnonymousClass2 implements CancelableFontCallback.ApplyFont {
@Override // com.google.android.material.resources.CancelableFontCallback.ApplyFont
public final void a(Typeface typeface) {
throw null;
}
}
public CollapsingTextHelper(TextInputLayout textInputLayout) {
this.f11807a = textInputLayout;
TextPaint textPaint = new TextPaint(129);
this.O = textPaint;
this.P = new TextPaint(textPaint);
this.d = new Rect();
this.f11808c = new Rect();
this.e = new RectF();
i(textInputLayout.getContext().getResources().getConfiguration());
}
public static int a(float f, int i, int i2) {
float f2 = 1.0f - f;
return Color.argb(Math.round((Color.alpha(i2) * f) + (Color.alpha(i) * f2)), Math.round((Color.red(i2) * f) + (Color.red(i) * f2)), Math.round((Color.green(i2) * f) + (Color.green(i) * f2)), Math.round((Color.blue(i2) * f) + (Color.blue(i) * f2)));
}
public static float h(float f, float f2, float f3, TimeInterpolator timeInterpolator) {
if (timeInterpolator != null) {
f3 = timeInterpolator.getInterpolation(f3);
}
return AnimationUtils.a(f, f2, f3);
}
public static boolean k(Rect rect, int i, int i2, int i3, int i4) {
if (rect.left == i && rect.top == i2 && rect.right == i3 && rect.bottom == i4) {
return true;
}
return false;
}
public final void b() {
float f = this.b;
float f2 = this.f11808c.left;
Rect rect = this.d;
float h = h(f2, rect.left, f, this.Q);
RectF rectF = this.e;
rectF.left = h;
rectF.top = h(this.m, this.n, f, this.Q);
rectF.right = h(r1.right, rect.right, f, this.Q);
rectF.bottom = h(r1.bottom, rect.bottom, f, this.Q);
this.q = h(this.o, this.p, f, this.Q);
this.r = h(this.m, this.n, f, this.Q);
d(f, false);
TextInputLayout textInputLayout = this.f11807a;
textInputLayout.postInvalidateOnAnimation();
FastOutSlowInInterpolator fastOutSlowInInterpolator = AnimationUtils.b;
this.b0 = 1.0f - h(0.0f, 1.0f, 1.0f - f, fastOutSlowInInterpolator);
textInputLayout.postInvalidateOnAnimation();
this.c0 = h(1.0f, 0.0f, f, fastOutSlowInInterpolator);
textInputLayout.postInvalidateOnAnimation();
ColorStateList colorStateList = this.k;
ColorStateList colorStateList2 = this.j;
TextPaint textPaint = this.O;
if (colorStateList != colorStateList2) {
textPaint.setColor(a(f, g(colorStateList2), g(this.k)));
} else {
textPaint.setColor(g(colorStateList));
}
float f3 = this.W;
float f4 = this.X;
if (f3 != f4) {
textPaint.setLetterSpacing(h(f4, f3, f, fastOutSlowInInterpolator));
} else {
textPaint.setLetterSpacing(f3);
}
this.H = AnimationUtils.a(0.0f, this.S, f);
this.I = AnimationUtils.a(0.0f, this.T, f);
this.J = AnimationUtils.a(0.0f, this.U, f);
int a2 = a(f, 0, g(this.V));
this.K = a2;
textPaint.setShadowLayer(this.H, this.I, this.J, a2);
textInputLayout.postInvalidateOnAnimation();
}
public final boolean c(CharSequence charSequence) {
TextDirectionHeuristicCompat textDirectionHeuristicCompat;
boolean z = true;
if (this.f11807a.getLayoutDirection() != 1) {
z = false;
}
if (this.E) {
if (z) {
textDirectionHeuristicCompat = TextDirectionHeuristicsCompat.d;
} else {
textDirectionHeuristicCompat = TextDirectionHeuristicsCompat.f751c;
}
return textDirectionHeuristicCompat.a(charSequence.length(), charSequence);
}
return z;
}
public final void d(float f, boolean z) {
float f2;
Typeface typeface;
float f3;
int i;
int i2;
boolean z2;
boolean z3;
boolean z4;
boolean z5;
boolean z6;
boolean z7;
float h;
if (this.B != null) {
float width = this.d.width();
float width2 = this.f11808c.width();
float f4 = 1.0f;
if (Math.abs(f - 1.0f) < 1.0E-5f) {
if (q()) {
f2 = this.i;
} else {
f2 = this.h;
}
if (q()) {
f3 = this.W;
} else {
f3 = this.X;
}
if (q()) {
h = 1.0f;
} else {
h = h(this.h, this.i, f, this.R) / this.h;
}
this.F = h;
if (!q()) {
width = width2;
}
typeface = this.s;
width2 = width;
} else {
f2 = this.h;
float f5 = this.X;
typeface = this.v;
if (Math.abs(f - 0.0f) < 1.0E-5f) {
this.F = 1.0f;
} else {
this.F = h(this.h, this.i, f, this.R) / this.h;
}
float f6 = this.i / this.h;
float f7 = width2 * f6;
if (!z && f7 > width && q()) {
width2 = Math.min(width / f6, width2);
}
f3 = f5;
}
if (f < 0.5f) {
i = this.e0;
} else {
i = this.f0;
}
TextPaint textPaint = this.O;
boolean z8 = false;
if (width2 > 0.0f) {
if (this.G != f2) {
z2 = true;
} else {
z2 = false;
}
if (this.Y != f3) {
z3 = true;
} else {
z3 = false;
}
if (this.y != typeface) {
z4 = true;
} else {
z4 = false;
}
if (this.Z != null && width2 != r12.getWidth()) {
z5 = true;
} else {
z5 = false;
}
if (this.L != i) {
z6 = true;
} else {
z6 = false;
}
if (!z2 && !z3 && !z5 && !z4 && !z6 && !this.N) {
z7 = false;
} else {
z7 = true;
}
this.G = f2;
this.Y = f3;
this.y = typeface;
this.N = false;
this.L = i;
if (this.F != 1.0f) {
z8 = true;
}
textPaint.setLinearText(z8);
z8 = z7;
}
if (this.C != null && !z8) {
return;
}
textPaint.setTextSize(this.G);
textPaint.setTypeface(this.y);
textPaint.setLetterSpacing(this.Y);
boolean c2 = c(this.B);
this.D = c2;
if ((this.e0 <= 1 && this.f0 <= 1) || c2) {
i2 = 1;
} else {
i2 = i;
}
CharSequence charSequence = this.B;
if (!q()) {
f4 = this.F;
}
StaticLayout e = e(i2, textPaint, charSequence, width2 * f4, this.D);
this.Z = e;
this.C = e.getText();
}
}
public final StaticLayout e(int i, TextPaint textPaint, CharSequence charSequence, float f, boolean z) {
Layout.Alignment alignment;
StaticLayout staticLayout = null;
try {
if (i == 1) {
alignment = Layout.Alignment.ALIGN_NORMAL;
} else {
int absoluteGravity = Gravity.getAbsoluteGravity(this.f, this.D ? 1 : 0) & 7;
if (absoluteGravity != 1) {
if (absoluteGravity != 5) {
if (this.D) {
alignment = Layout.Alignment.ALIGN_OPPOSITE;
} else {
alignment = Layout.Alignment.ALIGN_NORMAL;
}
} else if (this.D) {
alignment = Layout.Alignment.ALIGN_NORMAL;
} else {
alignment = Layout.Alignment.ALIGN_OPPOSITE;
}
} else {
alignment = Layout.Alignment.ALIGN_CENTER;
}
}
StaticLayoutBuilderCompat staticLayoutBuilderCompat = new StaticLayoutBuilderCompat(charSequence, textPaint, (int) f);
staticLayoutBuilderCompat.l = this.A;
staticLayoutBuilderCompat.k = z;
staticLayoutBuilderCompat.e = alignment;
staticLayoutBuilderCompat.j = false;
staticLayoutBuilderCompat.f = i;
float f2 = this.g0;
staticLayoutBuilderCompat.g = 0.0f;
staticLayoutBuilderCompat.h = f2;
staticLayoutBuilderCompat.i = this.h0;
staticLayoutBuilderCompat.m = null;
staticLayout = staticLayoutBuilderCompat.a();
} catch (StaticLayoutBuilderCompat.StaticLayoutBuilderCompatException e) {
Log.e("CollapsingTextHelper", e.getCause().getMessage(), e);
}
staticLayout.getClass();
return staticLayout;
}
public final float f() {
int i = this.i0;
if (i != -1) {
return i;
}
float f = this.i;
TextPaint textPaint = this.P;
textPaint.setTextSize(f);
textPaint.setTypeface(this.s);
textPaint.setLetterSpacing(this.W);
return -textPaint.ascent();
}
public final int g(ColorStateList colorStateList) {
if (colorStateList == null) {
return 0;
}
int[] iArr = this.M;
if (iArr != null) {
return colorStateList.getColorForState(iArr, 0);
}
return colorStateList.getDefaultColor();
}
public final void i(Configuration configuration) {
if (Build.VERSION.SDK_INT >= 31) {
Typeface typeface = this.u;
if (typeface != null) {
this.t = TypefaceUtils.a(configuration, typeface);
}
Typeface typeface2 = this.x;
if (typeface2 != null) {
this.w = TypefaceUtils.a(configuration, typeface2);
}
Typeface typeface3 = this.t;
if (typeface3 == null) {
typeface3 = this.u;
}
this.s = typeface3;
Typeface typeface4 = this.w;
if (typeface4 == null) {
typeface4 = this.x;
}
this.v = typeface4;
j(true);
}
}
public final void j(boolean z) {
float f;
float f2;
int i;
CharSequence charSequence;
TextInputLayout textInputLayout = this.f11807a;
if ((textInputLayout.getHeight() > 0 && textInputLayout.getWidth() > 0) || z) {
d(1.0f, z);
CharSequence charSequence2 = this.C;
TextPaint textPaint = this.O;
if (charSequence2 != null && this.Z != null) {
if (q()) {
charSequence = TextUtils.ellipsize(this.C, textPaint, this.Z.getWidth(), this.A);
} else {
charSequence = this.C;
}
this.d0 = charSequence;
}
CharSequence charSequence3 = this.d0;
float f3 = 0.0f;
if (charSequence3 != null) {
this.a0 = textPaint.measureText(charSequence3, 0, charSequence3.length());
} else {
this.a0 = 0.0f;
}
int absoluteGravity = Gravity.getAbsoluteGravity(this.g, this.D ? 1 : 0);
int i2 = absoluteGravity & 112;
Rect rect = this.d;
if (i2 != 48) {
if (i2 != 80) {
this.n = rect.centerY() - ((textPaint.descent() - textPaint.ascent()) / 2.0f);
} else {
this.n = textPaint.ascent() + rect.bottom;
}
} else {
this.n = rect.top;
}
int i3 = absoluteGravity & 8388615;
if (i3 != 1) {
if (i3 != 5) {
this.p = rect.left;
} else {
this.p = rect.right - this.a0;
}
} else {
this.p = rect.centerX() - (this.a0 / 2.0f);
}
if (this.a0 <= rect.width()) {
float f4 = this.p;
float max = Math.max(0.0f, rect.left - f4) + f4;
this.p = max;
this.p = Math.min(0.0f, rect.right - (this.a0 + max)) + max;
}
float f5 = this.i;
TextPaint textPaint2 = this.P;
textPaint2.setTextSize(f5);
textPaint2.setTypeface(this.s);
textPaint2.setLetterSpacing(this.W);
if (textPaint2.descent() + (-textPaint2.ascent()) <= rect.height()) {
float f6 = this.n;
float max2 = Math.max(0.0f, rect.top - f6) + f6;
this.n = max2;
this.n = Math.min(0.0f, rect.bottom - (f() + max2)) + max2;
}
d(0.0f, z);
StaticLayout staticLayout = this.Z;
if (staticLayout != null) {
f = staticLayout.getHeight();
} else {
f = 0.0f;
}
StaticLayout staticLayout2 = this.Z;
if (staticLayout2 != null && this.e0 > 1) {
f2 = staticLayout2.getWidth();
} else {
CharSequence charSequence4 = this.C;
if (charSequence4 != null) {
f2 = textPaint.measureText(charSequence4, 0, charSequence4.length());
} else {
f2 = 0.0f;
}
}
StaticLayout staticLayout3 = this.Z;
if (staticLayout3 != null) {
i = staticLayout3.getLineCount();
} else {
i = 0;
}
this.l = i;
int absoluteGravity2 = Gravity.getAbsoluteGravity(this.f, this.D ? 1 : 0);
int i4 = absoluteGravity2 & 112;
Rect rect2 = this.f11808c;
if (i4 != 48) {
if (i4 != 80) {
this.m = rect2.centerY() - (f / 2.0f);
} else {
float f7 = rect2.bottom - f;
if (this.k0) {
f3 = textPaint.descent();
}
this.m = f7 + f3;
}
} else {
this.m = rect2.top;
}
int i5 = absoluteGravity2 & 8388615;
if (i5 != 1) {
if (i5 != 5) {
this.o = rect2.left;
} else {
this.o = rect2.right - f2;
}
} else {
this.o = rect2.centerX() - (f2 / 2.0f);
}
d(this.b, false);
textInputLayout.postInvalidateOnAnimation();
b();
}
}
public final void l(ColorStateList colorStateList) {
if (this.k == colorStateList && this.j == colorStateList) {
return;
}
this.k = colorStateList;
this.j = colorStateList;
j(false);
}
public final void m(int i) {
TextInputLayout textInputLayout = this.f11807a;
TextAppearance textAppearance = new TextAppearance(textInputLayout.getContext(), i);
ColorStateList colorStateList = textAppearance.k;
if (colorStateList != null) {
this.k = colorStateList;
}
float f = textAppearance.l;
if (f != 0.0f) {
this.i = f;
}
ColorStateList colorStateList2 = textAppearance.f11861a;
if (colorStateList2 != null) {
this.V = colorStateList2;
}
this.T = textAppearance.f;
this.U = textAppearance.g;
this.S = textAppearance.h;
this.W = textAppearance.j;
CancelableFontCallback cancelableFontCallback = this.z;
if (cancelableFontCallback != null) {
cancelableFontCallback.f11860c = true;
}
CancelableFontCallback.ApplyFont applyFont = new CancelableFontCallback.ApplyFont() { // from class: com.google.android.material.internal.CollapsingTextHelper.1
@Override // com.google.android.material.resources.CancelableFontCallback.ApplyFont
public final void a(Typeface typeface) {
CollapsingTextHelper collapsingTextHelper = CollapsingTextHelper.this;
if (collapsingTextHelper.n(typeface)) {
collapsingTextHelper.j(false);
}
}
};
textAppearance.a();
this.z = new CancelableFontCallback(applyFont, textAppearance.p);
textAppearance.b(textInputLayout.getContext(), this.z);
j(false);
}
public final boolean n(Typeface typeface) {
CancelableFontCallback cancelableFontCallback = this.z;
if (cancelableFontCallback != null) {
cancelableFontCallback.f11860c = true;
}
if (this.u != typeface) {
this.u = typeface;
Typeface a2 = TypefaceUtils.a(this.f11807a.getContext().getResources().getConfiguration(), typeface);
this.t = a2;
if (a2 == null) {
a2 = this.u;
}
this.s = a2;
return true;
}
return false;
}
public final boolean o(Typeface typeface) {
if (this.x != typeface) {
this.x = typeface;
Typeface a2 = TypefaceUtils.a(this.f11807a.getContext().getResources().getConfiguration(), typeface);
this.w = a2;
if (a2 == null) {
a2 = this.x;
}
this.v = a2;
return true;
}
return false;
}
public final void p(float f) {
float a2 = MathUtils.a(f, 0.0f, 1.0f);
if (a2 != this.b) {
this.b = a2;
b();
}
}
public final boolean q() {
if (this.f0 == 1) {
return true;
}
return false;
}
}