- [Custom controls] Fix special buttons index.
- [Language changer] change behavior
This commit is contained in:
khanhduytran0 2020-11-21 12:24:57 +07:00
parent dd6d080b4e
commit 9e71ff6aaa
6 changed files with 80 additions and 48 deletions

View file

@ -0,0 +1,31 @@
package net.kdt.pojavlaunch.utils;
import android.content.*;
import android.content.res.*;
import android.support.v7.preference.*;
import java.util.*;
import net.kdt.pojavlaunch.prefs.*;
public class LocaleUtils {
public static final Locale DEFAULT_LOCALE;
static {
DEFAULT_LOCALE = Locale.getDefault();
}
public static Context setLocale(Context context) {
if (LauncherPreferences.DEFAULT_PREF == null) {
LauncherPreferences.DEFAULT_PREF = PreferenceManager.getDefaultSharedPreferences(context);
LauncherPreferences.loadPreferences();
}
Locale locale = new Locale(LauncherPreferences.PREF_LANGUAGE);
Locale.setDefault(locale);
Resources res = context.getResources();
Configuration config = new Configuration(res.getConfiguration());
config.setLocale(locale);
context = context.createConfigurationContext(config);
return context;
}
}