Link Other maps to DownloadActivity

This commit is contained in:
Alexey Kulish 2015-11-08 09:52:47 +03:00
parent 34af6ee177
commit 4703b4ce90
4 changed files with 47 additions and 1 deletions

View file

@ -78,6 +78,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
List<TabActivity.TabItem> mTabs = new ArrayList<TabActivity.TabItem>(); List<TabActivity.TabItem> mTabs = new ArrayList<TabActivity.TabItem>();
public static final String FILTER_KEY = "filter"; public static final String FILTER_KEY = "filter";
public static final String FILTER_CAT = "filter_cat"; 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 TAB_TO_OPEN = "Tab_to_open";
public static final String LOCAL_TAB = "local"; public static final String LOCAL_TAB = "local";
@ -91,6 +92,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
private ViewPager viewPager; private ViewPager viewPager;
private String filter; private String filter;
private String filterCat; private String filterCat;
private String filterGroup;
protected Set<WeakReference<Fragment>> fragSet = new HashSet<>(); protected Set<WeakReference<Fragment>> fragSet = new HashSet<>();
private DownloadIndexesThread downloadThread; private DownloadIndexesThread downloadThread;
private DownloadValidationManager downloadValidationManager; private DownloadValidationManager downloadValidationManager;
@ -165,6 +167,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
if (intent != null && intent.getExtras() != null) { if (intent != null && intent.getExtras() != null) {
filter = intent.getExtras().getString(FILTER_KEY); filter = intent.getExtras().getString(FILTER_KEY);
filterCat = intent.getExtras().getString(FILTER_CAT); filterCat = intent.getExtras().getString(FILTER_CAT);
filterGroup = intent.getExtras().getString(FILTER_GROUP);
} }
showFirstTimeExternalStorage(); showFirstTimeExternalStorage();
} }
@ -605,6 +608,12 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
return res; return res;
} }
public String getFilterGroupAndClear() {
String res = filterGroup;
filterGroup = null;
return res;
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void updateDescriptionTextWithSize(DownloadActivity activity, View view) { public static void updateDescriptionTextWithSize(DownloadActivity activity, View view) {
TextView descriptionText = (TextView) view.findViewById(R.id.rightTextView); TextView descriptionText = (TextView) view.findViewById(R.id.rightTextView);

View file

@ -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() { public void trimEmptyGroups() {
if(groups != null) { if(groups != null) {
for(DownloadResourceGroup gr : groups) { for(DownloadResourceGroup gr : groups) {

View file

@ -112,6 +112,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
reloadData(); reloadData();
String filter = getDownloadActivity().getFilterAndClear(); String filter = getDownloadActivity().getFilterAndClear();
String filterCat = getDownloadActivity().getFilterCatAndClear(); String filterCat = getDownloadActivity().getFilterCatAndClear();
String filterGroup = getDownloadActivity().getFilterGroupAndClear();
if (filter != null) { if (filter != null) {
getDownloadActivity().showDialog(getActivity(), getDownloadActivity().showDialog(getActivity(),
SearchDialogFragment.createInstance(filter)); SearchDialogFragment.createInstance(filter));
@ -122,6 +123,10 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
.createInstance(uniqueId); .createInstance(uniqueId);
((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment); ((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment);
} }
} else if (filterGroup != null) {
final DownloadResourceGroupFragment regionDialogFragment = DownloadResourceGroupFragment
.createInstance(filterGroup);
((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment);
} }
} }

View file

@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -13,8 +14,10 @@ import net.osmand.map.WorldRegion;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.DownloadIndexesThread; import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.DownloadResourceGroup;
import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.download.DownloadValidationManager;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
@ -72,7 +75,16 @@ public class MapDataMenuController extends MenuController {
topRightTitleButtonController = new TitleButtonController() { topRightTitleButtonController = new TitleButtonController() {
@Override @Override
public void buttonPressed() { 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); topRightTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);