Select current navigation profile in attach roads
This commit is contained in:
parent
1f65840dd4
commit
95af82e531
5 changed files with 24 additions and 20 deletions
|
@ -119,9 +119,11 @@ public class Algorithms {
|
|||
}
|
||||
|
||||
public static String getFileNameWithoutExtension(String name) {
|
||||
int i = name.lastIndexOf('.');
|
||||
if (i >= 0) {
|
||||
name = name.substring(0, i);
|
||||
if (name != null) {
|
||||
int index = name.lastIndexOf('.');
|
||||
if (index != -1) {
|
||||
return name.substring(0, index);
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -153,16 +153,6 @@ public class AndroidUtils {
|
|||
R.color.icon_color_default_light, R.color.wikivoyage_active_dark);
|
||||
}
|
||||
|
||||
public static String trimExtension(String src) {
|
||||
if (src != null) {
|
||||
int index = src.lastIndexOf('.');
|
||||
if (index != -1) {
|
||||
return src.substring(0, index);
|
||||
}
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
public static String addColon(OsmandApplication app, @StringRes int stringRes) {
|
||||
return app.getString(R.string.ltr_or_rtl_combine_via_colon, app.getString(stringRes), "").trim();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.FileUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
|
@ -526,7 +525,7 @@ public class MapMarkersHelper {
|
|||
|
||||
private MapMarkersGroup createGPXMarkerGroup(File fl) {
|
||||
return new MapMarkersGroup(getMarkerGroupId(fl),
|
||||
AndroidUtils.trimExtension(fl.getName()),
|
||||
Algorithms.getFileNameWithoutExtension(fl.getName()),
|
||||
MapMarkersGroup.GPX_TYPE);
|
||||
}
|
||||
|
||||
|
|
|
@ -298,13 +298,15 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
|
|||
return (menuState & (MenuState.HEADER_ONLY | MenuState.HALF_SCREEN)) != 0;
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment, @NonNull LocationsHolder locationsHolder) {
|
||||
public static void showInstance(@NonNull FragmentManager fm, @Nullable Fragment targetFragment,
|
||||
@NonNull LocationsHolder locationsHolder, @Nullable ApplicationMode appMode) {
|
||||
try {
|
||||
if (!fm.isStateSaved()) {
|
||||
GpxApproximationFragment fragment = new GpxApproximationFragment();
|
||||
fragment.setRetainInstance(true);
|
||||
fragment.setTargetFragment(targetFragment, REQUEST_CODE);
|
||||
fragment.setLocationsHolder(locationsHolder);
|
||||
fragment.setSnapToRoadAppMode(appMode);
|
||||
fm.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment, TAG)
|
||||
.addToBackStack(TAG)
|
||||
|
@ -348,12 +350,19 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
|
|||
|
||||
@Override
|
||||
public void onProfileSelect(ApplicationMode applicationMode) {
|
||||
if (snapToRoadAppMode != applicationMode) {
|
||||
snapToRoadAppMode = applicationMode;
|
||||
if (setSnapToRoadAppMode(applicationMode)) {
|
||||
calculateGpxApproximation();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setSnapToRoadAppMode(ApplicationMode appMode) {
|
||||
if (appMode != null && snapToRoadAppMode != appMode) {
|
||||
snapToRoadAppMode = appMode;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public LocationsHolder getLocationsHolder() {
|
||||
return locationsHolder;
|
||||
}
|
||||
|
|
|
@ -706,8 +706,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
case SnapTrackWarningFragment.CONTINUE_RESULT_CODE:
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
ApplicationMode mode = editingCtx.getAppMode();
|
||||
if (mode == ApplicationMode.DEFAULT || "public_transport".equals(mode.getRoutingProfile())) {
|
||||
mode = null;
|
||||
}
|
||||
GpxApproximationFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||
this, new LocationsHolder(editingCtx.getPoints()));
|
||||
this, new LocationsHolder(editingCtx.getPoints()), mode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1522,7 +1526,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
|
||||
displayedName = FileUtils.createUniqueFileName(requireMyApplication(), suggestedName, GPX_INDEX_DIR, GPX_FILE_EXT);
|
||||
} else {
|
||||
displayedName = AndroidUtils.trimExtension(new File(gpxData.getGpxFile().path).getName());
|
||||
displayedName = Algorithms.getFileNameWithoutExtension(new File(gpxData.getGpxFile().path).getName());
|
||||
}
|
||||
return displayedName;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue