This source file includes following definitions.
- JNINamespace
- getDefaultLocale
- getJavaLocale
- getDisplayNameForLocale
- isLayoutRtl
- getFirstStrongCharacterDirection
- getDurationString
- nativeGetFirstStrongCharacterDirection
- nativeGetDurationString
package org.chromium.ui.base;
import android.content.res.Configuration;
import android.view.View;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import java.util.Locale;
@JNINamespace("l10n_util")
public class LocalizationUtils {
public static final int UNKNOWN_DIRECTION = 0;
public static final int RIGHT_TO_LEFT = 1;
public static final int LEFT_TO_RIGHT = 2;
private static Boolean sIsLayoutRtl;
private LocalizationUtils() { }
@CalledByNative
public static String getDefaultLocale() {
Locale locale = Locale.getDefault();
String language = locale.getLanguage();
String country = locale.getCountry();
if ("iw".equals(language)) {
language = "he";
} else if ("in".equals(language)) {
language = "id";
} else if ("tl".equals(language)) {
language = "fil";
}
return country.isEmpty() ? language : language + "-" + country;
}
@CalledByNative
private static Locale getJavaLocale(String language, String country, String variant) {
return new Locale(language, country, variant);
}
@CalledByNative
private static String getDisplayNameForLocale(Locale locale, Locale displayLocale) {
return locale.getDisplayName(displayLocale);
}
@CalledByNative
public static boolean isLayoutRtl() {
if (sIsLayoutRtl == null) {
Configuration configuration =
ApplicationStatus.getApplicationContext().getResources().getConfiguration();
sIsLayoutRtl = Boolean.valueOf(
ApiCompatibilityUtils.getLayoutDirection(configuration) ==
View.LAYOUT_DIRECTION_RTL);
}
return sIsLayoutRtl.booleanValue();
}
public static int getFirstStrongCharacterDirection(String string) {
return nativeGetFirstStrongCharacterDirection(string);
}
public static String getDurationString(long timeInMillis) {
return nativeGetDurationString(timeInMillis);
}
private static native int nativeGetFirstStrongCharacterDirection(String string);
private static native String nativeGetDurationString(long timeInMillis);
}