Link Other maps to DownloadActivity
This commit is contained in:
parent
34af6ee177
commit
4703b4ce90
4 changed files with 47 additions and 1 deletions
|
@ -78,6 +78,7 @@ public class DownloadActivity extends ActionBarProgressActivity implements Downl
|
|||
List<TabActivity.TabItem> mTabs = new ArrayList<TabActivity.TabItem>();
|
||||
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<WeakReference<Fragment>> 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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue