Merge pull request #8851 from osmandapp/pt_dev_setting
add native pt setting to dev plugin
This commit is contained in:
commit
0ca1fc1ce8
6 changed files with 25 additions and 2 deletions
|
@ -972,6 +972,9 @@ public class TransportRoutePlanner {
|
||||||
|
|
||||||
public static List<TransportRouteResult> convertToTransportRoutingResult(NativeTransportRoutingResult[] res,
|
public static List<TransportRouteResult> convertToTransportRoutingResult(NativeTransportRoutingResult[] res,
|
||||||
TransportRoutingConfiguration cfg) {
|
TransportRoutingConfiguration cfg) {
|
||||||
|
if (res.length == 0) {
|
||||||
|
return new ArrayList<TransportRouteResult>();
|
||||||
|
}
|
||||||
List<TransportRouteResult> convertedRes = new ArrayList<TransportRouteResult>();
|
List<TransportRouteResult> convertedRes = new ArrayList<TransportRouteResult>();
|
||||||
for (NativeTransportRoutingResult ntrr : res) {
|
for (NativeTransportRoutingResult ntrr : res) {
|
||||||
TransportRouteResult trr = new TransportRouteResult(cfg);
|
TransportRouteResult trr = new TransportRouteResult(cfg);
|
||||||
|
|
|
@ -25,6 +25,13 @@
|
||||||
android:summaryOn="@string/shared_string_enabled"
|
android:summaryOn="@string/shared_string_enabled"
|
||||||
android:title="@string/safe_mode" />
|
android:title="@string/safe_mode" />
|
||||||
|
|
||||||
|
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
|
||||||
|
android:key="pt_safe_mode"
|
||||||
|
android:layout="@layout/preference_with_descr_dialog_and_switch"
|
||||||
|
android:summaryOff="@string/shared_string_disabled"
|
||||||
|
android:summaryOn="@string/shared_string_enabled"
|
||||||
|
android:title="Native PT development" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="routing"
|
android:key="routing"
|
||||||
android:layout="@layout/preference_category_with_descr"
|
android:layout="@layout/preference_category_with_descr"
|
||||||
|
|
|
@ -3692,7 +3692,7 @@ public class OsmandSettings {
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final OsmandPreference<Boolean> SAFE_MODE = new BooleanPreference("safe_mode", false).makeGlobal();
|
public final OsmandPreference<Boolean> SAFE_MODE = new BooleanPreference("safe_mode", false).makeGlobal();
|
||||||
|
public final OsmandPreference<Boolean> PT_SAFE_MODE = new BooleanPreference("pt_safe_mode", false).makeGlobal();
|
||||||
public final OsmandPreference<Boolean> NATIVE_RENDERING_FAILED = new BooleanPreference("native_rendering_failed_init", false).makeGlobal();
|
public final OsmandPreference<Boolean> NATIVE_RENDERING_FAILED = new BooleanPreference("native_rendering_failed_init", false).makeGlobal();
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> USE_OPENGL_RENDER = new BooleanPreference("use_opengl_render",
|
public final OsmandPreference<Boolean> USE_OPENGL_RENDER = new BooleanPreference("use_opengl_render",
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
|
||||||
|
|
||||||
setupOpenglRenderPref();
|
setupOpenglRenderPref();
|
||||||
setupSafeModePref();
|
setupSafeModePref();
|
||||||
|
setupPTSafeMode();
|
||||||
|
|
||||||
setupDisableComplexRoutingPref();
|
setupDisableComplexRoutingPref();
|
||||||
setupFastRecalculationPref();
|
setupFastRecalculationPref();
|
||||||
|
@ -81,6 +82,16 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupPTSafeMode() {
|
||||||
|
SwitchPreferenceEx ptSafeMode = (SwitchPreferenceEx) findPreference(settings.PT_SAFE_MODE.getId());
|
||||||
|
if (!Version.isBlackberry(app)) {
|
||||||
|
ptSafeMode.setDescription("Switch to Java (safe) Public Transport routing calculation");
|
||||||
|
ptSafeMode.setIconSpaceReserved(false);
|
||||||
|
} else {
|
||||||
|
ptSafeMode.setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setupDisableComplexRoutingPref() {
|
private void setupDisableComplexRoutingPref() {
|
||||||
SwitchPreferenceEx disableComplexRouting = (SwitchPreferenceEx) findPreference(settings.DISABLE_COMPLEX_ROUTING.getId());
|
SwitchPreferenceEx disableComplexRouting = (SwitchPreferenceEx) findPreference(settings.DISABLE_COMPLEX_ROUTING.getId());
|
||||||
disableComplexRouting.setDescription(getString(R.string.disable_complex_routing_descr));
|
disableComplexRouting.setDescription(getString(R.string.disable_complex_routing_descr));
|
||||||
|
|
|
@ -42,12 +42,14 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
if (!Version.isBlackberry(app)) {
|
if (!Version.isBlackberry(app)) {
|
||||||
CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode, R.string.safe_mode_description);
|
CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode, R.string.safe_mode_description);
|
||||||
|
CheckBoxPreference nativePTCheckbox = createCheckBoxPreference(settings.PT_SAFE_MODE, "Native PT routing development", "Switch to Java (safe) Public Transport routing calculation");
|
||||||
// disable the checkbox if the library cannot be used
|
// disable the checkbox if the library cannot be used
|
||||||
if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
|
if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
|
||||||
nativeCheckbox.setEnabled(false);
|
nativeCheckbox.setEnabled(false);
|
||||||
nativeCheckbox.setChecked(true);
|
nativeCheckbox.setChecked(true);
|
||||||
}
|
}
|
||||||
cat.addPreference(nativeCheckbox);
|
cat.addPreference(nativeCheckbox);
|
||||||
|
cat.addPreference(nativePTCheckbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferenceCategory navigation = new PreferenceCategory(this);
|
PreferenceCategory navigation = new PreferenceCategory(this);
|
||||||
|
|
|
@ -494,7 +494,7 @@ public class TransportRoutingHelper {
|
||||||
TransportRoutePlanner planner = new TransportRoutePlanner();
|
TransportRoutePlanner planner = new TransportRoutePlanner();
|
||||||
TransportRoutingContext ctx = new TransportRoutingContext(cfg, library, files);
|
TransportRoutingContext ctx = new TransportRoutingContext(cfg, library, files);
|
||||||
ctx.calculationProgress = params.calculationProgress;
|
ctx.calculationProgress = params.calculationProgress;
|
||||||
if (ctx.library != null) {
|
if (ctx.library != null && !settings.PT_SAFE_MODE.get()) {
|
||||||
NativeTransportRoutingResult[] nativeRes = library.runNativePTRouting(
|
NativeTransportRoutingResult[] nativeRes = library.runNativePTRouting(
|
||||||
MapUtils.get31TileNumberX(params.start.getLongitude()),
|
MapUtils.get31TileNumberX(params.start.getLongitude()),
|
||||||
MapUtils.get31TileNumberY(params.start.getLatitude()),
|
MapUtils.get31TileNumberY(params.start.getLatitude()),
|
||||||
|
|
Loading…
Reference in a new issue