Fix undo, add directions, add rename
This commit is contained in:
parent
794d611f60
commit
daba36f28e
2 changed files with 51 additions and 5 deletions
|
@ -36,8 +36,11 @@ import androidx.recyclerview.widget.ItemTouchHelper;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.FileUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.Route;
|
||||
|
@ -71,6 +74,7 @@ import net.osmand.plus.measurementtool.command.RemovePointCommand;
|
|||
import net.osmand.plus.measurementtool.command.ReorderPointCommand;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.views.MapControlsLayer;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
|
@ -108,6 +112,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
private ImageView undoBtn;
|
||||
private ImageView redoBtn;
|
||||
private ImageView mainIcon;
|
||||
private Snackbar snackbar;
|
||||
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean progressBarVisible;
|
||||
|
@ -591,6 +596,14 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void directions() {
|
||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||
if (mapControlsLayer != null) {
|
||||
mapControlsLayer.doRoute(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToGpxOnClick() {
|
||||
if (mapActivity != null && measurementLayer != null) {
|
||||
|
@ -741,6 +754,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
private void removePoint(MeasurementToolLayer layer, int position) {
|
||||
editingCtx.getCommandManager().execute(new RemovePointCommand(layer, position));
|
||||
adapter.notifyDataSetChanged();
|
||||
enable(undoBtn);
|
||||
disable(redoBtn);
|
||||
updateText();
|
||||
saved = false;
|
||||
|
@ -1438,9 +1452,17 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
if (openTrackActivity) {
|
||||
dismiss(activity);
|
||||
} else {
|
||||
Toast.makeText(activity,
|
||||
MessageFormat.format(getString(R.string.gpx_saved_sucessfully), toSave.getAbsolutePath()),
|
||||
Toast.LENGTH_LONG).show();
|
||||
snackbar = Snackbar.make(activity.getLayout(),
|
||||
MessageFormat.format(getString(R.string.gpx_saved_sucessfully), toSave.getName()),
|
||||
Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.shared_string_rename, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
FileUtils.renameFile(getActivity(), toSave, null);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSnackbar(snackbar, nightMode);
|
||||
snackbar.show();
|
||||
if (close) {
|
||||
dismiss(activity);
|
||||
}
|
||||
|
|
|
@ -27,8 +27,12 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
Bundle args = getArguments();
|
||||
boolean snapToRoadEnabled = args.getBoolean(SNAP_TO_ROAD_ENABLED_KEY);
|
||||
boolean addLineMode = args.getBoolean(ADD_LINE_MODE_KEY);
|
||||
boolean snapToRoadEnabled = false;
|
||||
boolean addLineMode = false;
|
||||
if (args != null) {
|
||||
snapToRoadEnabled = args.getBoolean(SNAP_TO_ROAD_ENABLED_KEY);
|
||||
addLineMode = args.getBoolean(ADD_LINE_MODE_KEY);
|
||||
}
|
||||
|
||||
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
||||
|
||||
|
@ -51,6 +55,24 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
BaseBottomSheetItem directions = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark))
|
||||
.setTitle(getString(R.string.get_directions))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.directions();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(directions);
|
||||
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
if (addLineMode && !snapToRoadEnabled) {
|
||||
BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||
|
@ -151,6 +173,8 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
|
||||
void snapToRoadOnCLick();
|
||||
|
||||
void directions();
|
||||
|
||||
void addToGpxOnClick();
|
||||
|
||||
void saveAsNewTrackOnClick();
|
||||
|
|
Loading…
Reference in a new issue