219 lines
4.8 KiB
Smali
219 lines
4.8 KiB
Smali
.class final Landroidx/core/os/LocaleHelper;
|
|
.super Ljava/lang/Object;
|
|
.source "LocaleHelper.java"
|
|
|
|
|
|
# annotations
|
|
.annotation build Landroidx/annotation/RestrictTo;
|
|
value = {
|
|
.enum Landroidx/annotation/RestrictTo$Scope;->LIBRARY_GROUP:Landroidx/annotation/RestrictTo$Scope;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# direct methods
|
|
.method private constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method static forLanguageTag(Ljava/lang/String;)Ljava/util/Locale;
|
|
.locals 6
|
|
|
|
const-string v0, "-"
|
|
|
|
invoke-virtual {p0, v0}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
|
|
|
|
move-result v1
|
|
|
|
const/4 v2, -0x1
|
|
|
|
const/4 v3, 0x2
|
|
|
|
const/4 v4, 0x0
|
|
|
|
const/4 v5, 0x1
|
|
|
|
if-eqz v1, :cond_2
|
|
|
|
invoke-virtual {p0, v0, v2}, Ljava/lang/String;->split(Ljava/lang/String;I)[Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
array-length v1, v0
|
|
|
|
if-le v1, v3, :cond_0
|
|
|
|
new-instance p0, Ljava/util/Locale;
|
|
|
|
aget-object v1, v0, v4
|
|
|
|
aget-object v2, v0, v5
|
|
|
|
aget-object v0, v0, v3
|
|
|
|
invoke-direct {p0, v1, v2, v0}, Ljava/util/Locale;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_0
|
|
array-length v1, v0
|
|
|
|
if-le v1, v5, :cond_1
|
|
|
|
new-instance p0, Ljava/util/Locale;
|
|
|
|
aget-object v1, v0, v4
|
|
|
|
aget-object v0, v0, v5
|
|
|
|
invoke-direct {p0, v1, v0}, Ljava/util/Locale;-><init>(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_1
|
|
array-length v1, v0
|
|
|
|
if-ne v1, v5, :cond_5
|
|
|
|
new-instance p0, Ljava/util/Locale;
|
|
|
|
aget-object v0, v0, v4
|
|
|
|
invoke-direct {p0, v0}, Ljava/util/Locale;-><init>(Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_2
|
|
const-string v0, "_"
|
|
|
|
invoke-virtual {p0, v0}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_6
|
|
|
|
invoke-virtual {p0, v0, v2}, Ljava/lang/String;->split(Ljava/lang/String;I)[Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
array-length v1, v0
|
|
|
|
if-le v1, v3, :cond_3
|
|
|
|
new-instance p0, Ljava/util/Locale;
|
|
|
|
aget-object v1, v0, v4
|
|
|
|
aget-object v2, v0, v5
|
|
|
|
aget-object v0, v0, v3
|
|
|
|
invoke-direct {p0, v1, v2, v0}, Ljava/util/Locale;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_3
|
|
array-length v1, v0
|
|
|
|
if-le v1, v5, :cond_4
|
|
|
|
new-instance p0, Ljava/util/Locale;
|
|
|
|
aget-object v1, v0, v4
|
|
|
|
aget-object v0, v0, v5
|
|
|
|
invoke-direct {p0, v1, v0}, Ljava/util/Locale;-><init>(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_4
|
|
array-length v1, v0
|
|
|
|
if-ne v1, v5, :cond_5
|
|
|
|
new-instance p0, Ljava/util/Locale;
|
|
|
|
aget-object v0, v0, v4
|
|
|
|
invoke-direct {p0, v0}, Ljava/util/Locale;-><init>(Ljava/lang/String;)V
|
|
|
|
return-object p0
|
|
|
|
:cond_5
|
|
new-instance v0, Ljava/lang/IllegalArgumentException;
|
|
|
|
new-instance v1, Ljava/lang/StringBuilder;
|
|
|
|
const-string v2, "Can not parse language tag: ["
|
|
|
|
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
|
|
|
|
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string p0, "]"
|
|
|
|
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-direct {v0, p0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_6
|
|
new-instance v0, Ljava/util/Locale;
|
|
|
|
invoke-direct {v0, p0}, Ljava/util/Locale;-><init>(Ljava/lang/String;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method static toLanguageTag(Ljava/util/Locale;)Ljava/lang/String;
|
|
.locals 2
|
|
|
|
new-instance v0, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
invoke-virtual {p0}, Ljava/util/Locale;->getLanguage()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p0}, Ljava/util/Locale;->getCountry()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
invoke-virtual {v1}, Ljava/lang/String;->isEmpty()Z
|
|
|
|
move-result v1
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
const-string v1, "-"
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {p0}, Ljava/util/Locale;->getCountry()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
:cond_0
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|