mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-26 08:07:27 +00:00
Create LocaleManager
This commit is contained in:
parent
70dd2d4829
commit
7c74be2790
@ -2,8 +2,6 @@ package com.topjohnwu.magisk;
|
|||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
@ -11,21 +9,18 @@ import com.topjohnwu.magisk.container.Module;
|
|||||||
import com.topjohnwu.magisk.database.MagiskDatabaseHelper;
|
import com.topjohnwu.magisk.database.MagiskDatabaseHelper;
|
||||||
import com.topjohnwu.magisk.database.RepoDatabaseHelper;
|
import com.topjohnwu.magisk.database.RepoDatabaseHelper;
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
import com.topjohnwu.magisk.utils.RootUtils;
|
import com.topjohnwu.magisk.utils.RootUtils;
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.superuser.ContainerApp;
|
import com.topjohnwu.superuser.ContainerApp;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MagiskManager extends ContainerApp {
|
public class MagiskManager extends ContainerApp {
|
||||||
|
|
||||||
public static Locale locale;
|
|
||||||
public static Locale defaultLocale;
|
|
||||||
|
|
||||||
// Topics
|
// Topics
|
||||||
public final Topic magiskHideDone = new Topic();
|
public final Topic magiskHideDone = new Topic();
|
||||||
public final Topic reloadActivity = new Topic();
|
public final Topic reloadActivity = new Topic();
|
||||||
@ -40,7 +35,6 @@ public class MagiskManager extends ContainerApp {
|
|||||||
|
|
||||||
// Data
|
// Data
|
||||||
public Map<String, Module> moduleMap;
|
public Map<String, Module> moduleMap;
|
||||||
public List<Locale> locales;
|
|
||||||
|
|
||||||
// Global resources
|
// Global resources
|
||||||
public SharedPreferences prefs;
|
public SharedPreferences prefs;
|
||||||
@ -61,7 +55,7 @@ public class MagiskManager extends ContainerApp {
|
|||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
mDB = MagiskDatabaseHelper.getInstance(this);
|
mDB = MagiskDatabaseHelper.getInstance(this);
|
||||||
locale = defaultLocale = Locale.getDefault();
|
LocaleManager.locale = LocaleManager.defaultLocale = Locale.getDefault();
|
||||||
|
|
||||||
String pkg = mDB.getStrings(Const.Key.SU_MANAGER, null);
|
String pkg = mDB.getStrings(Const.Key.SU_MANAGER, null);
|
||||||
if (pkg != null && getPackageName().equals(Const.ORIG_PKG_NAME)) {
|
if (pkg != null && getPackageName().equals(Const.ORIG_PKG_NAME)) {
|
||||||
@ -76,21 +70,8 @@ public class MagiskManager extends ContainerApp {
|
|||||||
} catch (PackageManager.NameNotFoundException ignored) {}
|
} catch (PackageManager.NameNotFoundException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocale();
|
LocaleManager.setLocale();
|
||||||
Global.loadConfig();
|
Global.loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocale() {
|
|
||||||
Global.localeConfig = prefs.getString(Const.Key.LOCALE, "");
|
|
||||||
if (Global.localeConfig.isEmpty()) {
|
|
||||||
locale = defaultLocale;
|
|
||||||
} else {
|
|
||||||
locale = Locale.forLanguageTag(Global.localeConfig);
|
|
||||||
}
|
|
||||||
Resources res = getBaseContext().getResources();
|
|
||||||
Configuration config = new Configuration(res.getConfiguration());
|
|
||||||
config.setLocale(locale);
|
|
||||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
|||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
import com.topjohnwu.magisk.utils.Download;
|
import com.topjohnwu.magisk.utils.Download;
|
||||||
import com.topjohnwu.magisk.utils.FingerprintHelper;
|
import com.topjohnwu.magisk.utils.FingerprintHelper;
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
import com.topjohnwu.magisk.utils.RootUtils;
|
import com.topjohnwu.magisk.utils.RootUtils;
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
@ -212,18 +213,18 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setLocalePreference(ListPreference lp) {
|
private void setLocalePreference(ListPreference lp) {
|
||||||
CharSequence[] entries = new CharSequence[mm.locales.size() + 1];
|
CharSequence[] entries = new CharSequence[LocaleManager.locales.size() + 1];
|
||||||
CharSequence[] entryValues = new CharSequence[mm.locales.size() + 1];
|
CharSequence[] entryValues = new CharSequence[LocaleManager.locales.size() + 1];
|
||||||
entries[0] = Utils.getLocaleString(MagiskManager.defaultLocale, R.string.system_default);
|
entries[0] = LocaleManager.getString(LocaleManager.defaultLocale, R.string.system_default);
|
||||||
entryValues[0] = "";
|
entryValues[0] = "";
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (Locale locale : mm.locales) {
|
for (Locale locale : LocaleManager.locales) {
|
||||||
entries[i] = locale.getDisplayName(locale);
|
entries[i] = locale.getDisplayName(locale);
|
||||||
entryValues[i++] = locale.toLanguageTag();
|
entryValues[i++] = locale.toLanguageTag();
|
||||||
}
|
}
|
||||||
lp.setEntries(entries);
|
lp.setEntries(entries);
|
||||||
lp.setEntryValues(entryValues);
|
lp.setEntryValues(entryValues);
|
||||||
lp.setSummary(MagiskManager.locale.getDisplayName(MagiskManager.locale));
|
lp.setSummary(LocaleManager.locale.getDisplayName(LocaleManager.locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -282,7 +283,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
|
|||||||
mm.mDB.setSettings(key, Utils.getPrefsInt(prefs, key));
|
mm.mDB.setSettings(key, Utils.getPrefsInt(prefs, key));
|
||||||
break;
|
break;
|
||||||
case Const.Key.LOCALE:
|
case Const.Key.LOCALE:
|
||||||
mm.setLocale();
|
LocaleManager.setLocale();
|
||||||
mm.reloadActivity.publish(false);
|
mm.reloadActivity.publish(false);
|
||||||
break;
|
break;
|
||||||
case Const.Key.UPDATE_CHANNEL:
|
case Const.Key.UPDATE_CHANNEL:
|
||||||
|
@ -8,13 +8,13 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.asyncs.CheckUpdates;
|
import com.topjohnwu.magisk.asyncs.CheckUpdates;
|
||||||
import com.topjohnwu.magisk.asyncs.LoadModules;
|
import com.topjohnwu.magisk.asyncs.LoadModules;
|
||||||
import com.topjohnwu.magisk.asyncs.ParallelTask;
|
|
||||||
import com.topjohnwu.magisk.asyncs.UpdateRepos;
|
import com.topjohnwu.magisk.asyncs.UpdateRepos;
|
||||||
import com.topjohnwu.magisk.components.Activity;
|
import com.topjohnwu.magisk.components.Activity;
|
||||||
import com.topjohnwu.magisk.database.RepoDatabaseHelper;
|
import com.topjohnwu.magisk.database.RepoDatabaseHelper;
|
||||||
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
|
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
import com.topjohnwu.magisk.utils.Download;
|
import com.topjohnwu.magisk.utils.Download;
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class SplashActivity extends Activity {
|
|||||||
Global.importPrefs();
|
Global.importPrefs();
|
||||||
|
|
||||||
// Dynamic detect all locales
|
// Dynamic detect all locales
|
||||||
new LoadLocale().exec();
|
new LocaleManager.LoadLocale().exec();
|
||||||
|
|
||||||
// Create notification channel on Android O
|
// Create notification channel on Android O
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
@ -72,16 +72,4 @@ public class SplashActivity extends Activity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class LoadLocale extends ParallelTask<Void, Void, Void> {
|
|
||||||
@Override
|
|
||||||
protected Void doInBackground(Void... voids) {
|
|
||||||
Global.MM().locales = Utils.getAvailableLocale();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(Void aVoid) {
|
|
||||||
Global.MM().localeDone.publish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import android.view.WindowManager;
|
|||||||
import com.topjohnwu.magisk.Global;
|
import com.topjohnwu.magisk.Global;
|
||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
|
|
||||||
public abstract class FlavorActivity extends AppCompatActivity {
|
public abstract class FlavorActivity extends AppCompatActivity {
|
||||||
@ -20,7 +21,7 @@ public abstract class FlavorActivity extends AppCompatActivity {
|
|||||||
public FlavorActivity() {
|
public FlavorActivity() {
|
||||||
super();
|
super();
|
||||||
Configuration configuration = new Configuration();
|
Configuration configuration = new Configuration();
|
||||||
configuration.setLocale(MagiskManager.locale);
|
configuration.setLocale(LocaleManager.locale);
|
||||||
applyOverrideConfiguration(configuration);
|
applyOverrideConfiguration(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package com.topjohnwu.magisk.container;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.MagiskManager;
|
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.magisk.utils.WebService;
|
import com.topjohnwu.magisk.utils.WebService;
|
||||||
@ -77,7 +77,7 @@ public class Repo extends BaseModule {
|
|||||||
|
|
||||||
public String getLastUpdateString() {
|
public String getLastUpdateString() {
|
||||||
return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM,
|
return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM,
|
||||||
MagiskManager.locale).format(mLastUpdate);
|
LocaleManager.locale).format(mLastUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getLastUpdate() {
|
public Date getLastUpdate() {
|
||||||
|
@ -3,7 +3,7 @@ package com.topjohnwu.magisk.container;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -47,10 +47,10 @@ public class SuLogEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDateString() {
|
public String getDateString() {
|
||||||
return DateFormat.getDateInstance(DateFormat.MEDIUM, MagiskManager.locale).format(date);
|
return DateFormat.getDateInstance(DateFormat.MEDIUM, LocaleManager.locale).format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimeString() {
|
public String getTimeString() {
|
||||||
return new SimpleDateFormat("h:mm a", MagiskManager.locale).format(date);
|
return new SimpleDateFormat("h:mm a", LocaleManager.locale).format(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import com.topjohnwu.magisk.R;
|
|||||||
import com.topjohnwu.magisk.container.Policy;
|
import com.topjohnwu.magisk.container.Policy;
|
||||||
import com.topjohnwu.magisk.container.SuLogEntry;
|
import com.topjohnwu.magisk.container.SuLogEntry;
|
||||||
import com.topjohnwu.magisk.utils.Const;
|
import com.topjohnwu.magisk.utils.Const;
|
||||||
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
import com.topjohnwu.superuser.io.SuFile;
|
import com.topjohnwu.superuser.io.SuFile;
|
||||||
@ -236,7 +237,7 @@ public class MagiskDatabaseHelper {
|
|||||||
String dateString = null, newString;
|
String dateString = null, newString;
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
Date date = new Date(c.getLong(c.getColumnIndex("time")));
|
Date date = new Date(c.getLong(c.getColumnIndex("time")));
|
||||||
newString = DateFormat.getDateInstance(DateFormat.MEDIUM, MagiskManager.locale).format(date);
|
newString = DateFormat.getDateInstance(DateFormat.MEDIUM, LocaleManager.locale).format(date);
|
||||||
if (!TextUtils.equals(dateString, newString)) {
|
if (!TextUtils.equals(dateString, newString)) {
|
||||||
dateString = newString;
|
dateString = newString;
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.Global;
|
||||||
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
|
import com.topjohnwu.magisk.R;
|
||||||
|
import com.topjohnwu.magisk.asyncs.ParallelTask;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class LocaleManager {
|
||||||
|
public static Locale locale;
|
||||||
|
public static Locale defaultLocale;
|
||||||
|
public static List<Locale> locales;
|
||||||
|
|
||||||
|
public static void setLocale() {
|
||||||
|
MagiskManager mm = Global.MM();
|
||||||
|
Global.localeConfig = mm.prefs.getString(Const.Key.LOCALE, "");
|
||||||
|
if (Global.localeConfig.isEmpty()) {
|
||||||
|
locale = defaultLocale;
|
||||||
|
} else {
|
||||||
|
locale = Locale.forLanguageTag(Global.localeConfig);
|
||||||
|
}
|
||||||
|
Resources res = mm.getResources();
|
||||||
|
Configuration config = new Configuration(res.getConfiguration());
|
||||||
|
config.setLocale(locale);
|
||||||
|
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getString(Locale locale, @StringRes int id) {
|
||||||
|
Configuration config = Global.MM().getResources().getConfiguration();
|
||||||
|
config.setLocale(locale);
|
||||||
|
return getString(config, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(Configuration config, @StringRes int id) {
|
||||||
|
return Global.MM().createConfigurationContext(config).getString(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Locale> getAvailableLocale() {
|
||||||
|
List<Locale> locales = new ArrayList<>();
|
||||||
|
HashSet<String> set = new HashSet<>();
|
||||||
|
MagiskManager mm = Global.MM();
|
||||||
|
Locale locale;
|
||||||
|
|
||||||
|
@StringRes int compareId = R.string.download_file_error;
|
||||||
|
|
||||||
|
// Add default locale
|
||||||
|
locales.add(Locale.ENGLISH);
|
||||||
|
set.add(getString(Locale.ENGLISH, compareId));
|
||||||
|
|
||||||
|
// Add some special locales
|
||||||
|
locales.add(Locale.TAIWAN);
|
||||||
|
set.add(getString(Locale.TAIWAN, compareId));
|
||||||
|
locale = new Locale("pt", "BR");
|
||||||
|
locales.add(locale);
|
||||||
|
set.add(getString(locale, compareId));
|
||||||
|
|
||||||
|
// Other locales
|
||||||
|
Configuration config = mm.getResources().getConfiguration();
|
||||||
|
for (String s : mm.getAssets().getLocales()) {
|
||||||
|
locale = Locale.forLanguageTag(s);
|
||||||
|
config.setLocale(locale);
|
||||||
|
if (set.add(getString(config, compareId))) {
|
||||||
|
locales.add(locale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(locales, (a, b) -> a.getDisplayName(a).compareTo(b.getDisplayName(b)));
|
||||||
|
|
||||||
|
return locales;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LoadLocale extends ParallelTask<Void, Void, Void> {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
locales = getAvailableLocale();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
Global.MM().localeDone.publish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,21 +5,14 @@ import android.app.job.JobScheduler;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.OpenableColumns;
|
import android.provider.OpenableColumns;
|
||||||
import android.support.annotation.StringRes;
|
|
||||||
|
|
||||||
import com.topjohnwu.magisk.Global;
|
import com.topjohnwu.magisk.Global;
|
||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.R;
|
|
||||||
import com.topjohnwu.magisk.services.UpdateCheckService;
|
import com.topjohnwu.magisk.services.UpdateCheckService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
@ -54,45 +47,6 @@ public class Utils {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getLocaleString(Locale locale, @StringRes int id) {
|
|
||||||
Context context = Global.MM();
|
|
||||||
Configuration config = context.getResources().getConfiguration();
|
|
||||||
config.setLocale(locale);
|
|
||||||
Context localizedContext = context.createConfigurationContext(config);
|
|
||||||
return localizedContext.getString(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Locale> getAvailableLocale() {
|
|
||||||
List<Locale> locales = new ArrayList<>();
|
|
||||||
HashSet<String> set = new HashSet<>();
|
|
||||||
Locale locale;
|
|
||||||
|
|
||||||
@StringRes int compareId = R.string.download_file_error;
|
|
||||||
|
|
||||||
// Add default locale
|
|
||||||
locales.add(Locale.ENGLISH);
|
|
||||||
set.add(getLocaleString(Locale.ENGLISH, compareId));
|
|
||||||
|
|
||||||
// Add some special locales
|
|
||||||
locales.add(Locale.TAIWAN);
|
|
||||||
set.add(getLocaleString(Locale.TAIWAN, compareId));
|
|
||||||
locale = new Locale("pt", "BR");
|
|
||||||
locales.add(locale);
|
|
||||||
set.add(getLocaleString(locale, compareId));
|
|
||||||
|
|
||||||
// Other locales
|
|
||||||
for (String s : Global.MM().getAssets().getLocales()) {
|
|
||||||
locale = Locale.forLanguageTag(s);
|
|
||||||
if (set.add(getLocaleString(locale, compareId))) {
|
|
||||||
locales.add(locale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(locales, (l1, l2) -> l1.getDisplayName(l1).compareTo(l2.getDisplayName(l2)));
|
|
||||||
|
|
||||||
return locales;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int dpInPx(int dp) {
|
public static int dpInPx(int dp) {
|
||||||
Context context = Global.MM();
|
Context context = Global.MM();
|
||||||
float scale = context.getResources().getDisplayMetrics().density;
|
float scale = context.getResources().getDisplayMetrics().density;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user