diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index e188a8a017..7ab4f2e41d 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -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; @@ -79,6 +80,8 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import static net.osmand.plus.download.ui.SearchDialogFragment.SHOW_WIKI_KEY; + public class DownloadActivity extends AbstractDownloadActivity implements DownloadEvents, OnRequestPermissionsResultCallback { private static final Log LOG = PlatformUtil.getLog(DownloadActivity.class); @@ -100,6 +103,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); @@ -193,6 +197,11 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo final Intent intent = getIntent(); if (intent != null && intent.getExtras() != null) { + String region = getIntent().getStringExtra(REGION_TO_SEARCH); + if (region != null && !region.isEmpty()) { + showDialog(this, SearchDialogFragment.createInstance(region, + getIntent().getBooleanExtra(SHOW_WIKI_KEY, false))); + } filter = intent.getExtras().getString(FILTER_KEY); filterCat = intent.getExtras().getString(FILTER_CAT); filterGroup = intent.getExtras().getString(FILTER_GROUP); diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java index 44254053bb..0d30efc9ae 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java @@ -65,6 +65,8 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven public static final String TAG = "SearchDialogFragment"; private static final String SEARCH_TEXT_DLG_KEY = "search_text_dlg_key"; + public static final String SHOW_WIKI_KEY = "show_wiki_key"; + private boolean showWiki; private ListView listView; private SearchListAdapter listAdapter; private BannerAndDownloadFreeVersion banner; @@ -89,12 +91,16 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven if (savedInstanceState != null) { searchText = savedInstanceState.getString(SEARCH_TEXT_DLG_KEY); + showWiki = savedInstanceState.getBoolean(SHOW_WIKI_KEY); } if (searchText == null) { searchText = getArguments().getString(SEARCH_TEXT_DLG_KEY); + showWiki = getArguments().getBoolean(SHOW_WIKI_KEY); } - if (searchText == null) + if (searchText == null) { searchText = ""; + showWiki = false; + } Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); toolbar.setNavigationIcon(R.drawable.ic_arrow_back); @@ -208,6 +214,7 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven @Override public void onSaveInstanceState(Bundle outState) { outState.putString(SEARCH_TEXT_DLG_KEY, searchText); + outState.putBoolean(SHOW_WIKI_KEY, showWiki); super.onSaveInstanceState(outState); } @@ -234,14 +241,19 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven return (DownloadActivity) getActivity(); } - public static SearchDialogFragment createInstance(String searchText) { + public static SearchDialogFragment createInstance(String searchText, boolean showWiki) { Bundle bundle = new Bundle(); bundle.putString(SEARCH_TEXT_DLG_KEY, searchText); + bundle.putBoolean(SHOW_WIKI_KEY, showWiki); SearchDialogFragment fragment = new SearchDialogFragment(); fragment.setArguments(bundle); return fragment; } + public static SearchDialogFragment createInstance(String searchText) { + return createInstance(searchText, false); + } + @Override public void onItemClick(AdapterView parent, View v, int position, long id) { Object obj = listAdapter.getItem(position); @@ -464,9 +476,10 @@ 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 + && showWiki)) { filter.add(item); - break; } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleWikiLinkFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleWikiLinkFragment.java index f1a8c1be39..1d30bdc1af 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleWikiLinkFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleWikiLinkFragment.java @@ -17,8 +17,11 @@ 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; +import static net.osmand.plus.download.ui.SearchDialogFragment.SHOW_WIKI_KEY; + public class WikivoyageArticleWikiLinkFragment extends MenuBottomSheetDialogFragment { public static final String TAG = WikivoyageArticleWikiLinkFragment.class.getSimpleName(); @@ -74,6 +77,8 @@ 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); + newIntent.putExtra(SHOW_WIKI_KEY, true); mapActivity.startActivity(newIntent); dismiss(); }