Add "clear all intermediate points" item into waypoints dialog options
This commit is contained in:
parent
ce65af24dd
commit
daf17c361d
3 changed files with 40 additions and 0 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="clear_all_intermediates">Clear all intermediate points</string>
|
||||
<string name="group_deleted">Group deleted</string>
|
||||
<string name="rendering_attr_whiteWaterSports_name">Whitewater sports</string>
|
||||
<string name="distance_farthest">Distance: farthest first</string>
|
||||
|
|
|
@ -449,6 +449,13 @@ public class TargetPointsHelper {
|
|||
updateRouteAndRefresh(updateRoute);
|
||||
}
|
||||
|
||||
public void clearAllIntermediatePoints(boolean updateRoute) {
|
||||
cancelAllIntermediatePointsAddressRequests();
|
||||
settings.clearIntermediatePoints();
|
||||
intermediatePoints.clear();
|
||||
readFromSettings();
|
||||
updateRouteAndRefresh(updateRoute);
|
||||
}
|
||||
|
||||
public void reorderAllTargetPoints(List<TargetPoint> point, boolean updateRoute) {
|
||||
cancelTargetPointAddressRequest();
|
||||
|
|
|
@ -42,6 +42,7 @@ import net.osmand.plus.activities.MapActivityLayers;
|
|||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
|
@ -474,6 +475,11 @@ public class WaypointDialogHelper {
|
|||
updateRouteInfoMenu(ctx);
|
||||
}
|
||||
|
||||
private static void clearAllIntermediatePoints(Activity ctx, TargetPointsHelper targetPointsHelper, WaypointDialogHelper helper) {
|
||||
targetPointsHelper.clearAllIntermediatePoints(true);
|
||||
updateControls(ctx, helper);
|
||||
}
|
||||
|
||||
private static void replaceStartWithFirstIntermediate(TargetPointsHelper targetPointsHelper, Activity ctx,
|
||||
WaypointDialogHelper helper) {
|
||||
List<TargetPoint> intermediatePoints = targetPointsHelper.getIntermediatePointsWithTarget();
|
||||
|
@ -1018,6 +1024,32 @@ public class WaypointDialogHelper {
|
|||
})
|
||||
.create();
|
||||
items.add(reorderStartAndFinishItem);
|
||||
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
// add waypoint item
|
||||
|
||||
BaseBottomSheetItem clearIntermediatesItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_clear_all))
|
||||
.setTitle(getString(R.string.clear_all_intermediates))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setDisabled(getMyApplication().getTargetPointsHelper().getIntermediatePoints().isEmpty())
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
WaypointDialogHelper.clearAllIntermediatePoints(
|
||||
mapActivity,
|
||||
mapActivity.getMyApplication().getTargetPointsHelper(),
|
||||
mapActivity.getDashboard().getWaypointDialogHelper()
|
||||
);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(clearIntermediatesItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue