Plan route point menu UI
This commit is contained in:
parent
7e2dfb4344
commit
d413591a0d
5 changed files with 377 additions and 128 deletions
|
@ -11,7 +11,10 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="plan_route_change_route_type_after">Change route type after</string>
|
||||||
|
<string name="plan_route_change_route_type_before">Change route type before</string>
|
||||||
|
<string name="plan_route_trim_after">Trim after</string>
|
||||||
|
<string name="plan_route_trim_before">Trim before</string>
|
||||||
<string name="rourte_between_points_add_track_desc">Select a track file for which a new segment will be added.</string>
|
<string name="rourte_between_points_add_track_desc">Select a track file for which a new segment will be added.</string>
|
||||||
<string name="navigation_profile">Navigation profile</string>
|
<string name="navigation_profile">Navigation profile</string>
|
||||||
<string name="threshold_distance">Threshold distance</string>
|
<string name="threshold_distance">Threshold distance</string>
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
package net.osmand.plus.base.bottomsheetmenu;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorRes;
|
||||||
|
import androidx.annotation.LayoutRes;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
|
||||||
|
public class BottomSheetItemWithDescriptionDifHeight extends BottomSheetItemWithDescription {
|
||||||
|
|
||||||
|
private int minHeight;
|
||||||
|
|
||||||
|
public BottomSheetItemWithDescriptionDifHeight(View customView,
|
||||||
|
@LayoutRes int layoutId,
|
||||||
|
Object tag,
|
||||||
|
boolean disabled,
|
||||||
|
View.OnClickListener onClickListener,
|
||||||
|
int position,
|
||||||
|
Drawable icon,
|
||||||
|
Drawable background,
|
||||||
|
CharSequence title,
|
||||||
|
@ColorRes int titleColorId,
|
||||||
|
boolean iconHidden,
|
||||||
|
CharSequence description,
|
||||||
|
@ColorRes int descriptionColorId,
|
||||||
|
int descriptionMaxLines,
|
||||||
|
boolean descriptionLinksClickable,
|
||||||
|
int minHeight) {
|
||||||
|
super(customView,
|
||||||
|
layoutId,
|
||||||
|
tag,
|
||||||
|
disabled,
|
||||||
|
onClickListener,
|
||||||
|
position,
|
||||||
|
icon,
|
||||||
|
background,
|
||||||
|
title,
|
||||||
|
titleColorId,
|
||||||
|
iconHidden,
|
||||||
|
description,
|
||||||
|
descriptionColorId,
|
||||||
|
descriptionMaxLines,
|
||||||
|
descriptionLinksClickable);
|
||||||
|
|
||||||
|
this.minHeight = minHeight;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inflate(Context context, ViewGroup container, boolean nightMode) {
|
||||||
|
super.inflate(context, container, nightMode);
|
||||||
|
if (minHeight == 0) {
|
||||||
|
minHeight = ViewCompat.getMinimumHeight(view);
|
||||||
|
}
|
||||||
|
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams();
|
||||||
|
params.height = minHeight;
|
||||||
|
view.setMinimumHeight(minHeight);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends BottomSheetItemWithDescription.Builder {
|
||||||
|
|
||||||
|
int minHeight;
|
||||||
|
|
||||||
|
public Builder setMinHeight(int minHeight) {
|
||||||
|
this.minHeight = minHeight;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BottomSheetItemWithDescriptionDifHeight create() {
|
||||||
|
return new BottomSheetItemWithDescriptionDifHeight(customView,
|
||||||
|
layoutId,
|
||||||
|
tag,
|
||||||
|
disabled,
|
||||||
|
onClickListener,
|
||||||
|
position,
|
||||||
|
icon,
|
||||||
|
background,
|
||||||
|
title,
|
||||||
|
titleColorId,
|
||||||
|
iconHidden,
|
||||||
|
description,
|
||||||
|
descriptionColorId,
|
||||||
|
descriptionMaxLines,
|
||||||
|
descriptionLinksClickable,
|
||||||
|
minHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -102,7 +102,7 @@ import static net.osmand.plus.measurementtool.SelectFileBottomSheet.SelectFileLi
|
||||||
import static net.osmand.plus.measurementtool.StartPlanRouteBottomSheet.StartPlanRouteListener;
|
import static net.osmand.plus.measurementtool.StartPlanRouteBottomSheet.StartPlanRouteListener;
|
||||||
|
|
||||||
public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener,
|
public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener,
|
||||||
OptionsFragmentListener, GpxApproximationFragmentListener {
|
OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener {
|
||||||
|
|
||||||
public static final String TAG = MeasurementToolFragment.class.getSimpleName();
|
public static final String TAG = MeasurementToolFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -191,12 +191,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
measurementLayer.setEditingCtx(editingCtx);
|
measurementLayer.setEditingCtx(editingCtx);
|
||||||
|
|
||||||
// Handling screen rotation
|
// Handling screen rotation
|
||||||
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
|
|
||||||
Fragment selectedPointFragment = fragmentManager.findFragmentByTag(SelectedPointBottomSheetDialogFragment.TAG);
|
|
||||||
if (selectedPointFragment != null) {
|
|
||||||
SelectedPointBottomSheetDialogFragment fragment = (SelectedPointBottomSheetDialogFragment) selectedPointFragment;
|
|
||||||
fragment.setListener(createSelectedPointFragmentListener());
|
|
||||||
}
|
|
||||||
Fragment saveAsNewTrackFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(SaveAsNewTrackBottomSheetDialogFragment.TAG);
|
Fragment saveAsNewTrackFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(SaveAsNewTrackBottomSheetDialogFragment.TAG);
|
||||||
if (saveAsNewTrackFragment != null) {
|
if (saveAsNewTrackFragment != null) {
|
||||||
((SaveAsNewTrackBottomSheetDialogFragment) saveAsNewTrackFragment).setListener(createSaveAsNewTrackFragmentListener());
|
((SaveAsNewTrackBottomSheetDialogFragment) saveAsNewTrackFragment).setListener(createSaveAsNewTrackFragmentListener());
|
||||||
|
@ -716,61 +710,78 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SelectedPointFragmentListener createSelectedPointFragmentListener() {
|
@Override
|
||||||
return new SelectedPointFragmentListener() {
|
public void onMovePoint() {
|
||||||
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
|
if (measurementLayer != null) {
|
||||||
|
measurementLayer.enterMovingPointMode();
|
||||||
|
}
|
||||||
|
switchMovePointMode(true);
|
||||||
|
}
|
||||||
|
|
||||||
final MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
@Override
|
||||||
|
public void onDeletePoint() {
|
||||||
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
|
if (measurementLayer != null) {
|
||||||
|
removePoint(measurementLayer, editingCtx.getSelectedPointPosition());
|
||||||
|
}
|
||||||
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveOnClick() {
|
public void onAddPointAfter() {
|
||||||
if (measurementLayer != null) {
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
measurementLayer.enterMovingPointMode();
|
if (measurementLayer != null) {
|
||||||
}
|
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||||
switchMovePointMode(true);
|
editingCtx.setInAddPointMode(true);
|
||||||
}
|
editingCtx.splitSegments(editingCtx.getSelectedPointPosition() + 1);
|
||||||
|
}
|
||||||
|
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_after));
|
||||||
|
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_addpoint_above));
|
||||||
|
switchAddPointBeforeAfterMode(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteOnClick() {
|
public void onAddPointBefore() {
|
||||||
if (measurementLayer != null) {
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
removePoint(measurementLayer, editingCtx.getSelectedPointPosition());
|
if (measurementLayer != null) {
|
||||||
}
|
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setInAddPointMode(true);
|
||||||
}
|
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
||||||
|
}
|
||||||
|
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_before));
|
||||||
|
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_addpoint_below));
|
||||||
|
switchAddPointBeforeAfterMode(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPointAfterOnClick() {
|
public void onTrimRouteBefore() {
|
||||||
if (measurementLayer != null) {
|
|
||||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
|
||||||
editingCtx.setInAddPointMode(true);
|
|
||||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition() + 1);
|
|
||||||
}
|
|
||||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_after));
|
|
||||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_addpoint_above));
|
|
||||||
switchAddPointBeforeAfterMode(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void addPointBeforeOnClick() {
|
|
||||||
if (measurementLayer != null) {
|
|
||||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
|
||||||
editingCtx.setInAddPointMode(true);
|
|
||||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
|
||||||
}
|
|
||||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_before));
|
|
||||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_addpoint_below));
|
|
||||||
switchAddPointBeforeAfterMode(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCloseMenu() {
|
public void onTrimRouteAfter() {
|
||||||
setDefaultMapPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public void onClearSelection() {
|
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
@Override
|
||||||
}
|
public void onChangeRouteTypeBefore() {
|
||||||
};
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChangeRouteTypeAfter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCloseMenu() {
|
||||||
|
setDefaultMapPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClearSelection() {
|
||||||
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1067,10 +1078,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSelectedPointMenu(MapActivity mapActivity) {
|
private void openSelectedPointMenu(MapActivity mapActivity) {
|
||||||
SelectedPointBottomSheetDialogFragment fragment = new SelectedPointBottomSheetDialogFragment();
|
if (mapActivity != null) {
|
||||||
fragment.setUsedOnMap(true);
|
SelectedPointBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), this);
|
||||||
fragment.setListener(createSelectedPointFragmentListener());
|
}
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), SelectedPointBottomSheetDialogFragment.TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSaveAsNewTrackMenu(MapActivity mapActivity) {
|
private void openSaveAsNewTrackMenu(MapActivity mapActivity) {
|
||||||
|
@ -1083,7 +1093,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
private void showAddToTrackDialog(final MapActivity mapActivity) {
|
private void showAddToTrackDialog(final MapActivity mapActivity) {
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
SelectFileBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
|
SelectFileBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
createAddToTrackFileListener(),ADD_TO_TRACK);
|
createAddToTrackFileListener(), ADD_TO_TRACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1182,14 +1192,14 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||||
}
|
}
|
||||||
mapActivity.showTopToolbar(toolBarController);
|
mapActivity.showTopToolbar(toolBarController);
|
||||||
|
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
||||||
|
AndroidUiHelper.setVisibility(mapActivity, enable ? View.VISIBLE : View.GONE,
|
||||||
|
R.id.move_point_text,
|
||||||
|
R.id.move_point_controls);
|
||||||
|
mainIcon.setImageDrawable(getActiveIcon(enable
|
||||||
|
? R.drawable.ic_action_move_point
|
||||||
|
: R.drawable.ic_action_ruler));
|
||||||
}
|
}
|
||||||
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
|
||||||
AndroidUiHelper.setVisibility(mapActivity, enable ? View.VISIBLE : View.GONE,
|
|
||||||
R.id.move_point_text,
|
|
||||||
R.id.move_point_controls);
|
|
||||||
mainIcon.setImageDrawable(getActiveIcon(enable
|
|
||||||
? R.drawable.ic_action_move_point
|
|
||||||
: R.drawable.ic_action_ruler));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchAddPointBeforeAfterMode(boolean enable) {
|
private void switchAddPointBeforeAfterMode(boolean enable) {
|
||||||
|
@ -1202,13 +1212,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||||
}
|
}
|
||||||
mapActivity.showTopToolbar(toolBarController);
|
mapActivity.showTopToolbar(toolBarController);
|
||||||
}
|
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
||||||
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
AndroidUiHelper.setVisibility(mapActivity, enable ? View.VISIBLE : View.GONE,
|
||||||
AndroidUiHelper.setVisibility(mapActivity,enable ? View.VISIBLE : View.GONE,
|
R.id.add_point_before_after_text,
|
||||||
R.id.add_point_before_after_text,
|
R.id.add_point_before_after_controls);
|
||||||
R.id.add_point_before_after_controls);
|
if (!enable) {
|
||||||
if (!enable) {
|
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler));
|
||||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,8 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
||||||
items.add(new OptionsDividerItem(getContext()));
|
items.add(new OptionsDividerItem(getContext()));
|
||||||
|
|
||||||
BaseBottomSheetItem clearAllItem = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem clearAllItem = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getIcon(R.drawable.ic_action_reset_to_default_dark, (
|
.setIcon(getIcon(R.drawable.ic_action_reset_to_default_dark,
|
||||||
nightMode ? R.color.color_osm_edit_delete : R.color.color_osm_edit_delete)))
|
nightMode ? R.color.color_osm_edit_delete : R.color.color_osm_edit_delete))
|
||||||
.setTitle(getString(R.string.shared_string_clear_all))
|
.setTitle(getString(R.string.shared_string_clear_all))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple_pad_32dp)
|
.setLayoutId(R.layout.bottom_sheet_item_simple_pad_32dp)
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
|
@ -2,42 +2,44 @@ package net.osmand.plus.measurementtool;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
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.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescriptionDifHeight;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleDividerItem;
|
||||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
public final static String TAG = "SelectedPointBottomSheetDialogFragment";
|
public static final String TAG = SelectedPointBottomSheetDialogFragment.class.getSimpleName();
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(SelectedPointBottomSheetDialogFragment.class);
|
||||||
private SelectedPointFragmentListener listener;
|
|
||||||
|
|
||||||
public void setListener(SelectedPointFragmentListener listener) {
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
BaseBottomSheetItem titleItem = new BottomSheetItemWithDescription.Builder()
|
BaseBottomSheetItem titleItem = new BottomSheetItemWithDescriptionDifHeight.Builder()
|
||||||
.setDescription(getDescription())
|
.setMinHeight(getResources().getDimensionPixelSize(R.dimen.measurement_tool_up_down_row_height))
|
||||||
|
.setDescription(getDescription(true))
|
||||||
.setIcon(getActiveIcon(R.drawable.ic_action_measure_point))
|
.setIcon(getActiveIcon(R.drawable.ic_action_measure_point))
|
||||||
.setTitle(getTitle())
|
.setTitle(getTitle())
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
||||||
|
@ -49,12 +51,13 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
BaseBottomSheetItem moveItem = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem moveItem = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_move_point))
|
.setIcon(getContentIcon(R.drawable.ic_action_move_point))
|
||||||
.setTitle(getString(R.string.shared_string_move))
|
.setTitle(getString(R.string.shared_string_move))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
.setLayoutId(R.layout.bottom_sheet_item_simple_pad_32dp)
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (listener != null) {
|
Fragment targetFragment = getTargetFragment();
|
||||||
listener.moveOnClick();
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onMovePoint();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
@ -62,33 +65,18 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
.create();
|
.create();
|
||||||
items.add(moveItem);
|
items.add(moveItem);
|
||||||
|
|
||||||
BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
|
items.add(new OptionsDividerItem(getContext()));
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_remove_dark))
|
|
||||||
.setTitle(getString(R.string.shared_string_delete))
|
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (listener != null) {
|
|
||||||
listener.deleteOnClick();
|
|
||||||
}
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
items.add(deleteItem);
|
|
||||||
|
|
||||||
items.add(new DividerHalfItem(getContext()));
|
|
||||||
|
|
||||||
BaseBottomSheetItem addAfterItem = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem addAfterItem = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_addpoint_above))
|
.setIcon(getContentIcon(R.drawable.ic_action_addpoint_above))
|
||||||
.setTitle(getString(R.string.add_point_after))
|
.setTitle(getString(R.string.add_point_after))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
.setLayoutId(R.layout.bottom_sheet_item_simple_pad_32dp)
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (listener != null) {
|
Fragment targetFragment = getTargetFragment();
|
||||||
listener.addPointAfterOnClick();
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onAddPointAfter();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
@ -99,33 +87,136 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
BaseBottomSheetItem addBeforeItem = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem addBeforeItem = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_addpoint_below))
|
.setIcon(getContentIcon(R.drawable.ic_action_addpoint_below))
|
||||||
.setTitle(getString(R.string.add_point_before))
|
.setTitle(getString(R.string.add_point_before))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
.setLayoutId(R.layout.bottom_sheet_item_simple_pad_32dp)
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (listener != null) {
|
Fragment targetFragment = getTargetFragment();
|
||||||
listener.addPointBeforeOnClick();
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onAddPointBefore();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
items.add(addBeforeItem);
|
items.add(addBeforeItem);
|
||||||
|
|
||||||
|
items.add(new OptionsDividerItem(getContext()));
|
||||||
|
|
||||||
|
BaseBottomSheetItem trimRouteBefore = new BottomSheetItemWithDescriptionDifHeight.Builder()
|
||||||
|
.setMinHeight(getResources().getDimensionPixelSize(R.dimen.measurement_tool_up_down_row_height))
|
||||||
|
.setDescription(getDescription(true))
|
||||||
|
.setIcon(getContentIcon(R.drawable.ic_action_trim_left))
|
||||||
|
.setTitle(getString(R.string.plan_route_trim_before))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Fragment targetFragment = getTargetFragment();
|
||||||
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onTrimRouteBefore();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(trimRouteBefore);
|
||||||
|
|
||||||
|
BaseBottomSheetItem trimRouteAfter = new BottomSheetItemWithDescriptionDifHeight.Builder()
|
||||||
|
.setMinHeight(getResources().getDimensionPixelSize(R.dimen.measurement_tool_up_down_row_height))
|
||||||
|
.setDescription(getDescription(false))
|
||||||
|
.setIcon(getContentIcon(R.drawable.ic_action_trim_right))
|
||||||
|
.setTitle(getString(R.string.plan_route_trim_after))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Fragment targetFragment = getTargetFragment();
|
||||||
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onTrimRouteAfter();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(trimRouteAfter);
|
||||||
|
|
||||||
|
items.add(new OptionsDividerItem(getContext()));
|
||||||
|
|
||||||
|
BaseBottomSheetItem changeRouteTypeBefore = new BottomSheetItemWithDescriptionDifHeight.Builder()
|
||||||
|
.setMinHeight(getResources().getDimensionPixelSize(R.dimen.measurement_tool_up_down_row_height))
|
||||||
|
.setDescription(getDescription(true))
|
||||||
|
.setIcon(getRouteTypeIcon(true))
|
||||||
|
.setTitle(getString(R.string.plan_route_change_route_type_before))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Fragment targetFragment = getTargetFragment();
|
||||||
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onChangeRouteTypeBefore();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(changeRouteTypeBefore);
|
||||||
|
|
||||||
|
BaseBottomSheetItem changeRouteTypeAfter = new BottomSheetItemWithDescriptionDifHeight.Builder()
|
||||||
|
.setMinHeight(getResources().getDimensionPixelSize(R.dimen.measurement_tool_up_down_row_height))
|
||||||
|
.setDescription(getDescription(false))
|
||||||
|
.setIcon(getRouteTypeIcon(false))
|
||||||
|
.setTitle(getString(R.string.plan_route_change_route_type_after))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Fragment targetFragment = getTargetFragment();
|
||||||
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onChangeRouteTypeAfter();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(changeRouteTypeAfter);
|
||||||
|
|
||||||
|
items.add(new OptionsDividerItem(getContext()));
|
||||||
|
|
||||||
|
BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
|
||||||
|
.setIcon(getIcon(R.drawable.ic_action_delete_dark,
|
||||||
|
nightMode ? R.color.color_osm_edit_delete : R.color.color_osm_edit_delete))
|
||||||
|
.setTitle(getString(R.string.shared_string_delete))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_simple_pad_32dp)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Fragment targetFragment = getTargetFragment();
|
||||||
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onDeletePoint();
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.create();
|
||||||
|
items.add(deleteItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
if (listener != null) {
|
Fragment targetFragment = getTargetFragment();
|
||||||
listener.onCloseMenu();
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onCloseMenu();
|
||||||
}
|
}
|
||||||
super.dismiss();
|
super.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(@NonNull DialogInterface dialog) {
|
||||||
if (listener != null) {
|
Fragment targetFragment = getTargetFragment();
|
||||||
listener.onCloseMenu();
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
listener.onClearSelection();
|
((SelectedPointFragmentListener) targetFragment).onCloseMenu();
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onClearSelection();
|
||||||
}
|
}
|
||||||
super.onCancel(dialog);
|
super.onCancel(dialog);
|
||||||
}
|
}
|
||||||
|
@ -137,8 +228,9 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDismissButtonClickAction() {
|
protected void onDismissButtonClickAction() {
|
||||||
if (listener != null) {
|
Fragment targetFragment = getTargetFragment();
|
||||||
listener.onClearSelection();
|
if (targetFragment instanceof SelectedPointFragmentListener) {
|
||||||
|
((SelectedPointFragmentListener) targetFragment).onClearSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +267,7 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private String getDescription() {
|
private String getDescription(boolean before) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity == null) {
|
if (mapActivity == null) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -195,7 +287,16 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
description.append(getString(R.string.shared_string_control_start));
|
description.append(getString(R.string.shared_string_control_start));
|
||||||
} else {
|
} else {
|
||||||
float dist = 0;
|
float dist = 0;
|
||||||
for (int i = 1; i <= pos; i++) {
|
int startIdx;
|
||||||
|
int endIdx;
|
||||||
|
if (before) {
|
||||||
|
startIdx = 1;
|
||||||
|
endIdx = pos;
|
||||||
|
} else {
|
||||||
|
startIdx = pos + 1;
|
||||||
|
endIdx = points.size() - 1;
|
||||||
|
}
|
||||||
|
for (int i = startIdx; i <= endIdx; i++) {
|
||||||
WptPt first = points.get(i - 1);
|
WptPt first = points.get(i - 1);
|
||||||
WptPt second = points.get(i);
|
WptPt second = points.get(i);
|
||||||
dist += MapUtils.getDistance(first.lat, first.lon, second.lat, second.lon);
|
dist += MapUtils.getDistance(first.lat, first.lon, second.lat, second.lon);
|
||||||
|
@ -220,15 +321,56 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
return description.toString();
|
return description.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Drawable getRouteTypeIcon(boolean before) {
|
||||||
|
Drawable icon = getContentIcon(R.drawable.ic_action_split_interval);
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity == null) {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
MeasurementEditingContext editingCtx = mapActivity.getMapLayers().getMeasurementToolLayer().getEditingCtx();
|
||||||
|
int pos = editingCtx.getSelectedPointPosition();
|
||||||
|
pos = before ? pos : Math.max(pos - 1, 0);
|
||||||
|
|
||||||
|
String profileType = editingCtx.getPoints().get(pos).getProfileType();
|
||||||
|
ApplicationMode routeAppMode = ApplicationMode.valueOfStringKey(profileType, null);
|
||||||
|
if (routeAppMode != null) {
|
||||||
|
icon = getIcon(routeAppMode.getIconRes(), routeAppMode.getIconColorInfo().getColor(nightMode));
|
||||||
|
}
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment) {
|
||||||
|
try {
|
||||||
|
if (!fm.isStateSaved()) {
|
||||||
|
SelectedPointBottomSheetDialogFragment fragment = new SelectedPointBottomSheetDialogFragment();
|
||||||
|
fragment.setRetainInstance(true);
|
||||||
|
fragment.setTargetFragment(targetFragment, 0);
|
||||||
|
fragment.show(fm, TAG);
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
LOG.error("showInstance", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface SelectedPointFragmentListener {
|
interface SelectedPointFragmentListener {
|
||||||
|
|
||||||
void moveOnClick();
|
void onMovePoint();
|
||||||
|
|
||||||
void deleteOnClick();
|
void onDeletePoint();
|
||||||
|
|
||||||
void addPointAfterOnClick();
|
void onAddPointAfter();
|
||||||
|
|
||||||
void addPointBeforeOnClick();
|
void onAddPointBefore();
|
||||||
|
|
||||||
|
void onTrimRouteBefore();
|
||||||
|
|
||||||
|
void onTrimRouteAfter();
|
||||||
|
|
||||||
|
void onChangeRouteTypeBefore();
|
||||||
|
|
||||||
|
void onChangeRouteTypeAfter();
|
||||||
|
|
||||||
void onCloseMenu();
|
void onCloseMenu();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue