Add Straight Line and BRouter (if installed) to Routing Types list.
Extracted string resources, refactoring and general clean up of code Add RouteService to ApplicationMode (to set straight line for AIRCRAFT mode
This commit is contained in:
parent
361dfbaa6c
commit
9916b72555
5 changed files with 107 additions and 77 deletions
|
@ -94,7 +94,6 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
BICYCLE,
|
BICYCLE,
|
||||||
BOAT,
|
BOAT,
|
||||||
PUBLIC_TRANSPORT,
|
PUBLIC_TRANSPORT,
|
||||||
CUSTOM
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,13 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="profile_alert_need_routing_type_title">Select Routing Type</string>
|
||||||
|
<string name="profile_alert_need_routing_type_msg">You need to select Routing Type to create New Application Profile</string>
|
||||||
|
<string name="profile_alert_need_profile_name_title">Enter Profile Name</string>
|
||||||
|
<string name="profile_alert_need_profile_name_msg">Profile name shouldn\'t be empty!</string>
|
||||||
|
<string name="profile_alert_duplicate_name_title">Duplicate Name</string>
|
||||||
|
<string name="profile_alert_duplicate_name_msg">There is already profile with such name</string>
|
||||||
|
<string name="profile_alert_cant_delete_base">You cannot delete OsmAnd base profiles</string>
|
||||||
<string name="profile_alert_need_save_title">Save Changes</string>
|
<string name="profile_alert_need_save_title">Save Changes</string>
|
||||||
<string name="profile_alert_need_save_msg">You need to save changes to Profile before proceed</string>
|
<string name="profile_alert_need_save_msg">You need to save changes to Profile before proceed</string>
|
||||||
<string name="profile_alert_delete_title">Delete Profile</string>
|
<string name="profile_alert_delete_title">Delete Profile</string>
|
||||||
|
@ -30,7 +37,7 @@
|
||||||
<string name="osmand_default_routing">OsmAnd routing</string>
|
<string name="osmand_default_routing">OsmAnd routing</string>
|
||||||
<string name="custom_routing">Custom routing profile</string>
|
<string name="custom_routing">Custom routing profile</string>
|
||||||
<string name="special_routing_type">Special routing</string>
|
<string name="special_routing_type">Special routing</string>
|
||||||
<string name="online_routing_type">Online routing</string>
|
<string name="third_party_routing_type">3rd-party routing</string>
|
||||||
|
|
||||||
<string name="files_moved">Moved %1$d files (%2$s).</string>
|
<string name="files_moved">Moved %1$d files (%2$s).</string>
|
||||||
<string name="files_copied">Copied %1$d files (%2$s).</string>
|
<string name="files_copied">Copied %1$d files (%2$s).</string>
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ public class ApplicationMode {
|
||||||
private static List<ApplicationMode> values = new ArrayList<>();
|
private static List<ApplicationMode> values = new ArrayList<>();
|
||||||
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<>();
|
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<>();
|
||||||
/*
|
/*
|
||||||
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian"); NAUTICAL("boat"); PUBLIC_TRANSPORT("Public transport")
|
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian"); NAUTICAL("boat"); PUBLIC_TRANSPORT("Public transport"); AIRCRAFT("Aircraft")
|
||||||
*/
|
*/
|
||||||
public static final ApplicationMode DEFAULT = create(R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation().
|
public static final ApplicationMode DEFAULT = create(R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation().
|
||||||
icon(R.drawable.map_world_globe_dark, R.drawable.ic_world_globe_dark).reg();
|
icon(R.drawable.map_world_globe_dark, R.drawable.ic_world_globe_dark).reg();
|
||||||
|
@ -54,7 +55,7 @@ public class ApplicationMode {
|
||||||
icon(R.drawable.map_action_sail_boat_dark, R.drawable.ic_action_sail_boat_dark).setRoutingProfile("boat").reg();
|
icon(R.drawable.map_action_sail_boat_dark, R.drawable.ic_action_sail_boat_dark).setRoutingProfile("boat").reg();
|
||||||
|
|
||||||
public static final ApplicationMode AIRCRAFT = create(R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation().
|
public static final ApplicationMode AIRCRAFT = create(R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation().
|
||||||
icon(R.drawable.map_action_aircraft, R.drawable.ic_action_aircraft).reg();
|
icon(R.drawable.map_action_aircraft, R.drawable.ic_action_aircraft).setRouteService(RouteService.STRAIGHT).reg();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, PEDESTRIAN, BICYCLE, BOAT, PUBLIC_TRANSPORT};
|
ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, PEDESTRIAN, BICYCLE, BOAT, PUBLIC_TRANSPORT};
|
||||||
|
@ -207,9 +208,12 @@ public class ApplicationMode {
|
||||||
applicationMode.routingProfile = routingProfileName;
|
applicationMode.routingProfile = routingProfileName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApplicationModeBuilder setRouteService(RouteService service) {
|
||||||
|
applicationMode.routeService = service;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static ApplicationModeBuilder create(int key, String stringKey) {
|
private static ApplicationModeBuilder create(int key, String stringKey) {
|
||||||
ApplicationModeBuilder builder = new ApplicationModeBuilder();
|
ApplicationModeBuilder builder = new ApplicationModeBuilder();
|
||||||
|
@ -412,6 +416,10 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RouteService getRouteService() {
|
||||||
|
return routeService;
|
||||||
|
}
|
||||||
|
|
||||||
public static ApplicationMode valueOfStringKey(String key, ApplicationMode def) {
|
public static ApplicationMode valueOfStringKey(String key, ApplicationMode def) {
|
||||||
for (ApplicationMode p : values) {
|
for (ApplicationMode p : values) {
|
||||||
if (p.getStringKey().equals(key)) {
|
if (p.getStringKey().equals(key)) {
|
||||||
|
@ -468,6 +476,7 @@ public class ApplicationMode {
|
||||||
@Expose private int locationIconDayLost = R.drawable.map_pedestrian_location_lost;
|
@Expose private int locationIconDayLost = R.drawable.map_pedestrian_location_lost;
|
||||||
@Expose private int locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
|
@Expose private int locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
|
||||||
@Expose private String routingProfile = null;
|
@Expose private String routingProfile = null;
|
||||||
|
@Expose private RouteService routeService = RouteService.OSMAND;
|
||||||
private static StateChangedListener<String> listener;
|
private static StateChangedListener<String> listener;
|
||||||
private static OsmAndAppCustomization.OsmAndAppCustomizationListener customizationListener;
|
private static OsmAndAppCustomization.OsmAndAppCustomizationListener customizationListener;
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,9 @@ import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -52,6 +50,7 @@ import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.profiles.ProfileBottomSheetDialogFragment.ProfileTypeDialogListener;
|
import net.osmand.plus.profiles.ProfileBottomSheetDialogFragment.ProfileTypeDialogListener;
|
||||||
import net.osmand.plus.profiles.SelectIconBottomSheetDialogFragment.IconIdListener;
|
import net.osmand.plus.profiles.SelectIconBottomSheetDialogFragment.IconIdListener;
|
||||||
|
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||||
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
import net.osmand.plus.widgets.OsmandTextFieldBoxes;
|
||||||
import net.osmand.router.GeneralRouter;
|
import net.osmand.router.GeneralRouter;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -159,18 +158,23 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
.getBackground();
|
.getBackground();
|
||||||
|
|
||||||
if (isNightMode) {
|
if (isNightMode) {
|
||||||
profileNameTextBox.setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
profileNameTextBox
|
||||||
navTypeTextBox.setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
.setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
||||||
selectIconBtnBackground.setColor(app.getResources().getColor(R.color.text_field_box_dark));
|
navTypeTextBox
|
||||||
|
.setPrimaryColor(ContextCompat.getColor(app, R.color.color_dialog_buttons_dark));
|
||||||
|
selectIconBtnBackground
|
||||||
|
.setColor(app.getResources().getColor(R.color.text_field_box_dark));
|
||||||
} else {
|
} else {
|
||||||
selectIconBtnBackground.setColor(app.getResources().getColor(R.color.text_field_box_light));
|
selectIconBtnBackground
|
||||||
|
.setColor(app.getResources().getColor(R.color.text_field_box_light));
|
||||||
}
|
}
|
||||||
|
|
||||||
String title = "New Profile";
|
String title = "New Profile";
|
||||||
int startIconId = R.drawable.map_world_globe_dark;
|
int startIconId = R.drawable.map_world_globe_dark;
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
isDataChanged = true;
|
isDataChanged = true;
|
||||||
title = String.format("Custom %s", getResources().getString(profile.parent.getStringResource()));
|
title = String
|
||||||
|
.format("Custom %s", getResources().getString(profile.parent.getStringResource()));
|
||||||
startIconId = profile.parent.getSmallIconDark();
|
startIconId = profile.parent.getSmallIconDark();
|
||||||
profile.iconId = startIconId;
|
profile.iconId = startIconId;
|
||||||
} else if (isUserProfile) {
|
} else if (isUserProfile) {
|
||||||
|
@ -224,30 +228,17 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
} else {
|
} else {
|
||||||
for (RoutingProfileDataObject rp : routingProfileDataObjects) {
|
for (RoutingProfileDataObject rp : routingProfileDataObjects) {
|
||||||
if (profile.stringKey.equals(rp.getStringKey())) {
|
if (profile.stringKey.equals(rp.getStringKey())) {
|
||||||
switch (rp.getStringKey()) {
|
navTypeEt.setText(
|
||||||
case "car":
|
RoutingProfilesResources.valueOf(rp.getStringKey().toUpperCase())
|
||||||
navTypeEt.setText(R.string.rendering_value_car_name);
|
.getStringRes());
|
||||||
break;
|
|
||||||
case "pedestrian":
|
|
||||||
navTypeEt.setText(R.string.rendering_value_pedestrian_name);
|
|
||||||
break;
|
|
||||||
case "bicycle":
|
|
||||||
navTypeEt.setText(R.string.rendering_value_bicycle_name);
|
|
||||||
break;
|
|
||||||
case "public_transport":
|
|
||||||
navTypeEt.setText(R.string.app_mode_public_transport);
|
|
||||||
break;
|
|
||||||
case "boat":
|
|
||||||
navTypeEt.setText(R.string.app_mode_boat);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
navTypeEt.clearFocus();
|
navTypeEt.clearFocus();
|
||||||
}
|
}
|
||||||
profileNameEt.clearFocus();
|
profileNameEt.clearFocus();
|
||||||
|
|
||||||
if (getActivity() != null && ((EditProfileActivity) getActivity()).getSupportActionBar() != null) {
|
if (getActivity() != null
|
||||||
|
&& ((EditProfileActivity) getActivity()).getSupportActionBar() != null) {
|
||||||
((EditProfileActivity) getActivity()).getSupportActionBar().setTitle(title);
|
((EditProfileActivity) getActivity()).getSupportActionBar().setTitle(title);
|
||||||
((EditProfileActivity) getActivity()).getSupportActionBar().setElevation(5.0f);
|
((EditProfileActivity) getActivity()).getSupportActionBar().setElevation(5.0f);
|
||||||
}
|
}
|
||||||
|
@ -265,9 +256,13 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
|
|
||||||
profileNameEt.addTextChangedListener(new TextWatcher() {
|
profileNameEt.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
if (getActivity() instanceof OsmandActionBarActivity) {
|
if (getActivity() instanceof OsmandActionBarActivity) {
|
||||||
|
@ -288,7 +283,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
ProfileBottomSheetDialogFragment fragment = new ProfileBottomSheetDialogFragment();
|
ProfileBottomSheetDialogFragment fragment = new ProfileBottomSheetDialogFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
if (profile.routingProfileDataObject != null) {
|
if (profile.routingProfileDataObject != null) {
|
||||||
bundle.putString(SELECTED_KEY, profile.routingProfileDataObject.getStringKey());
|
bundle.putString(SELECTED_KEY,
|
||||||
|
profile.routingProfileDataObject.getStringKey());
|
||||||
}
|
}
|
||||||
bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE);
|
bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE);
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
|
@ -437,7 +433,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
baseTypeListener = new ProfileTypeDialogListener() {
|
baseTypeListener = new ProfileTypeDialogListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectedType(int pos) {
|
public void onSelectedType(int pos) {
|
||||||
String key = SettingsProfileFragment.getBaseProfiles(getMyApplication()).get(pos).getStringKey();
|
String key = SettingsProfileFragment.getBaseProfiles(getMyApplication()).get(pos)
|
||||||
|
.getStringKey();
|
||||||
setupBaseProfileView(key);
|
setupBaseProfileView(key);
|
||||||
profile.parent = ApplicationMode.valueOfStringKey(key, ApplicationMode.DEFAULT);
|
profile.parent = ApplicationMode.valueOfStringKey(key, ApplicationMode.DEFAULT);
|
||||||
}
|
}
|
||||||
|
@ -500,7 +497,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
navTypeListener = new ProfileTypeDialogListener() {
|
navTypeListener = new ProfileTypeDialogListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectedType(int pos) {
|
public void onSelectedType(int pos) {
|
||||||
updateRoutingProfile(pos);}
|
updateRoutingProfile(pos);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return navTypeListener;
|
return navTypeListener;
|
||||||
|
@ -564,8 +562,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
private boolean saveNewProfile() {
|
private boolean saveNewProfile() {
|
||||||
if (profile.routingProfileDataObject == null) {
|
if (profile.routingProfileDataObject == null) {
|
||||||
showSaveWarningDialog(
|
showSaveWarningDialog(
|
||||||
"Select Routing Type",
|
getString(R.string.profile_alert_need_routing_type_title),
|
||||||
"You need to select Routing Type to create New Application Profile",
|
getString(R.string.profile_alert_need_routing_type_msg),
|
||||||
getActivity());
|
getActivity());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -573,8 +571,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
if (profile.userProfileTitle.isEmpty()
|
if (profile.userProfileTitle.isEmpty()
|
||||||
|| profile.userProfileTitle.replace(" ", "").length() < 1) {
|
|| profile.userProfileTitle.replace(" ", "").length() < 1) {
|
||||||
showSaveWarningDialog(
|
showSaveWarningDialog(
|
||||||
"Enter Profile Name",
|
getString(R.string.profile_alert_need_profile_name_title),
|
||||||
"Profile name shouldn't be empty!",
|
getString(R.string.profile_alert_need_profile_name_msg),
|
||||||
getActivity()
|
getActivity()
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
@ -586,8 +584,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
if (isNew || !Algorithms.isEmpty(mode.getUserProfileName())
|
if (isNew || !Algorithms.isEmpty(mode.getUserProfileName())
|
||||||
&& !mode.getUserProfileName().equals(profile.userProfileTitle)) {
|
&& !mode.getUserProfileName().equals(profile.userProfileTitle)) {
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||||
bld.setTitle("Duplicate Name");
|
bld.setTitle(R.string.profile_alert_duplicate_name_title);
|
||||||
bld.setMessage("There is already profile with such name");
|
bld.setMessage(R.string.profile_alert_duplicate_name_msg);
|
||||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||||
bld.show();
|
bld.show();
|
||||||
bld.setOnDismissListener(new OnDismissListener() {
|
bld.setOnDismissListener(new OnDismissListener() {
|
||||||
|
@ -609,7 +607,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
String customStringKey = profile.stringKey;
|
String customStringKey = profile.stringKey;
|
||||||
if (isNew && profile.parent != null) {
|
if (isNew && profile.parent != null) {
|
||||||
customStringKey =
|
customStringKey =
|
||||||
profile.parent.getStringKey() + "_" + profile.userProfileTitle.hashCode();
|
profile.parent.getStringKey() + "_" + System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
|
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
|
||||||
|
@ -618,6 +616,9 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
.icon(profile.iconId, profile.iconId);
|
.icon(profile.iconId, profile.iconId);
|
||||||
|
|
||||||
if (profile.routingProfileDataObject != null) {
|
if (profile.routingProfileDataObject != null) {
|
||||||
|
// if () {
|
||||||
|
//
|
||||||
|
// }
|
||||||
builder.setRoutingProfile(profile.routingProfileDataObject.getStringKey());
|
builder.setRoutingProfile(profile.routingProfileDataObject.getStringKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,7 +626,20 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
ApplicationMode.saveCustomModeToSettings(getSettings());
|
ApplicationMode.saveCustomModeToSettings(getSettings());
|
||||||
|
|
||||||
if (!ApplicationMode.values(app).contains(mode)) {
|
if (!ApplicationMode.values(app).contains(mode)) {
|
||||||
ApplicationMode.changeProfileStatus(mode, true, getMyApplication());
|
boolean save = ApplicationMode.changeProfileStatus(mode, true, getMyApplication());
|
||||||
|
|
||||||
|
if (save && getSettings() != null) {
|
||||||
|
if (profile.routingProfileDataObject.getStringKey()
|
||||||
|
.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.toString())) {
|
||||||
|
getSettings().ROUTER_SERVICE.setModeValue(mode, RouteService.STRAIGHT);
|
||||||
|
} else if (profile.routingProfileDataObject.getStringKey()
|
||||||
|
.equals(RoutingProfilesResources.BROUTER_MODE.toString())) {
|
||||||
|
getSettings().ROUTER_SERVICE.setModeValue(mode, RouteService.BROUTER);
|
||||||
|
} else {
|
||||||
|
getSettings().ROUTER_SERVICE.setModeValue(mode, RouteService.OSMAND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
isDataChanged = false;
|
isDataChanged = false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -655,7 +669,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
|
||||||
bld.setTitle(R.string.profile_alert_delete_title);
|
bld.setTitle(R.string.profile_alert_delete_title);
|
||||||
bld.setMessage(String
|
bld.setMessage(String
|
||||||
.format(getString(R.string.profile_alert_delete_msg), profile.userProfileTitle));
|
.format(getString(R.string.profile_alert_delete_msg),
|
||||||
|
profile.userProfileTitle));
|
||||||
bld.setPositiveButton(R.string.shared_string_delete,
|
bld.setPositiveButton(R.string.shared_string_delete,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -670,28 +685,28 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||||
bld.show();
|
bld.show();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getActivity(), "You cannot delete OsmAnd base profiles",
|
Toast.makeText(getActivity(), R.string.profile_alert_cant_delete_base,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
|
static List<RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
|
||||||
List<RoutingProfileDataObject> profilesObjects = new ArrayList<>();
|
List<RoutingProfileDataObject> profilesObjects = new ArrayList<>();
|
||||||
profilesObjects.add(new RoutingProfileDataObject(
|
profilesObjects.add(new RoutingProfileDataObject(
|
||||||
RoutingProfilesResources.STRAIGHT_LINE.toString(),
|
RoutingProfilesResources.STRAIGHT_LINE_MODE.toString(),
|
||||||
context.getString(RoutingProfilesResources.STRAIGHT_LINE.getStringRes()),
|
context.getString(RoutingProfilesResources.STRAIGHT_LINE_MODE.getStringRes()),
|
||||||
context.getString(R.string.special_routing_type),
|
context.getString(R.string.special_routing_type),
|
||||||
RoutingProfilesResources.STRAIGHT_LINE.getIconRes(),
|
RoutingProfilesResources.STRAIGHT_LINE_MODE.getIconRes(),
|
||||||
false, null));
|
false, null));
|
||||||
|
if (context.getBRouterService() != null) {
|
||||||
profilesObjects.add(new RoutingProfileDataObject(
|
profilesObjects.add(new RoutingProfileDataObject(
|
||||||
RoutingProfilesResources.BROUTER.toString(),
|
RoutingProfilesResources.BROUTER_MODE.toString(),
|
||||||
context.getString(RoutingProfilesResources.BROUTER.getStringRes()),
|
context.getString(RoutingProfilesResources.BROUTER_MODE.getStringRes()),
|
||||||
context.getString(R.string.online_routing_type),
|
context.getString(R.string.third_party_routing_type),
|
||||||
RoutingProfilesResources.BROUTER.getIconRes(),
|
RoutingProfilesResources.BROUTER_MODE.getIconRes(),
|
||||||
false, null));
|
false, null));
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, GeneralRouter> inputProfiles = context.getRoutingConfig().getAllRoutes();
|
Map<String, GeneralRouter> inputProfiles = context.getRoutingConfig().getAllRoutes();
|
||||||
for (Entry<String, GeneralRouter> e : inputProfiles.entrySet()) {
|
for (Entry<String, GeneralRouter> e : inputProfiles.entrySet()) {
|
||||||
|
@ -700,26 +715,28 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
String description;
|
String description;
|
||||||
if (e.getValue().getFilename() == null) {
|
if (e.getValue().getFilename() == null) {
|
||||||
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
|
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
|
||||||
name = context.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
|
name = context
|
||||||
|
.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
|
||||||
description = context.getString(R.string.osmand_default_routing);
|
description = context.getString(R.string.osmand_default_routing);
|
||||||
} else {
|
} else {
|
||||||
description = context.getString(R.string.custom_routing);
|
description = context.getString(R.string.custom_routing);
|
||||||
}
|
}
|
||||||
profilesObjects.add(new RoutingProfileDataObject(e.getKey(), name, description, iconRes, false,
|
profilesObjects
|
||||||
|
.add(new RoutingProfileDataObject(e.getKey(), name, description, iconRes, false,
|
||||||
e.getValue().getFilename()));
|
e.getValue().getFilename()));
|
||||||
}
|
}
|
||||||
return profilesObjects;
|
return profilesObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RoutingProfilesResources {
|
public enum RoutingProfilesResources {
|
||||||
STRAIGHT_LINE(R.string.routing_profile_straightline, R.drawable.ic_action_split_interval),
|
STRAIGHT_LINE_MODE(R.string.routing_profile_straightline,R.drawable.ic_action_split_interval),
|
||||||
BROUTER(R.string.routing_profile_broutrer, R.drawable.ic_action_split_interval),
|
BROUTER_MODE(R.string.routing_profile_broutrer, R.drawable.ic_action_split_interval),
|
||||||
CAR (R.string.rendering_value_car_name, R.drawable.ic_action_car_dark),
|
CAR(R.string.rendering_value_car_name, R.drawable.ic_action_car_dark),
|
||||||
PEDESTRIAN (R.string.rendering_value_pedestrian_name, R.drawable.map_action_pedestrian_dark),
|
PEDESTRIAN(R.string.rendering_value_pedestrian_name, R.drawable.map_action_pedestrian_dark),
|
||||||
BICYCLE (R.string.rendering_value_bicycle_name, R.drawable.map_action_bicycle_dark),
|
BICYCLE(R.string.rendering_value_bicycle_name, R.drawable.map_action_bicycle_dark),
|
||||||
PUBLIC_TRANSPORT (R.string.app_mode_public_transport, R.drawable.map_action_bus_dark),
|
PUBLIC_TRANSPORT(R.string.app_mode_public_transport, R.drawable.map_action_bus_dark),
|
||||||
BOAT (R.string.app_mode_boat, R.drawable.map_action_sail_boat_dark),
|
BOAT(R.string.app_mode_boat, R.drawable.map_action_sail_boat_dark),
|
||||||
GEOCODING (R.string.routing_profile_geocoding, R.drawable.ic_action_world_globe);
|
GEOCODING(R.string.routing_profile_geocoding, R.drawable.ic_action_world_globe);
|
||||||
|
|
||||||
int stringRes;
|
int stringRes;
|
||||||
int iconRes;
|
int iconRes;
|
||||||
|
@ -739,6 +756,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ApplicationProfileObject {
|
private class ApplicationProfileObject {
|
||||||
|
|
||||||
int key = -1;
|
int key = -1;
|
||||||
String stringKey;
|
String stringKey;
|
||||||
String userProfileTitle = "";
|
String userProfileTitle = "";
|
||||||
|
|
|
@ -682,9 +682,7 @@ public class RouteProvider {
|
||||||
GeneralRouter generalRouter) throws IOException, FileNotFoundException {
|
GeneralRouter generalRouter) throws IOException, FileNotFoundException {
|
||||||
GeneralRouterProfile p ;
|
GeneralRouterProfile p ;
|
||||||
|
|
||||||
if (params.mode.getRoutingProfile() != null ) {
|
if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||||
p = GeneralRouterProfile.CUSTOM;
|
|
||||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
|
||||||
p = GeneralRouterProfile.BICYCLE;
|
p = GeneralRouterProfile.BICYCLE;
|
||||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
||||||
p = GeneralRouterProfile.PEDESTRIAN;
|
p = GeneralRouterProfile.PEDESTRIAN;
|
||||||
|
@ -695,7 +693,6 @@ public class RouteProvider {
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
log.debug("General Router Profile:" + p.name());
|
|
||||||
|
|
||||||
Map<String, String> paramsR = new LinkedHashMap<String, String>();
|
Map<String, String> paramsR = new LinkedHashMap<String, String>();
|
||||||
for(Map.Entry<String, RoutingParameter> e : generalRouter.getParameters().entrySet()){
|
for(Map.Entry<String, RoutingParameter> e : generalRouter.getParameters().entrySet()){
|
||||||
|
@ -724,8 +721,8 @@ public class RouteProvider {
|
||||||
// make visible
|
// make visible
|
||||||
int memoryLimit = (int) (0.95 * ((rt.maxMemory() - rt.totalMemory()) + rt.freeMemory()) / mb);
|
int memoryLimit = (int) (0.95 * ((rt.maxMemory() - rt.totalMemory()) + rt.freeMemory()) / mb);
|
||||||
log.warn("Use " + memoryLimit + " MB Free " + rt.freeMemory() / mb + " of " + rt.totalMemory() / mb + " max " + rt.maxMemory() / mb);
|
log.warn("Use " + memoryLimit + " MB Free " + rt.freeMemory() / mb + " of " + rt.totalMemory() / mb + " max " + rt.maxMemory() / mb);
|
||||||
String name = p == GeneralRouterProfile.CUSTOM ? params.mode.getRoutingProfile() : p.name().toLowerCase();
|
|
||||||
RoutingConfiguration cf = config.build(name, params.start.hasBearing() ?
|
RoutingConfiguration cf = config.build(p.name().toLowerCase(), params.start.hasBearing() ?
|
||||||
params.start.getBearing() / 180d * Math.PI : null,
|
params.start.getBearing() / 180d * Math.PI : null,
|
||||||
memoryLimit, paramsR);
|
memoryLimit, paramsR);
|
||||||
return cf;
|
return cf;
|
||||||
|
|
Loading…
Reference in a new issue