Prevent crash

pull/200/head
M66B 3 years ago
parent 7618dd949f
commit 86615c4a2d

@ -64,22 +64,25 @@ public class ApplicationEx extends Application
.commit(); // apply won't work here .commit(); // apply won't work here
} }
String tag = Locale.getDefault().toLanguageTag(); try {
if (!("de-AT".equals(tag) || "de-LI".equals(tag))) String language = prefs.getString("language", null);
tag = null;
String language = prefs.getString("language", tag);
if (language != null) { if (language != null) {
if ("de-AT".equals(language) || "de-LI".equals(language)) if ("de-AT".equals(language) || "de-LI".equals(language))
language = "de-DE"; language = "de-DE";
Locale locale = Locale.forLanguageTag(language); Locale locale = Locale.forLanguageTag(language);
EntityLog.log(context, "Set language=" + language + " locale=" + locale); Log.i("Set language=" + language + " locale=" + locale);
Locale.setDefault(locale); Locale.setDefault(locale);
Configuration config = new Configuration(); Configuration config;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
config.setTo(context.getResources().getConfiguration()); config = new Configuration(context.getResources().getConfiguration());
else
config = new Configuration();
config.setLocale(locale); config.setLocale(locale);
return context.createConfigurationContext(config); return context.createConfigurationContext(config);
} }
} catch (Throwable ex) {
Log.e(ex);
}
return context; return context;
} }

Loading…
Cancel
Save