Support API 16 (Android 4.1)

Because why not
This commit is contained in:
topjohnwu
2019-02-02 05:06:13 -05:00
parent 9fbe5895b7
commit 62acc17e42
15 changed files with 125 additions and 97 deletions

View File

@@ -100,9 +100,13 @@ public class LocaleManager {
}
public static Context getLocaleContext(Context context, Locale locale) {
Configuration config = new Configuration(context.getResources().getConfiguration());
config.setLocale(locale);
return context.createConfigurationContext(config);
if (Build.VERSION.SDK_INT >= 17) {
Configuration config = new Configuration(context.getResources().getConfiguration());
config.setLocale(locale);
return context.createConfigurationContext(config);
} else {
return context;
}
}
public static Context getLocaleContext(Locale locale) {
@@ -114,6 +118,8 @@ public class LocaleManager {
}
public static void loadAvailableLocales(@StringRes int compareId) {
if (Build.VERSION.SDK_INT < 17)
return;
Shell.EXECUTOR.execute(() -> {
locales = new ArrayList<>();
HashSet<String> set = new HashSet<>();

View File

@@ -77,7 +77,7 @@ public class Utils {
public static String getAppLabel(ApplicationInfo info, PackageManager pm) {
try {
if (info.labelRes > 0) {
if (info.labelRes > 0 && Build.VERSION.SDK_INT >= 17) {
Resources res = pm.getResourcesForApplication(info);
Configuration config = new Configuration();
config.setLocale(LocaleManager.locale);