Fix Wikivoyage Card to suggest download maps

This commit is contained in:
Dima-1 2020-12-22 19:23:32 +02:00
parent ecb5354b5a
commit 7944fc3a2b
7 changed files with 26 additions and 16 deletions

View file

@ -80,7 +80,7 @@ public class DownloadResources extends DownloadResourceGroup {
List<IndexItem> items = getWikivoyageItems();
if (items != null) {
for (IndexItem ii : items) {
if (ii.getFileName().equals(fileName)) {
if (ii.getTargetFile(app).getName().equals(fileName)) {
return ii;
}
}

View file

@ -301,7 +301,7 @@ public class WikiArticleHelper {
return null;
}
String firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + P_CLOSED.length());
while (firstParagraphHtml.length() == (P_OPENED.length() + P_CLOSED.length())
while (firstParagraphHtml.substring(P_OPENED.length(), firstParagraphHtml.length() - P_CLOSED.length()).trim().isEmpty()
&& (firstParagraphEnd + P_CLOSED.length()) < content.length()) {
firstParagraphStart = content.indexOf(P_OPENED, firstParagraphEnd);
firstParagraphEnd = firstParagraphStart == -1 ? -1 : content.indexOf(P_CLOSED, firstParagraphStart);

View file

@ -46,6 +46,7 @@ public class TravelDbHelper implements TravelHelper {
private static final Log LOG = PlatformUtil.getLog(TravelDbHelper.class);
private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite";
private static final String ARTICLES_TABLE_NAME = "travel_articles";
private static final String POPULAR_TABLE_NAME = "popular_articles";
private static final String ARTICLES_POP_INDEX = "popularity_index";
@ -185,6 +186,11 @@ public class TravelDbHelper implements TravelHelper {
return null;
}
@Override
public String getWikivoyageFileName() {
return WORLD_WIKIVOYAGE_FILE_NAME;
}
public List<File> getExistingTravelBooks() {
return existingTravelBooks;
}

View file

@ -49,4 +49,6 @@ public interface TravelHelper {
// For TravelOBFHelper it could always return "" and should be no problem
// Bookmarks should be refactored properly to support multiple files
String getSelectedTravelBookName();
String getWikivoyageFileName();
}

View file

@ -37,8 +37,10 @@ import static net.osmand.CollatorStringMatcher.StringMatcherMode.CHECK_EQUALS_FR
public class TravelObfHelper implements TravelHelper {
private static final Log LOG = PlatformUtil.getLog(TravelObfHelper.class);
public static final String ROUTE_ARTICLE = "route_article";
public static final int SEARCH_RADIUS = 100000;
private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.travel.obf";
private static final String ROUTE_ARTICLE = "route_article";
private static final int SEARCH_RADIUS = 100000;
private final OsmandApplication app;
private final Collator collator;
@ -392,4 +394,9 @@ public class TravelObfHelper implements TravelHelper {
public String getSelectedTravelBookName() {
return "";
}
@Override
public String getWikivoyageFileName() {
return WORLD_WIKIVOYAGE_FILE_NAME;
}
}

View file

@ -45,8 +45,6 @@ import java.util.List;
public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEvents, TravelLocalDataHelper.Listener {
private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite";
private static boolean SHOW_TRAVEL_UPDATE_CARD = true;
private static boolean SHOW_TRAVEL_NEEDED_MAPS_CARD = true;
@ -342,14 +340,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
return res.toArray(new IndexItem[0]);
}
@NonNull
private String getWikivoyageFileName() {
// OsmandApplication app = getMyApplication();
// File selectedTravelBook = app != null ? app.getTravelDbHelper().getSelectedTravelBook() : null;
// return selectedTravelBook == null ? WORLD_WIKIVOYAGE_FILE_NAME : selectedTravelBook.getName();
return WORLD_WIKIVOYAGE_FILE_NAME;
}
private void removeDownloadUpdateCard() {
if (adapter != null) {
adapter.removeDownloadUpdateCard();
@ -379,7 +369,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
ProcessIndexItemsTask(ExploreTabFragment fragment) {
app = fragment.getMyApplication();
weakFragment = new WeakReference<>(fragment);
fileName = fragment.getWikivoyageFileName();
fileName = app.getTravelHelper().getWikivoyageFileName();
}
@Override

View file

@ -61,6 +61,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
protected List<WeakReference<Fragment>> fragments = new ArrayList<>();
private LockableViewPager viewPager;
private boolean finishDownloading = false;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -313,10 +314,12 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
public void populateData() {
switchProgressBarVisibility(true);
finishDownloading = false;
new LoadWikivoyageData(this).execute();
}
private void onDataLoaded() {
finishDownloading = true;
switchProgressBarVisibility(false);
updateSearchBarVisibility();
updateFragments();
@ -353,7 +356,9 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
}
public void onTabFragmentResume(Fragment fragment) {
updateFragments();
if(finishDownloading) {
updateFragments();
}
}
@Override