Merge pull request #10985 from osmandapp/fix_open_on_map_39

Fix open on map, travel article svg image thumbs, show more progress.
This commit is contained in:
vshcherb 2021-02-23 12:08:26 +02:00 committed by GitHub
commit 17fa1ed0af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 38 deletions

11
OsmAnd/.gitignore vendored
View file

@ -39,11 +39,7 @@ mx_*
valgrind/ valgrind/
bin/ bin/
dist/ dist/
assets/specialphrases/*
assets/voice/*
assets/fonts/*
assets/feature_articles/*
assets/World_basemap_mini*
gen/ gen/
local.properties local.properties
raw/ raw/
@ -56,6 +52,11 @@ out/
use/ use/
osmand.properties osmand.properties
osmand.xml osmand.xml
assets/specialphrases/*
assets/voice/*
assets/fonts/*
assets/feature_articles/*
assets/*.obf
assets/style.css assets/style.css
assets/poi_categories.json assets/poi_categories.json
assets/help/*.html assets/help/*.html

View file

@ -159,7 +159,8 @@ public class TravelArticle {
System.err.println(e.getMessage()); System.err.println(e.getMessage());
} }
String prefix = thumbnail ? THUMB_PREFIX : REGULAR_PREFIX; String prefix = thumbnail ? THUMB_PREFIX : REGULAR_PREFIX;
return IMAGE_ROOT_URL + "thumb/" + hash[0] + "/" + hash[1] + "/" + imageTitle + "/" + prefix + imageTitle; String suffix = imageTitle.endsWith(".svg") ? ".png" : "";
return IMAGE_ROOT_URL + "thumb/" + hash[0] + "/" + hash[1] + "/" + imageTitle + "/" + prefix + imageTitle + suffix;
} }
@Size(2) @Size(2)

View file

@ -943,6 +943,7 @@ public class TravelObfHelper implements TravelHelper {
} }
if (!Algorithms.isEmpty(amenities)) { if (!Algorithms.isEmpty(amenities)) {
article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, readGpx, callback); article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, readGpx, callback);
break;
} }
} }
return article; return article;

View file

@ -49,7 +49,6 @@ import java.util.List;
import static net.osmand.plus.download.DownloadResources.WIKIVOYAGE_FILE_FILTER; import static net.osmand.plus.download.DownloadResources.WIKIVOYAGE_FILE_FILTER;
import static net.osmand.plus.resources.ResourceManager.DEFAULT_WIKIVOYAGE_TRAVEL_OBF; import static net.osmand.plus.resources.ResourceManager.DEFAULT_WIKIVOYAGE_TRAVEL_OBF;
import static net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity.*;
public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEvents, TravelLocalDataHelper.Listener { public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEvents, TravelLocalDataHelper.Listener {
@ -95,10 +94,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
if (app != null) { if (app != null) {
app.getTravelHelper().getBookmarksHelper().addListener(this); app.getTravelHelper().getBookmarksHelper().addListener(this);
} }
WikivoyageExploreActivity exploreActivity = getExploreActivity();
if (exploreActivity != null) {
exploreActivity.onTabFragmentResume(this);
}
} }
@Override @Override
@ -141,7 +136,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
app.getTravelHelper().initializeDataOnAppStartup(); app.getTravelHelper().initializeDataOnAppStartup();
WikivoyageExploreActivity exploreActivity = getExploreActivity(); WikivoyageExploreActivity exploreActivity = getExploreActivity();
if (exploreActivity != null) { if (exploreActivity != null) {
exploreActivity.populateData(); exploreActivity.populateData(true);
} }
} else { } else {
removeRedundantCards(); removeRedundantCards();
@ -194,8 +189,9 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
travelButtonCard.setListener(new TravelNeededMapsCard.CardListener() { travelButtonCard.setListener(new TravelNeededMapsCard.CardListener() {
@Override @Override
public void onPrimaryButtonClick() { public void onPrimaryButtonClick() {
if (activity instanceof WikivoyageExploreActivity) { WikivoyageExploreActivity exploreActivity = getExploreActivity();
new LoadWikivoyageData((WikivoyageExploreActivity) activity, false).execute(); if (exploreActivity != null) {
exploreActivity.populateData(false);
} }
} }

View file

@ -1,6 +1,5 @@
package net.osmand.plus.wikivoyage.explore; package net.osmand.plus.wikivoyage.explore;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -80,10 +79,6 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Trav
if (dataHelper != null) { if (dataHelper != null) {
dataHelper.addListener(this); dataHelper.addListener(this);
} }
WikivoyageExploreActivity exploreActivity = getExploreActivity();
if (exploreActivity != null) {
exploreActivity.onTabFragmentResume(this);
}
} }
@Override @Override
@ -105,16 +100,6 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Trav
} }
} }
@Nullable
private WikivoyageExploreActivity getExploreActivity() {
Activity activity = getActivity();
if (activity != null && activity instanceof WikivoyageExploreActivity) {
return (WikivoyageExploreActivity) activity;
} else {
return null;
}
}
public void invalidateAdapter() { public void invalidateAdapter() {
if (adapter != null) { if (adapter != null) {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();

View file

@ -156,7 +156,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
}); });
updateSearchBarVisibility(); updateSearchBarVisibility();
populateData(); populateData(true);
} }
@Override @Override
@ -249,7 +249,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
invalidateTabAdapters(); invalidateTabAdapters();
break; break;
case WikivoyageOptionsBottomSheetDialogFragment.TRAVEL_BOOK_CHANGED: case WikivoyageOptionsBottomSheetDialogFragment.TRAVEL_BOOK_CHANGED:
populateData(); populateData(true);
break; break;
} }
} }
@ -313,7 +313,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
return ContextCompat.getColor(app, colorId); return ContextCompat.getColor(app, colorId);
} }
public void populateData() { public void populateData(final boolean resetData) {
switchProgressBarVisibility(true); switchProgressBarVisibility(true);
if (app.isApplicationInitializing()) { if (app.isApplicationInitializing()) {
final WeakReference<WikivoyageExploreActivity> activityRef = new WeakReference<>(this); final WeakReference<WikivoyageExploreActivity> activityRef = new WeakReference<>(this);
@ -326,12 +326,12 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
public void onFinish(AppInitializer init) { public void onFinish(AppInitializer init) {
WikivoyageExploreActivity activity = activityRef.get(); WikivoyageExploreActivity activity = activityRef.get();
if (AndroidUtils.isActivityNotDestroyed(activity)) { if (AndroidUtils.isActivityNotDestroyed(activity)) {
new LoadWikivoyageData(activity,true).execute(); new LoadWikivoyageData(activity, resetData).execute();
} }
} }
}); });
} else { } else {
new LoadWikivoyageData(this,true).execute(); new LoadWikivoyageData(this, resetData).execute();
} }
} }
@ -371,10 +371,6 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
} }
} }
public void onTabFragmentResume(Fragment fragment) {
updateFragments();
}
@Override @Override
public void savedArticlesUpdated() { public void savedArticlesUpdated() {
updateFragments(); updateFragments();