Fix wiki issues

This commit is contained in:
Victor Shcherb 2015-06-19 01:09:10 +02:00
parent caa20dcb3b
commit 4335926c8b
4 changed files with 25 additions and 15 deletions

View file

@ -267,9 +267,7 @@ public class AppInitializer implements IProgress {
app.favorites = startupInit(new FavouritesDbHelper(app), FavouritesDbHelper.class);
app.waypointHelper = startupInit(new WaypointHelper(app), WaypointHelper.class);
app.regions = startupInit(new OsmandRegions(), OsmandRegions.class);
String lang = osmandSettings.PREFERRED_LOCALE.get();
String clang = "".equals(lang) ? new Locale(lang).getLanguage() : lang;
app.regions.setLocale(clang);
app.regions.setLocale(app.getLanguage());
app.poiFilters = startupInit(new PoiFiltersHelper(app), PoiFiltersHelper.class);
app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class);
app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);

View file

@ -78,7 +78,6 @@ public class OsmandApplication extends Application {
Handler uiHandler;
NavigationService navigationService;
private Locale preferredLocale = null;
// start variables
ResourceManager resourceManager;
@ -101,6 +100,7 @@ public class OsmandApplication extends Application {
RoutingConfiguration.Builder defaultRoutingConfig;
private Locale preferredLocale = null;
private Locale defaultLocale;
private File externalStorageDirectory;
@ -131,11 +131,11 @@ public class OsmandApplication extends Application {
osmandSettings = appCustomization.getOsmandSettings();
externalStorageDirectory = osmandSettings.getExternalStorageDirectory();
checkPreferredLocale();
appInitializer.onCreateApplication();
// if(!osmandSettings.FOLLOW_THE_ROUTE.get()) {
// targetPointsHelper.clearPointToNavigate(false);
// }
checkPreferredLocale();
startApplication();
System.out.println("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
timeToStart = System.currentTimeMillis();
@ -623,6 +623,13 @@ public class OsmandApplication extends Application {
}
}
public String getLanguage() {
if(preferredLocale != null) {
return preferredLocale.getLanguage();
}
return Locale.getDefault().getLanguage();
}
public RoutingConfiguration.Builder getDefaultRoutingConfig() {
if(defaultRoutingConfig == null) {
defaultRoutingConfig = appInitializer.getLazyDefaultRoutingConfig();

View file

@ -598,14 +598,17 @@ public class DownloadIndexesThread {
File file = new File(((AssetIndexItem) item).getDestFile());
oldItemSize = file.length();
} else {
oldItemSize = new File(item.getType().getDownloadFolder(app, item), sfName +"/_config.p").length();
try {
InputStream is = ctx.getAssets(). open("voice/" + sfName + "/config.p");
if(is != null) {
oldItemSize = is.available();
is.close();
File fl = new File(item.getType().getDownloadFolder(app, item), sfName +"/_config.p");
if (fl.exists()) {
oldItemSize = fl.length();
try {
InputStream is = ctx.getAssets().open("voice/" + sfName + "/config.p");
if (is != null) {
itemSize = is.available();
is.close();
}
} catch (IOException e) {
}
} catch (IOException e) {
}
}
}

View file

@ -337,9 +337,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
public static void showDescriptionDialog(Context ctx, OsmandApplication app, Amenity a) {
String lang = app.getSettings().MAP_PREFERRED_LOCALE.get();
if (a.getType().isWiki()) {
// First choice to display wiki article in should be the selected OsmAnd locale (not the map display language)
//showWiki(ctx, app, a, lang);
showWiki(ctx, app, a, app.getSettings().MAP_PREFERRED_LOCALE.get());
String preferredLang = lang;
if(Algorithms.isEmpty(preferredLang)) {
preferredLang = app.getLanguage();
}
showWiki(ctx, app, a, preferredLang);
} else {
String d = OsmAndFormatter.getAmenityDescriptionContent(app, a, false);
SpannableString spannable = new SpannableString(d);