route profile naming changes

This commit is contained in:
madwasp79 2019-05-23 15:29:38 +03:00
parent 35bd2ede3d
commit baf0fb4294
2 changed files with 45 additions and 30 deletions

View file

@ -709,12 +709,12 @@ public class EditProfileFragment extends BaseOsmAndFragment {
int iconRes = R.drawable.ic_action_gdirections_dark; int iconRes = R.drawable.ic_action_gdirections_dark;
String name = e.getValue().getProfileName(); String name = e.getValue().getProfileName();
String description = context.getString(R.string.osmand_default_routing); String description = context.getString(R.string.osmand_default_routing);
if (RoutingProfilesResources.isRpValue(name.toUpperCase())){ if (!Algorithms.isEmpty(e.getValue().getFilename())) {
description = e.getValue().getFilename();
} else if (RoutingProfilesResources.isRpValue(name.toUpperCase())){
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes(); iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
name = context name = context
.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes()); .getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
} else if (!Algorithms.isEmpty(e.getValue().getFilename())) {
description = e.getValue().getFilename();
} }
profilesObjects.add(new RoutingProfileDataObject(e.getKey(), name, description, profilesObjects.add(new RoutingProfileDataObject(e.getKey(), name, description,
iconRes, false, e.getValue().getFilename())); iconRes, false, e.getValue().getFilename()));

View file

@ -1,11 +1,15 @@
package net.osmand.plus.routepreparationmenu; package net.osmand.plus.routepreparationmenu;
import android.Manifest;
import android.Manifest.permission;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@ -27,6 +31,7 @@ import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
@ -212,6 +217,8 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
} }
private void createMyLocItem() { private void createMyLocItem() {
BaseBottomSheetItem myLocationItem = new SimpleBottomSheetItem.Builder() BaseBottomSheetItem myLocationItem = new SimpleBottomSheetItem.Builder()
.setIcon(getIcon(R.drawable.ic_action_location_color, 0)) .setIcon(getIcon(R.drawable.ic_action_location_color, 0))
.setTitle(getString(R.string.shared_string_my_location)) .setTitle(getString(R.string.shared_string_my_location))
@ -221,33 +228,39 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
public void onClick(View v) { public void onClick(View v) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null) { if (app != null) {
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); if (getActivity() != null && !OsmAndLocationProvider.isLocationPermissionAvailable(getActivity())) {
Location myLocation = app.getLocationProvider().getLastKnownLocation(); ActivityCompat.requestPermissions(getActivity(),
if (myLocation != null) { new String[] {Manifest.permission.ACCESS_FINE_LOCATION},
LatLon ll = new LatLon(myLocation.getLatitude(), myLocation.getLongitude()); OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
switch (pointType) { } else {
case START: TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
if (targetPointsHelper.getPointToStart() != null) { Location myLocation = app.getLocationProvider().getLastKnownLocation();
targetPointsHelper.clearStartPoint(true); if (myLocation != null) {
app.getSettings().backupPointToStart(); LatLon ll = new LatLon(myLocation.getLatitude(), myLocation.getLongitude());
} switch (pointType) {
break; case START:
case TARGET: if (targetPointsHelper.getPointToStart() != null) {
app.showShortToastMessage(R.string.add_destination_point); targetPointsHelper.clearStartPoint(true);
targetPointsHelper.navigateToPoint(ll, true, -1); app.getSettings().backupPointToStart();
break; }
case INTERMEDIATE: break;
app.showShortToastMessage(R.string.add_intermediate_point); case TARGET:
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size()); app.showShortToastMessage(R.string.add_destination_point);
break; targetPointsHelper.navigateToPoint(ll, true, -1);
case HOME: break;
app.showShortToastMessage(R.string.add_intermediate_point); case INTERMEDIATE:
targetPointsHelper.setHomePoint(ll, null); app.showShortToastMessage(R.string.add_intermediate_point);
break; targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size());
case WORK: break;
app.showShortToastMessage(R.string.add_intermediate_point); case HOME:
targetPointsHelper.setWorkPoint(ll, null); app.showShortToastMessage(R.string.add_intermediate_point);
break; targetPointsHelper.setHomePoint(ll, null);
break;
case WORK:
app.showShortToastMessage(R.string.add_intermediate_point);
targetPointsHelper.setWorkPoint(ll, null);
break;
}
} }
} }
} }
@ -257,6 +270,8 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
items.add(myLocationItem); items.add(myLocationItem);
} }
private void createSelectOnTheMapItem() { private void createSelectOnTheMapItem() {
BaseBottomSheetItem selectOnTheMapItem = new SimpleBottomSheetItem.Builder() BaseBottomSheetItem selectOnTheMapItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_show_on_map)) .setIcon(getContentIcon(R.drawable.ic_show_on_map))