discord-jadx/app/src/main/java/com/discord/utilities/font/FontUtils.java

49 lines
1.9 KiB
Java

package com.discord.utilities.font;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.provider.Settings;
import android.util.TypedValue;
import androidx.annotation.AttrRes;
import androidx.core.content.res.ResourcesCompat;
import com.discord.stores.StoreStream;
import d0.a0.a;
import d0.z.d.m;
/* compiled from: FontUtils.kt */
public final class FontUtils {
public static final FontUtils INSTANCE = new FontUtils();
public static final int MAX_FONT_SCALING = 150;
public static final int MIN_FONT_SCALING = 80;
public static final int USE_SYSTEM_FONT_SCALE = -1;
private FontUtils() {
}
public final int getSystemFontScaleInt(ContentResolver contentResolver) {
m.checkNotNullParameter(contentResolver, "contentResolver");
return a.roundToInt(Settings.System.getFloat(contentResolver, "font_scale", 1.0f) * ((float) 100));
}
public final float getTargetFontScaleFloat(Context context) {
m.checkNotNullParameter(context, "context");
StoreStream.Companion companion = StoreStream.Companion;
return companion.getUserSettingsSystem().getFontScale() == -1 ? Settings.System.getFloat(context.getContentResolver(), "font_scale", 1.0f) : ((float) companion.getUserSettingsSystem().getFontScale()) / 100.0f;
}
public final Typeface getThemedFont(Context context, @AttrRes int i) {
m.checkNotNullParameter(context, "context");
return ResourcesCompat.getFont(context, getThemedFontResId(context, i));
}
public final int getThemedFontResId(Context context, @AttrRes int i) {
Resources.Theme theme;
TypedValue typedValue = new TypedValue();
if (!(context == null || (theme = context.getTheme()) == null)) {
theme.resolveAttribute(i, typedValue, true);
}
return typedValue.resourceId;
}
}