mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-17 11:27:17 +01:00
130 lines
7.3 KiB
Java
130 lines
7.3 KiB
Java
package com.facebook.react.modules.i18nmanager;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
import androidx.core.text.TextUtilsCompat;
|
|
import com.amazon.alexa.api.compat.model.assistant.subcomponent.AlexaEventBundleKeys;
|
|
import java.util.Locale;
|
|
import kotlin.Deprecated;
|
|
import kotlin.Metadata;
|
|
import kotlin.ReplaceWith;
|
|
import kotlin.jvm.JvmName;
|
|
import kotlin.jvm.JvmStatic;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.text.StringsKt;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\t\n\u0002\u0010\u000e\n\u0002\b\u0005\u0018\u0000 \u00192\u00020\u0001:\u0001\u0019B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u000e\u0010\u0004\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u0007J\u0010\u0010\b\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u0007H\u0002J\u0010\u0010\t\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u0007H\u0002J\u0016\u0010\n\u001a\u00020\u000b2\u0006\u0010\u0006\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\u0005J\u000e\u0010\f\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u0007J\u0016\u0010\r\u001a\u00020\u000b2\u0006\u0010\u0006\u001a\u00020\u00072\u0006\u0010\u000e\u001a\u00020\u0005J\u0010\u0010\u000f\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u0007H\u0002J\u0016\u0010\u0010\u001a\u00020\u000b2\u0006\u0010\u0006\u001a\u00020\u00072\u0006\u0010\u0010\u001a\u00020\u0005J \u0010\u0013\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u00072\u0006\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0016\u001a\u00020\u0005H\u0002J \u0010\u0017\u001a\u00020\u000b2\u0006\u0010\u0006\u001a\u00020\u00072\u0006\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0018\u001a\u00020\u0005H\u0002R\u0014\u0010\u0011\u001a\u00020\u00058BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0011\u0010\u0012¨\u0006\u001a"}, d2 = {"Lcom/facebook/react/modules/i18nmanager/I18nUtil;", "", "<init>", "()V", "isRTL", "", "context", "Landroid/content/Context;", "applicationHasRtlSupport", "isRTLAllowed", "allowRTL", "", "doLeftAndRightSwapInRTL", "swapLeftAndRightInRTL", "flip", "isRTLForced", "forceRTL", "isDevicePreferredLanguageRTL", "()Z", "isPrefSet", "key", "", "defaultValue", "setPref", "value", "Companion", "ReactAndroid_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
|
|
/* loaded from: classes6.dex */
|
|
public final class I18nUtil {
|
|
|
|
@NotNull
|
|
private static final String KEY_FOR_PERFS_MAKE_RTL_FLIP_LEFT_AND_RIGHT_STYLES = "RCTI18nUtil_makeRTLFlipLeftAndRightStyles";
|
|
|
|
@NotNull
|
|
private static final String KEY_FOR_PREFS_ALLOWRTL = "RCTI18nUtil_allowRTL";
|
|
|
|
@NotNull
|
|
private static final String KEY_FOR_PREFS_FORCERTL = "RCTI18nUtil_forceRTL";
|
|
|
|
@NotNull
|
|
private static final String SHARED_PREFS_NAME = "com.facebook.react.modules.i18nmanager.I18nUtil";
|
|
|
|
/* renamed from: Companion, reason: from kotlin metadata */
|
|
@NotNull
|
|
public static final Companion INSTANCE = new Companion(null);
|
|
|
|
@NotNull
|
|
private static final I18nUtil instance = new I18nUtil();
|
|
|
|
private I18nUtil() {
|
|
}
|
|
|
|
private final boolean applicationHasRtlSupport(Context context) {
|
|
return (context.getApplicationInfo().flags & 4194304) != 0;
|
|
}
|
|
|
|
@JvmStatic
|
|
@NotNull
|
|
public static final I18nUtil getInstance() {
|
|
return INSTANCE.getInstance();
|
|
}
|
|
|
|
private final boolean isDevicePreferredLanguageRTL() {
|
|
return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == 1;
|
|
}
|
|
|
|
private final boolean isPrefSet(Context context, String key, boolean defaultValue) {
|
|
return context.getSharedPreferences(SHARED_PREFS_NAME, 0).getBoolean(key, defaultValue);
|
|
}
|
|
|
|
private final boolean isRTLAllowed(Context context) {
|
|
return isPrefSet(context, KEY_FOR_PREFS_ALLOWRTL, true);
|
|
}
|
|
|
|
private final boolean isRTLForced(Context context) {
|
|
return isPrefSet(context, KEY_FOR_PREFS_FORCERTL, false) || StringsKt.equals(System.getProperty("FORCE_RTL_FOR_TESTING", "false"), "true", true);
|
|
}
|
|
|
|
private final void setPref(Context context, String key, boolean value) {
|
|
SharedPreferences.Editor edit = context.getSharedPreferences(SHARED_PREFS_NAME, 0).edit();
|
|
edit.putBoolean(key, value);
|
|
edit.apply();
|
|
}
|
|
|
|
public final void allowRTL(@NotNull Context context, boolean allowRTL) {
|
|
context.getClass();
|
|
setPref(context, KEY_FOR_PREFS_ALLOWRTL, allowRTL);
|
|
}
|
|
|
|
public final boolean doLeftAndRightSwapInRTL(@NotNull Context context) {
|
|
context.getClass();
|
|
return isPrefSet(context, KEY_FOR_PERFS_MAKE_RTL_FLIP_LEFT_AND_RIGHT_STYLES, true);
|
|
}
|
|
|
|
public final void forceRTL(@NotNull Context context, boolean forceRTL) {
|
|
context.getClass();
|
|
setPref(context, KEY_FOR_PREFS_FORCERTL, forceRTL);
|
|
}
|
|
|
|
public final boolean isRTL(@NotNull Context context) {
|
|
context.getClass();
|
|
if (!applicationHasRtlSupport(context)) {
|
|
return false;
|
|
}
|
|
if (isRTLForced(context)) {
|
|
return true;
|
|
}
|
|
return isRTLAllowed(context) && isDevicePreferredLanguageRTL();
|
|
}
|
|
|
|
public final void swapLeftAndRightInRTL(@NotNull Context context, boolean flip) {
|
|
context.getClass();
|
|
setPref(context, KEY_FOR_PERFS_MAKE_RTL_FLIP_LEFT_AND_RIGHT_STYLES, flip);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0005\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\r\u0010\u0006\u001a\u00020\u0005H\u0007¢\u0006\u0002\b\rR\u0013\u0010\u0004\u001a\u00020\u00058G¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007R\u000e\u0010\b\u001a\u00020\tX\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\tX\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\tX\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\tX\u0082T¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Lcom/facebook/react/modules/i18nmanager/I18nUtil$Companion;", "", "<init>", "()V", AlexaEventBundleKeys.INSTANCE, "Lcom/facebook/react/modules/i18nmanager/I18nUtil;", "getInstance", "()Lcom/facebook/react/modules/i18nmanager/I18nUtil;", "SHARED_PREFS_NAME", "", "KEY_FOR_PREFS_ALLOWRTL", "KEY_FOR_PREFS_FORCERTL", "KEY_FOR_PERFS_MAKE_RTL_FLIP_LEFT_AND_RIGHT_STYLES", "DEPRECATED$getInstance", "ReactAndroid_release"}, k = 1, mv = {2, 1, 0}, xi = 48)
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
@Deprecated(message = "Use .instance instead, this API is only for backward compat", replaceWith = @ReplaceWith(expression = AlexaEventBundleKeys.INSTANCE, imports = {}))
|
|
@JvmName(name = "DEPRECATED$getInstance")
|
|
@NotNull
|
|
public final I18nUtil DEPRECATED$getInstance() {
|
|
return getInstance();
|
|
}
|
|
|
|
@JvmStatic
|
|
@NotNull
|
|
public final I18nUtil getInstance() {
|
|
return I18nUtil.instance;
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
}
|
|
}
|