Merge pull request #6968 from osmandapp/app_profiles

App profiles
This commit is contained in:
Alexey 2019-05-23 15:01:28 +03:00 committed by GitHub
commit 781d4e1c53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 15 deletions

View file

@ -130,7 +130,7 @@ public class RoutingConfiguration {
} }
public Map<String, GeneralRouter> getAllRoutes() { public Map<String, GeneralRouter> getAllRouters() {
return routers; return routers;
} }

View file

@ -343,7 +343,7 @@
<dimen name="setting_profile_item_height">64dp</dimen> <dimen name="setting_profile_item_height">64dp</dimen>
<dimen name="setting_profile_image_margin">20dp</dimen> <dimen name="setting_profile_image_margin">24dp</dimen>
<dimen name="setting_profile_item_switch_margin">18dp</dimen> <dimen name="setting_profile_item_switch_margin">18dp</dimen>
</resources> </resources>

View file

@ -11,6 +11,11 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="select_icon_profile_dialog_title">Select icon</string>
<string name="settings_routing_mode_string">Mode: %s</string>
<string name="settings_derived_routing_mode_string">User Mode, derived from: %s</string>
<string name="routing_profile_ski">Ski</string>
<string name="profile_type_descr_string">Type: %s</string> <string name="profile_type_descr_string">Type: %s</string>
<string name="profile_type_base_string">Base Profile</string> <string name="profile_type_base_string">Base Profile</string>
<string name="profile_alert_need_routing_type_title">Select navigation type</string> <string name="profile_alert_need_routing_type_title">Select navigation type</string>
@ -3150,6 +3155,6 @@
<string name="run_full_osmand_header">Launch OsmAnd?</string> <string name="run_full_osmand_header">Launch OsmAnd?</string>
<string name="routing_attr_avoid_sett_name">Avoid cobblestone and sett</string> <string name="routing_attr_avoid_sett_name">Avoid cobblestone and sett</string>
<string name="routing_attr_avoid_sett_description">Avoid cobblestone and sett</string> <string name="routing_attr_avoid_sett_description">Avoid cobblestone and sett</string>
<string name="select_icon_profile_dialog_title">Select icon</string>
</resources> </resources>

View file

@ -58,7 +58,7 @@ public class ApplicationMode {
icon(R.drawable.map_action_aircraft, R.drawable.ic_action_aircraft).setRouteService(RouteService.STRAIGHT).setRoutingProfile("STRAIGHT_LINE_MODE").reg(); icon(R.drawable.map_action_aircraft, R.drawable.ic_action_aircraft).setRouteService(RouteService.STRAIGHT).setRoutingProfile("STRAIGHT_LINE_MODE").reg();
static { static {
ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, PEDESTRIAN, BICYCLE, BOAT, AIRCRAFT, PUBLIC_TRANSPORT, }; ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, PEDESTRIAN, BICYCLE, BOAT, AIRCRAFT, PUBLIC_TRANSPORT};
ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[]{CAR, BICYCLE, BOAT, AIRCRAFT, PUBLIC_TRANSPORT}; ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[]{CAR, BICYCLE, BOAT, AIRCRAFT, PUBLIC_TRANSPORT};
ApplicationMode[] exceptAirBoatDefault = new ApplicationMode[]{CAR, BICYCLE, PEDESTRIAN}; ApplicationMode[] exceptAirBoatDefault = new ApplicationMode[]{CAR, BICYCLE, PEDESTRIAN};
ApplicationMode[] pedestrian = new ApplicationMode[]{PEDESTRIAN}; ApplicationMode[] pedestrian = new ApplicationMode[]{PEDESTRIAN};

View file

@ -377,9 +377,10 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
? mode.toHumanString(SettingsBaseActivity.this) ? mode.toHumanString(SettingsBaseActivity.this)
: mode.getUserProfileName(); : mode.getUserProfileName();
String subtitle = mode.getParent() == null String subtitle = mode.getParent() == null
? "Mode: " + Algorithms.capitalizeFirstLetterAndLowercase(mode.getStringKey().replace("_", "")) ? String.format(getString(R.string.settings_routing_mode_string), Algorithms
: "User Mode, derived from: " + Algorithms .capitalizeFirstLetterAndLowercase(mode.getStringKey().replace("_", "")))
.capitalizeFirstLetterAndLowercase(mode.getParent().getStringKey()); : String.format(getString(R.string.settings_derived_routing_mode_string), Algorithms
.capitalizeFirstLetterAndLowercase(mode.getParent().getStringKey()));
getModeTitleTV().setText(title); getModeTitleTV().setText(title);
getModeSubTitleTV().setText(subtitle); getModeSubTitleTV().setText(subtitle);
getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getSmallIconDark(), getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getSmallIconDark(),

View file

@ -704,22 +704,20 @@ public class EditProfileFragment extends BaseOsmAndFragment {
false, null)); false, null));
} }
Map<String, GeneralRouter> inputProfiles = context.getRoutingConfig().getAllRoutes(); Map<String, GeneralRouter> inputProfiles = context.getRoutingConfig().getAllRouters();
for (Entry<String, GeneralRouter> e : inputProfiles.entrySet()) { for (Entry<String, GeneralRouter> e : inputProfiles.entrySet()) {
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; String description = context.getString(R.string.osmand_default_routing);
if (e.getValue().getFilename() == null) { 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());
description = context.getString(R.string.osmand_default_routing); } else if (!Algorithms.isEmpty(e.getValue().getFilename())) {
} else {
description = e.getValue().getFilename(); description = e.getValue().getFilename();
} }
profilesObjects profilesObjects.add(new RoutingProfileDataObject(e.getKey(), name, description,
.add(new RoutingProfileDataObject(e.getKey(), name, description, iconRes, false, iconRes, false, e.getValue().getFilename()));
e.getValue().getFilename()));
} }
return profilesObjects; return profilesObjects;
} }
@ -730,6 +728,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
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),
SKI(R.string.routing_profile_ski, R.drawable.ic_plugin_skimaps),
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);
@ -749,6 +748,18 @@ public class EditProfileFragment extends BaseOsmAndFragment {
public int getIconRes() { public int getIconRes() {
return iconRes; return iconRes;
} }
private static final List<String> rpValues = new ArrayList<>();
static {
for (RoutingProfilesResources rpr : RoutingProfilesResources.values()) {
rpValues.add(rpr.name());
}
}
public static boolean isRpValue(String value) {
return rpValues.contains(value);
}
} }
private class ApplicationProfileObject { private class ApplicationProfileObject {

View file

@ -217,6 +217,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
icons.add(new IconResWithDescr(R.drawable.ic_action_truck_dark, R.string.app_mode_truck,false)); icons.add(new IconResWithDescr(R.drawable.ic_action_truck_dark, R.string.app_mode_truck,false));
icons.add(new IconResWithDescr(R.drawable.ic_action_motorcycle_dark, R.string.app_mode_motorcycle,false)); icons.add(new IconResWithDescr(R.drawable.ic_action_motorcycle_dark, R.string.app_mode_motorcycle,false));
icons.add(new IconResWithDescr(R.drawable.ic_action_trekking_dark, R.string.app_mode_hiking,false)); icons.add(new IconResWithDescr(R.drawable.ic_action_trekking_dark, R.string.app_mode_hiking,false));
icons.add(new IconResWithDescr(R.drawable.ic_plugin_skimaps, R.string.routing_profile_ski, false));
return icons; return icons;
} }