Adding markers from favorites instead of waypoints
This commit is contained in:
parent
0d651ca2d5
commit
0739a11bef
3 changed files with 78 additions and 82 deletions
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="select_map_markers">Select Map Markers</string>
|
||||
<string name="shared_string_reverse_order">Reverse order</string>
|
||||
<string name="show_map_markers">Map Markers</string>
|
||||
<string name="show_map_markers_description">Activate Map Markers feature</string>
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ActionMode;
|
||||
|
@ -44,6 +43,7 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
|||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -78,10 +78,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
public static final int DELETE_ID = 2;
|
||||
public static final int DELETE_ACTION_ID = 3;
|
||||
public static final int SHARE_ID = 4;
|
||||
public static final int SELECT_DESTINATIONS_ID = 5;
|
||||
public static final int SELECT_DESTINATIONS_ACTION_MODE_ID = 6;
|
||||
public static final int SELECT_MAP_MARKERS_ID = 5;
|
||||
public static final int SELECT_MAP_MARKERS_ACTION_MODE_ID = 6;
|
||||
|
||||
private FavouritesAdapter favouritesAdapter = new FavouritesAdapter();;
|
||||
private FavouritesAdapter favouritesAdapter = new FavouritesAdapter();
|
||||
private FavouritesDbHelper helper;
|
||||
|
||||
private boolean selectionMode = false;
|
||||
|
@ -115,7 +115,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
protected void onPreExecute() {
|
||||
showProgressBar();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
|
@ -275,8 +275,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
// export();
|
||||
// return true;
|
||||
// } else
|
||||
if (item.getItemId() == SELECT_DESTINATIONS_ID) {
|
||||
selectDestinations();
|
||||
if (item.getItemId() == SELECT_MAP_MARKERS_ID) {
|
||||
selectMapMarkers();
|
||||
return true;
|
||||
} else if (item.getItemId() == SHARE_ID) {
|
||||
shareFavourites();
|
||||
|
@ -292,28 +292,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void selectDestinations() {
|
||||
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
|
||||
if (targetPointsHelper.getIntermediatePoints().size() > 0) {
|
||||
final FragmentActivity act = getActivity();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(act);
|
||||
builder.setTitle(R.string.new_directions_point_dialog);
|
||||
builder.setItems(
|
||||
new String[] { act.getString(R.string.keep_intermediate_points),
|
||||
act.getString(R.string.clear_intermediate_points)},
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == 1) {
|
||||
targetPointsHelper.clearPointToNavigate(false);
|
||||
}
|
||||
enterIntermediatesMode();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
} else {
|
||||
enterIntermediatesMode();
|
||||
}
|
||||
private void selectMapMarkers() {
|
||||
enterMapMarkersMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -365,12 +345,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
|
||||
|
||||
if (!MenuItemCompat.isActionViewExpanded(mi)) {
|
||||
createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark,
|
||||
R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
createMenuItem(menu, SELECT_DESTINATIONS_ID, R.string.select_destination_and_intermediate_points, R.drawable.ic_action_intermediate,
|
||||
if (getSettings().USE_MAP_MARKERS.get()) {
|
||||
createMenuItem(menu, SELECT_MAP_MARKERS_ID, R.string.select_map_markers, R.drawable.ic_action_flag_dark,
|
||||
R.drawable.ic_action_flag_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
} else {
|
||||
createMenuItem(menu, SELECT_MAP_MARKERS_ID, R.string.select_destination_and_intermediate_points, R.drawable.ic_action_intermediate,
|
||||
R.drawable.ic_action_intermediate, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark,
|
||||
R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
// createMenuItem(menu, EXPORT_ID, R.string.shared_string_export, R.drawable.ic_action_gsave_light,
|
||||
|
@ -380,7 +364,6 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public void showProgressBar() {
|
||||
getActionBarActivity().setSupportProgressBarIndeterminateVisibility(true);
|
||||
}
|
||||
|
@ -389,15 +372,21 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
getActionBarActivity().setSupportProgressBarIndeterminateVisibility(false);
|
||||
}
|
||||
|
||||
private void enterIntermediatesMode() {
|
||||
private void enterMapMarkersMode() {
|
||||
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
enableSelectionMode(true);
|
||||
createMenuItem(menu, SELECT_DESTINATIONS_ACTION_MODE_ID, R.string.select_destination_and_intermediate_points,
|
||||
if (getSettings().USE_MAP_MARKERS.get()) {
|
||||
createMenuItem(menu, SELECT_MAP_MARKERS_ACTION_MODE_ID, R.string.select_map_markers,
|
||||
R.drawable.ic_action_flag_dark, R.drawable.ic_action_flag_dark,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
} else {
|
||||
createMenuItem(menu, SELECT_MAP_MARKERS_ACTION_MODE_ID, R.string.select_destination_and_intermediate_points,
|
||||
R.drawable.ic_action_intermediate, R.drawable.ic_action_intermediate,
|
||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
|
||||
}
|
||||
favoritesSelected.clear();
|
||||
groupsToDelete.clear();
|
||||
favouritesAdapter.notifyDataSetInvalidated();
|
||||
|
@ -418,9 +407,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
if (item.getItemId() == SELECT_DESTINATIONS_ACTION_MODE_ID) {
|
||||
if (item.getItemId() == SELECT_MAP_MARKERS_ACTION_MODE_ID) {
|
||||
mode.finish();
|
||||
selectDestinationImpl();
|
||||
selectMapMarkersImpl();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -428,8 +417,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
|
||||
}
|
||||
|
||||
private void selectDestinationImpl() {
|
||||
private void selectMapMarkersImpl() {
|
||||
if(!favoritesSelected.isEmpty()) {
|
||||
if (getSettings().USE_MAP_MARKERS.get()) {
|
||||
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
|
||||
for (FavouritePoint fp : favoritesSelected) {
|
||||
markersHelper.addMapMarker(new LatLon(fp.getLatitude(), fp.getLongitude()),
|
||||
new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
|
||||
}
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
} else {
|
||||
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
|
||||
for (FavouritePoint fp : favoritesSelected) {
|
||||
targetPointsHelper.navigateToPoint(new LatLon(fp.getLatitude(), fp.getLongitude()), false,
|
||||
|
@ -440,7 +437,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
targetPointsHelper.updateRouteAndRefresh(true);
|
||||
}
|
||||
IntermediatePointsDialog.openIntermediatePointsDialog(getActivity(), getMyApplication(), true);
|
||||
//MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -612,7 +609,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
} else {
|
||||
AccessibleToast.makeText(getActivity(), warning, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
if (tosave.exists()) {
|
||||
|
@ -632,7 +629,6 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class FavouritesAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
|
||||
|
||||
private static final boolean showOptionsButton = false;
|
||||
|
@ -861,7 +857,6 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
|
||||
public void setFilterResults(Set<?> values) {
|
||||
this.filter = values;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -650,7 +650,7 @@ public class MapMarkerDialogHelper {
|
|||
wpt.lat = marker.getLatitude();
|
||||
wpt.lon = marker.getLongitude();
|
||||
wpt.setColor(mapActivity.getResources().getColor(getMapMarkerColorId(marker.colorIndex)));
|
||||
//wpt.name = desc;
|
||||
wpt.name = marker.getOnlyName();
|
||||
//wpt.link = r.getFileName();
|
||||
//wpt.time = r.getFile().lastModified();
|
||||
//wpt.category = r.getSearchHistoryType();
|
||||
|
|
Loading…
Reference in a new issue