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);
|
accessibilityAssistant = new AccessibilityAssistant(this);
|
||||||
|
|
||||||
setContentView(R.layout.download);
|
setContentView(R.layout.download);
|
||||||
|
// Search for the region from Wikivoyage article
|
||||||
String region = getIntent() == null ? "" : getIntent().getStringExtra(REGION_TO_SEARCH);
|
String region = getIntent() == null ? "" : getIntent().getStringExtra(REGION_TO_SEARCH);
|
||||||
if (region != null && !region.isEmpty()) {
|
if (region != null && !region.isEmpty()) {
|
||||||
showDialog(this, SearchDialogFragment.createInstance(region));
|
showDialog(this, SearchDialogFragment.createInstance(region, true));
|
||||||
}
|
}
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
getSupportActionBar().setTitle(R.string.shared_string_map);
|
getSupportActionBar().setTitle(R.string.shared_string_map);
|
||||||
|
|
|
@ -65,6 +65,8 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
||||||
|
|
||||||
public static final String TAG = "SearchDialogFragment";
|
public static final String TAG = "SearchDialogFragment";
|
||||||
private static final String SEARCH_TEXT_DLG_KEY = "search_text_dlg_key";
|
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 ListView listView;
|
||||||
private SearchListAdapter listAdapter;
|
private SearchListAdapter listAdapter;
|
||||||
private BannerAndDownloadFreeVersion banner;
|
private BannerAndDownloadFreeVersion banner;
|
||||||
|
@ -89,12 +91,16 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
searchText = savedInstanceState.getString(SEARCH_TEXT_DLG_KEY);
|
searchText = savedInstanceState.getString(SEARCH_TEXT_DLG_KEY);
|
||||||
|
showWiki = savedInstanceState.getBoolean(SHOW_WIKI_KEY);
|
||||||
}
|
}
|
||||||
if (searchText == null) {
|
if (searchText == null) {
|
||||||
searchText = getArguments().getString(SEARCH_TEXT_DLG_KEY);
|
searchText = getArguments().getString(SEARCH_TEXT_DLG_KEY);
|
||||||
|
showWiki = getArguments().getBoolean(SHOW_WIKI_KEY);
|
||||||
}
|
}
|
||||||
if (searchText == null)
|
if (searchText == null) {
|
||||||
searchText = "";
|
searchText = "";
|
||||||
|
showWiki = false;
|
||||||
|
}
|
||||||
|
|
||||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||||
toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
|
toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
|
||||||
|
@ -208,6 +214,7 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
outState.putString(SEARCH_TEXT_DLG_KEY, searchText);
|
outState.putString(SEARCH_TEXT_DLG_KEY, searchText);
|
||||||
|
outState.putBoolean(SHOW_WIKI_KEY, showWiki);
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,14 +241,19 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
||||||
return (DownloadActivity) getActivity();
|
return (DownloadActivity) getActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchDialogFragment createInstance(String searchText) {
|
public static SearchDialogFragment createInstance(String searchText, boolean showWiki) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(SEARCH_TEXT_DLG_KEY, searchText);
|
bundle.putString(SEARCH_TEXT_DLG_KEY, searchText);
|
||||||
|
bundle.putBoolean(SHOW_WIKI_KEY, showWiki);
|
||||||
SearchDialogFragment fragment = new SearchDialogFragment();
|
SearchDialogFragment fragment = new SearchDialogFragment();
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SearchDialogFragment createInstance(String searchText) {
|
||||||
|
return createInstance(searchText, false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||||
Object obj = listAdapter.getItem(position);
|
Object obj = listAdapter.getItem(position);
|
||||||
|
@ -465,7 +477,8 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
||||||
if (g.getIndividualResources() != null) {
|
if (g.getIndividualResources() != null) {
|
||||||
for (IndexItem item : g.getIndividualResources()) {
|
for (IndexItem item : g.getIndividualResources()) {
|
||||||
if (item.getType() == DownloadActivityType.NORMAL_FILE
|
if (item.getType() == DownloadActivityType.NORMAL_FILE
|
||||||
|| item.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
|
|| (item.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||||
|
&& showWiki)) {
|
||||||
filter.add(item);
|
filter.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue