From 7aa63847dfcf9a862efe1e2f50b0d0e79113972e Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 20 Oct 2015 22:01:46 +0300 Subject: [PATCH] Downloads search done --- .../download/ui/SearchDialogFragment.java | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java index 9793d5adc3..3ee2ee0202 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java @@ -27,8 +27,10 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion; +import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.download.DownloadResourceGroup; +import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType; import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.IndexItem; @@ -323,10 +325,44 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven } private void processGroup(DownloadResourceGroup group, List filter, List> conds) { - String indexLC = group.getName(ctx).toLowerCase(); - if (isMatch(conds, false, indexLC)) { + String name = group.getName(ctx).toLowerCase(); + if (group.getType().isScreen() && group.getParentGroup() != null + && group.getParentGroup().getParentGroup() != null + && group.getParentGroup().getParentGroup().getType() != DownloadResourceGroupType.WORLD + && isMatch(conds, false, name)) { + filter.add(group); + + for (DownloadResourceGroup g : group.getGroups()) { + if (g.getType() == DownloadResourceGroupType.REGION_MAPS) { + if (g.getIndividualResources() != null) { + for (IndexItem item : g.getIndividualResources()) { + if (item.getType() == DownloadActivityType.NORMAL_FILE) { + filter.add(item); + break; + } + } + } + break; + } + } } + + // process other maps & voice prompts + if (group.getType() == DownloadResourceGroupType.OTHER_MAPS_HEADER + || group.getType() == DownloadResourceGroupType.VOICE_HEADER_REC + || group.getType() == DownloadResourceGroupType.VOICE_HEADER_TTS) { + if (group.getIndividualResources() != null) { + for (IndexItem item : group.getIndividualResources()) { + name = item.getVisibleName(ctx, osmandRegions, false).toLowerCase(); + if (isMatch(conds, false, name)) { + filter.add(item); + break; + } + } + } + } + if (group.getGroups() != null) { for (DownloadResourceGroup g : group.getGroups()) { processGroup(g, filter, conds); @@ -361,31 +397,6 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven List filter = new ArrayList<>(); processGroup(root, filter, conds); - /* - List regions = new ArrayList<>(); - for (WorldRegion region : worldRegions) { - String indexLC = region.getName().toLowerCase(); - if (isMatch(conds, false, indexLC)) { - regions.add(region); - } - } - - for (WorldRegion region : regions) { - if (region.getSubregions().size() > 0) { - filter.add(region); - } - - List items = getDownloadActivity().getIndexItemsByRegion(region); - if (items.size() > 1) { - if (!filter.contains(region)) { - filter.add(region); - } - } else { - filter.addAll(items); - } - } - */ - final Collator collator = OsmAndCollator.primaryCollator(); Collections.sort(filter, new Comparator() { @Override