diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index c2bed57359..6a0098d7e4 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -78,6 +78,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl List mTabs = new ArrayList(); public static final String FILTER_KEY = "filter"; public static final String FILTER_CAT = "filter_cat"; + public static final String FILTER_GROUP = "filter_group"; public static final String TAB_TO_OPEN = "Tab_to_open"; public static final String LOCAL_TAB = "local"; @@ -91,6 +92,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl private ViewPager viewPager; private String filter; private String filterCat; + private String filterGroup; protected Set> fragSet = new HashSet<>(); private DownloadIndexesThread downloadThread; private DownloadValidationManager downloadValidationManager; @@ -165,6 +167,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl if (intent != null && intent.getExtras() != null) { filter = intent.getExtras().getString(FILTER_KEY); filterCat = intent.getExtras().getString(FILTER_CAT); + filterGroup = intent.getExtras().getString(FILTER_GROUP); } showFirstTimeExternalStorage(); } @@ -605,6 +608,12 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl return res; } + public String getFilterGroupAndClear() { + String res = filterGroup; + filterGroup = null; + return res; + } + @SuppressWarnings("deprecation") public static void updateDescriptionTextWithSize(DownloadActivity activity, View view) { TextView descriptionText = (TextView) view.findViewById(R.id.rightTextView); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadResourceGroup.java b/OsmAnd/src/net/osmand/plus/download/DownloadResourceGroup.java index f678997253..cefec714d6 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadResourceGroup.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadResourceGroup.java @@ -114,6 +114,26 @@ public class DownloadResourceGroup { } } + public DownloadResourceGroup getRegionGroup(WorldRegion region) { + DownloadResourceGroup res = null; + if (this.region == region) { + res = this; + } else if (groups != null) { + for (DownloadResourceGroup group : groups) { + if (group.region == region) { + res = group; + break; + } else { + res = group.getRegionGroup(region); + if (res != null) { + break; + } + } + } + } + return res; + } + public void trimEmptyGroups() { if(groups != null) { for(DownloadResourceGroup gr : groups) { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java index dae31b7939..804e3cd2bb 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java @@ -112,6 +112,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow reloadData(); String filter = getDownloadActivity().getFilterAndClear(); String filterCat = getDownloadActivity().getFilterCatAndClear(); + String filterGroup = getDownloadActivity().getFilterGroupAndClear(); if (filter != null) { getDownloadActivity().showDialog(getActivity(), SearchDialogFragment.createInstance(filter)); @@ -122,6 +123,10 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow .createInstance(uniqueId); ((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment); } + } else if (filterGroup != null) { + final DownloadResourceGroupFragment regionDialogFragment = DownloadResourceGroupFragment + .createInstance(filterGroup); + ((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java index 2f2a188c81..3d2784e875 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/MapDataMenuController.java @@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.app.AlertDialog; import android.content.DialogInterface; +import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -13,8 +14,10 @@ import net.osmand.map.WorldRegion; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadIndexesThread; +import net.osmand.plus.download.DownloadResourceGroup; import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.download.IndexItem; import net.osmand.plus.helpers.FileNameTranslationHelper; @@ -72,7 +75,16 @@ public class MapDataMenuController extends MenuController { topRightTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { - // todo other maps + getMapActivity().getContextMenu().close(); + + DownloadResourceGroup group = downloadThread.getIndexes().getRegionGroup(region); + if (group != null) { + final Intent intent = new Intent(getMapActivity(), getMapActivity().getMyApplication() + .getAppCustomization().getDownloadIndexActivity()); + intent.putExtra(DownloadActivity.FILTER_GROUP, group.getUniqueId()); + intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB); + getMapActivity().startActivity(intent); + } } }; topRightTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);