Update OsmandApplication.java
Correct typo: preffered -> preferred and checkPreffered -> checkPreferred
This commit is contained in:
parent
7daf391753
commit
353cbff6b9
1 changed files with 14 additions and 14 deletions
|
@ -103,7 +103,7 @@ public class OsmandApplication extends Application {
|
||||||
private RoutingConfiguration.Builder defaultRoutingConfig;
|
private RoutingConfiguration.Builder defaultRoutingConfig;
|
||||||
|
|
||||||
private boolean applicationInitializing = false;
|
private boolean applicationInitializing = false;
|
||||||
private Locale prefferedLocale = null;
|
private Locale preferredLocale = null;
|
||||||
|
|
||||||
SQLiteAPI sqliteAPI;
|
SQLiteAPI sqliteAPI;
|
||||||
BRouterServiceConnection bRouterServiceConnection;
|
BRouterServiceConnection bRouterServiceConnection;
|
||||||
|
@ -157,7 +157,7 @@ public class OsmandApplication extends Application {
|
||||||
// targetPointsHelper.clearPointToNavigate(false);
|
// targetPointsHelper.clearPointToNavigate(false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
checkPrefferedLocale();
|
checkPreferredLocale();
|
||||||
startApplication();
|
startApplication();
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
|
LOG.debug("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
|
||||||
|
@ -254,26 +254,26 @@ public class OsmandApplication extends Application {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
if (prefferedLocale != null && !newConfig.locale.getLanguage().equals(prefferedLocale.getLanguage())) {
|
if (preferredLocale != null && !newConfig.locale.getLanguage().equals(preferredLocale.getLanguage())) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
// ugly fix ! On devices after 4.0 screen is blinking when you rotate device!
|
// ugly fix ! On devices after 4.0 screen is blinking when you rotate device!
|
||||||
if (Build.VERSION.SDK_INT < 14) {
|
if (Build.VERSION.SDK_INT < 14) {
|
||||||
newConfig.locale = prefferedLocale;
|
newConfig.locale = preferredLocale;
|
||||||
}
|
}
|
||||||
getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
|
getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
|
||||||
Locale.setDefault(prefferedLocale);
|
Locale.setDefault(preferredLocale);
|
||||||
} else {
|
} else {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPrefferedLocale() {
|
public void checkPreferredLocale() {
|
||||||
Configuration config = getBaseContext().getResources().getConfiguration();
|
Configuration config = getBaseContext().getResources().getConfiguration();
|
||||||
String lang = osmandSettings.PREFERRED_LOCALE.get();
|
String lang = osmandSettings.PREFERRED_LOCALE.get();
|
||||||
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
|
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
|
||||||
prefferedLocale = new Locale(lang);
|
preferredLocale = new Locale(lang);
|
||||||
Locale.setDefault(prefferedLocale);
|
Locale.setDefault(preferredLocale);
|
||||||
config.locale = prefferedLocale;
|
config.locale = preferredLocale;
|
||||||
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
|
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
|
||||||
}
|
}
|
||||||
String clang = "".equals(lang) ? config.locale.getLanguage() : lang;
|
String clang = "".equals(lang) ? config.locale.getLanguage() : lang;
|
||||||
|
@ -763,13 +763,13 @@ public class OsmandApplication extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLanguage(Context context) {
|
public void setLanguage(Context context) {
|
||||||
if (prefferedLocale != null) {
|
if (preferredLocale != null) {
|
||||||
Configuration config = context.getResources().getConfiguration();
|
Configuration config = context.getResources().getConfiguration();
|
||||||
String lang = prefferedLocale.getLanguage();
|
String lang = preferredLocale.getLanguage();
|
||||||
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
|
if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) {
|
||||||
prefferedLocale = new Locale(lang);
|
preferredLocale = new Locale(lang);
|
||||||
Locale.setDefault(prefferedLocale);
|
Locale.setDefault(preferredLocale);
|
||||||
config.locale = prefferedLocale;
|
config.locale = preferredLocale;
|
||||||
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
|
context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue