Show wiki maps only from wikivoyage article
This commit is contained in:
parent
8eb9d6575f
commit
825c9bdc21
2 changed files with 18 additions and 4 deletions
|
@ -138,9 +138,10 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
accessibilityAssistant = new AccessibilityAssistant(this);
|
||||
|
||||
setContentView(R.layout.download);
|
||||
// Search for the region from Wikivoyage article
|
||||
String region = getIntent() == null ? "" : getIntent().getStringExtra(REGION_TO_SEARCH);
|
||||
if (region != null && !region.isEmpty()) {
|
||||
showDialog(this, SearchDialogFragment.createInstance(region));
|
||||
showDialog(this, SearchDialogFragment.createInstance(region, true));
|
||||
}
|
||||
//noinspection ConstantConditions
|
||||
getSupportActionBar().setTitle(R.string.shared_string_map);
|
||||
|
|
|
@ -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";
|
||||
private 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);
|
||||
|
@ -465,7 +477,8 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
if (g.getIndividualResources() != null) {
|
||||
for (IndexItem item : g.getIndividualResources()) {
|
||||
if (item.getType() == DownloadActivityType.NORMAL_FILE
|
||||
|| item.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
|
||||
|| (item.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||
&& showWiki)) {
|
||||
filter.add(item);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue