Merge pull request #8851 from osmandapp/pt_dev_setting

add native pt setting to dev plugin
This commit is contained in:
vshcherb 2020-04-28 15:29:55 +02:00 committed by GitHub
commit 0ca1fc1ce8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 2 deletions

View file

@ -972,6 +972,9 @@ public class TransportRoutePlanner {
public static List<TransportRouteResult> convertToTransportRoutingResult(NativeTransportRoutingResult[] res,
TransportRoutingConfiguration cfg) {
if (res.length == 0) {
return new ArrayList<TransportRouteResult>();
}
List<TransportRouteResult> convertedRes = new ArrayList<TransportRouteResult>();
for (NativeTransportRoutingResult ntrr : res) {
TransportRouteResult trr = new TransportRouteResult(cfg);

View file

@ -25,6 +25,13 @@
android:summaryOn="@string/shared_string_enabled"
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
android:key="routing"
android:layout="@layout/preference_category_with_descr"

View file

@ -3692,7 +3692,7 @@ public class OsmandSettings {
// 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> 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> USE_OPENGL_RENDER = new BooleanPreference("use_opengl_render",

View file

@ -35,6 +35,7 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
setupOpenglRenderPref();
setupSafeModePref();
setupPTSafeMode();
setupDisableComplexRoutingPref();
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() {
SwitchPreferenceEx disableComplexRouting = (SwitchPreferenceEx) findPreference(settings.DISABLE_COMPLEX_ROUTING.getId());
disableComplexRouting.setDescription(getString(R.string.disable_complex_routing_descr));

View file

@ -42,12 +42,14 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
if (!Version.isBlackberry(app)) {
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
if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
nativeCheckbox.setEnabled(false);
nativeCheckbox.setChecked(true);
}
cat.addPreference(nativeCheckbox);
cat.addPreference(nativePTCheckbox);
}
PreferenceCategory navigation = new PreferenceCategory(this);

View file

@ -494,7 +494,7 @@ public class TransportRoutingHelper {
TransportRoutePlanner planner = new TransportRoutePlanner();
TransportRoutingContext ctx = new TransportRoutingContext(cfg, library, files);
ctx.calculationProgress = params.calculationProgress;
if (ctx.library != null) {
if (ctx.library != null && !settings.PT_SAFE_MODE.get()) {
NativeTransportRoutingResult[] nativeRes = library.runNativePTRouting(
MapUtils.get31TileNumberX(params.start.getLongitude()),
MapUtils.get31TileNumberY(params.start.getLatitude()),