Show needed wiki maps from wikivoyage article

This commit is contained in:
PaulStets 2018-05-01 12:39:23 +03:00
parent 57a411052b
commit 8eb9d6575f
3 changed files with 10 additions and 2 deletions

View file

@ -56,6 +56,7 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.ui.ActiveDownloadsDialogFragment;
import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
import net.osmand.plus.download.ui.LocalIndexesFragment;
import net.osmand.plus.download.ui.SearchDialogFragment;
import net.osmand.plus.download.ui.UpdatesIndexFragment;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
@ -100,6 +101,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
public static final String LOCAL_TAB = "local";
public static final String DOWNLOAD_TAB = "download";
public static final String UPDATES_TAB = "updates";
public static final String REGION_TO_SEARCH = "search_region";
public static final MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
public static final MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
public static final MessageFormat formatKb = new MessageFormat("{0, number,##.#} kB", Locale.US);
@ -136,6 +138,10 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
accessibilityAssistant = new AccessibilityAssistant(this);
setContentView(R.layout.download);
String region = getIntent() == null ? "" : getIntent().getStringExtra(REGION_TO_SEARCH);
if (region != null && !region.isEmpty()) {
showDialog(this, SearchDialogFragment.createInstance(region));
}
//noinspection ConstantConditions
getSupportActionBar().setTitle(R.string.shared_string_map);
final View downloadProgressLayout = findViewById(R.id.downloadProgressLayout);

View file

@ -464,9 +464,9 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
if (g.getType() == DownloadResourceGroupType.REGION_MAPS) {
if (g.getIndividualResources() != null) {
for (IndexItem item : g.getIndividualResources()) {
if (item.getType() == DownloadActivityType.NORMAL_FILE) {
if (item.getType() == DownloadActivityType.NORMAL_FILE
|| item.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
filter.add(item);
break;
}
}
}

View file

@ -17,6 +17,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
public class WikivoyageArticleWikiLinkFragment extends MenuBottomSheetDialogFragment {
@ -74,6 +75,7 @@ public class WikivoyageArticleWikiLinkFragment extends MenuBottomSheetDialogFrag
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getDownloadActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
newIntent.putExtra(DownloadActivity.REGION_TO_SEARCH, wikiRegion);
mapActivity.startActivity(newIntent);
dismiss();
}