Merge remote-tracking branch 'origin/conditionalRouting'
This commit is contained in:
commit
c85a669ec8
5 changed files with 63 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="temporary_conditional_routing">Consider temporary limitations</string>
|
||||
<string name="turn_on_profile_desc">Please turn on at least one application profile, to use this setting.</string>
|
||||
<string name="rendering_attr_winter_road_name">Winter road</string>
|
||||
<string name="rendering_attr_ice_road_name">Ice road</string>
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
android:key="snap_to_road"
|
||||
android:summary="@string/snap_to_road_descr"
|
||||
android:title="@string/snap_to_road"/>
|
||||
<CheckBoxPreference
|
||||
android:key="enable_time_conditional_routing"
|
||||
android:title="@string/temporary_conditional_routing"/>
|
||||
<Preference
|
||||
android:key="show_routing_alarms"
|
||||
android:summary="@string/show_warnings_descr"
|
||||
|
|
|
@ -209,6 +209,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
|
||||
|
||||
|
||||
registerBooleanPreference(settings.ENABLE_TIME_CONDITIONAL_ROUTING, screen);
|
||||
|
||||
addTurnScreenOn((PreferenceGroup) screen.findPreference("turn_screen_on"));
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutin
|
|||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRoutingParameter;
|
||||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteSimulationItem;
|
||||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.ShowAlongTheRouteItem;
|
||||
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.TimeConditionalRoutingItem;
|
||||
import net.osmand.plus.routing.RouteProvider;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
|
@ -96,6 +97,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
items.add(createAvoidRoadsItem(optionsItem));
|
||||
} else if (optionsItem instanceof GpxLocalRoutingParameter) {
|
||||
items.add(createGpxRoutingItem(optionsItem));
|
||||
} else if (optionsItem instanceof TimeConditionalRoutingItem) {
|
||||
items.add(createTimeConditionalRoutingItem(optionsItem));
|
||||
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
|
||||
items.add(createOtherSettingsRoutingItem(optionsItem));
|
||||
} else {
|
||||
|
@ -158,6 +161,26 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
return muteSoundItem[0];
|
||||
}
|
||||
|
||||
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
|
||||
final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1];
|
||||
timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(settings.ENABLE_TIME_CONDITIONAL_ROUTING.get())
|
||||
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
|
||||
.setTitle(getString(R.string.temporary_conditional_routing))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean enabled = !settings.ENABLE_TIME_CONDITIONAL_ROUTING.get();
|
||||
settings.ENABLE_TIME_CONDITIONAL_ROUTING.set(enabled);
|
||||
timeConditionalRoutingItem[0].setChecked(enabled);
|
||||
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
return timeConditionalRoutingItem[0];
|
||||
}
|
||||
|
||||
private BaseBottomSheetItem createShowAlongTheRouteItem(final LocalRoutingParameter optionsItem) {
|
||||
return new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
|
||||
|
@ -455,6 +478,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
ShowAlongTheRouteItem.KEY,
|
||||
GeneralRouter.ALLOW_PRIVATE,
|
||||
GeneralRouter.USE_SHORTEST_WAY,
|
||||
TimeConditionalRoutingItem.KEY,
|
||||
DividerItem.KEY,
|
||||
GpxLocalRoutingParameter.KEY,
|
||||
OtherSettingsRoutingParameter.KEY,
|
||||
|
@ -467,6 +491,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
GeneralRouter.ALLOW_MOTORWAYS,
|
||||
AvoidRoadsRoutingParameter.KEY,
|
||||
ShowAlongTheRouteItem.KEY,
|
||||
TimeConditionalRoutingItem.KEY,
|
||||
DividerItem.KEY,
|
||||
GpxLocalRoutingParameter.KEY,
|
||||
OtherSettingsRoutingParameter.KEY,
|
||||
|
@ -477,6 +502,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
DividerItem.KEY,
|
||||
AvoidRoadsRoutingParameter.KEY,
|
||||
ShowAlongTheRouteItem.KEY,
|
||||
TimeConditionalRoutingItem.KEY,
|
||||
DividerItem.KEY,
|
||||
GpxLocalRoutingParameter.KEY,
|
||||
OtherSettingsRoutingParameter.KEY,
|
||||
|
@ -487,12 +513,14 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
AvoidPTTypesRoutingParameter.KEY,
|
||||
// ShowAlongTheRouteItem.KEY,
|
||||
// DividerItem.KEY,
|
||||
TimeConditionalRoutingItem.KEY,
|
||||
OtherSettingsRoutingParameter.KEY),
|
||||
|
||||
OTHER(MuteSoundRoutingParameter.KEY,
|
||||
DividerItem.KEY,
|
||||
AvoidRoadsRoutingParameter.KEY,
|
||||
ShowAlongTheRouteItem.KEY,
|
||||
TimeConditionalRoutingItem.KEY,
|
||||
DividerItem.KEY,
|
||||
GpxLocalRoutingParameter.KEY,
|
||||
OtherSettingsRoutingParameter.KEY,
|
||||
|
|
|
@ -370,6 +370,8 @@ public class RoutingOptionsHelper {
|
|||
return new AvoidRoadsRoutingParameter();
|
||||
case GpxLocalRoutingParameter.KEY:
|
||||
return new GpxLocalRoutingParameter();
|
||||
case TimeConditionalRoutingItem.KEY:
|
||||
return new TimeConditionalRoutingItem();
|
||||
case OtherSettingsRoutingParameter.KEY:
|
||||
return new OtherSettingsRoutingParameter();
|
||||
default:
|
||||
|
@ -413,6 +415,7 @@ public class RoutingOptionsHelper {
|
|||
list.add(1, new VoiceGuidanceRoutingParameter());
|
||||
list.add(2, new InterruptMusicRoutingParameter());
|
||||
list.add(3, new AvoidRoadsRoutingParameter());
|
||||
list.add(4, new TimeConditionalRoutingItem());
|
||||
list.add(new GpxLocalRoutingParameter());
|
||||
list.add(new OtherSettingsRoutingParameter());
|
||||
return list;
|
||||
|
@ -750,6 +753,33 @@ public class RoutingOptionsHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static class TimeConditionalRoutingItem extends LocalRoutingParameter {
|
||||
|
||||
public static final String KEY = "TimeConditionalRoutingItem";
|
||||
|
||||
public String getKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
public boolean canAddToRouteMenu() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public TimeConditionalRoutingItem() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveIconId() {
|
||||
return R.drawable.ic_action_road_works_dark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisabledIconId() {
|
||||
return R.drawable.ic_action_road_works_dark;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShowAlongTheRouteItem extends LocalRoutingParameter {
|
||||
|
||||
public static final String KEY = "ShowAlongTheRouteItem";
|
||||
|
|
Loading…
Reference in a new issue