Downloads - added search
This commit is contained in:
parent
859a5e3231
commit
5091a5105a
10 changed files with 219 additions and 83 deletions
|
@ -403,7 +403,7 @@ public class OsmandRegions {
|
|||
if(locPrefix == null || locName == null) {
|
||||
throw new IllegalStateException("There is no prefix registered for " + fullName + " (" + parentFullName + ") ");
|
||||
}
|
||||
fullNamesToLocaleNames.put(fullName, locPrefix + " " + locName);
|
||||
fullNamesToLocaleNames.put(fullName, /*locPrefix + " " +*/ locName);
|
||||
String index = fullNamesToLowercaseIndex.get(fullName);
|
||||
String prindex = fullNamesToLowercaseIndex.get(parentFullName);
|
||||
fullNamesToLowercaseIndex.put(fullName, index + " " + prindex);
|
||||
|
|
8
OsmAnd/res/layout/download_search_items_fragment.xml
Normal file
8
OsmAnd/res/layout/download_search_items_fragment.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/ctx_menu_info_view_bg">
|
||||
<include layout="@layout/download_search_items_list"/>
|
||||
</LinearLayout>
|
11
OsmAnd/res/layout/download_search_items_list.xml
Normal file
11
OsmAnd/res/layout/download_search_items_list.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ListView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:focusable="true"
|
||||
android:groupIndicator="@android:color/transparent"
|
||||
android:background="@android:color/transparent"/>
|
||||
|
|
@ -107,7 +107,7 @@ public class WorldRegion implements Serializable {
|
|||
public void initWorld() {
|
||||
regionId = "";
|
||||
downloadsIdPrefix = "world_";
|
||||
name = null;
|
||||
name = "";
|
||||
superregion = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
|||
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
||||
import net.osmand.plus.activities.TabActivity;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.download.items.SearchDialogFragment;
|
||||
import net.osmand.plus.download.items.WorldItemsFragment;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||
|
@ -340,6 +341,10 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
if (f.isAdded()) {
|
||||
((WorldItemsFragment) f).onCategorizationFinished();
|
||||
}
|
||||
} else if (f instanceof SearchDialogFragment) {
|
||||
if (f.isAdded()) {
|
||||
((SearchDialogFragment) f).onCategorizationFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,54 +186,10 @@ public class DownloadIndexesThread {
|
|||
voiceRecItems.clear();
|
||||
voiceTTSItems.clear();
|
||||
|
||||
List<WorldRegion> mergedRegions = app.getWorldRegion().getFlattenedSubregions();
|
||||
mergedRegions.add(app.getWorldRegion());
|
||||
boolean voiceFilesProcessed = false;
|
||||
for (WorldRegion region : mergedRegions) {
|
||||
String downloadsIdPrefix = region.getDownloadsIdPrefix();
|
||||
|
||||
Map<String, IndexItem> regionResources = new HashMap<>();
|
||||
|
||||
Set<DownloadActivityType> typesSet = new TreeSet<>(new Comparator<DownloadActivityType>() {
|
||||
@Override
|
||||
public int compare(DownloadActivityType dat1, DownloadActivityType dat2) {
|
||||
return dat1.getTag().compareTo(dat2.getTag());
|
||||
}
|
||||
});
|
||||
|
||||
for (IndexItem resource : resourcesInRepository) {
|
||||
|
||||
if (!voiceFilesProcessed) {
|
||||
if (resource.getSimplifiedFileName().endsWith(".voice.zip")) {
|
||||
voiceRecItems.add(resource);
|
||||
continue;
|
||||
} else if (resource.getSimplifiedFileName().contains(".ttsvoice.zip")) {
|
||||
voiceTTSItems.add(resource);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!resource.getSimplifiedFileName().startsWith(downloadsIdPrefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
typesSet.add(resource.getType());
|
||||
regionResources.put(resource.getSimplifiedFileName(), resource);
|
||||
}
|
||||
|
||||
voiceFilesProcessed = true;
|
||||
|
||||
if (region.getSuperregion() != null && region.getSuperregion().getSuperregion() != app.getWorldRegion()) {
|
||||
if (region.getSuperregion().getResourceTypes() == null) {
|
||||
region.getSuperregion().setResourceTypes(typesSet);
|
||||
} else {
|
||||
region.getSuperregion().getResourceTypes().addAll(typesSet);
|
||||
}
|
||||
}
|
||||
|
||||
region.setResourceTypes(typesSet);
|
||||
resourcesByRegions.put(region, regionResources);
|
||||
for (WorldRegion region : app.getWorldRegion().getFlattenedSubregions()) {
|
||||
processRegion(resourcesInRepository, false, region);
|
||||
}
|
||||
processRegion(resourcesInRepository, true, app.getWorldRegion());
|
||||
|
||||
final Collator collator = OsmAndCollator.primaryCollator();
|
||||
final OsmandRegions osmandRegions = app.getRegions();
|
||||
|
@ -257,6 +213,50 @@ public class DownloadIndexesThread {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void processRegion(List<IndexItem> resourcesInRepository, boolean processVoiceFiles, WorldRegion region) {
|
||||
String downloadsIdPrefix = region.getDownloadsIdPrefix();
|
||||
|
||||
Map<String, IndexItem> regionResources = new HashMap<>();
|
||||
|
||||
Set<DownloadActivityType> typesSet = new TreeSet<>(new Comparator<DownloadActivityType>() {
|
||||
@Override
|
||||
public int compare(DownloadActivityType dat1, DownloadActivityType dat2) {
|
||||
return dat1.getTag().compareTo(dat2.getTag());
|
||||
}
|
||||
});
|
||||
|
||||
for (IndexItem resource : resourcesInRepository) {
|
||||
|
||||
if (processVoiceFiles) {
|
||||
if (resource.getSimplifiedFileName().endsWith(".voice.zip")) {
|
||||
voiceRecItems.add(resource);
|
||||
continue;
|
||||
} else if (resource.getSimplifiedFileName().contains(".ttsvoice.zip")) {
|
||||
voiceTTSItems.add(resource);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!resource.getSimplifiedFileName().startsWith(downloadsIdPrefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
typesSet.add(resource.getType());
|
||||
regionResources.put(resource.getSimplifiedFileName(), resource);
|
||||
}
|
||||
|
||||
if (region.getSuperregion() != null && region.getSuperregion().getSuperregion() != app.getWorldRegion()) {
|
||||
if (region.getSuperregion().getResourceTypes() == null) {
|
||||
region.getSuperregion().setResourceTypes(typesSet);
|
||||
} else {
|
||||
region.getSuperregion().getResourceTypes().addAll(typesSet);
|
||||
}
|
||||
}
|
||||
|
||||
region.setResourceTypes(typesSet);
|
||||
resourcesByRegions.put(region, regionResources);
|
||||
}
|
||||
|
||||
public class DownloadIndexesAsyncTask extends BasicProgressAsyncTask<IndexItem, Object, String> implements DownloadFileShowWarning {
|
||||
|
||||
private OsmandPreference<Integer> downloads;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package net.osmand.plus.download.items;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.WorldRegion;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -13,6 +8,12 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.WorldRegion;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
|
||||
public class RegionDialogFragment extends DialogFragment {
|
||||
public static final String TAG = "RegionDialogFragment";
|
||||
private static final String REGION_ID_DLG_KEY = "world_region_dialog_key";
|
||||
|
@ -21,7 +22,7 @@ public class RegionDialogFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
boolean isLightTheme = ((OsmandApplication) getActivity().getApplication())
|
||||
boolean isLightTheme = getMyApplication()
|
||||
.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
setStyle(STYLE_NO_FRAME, themeId);
|
||||
|
@ -61,7 +62,7 @@ public class RegionDialogFragment extends DialogFragment {
|
|||
toolbar.setTitle(region.getName());
|
||||
}
|
||||
}
|
||||
((DownloadActivity)getActivity()).initFreeVersionBanner(view);
|
||||
getDownloadActivity().initFreeVersionBanner(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -75,8 +76,12 @@ public class RegionDialogFragment extends DialogFragment {
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
private DownloadActivity getDownloadActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
||||
public void onRegionSelected(String regionId) {
|
||||
((DownloadActivity)getActivity()).showDialog(getActivity(), createInstance(regionId));
|
||||
getDownloadActivity().showDialog(getActivity(), createInstance(regionId));
|
||||
}
|
||||
|
||||
public static RegionDialogFragment createInstance(String regionId) {
|
||||
|
|
|
@ -5,8 +5,13 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.RelativeLayout.LayoutParams;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -18,12 +23,12 @@ public class SearchDialogFragment extends DialogFragment {
|
|||
public static final String TAG = "SearchDialogFragment";
|
||||
private static final String SEARCH_TEXT_DLG_KEY = "search_text_dlg_key";
|
||||
private String searchText;
|
||||
SearchView search;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
boolean isLightTheme = ((OsmandApplication) getActivity().getApplication())
|
||||
.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||
boolean isLightTheme = getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
setStyle(STYLE_NO_FRAME, themeId);
|
||||
}
|
||||
|
@ -51,13 +56,44 @@ public class SearchDialogFragment extends DialogFragment {
|
|||
}
|
||||
});
|
||||
|
||||
search = new SearchView(getActivity());
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 0, 0);
|
||||
search.setQueryHint("Enter map name");
|
||||
search.setLayoutParams(params);
|
||||
toolbar.addView(search);
|
||||
|
||||
search.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
}
|
||||
});
|
||||
|
||||
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
Fragment f = getChildFragmentManager().findFragmentByTag(SearchItemsFragment.TAG);
|
||||
if (f != null) {
|
||||
((SearchItemsFragment) f).updateSearchText(newText);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Fragment fragment = getChildFragmentManager().findFragmentById(R.id.fragmentContainer);
|
||||
if (fragment == null) {
|
||||
getChildFragmentManager().beginTransaction().add(R.id.fragmentContainer,
|
||||
SearchItemsFragment.createInstance(searchText)).commit();
|
||||
SearchItemsFragment.createInstance(searchText), SearchItemsFragment.TAG).commit();
|
||||
}
|
||||
|
||||
((DownloadActivity) getActivity()).initFreeVersionBanner(view);
|
||||
getDownloadActivity().initFreeVersionBanner(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -67,10 +103,28 @@ public class SearchDialogFragment extends DialogFragment {
|
|||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
//search.setIconifiedByDefault(false);
|
||||
search.setIconified(false);
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
private DownloadActivity getDownloadActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
||||
public void onCategorizationFinished() {
|
||||
Fragment f = getChildFragmentManager().findFragmentByTag(SearchItemsFragment.TAG);
|
||||
if (f != null) {
|
||||
((SearchItemsFragment) f).onCategorizationFinished();
|
||||
}
|
||||
}
|
||||
|
||||
public static SearchDialogFragment createInstance(String searchText) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SEARCH_TEXT_DLG_KEY, searchText);
|
||||
|
|
|
@ -13,6 +13,8 @@ import android.widget.Filter;
|
|||
import android.widget.Filterable;
|
||||
import android.widget.ListView;
|
||||
|
||||
import net.osmand.Collator;
|
||||
import net.osmand.OsmAndCollator;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -29,8 +31,11 @@ import net.osmand.plus.srtmplugin.SRTMPlugin;
|
|||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SearchItemsFragment extends Fragment {
|
||||
public static final String TAG = "SearchItemsFragment";
|
||||
|
@ -49,7 +54,7 @@ public class SearchItemsFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.download_items_fragment, container, false);
|
||||
View view = inflater.inflate(R.layout.download_search_items_fragment, container, false);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
searchText = savedInstanceState.getString(SEARCH_TEXT_KEY);
|
||||
|
@ -73,7 +78,6 @@ public class SearchItemsFragment extends Fragment {
|
|||
});
|
||||
|
||||
fillSearchItemsAdapter();
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -113,8 +117,25 @@ public class SearchItemsFragment extends Fragment {
|
|||
private void fillSearchItemsAdapter() {
|
||||
if (listAdapter != null) {
|
||||
listAdapter.clear();
|
||||
listAdapter.addWorldRegions(getMyApplication().getWorldRegion().getFlattenedSubregions());
|
||||
listAdapter.addIndexItems(getDownloadActivity().getIndexFiles());
|
||||
List<WorldRegion> flattenedList = getMyApplication().getWorldRegion().getFlattenedSubregions();
|
||||
List<IndexItem> indexItems = getDownloadActivity().getIndexFiles();
|
||||
if (flattenedList != null && flattenedList.size() > 0 &&
|
||||
indexItems != null && indexItems.size() > 0) {
|
||||
listAdapter.addWorldRegions(flattenedList);
|
||||
listAdapter.addIndexItems(indexItems);
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onCategorizationFinished() {
|
||||
fillSearchItemsAdapter();
|
||||
}
|
||||
|
||||
public void updateSearchText(String searchText) {
|
||||
this.searchText = searchText;
|
||||
if(listAdapter != null){
|
||||
listAdapter.getFilter().filter(searchText);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +250,7 @@ public class SearchItemsFragment extends Fragment {
|
|||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
FilterResults results = new FilterResults();
|
||||
if (constraint == null || constraint.length() == 0) {
|
||||
if (constraint == null || constraint.length() < 2) {
|
||||
results.values = new ArrayList<>();
|
||||
results.count = 0;
|
||||
} else {
|
||||
|
@ -251,22 +272,43 @@ public class SearchItemsFragment extends Fragment {
|
|||
Context c = getDownloadActivity();
|
||||
|
||||
for (WorldRegion region : worldRegions) {
|
||||
String indexLC = region.getName();
|
||||
String indexLC = region.getName().toLowerCase();
|
||||
if (isMatch(conds, false, indexLC)) {
|
||||
filter.add(region);
|
||||
}
|
||||
}
|
||||
|
||||
for (IndexItem item : indexItems) {
|
||||
String indexLC = osmandRegions.getDownloadNameIndexLowercase(item.getBasename());
|
||||
if (indexLC == null) {
|
||||
indexLC = item.getVisibleName(c, osmandRegions).toLowerCase();
|
||||
}
|
||||
String indexLC = item.getVisibleName(c, osmandRegions).toLowerCase();
|
||||
if (isMatch(conds, false, indexLC)) {
|
||||
filter.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
final Collator collator = OsmAndCollator.primaryCollator();
|
||||
Collections.sort(filter, new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object obj1, Object obj2) {
|
||||
|
||||
String str1;
|
||||
String str2;
|
||||
|
||||
if (obj1 instanceof WorldRegion) {
|
||||
str1 = ((WorldRegion) obj1).getName();
|
||||
} else {
|
||||
str1 = ((IndexItem) obj1).getVisibleName(getMyApplication(), osmandRegions);
|
||||
}
|
||||
|
||||
if (obj2 instanceof WorldRegion) {
|
||||
str2 = ((WorldRegion) obj2).getName();
|
||||
} else {
|
||||
str2 = ((IndexItem) obj2).getVisibleName(getMyApplication(), osmandRegions);
|
||||
}
|
||||
|
||||
return collator.compare(str1, str2);
|
||||
}
|
||||
});
|
||||
|
||||
results.values = filter;
|
||||
results.count = filter.size();
|
||||
}
|
||||
|
@ -296,6 +338,7 @@ public class SearchItemsFragment extends Fragment {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||
items.clear();
|
||||
List<Object> values = (List<Object>) results.values;
|
||||
if (values != null && !values.isEmpty()) {
|
||||
items.addAll(values);
|
||||
|
|
|
@ -42,6 +42,7 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
|||
private static final Log LOG = PlatformUtil.getLog(WorldItemsFragment.class);
|
||||
|
||||
public static final int RELOAD_ID = 0;
|
||||
public static final int SEARCH_ID = 1;
|
||||
|
||||
private WorldItemsAdapter listAdapter;
|
||||
|
||||
|
@ -70,7 +71,7 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
|||
|
||||
onCategorizationFinished();
|
||||
|
||||
((DownloadActivity) getActivity()).initFreeVersionBanner(view);
|
||||
getDownloadActivity().initFreeVersionBanner(view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -127,14 +128,14 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
|||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||
if (groupPosition == worldRegionsIndex) {
|
||||
WorldRegion region = (WorldRegion)listAdapter.getChild(groupPosition, childPosition);
|
||||
((DownloadActivity)getActivity()).showDialog(getActivity(), RegionDialogFragment.createInstance(region.getRegionId()));
|
||||
getDownloadActivity().showDialog(getActivity(), RegionDialogFragment.createInstance(region.getRegionId()));
|
||||
return true;
|
||||
} else if (groupPosition == voicePromptsIndex) {
|
||||
if (childPosition == voicePromptsItemsRecordedSubIndex) {
|
||||
((DownloadActivity)getActivity()).showDialog(getActivity(),
|
||||
getDownloadActivity().showDialog(getActivity(),
|
||||
VoiceDialogFragment.createInstance(VoicePromptsType.RECORDED));
|
||||
} else {
|
||||
((DownloadActivity) getActivity()).showDialog(getActivity(),
|
||||
getDownloadActivity().showDialog(getActivity(),
|
||||
VoiceDialogFragment.createInstance(VoicePromptsType.TTS));
|
||||
}
|
||||
}
|
||||
|
@ -143,19 +144,28 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
|||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
MenuItem item = menu.add(0, RELOAD_ID, 0, R.string.shared_string_refresh);
|
||||
item.setIcon(R.drawable.ic_action_refresh_dark);
|
||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
MenuItem itemReload = menu.add(0, RELOAD_ID, 0, R.string.shared_string_refresh);
|
||||
itemReload.setIcon(R.drawable.ic_action_refresh_dark);
|
||||
MenuItemCompat.setShowAsAction(itemReload, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
|
||||
MenuItem itemSearch = menu.add(0, SEARCH_ID, 1, R.string.shared_string_search);
|
||||
itemSearch.setIcon(R.drawable.ic_action_search_dark);
|
||||
MenuItemCompat.setShowAsAction(itemSearch, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == RELOAD_ID) {
|
||||
// re-create the thread
|
||||
DownloadActivity.downloadListIndexThread.runReloadIndexFiles();
|
||||
return true;
|
||||
switch (item.getItemId()) {
|
||||
case RELOAD_ID:
|
||||
// re-create the thread
|
||||
DownloadActivity.downloadListIndexThread.runReloadIndexFiles();
|
||||
return true;
|
||||
case SEARCH_ID:
|
||||
getDownloadActivity().showDialog(getActivity(), SearchDialogFragment.createInstance(""));
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private DownloadActivity getDownloadActivity() {
|
||||
|
|
Loading…
Reference in a new issue