Apply default anguage
This commit is contained in:
parent
aa3d253e2c
commit
00da1e90c6
2 changed files with 26 additions and 10 deletions
|
@ -109,6 +109,8 @@ public class OsmandApplication extends Application {
|
|||
|
||||
|
||||
RoutingConfiguration.Builder defaultRoutingConfig;
|
||||
private Locale defaultLocale;
|
||||
|
||||
|
||||
// Typeface
|
||||
|
||||
|
@ -276,11 +278,19 @@ public class OsmandApplication extends Application {
|
|||
public void checkPreferredLocale() {
|
||||
Configuration config = getBaseContext().getResources().getConfiguration();
|
||||
String lang = osmandSettings.PREFERRED_LOCALE.get();
|
||||
if(defaultLocale == null) {
|
||||
defaultLocale = Locale.getDefault();
|
||||
}
|
||||
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
|
||||
preferredLocale = new Locale(lang);
|
||||
Locale.setDefault(preferredLocale);
|
||||
config.locale = preferredLocale;
|
||||
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
|
||||
} else if("".equals(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) {
|
||||
Locale.setDefault(defaultLocale);
|
||||
config.locale = defaultLocale;
|
||||
preferredLocale = null;
|
||||
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -601,6 +611,10 @@ public class OsmandApplication extends Application {
|
|||
Locale.setDefault(preferredLocale);
|
||||
config.locale = preferredLocale;
|
||||
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
|
||||
} else if("".equals(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) {
|
||||
Locale.setDefault(defaultLocale);
|
||||
config.locale = defaultLocale;
|
||||
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -355,17 +355,19 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
settings.SPEAK_PEDESTRIAN, settings.SPEAK_SPEED_LIMIT,
|
||||
settings.SPEAK_SPEED_CAMERA,
|
||||
settings.ANNOUNCE_WPT, settings.ANNOUNCE_NEARBY_FAVORITES, settings.ANNOUNCE_NEARBY_POI}, preference.getTitle());
|
||||
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if(settings.SPEAK_SPEED_CAMERA.get()) {
|
||||
settings.SPEAK_SPEED_CAMERA.set(false);
|
||||
confirmSpeedCamerasDlg();
|
||||
if (!settings.SPEAK_SPEED_CAMERA.get()) {
|
||||
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (settings.SPEAK_SPEED_CAMERA.get()) {
|
||||
settings.SPEAK_SPEED_CAMERA.set(false);
|
||||
confirmSpeedCamerasDlg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue