add native pt setting to dev plugin

fix no result crash
This commit is contained in:
MadWasp79 2020-04-28 16:26:08 +03:00
parent fdb94ad33a
commit dd9e9ec9f2
7 changed files with 14 additions and 16 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

@ -11,8 +11,6 @@
Thx - Hardy
-->
<string name="pt_native_development">Native PT routing development</string>
<string name="pt_native_development_descr">Switch to Java (safe) Public Transport routing calculation</string>
<string name="download_unsupported_action">Unsupported action %1$s</string>
<string name="extra_maps_menu_group">Extra maps</string>
<string name="osm_live_payment_subscription_management">Payment will be charged to your Google Play account at the confirmation of purchase.\n\nSubscription automatically renews unless it is canceled before the renewal date. Your account will be charged for renewal period(month/three month/year) only on the renewal date.\n\nYou can manage and cancel your subscriptions by going to your Google Play settings.</string>

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

@ -859,7 +859,6 @@ public class AppInitializer implements IProgress {
OsmandSettings osmandSettings = app.getSettings();
if (osmandSettings.NATIVE_RENDERING_FAILED.get()) {
osmandSettings.SAFE_MODE.set(true);
osmandSettings.PT_SAFE_MODE.set(true);
osmandSettings.NATIVE_RENDERING_FAILED.set(false);
warnings.add(app.getString(R.string.native_library_not_supported));
} else {

View file

@ -500,17 +500,12 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
misc.addPreference(applicationDir);
CheckBoxPreference nativeCheckbox = createCheckBoxPreference(settings.SAFE_MODE, R.string.safe_mode,
R.string.safe_mode_description);
CheckBoxPreference nativePTCheckbox = createCheckBoxPreference(settings.PT_SAFE_MODE,
R.string.pt_native_development, R.string.pt_native_development_descr);
// 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);
nativePTCheckbox.setEnabled(false);
nativePTCheckbox.setChecked(true);
}
misc.addPreference(nativeCheckbox);
misc.addPreference(nativePTCheckbox);
int nav = getResources().getConfiguration().navigation;
if (nav == Configuration.NAVIGATION_DPAD || nav == Configuration.NAVIGATION_TRACKBALL ||

View file

@ -85,12 +85,10 @@ public class DevelopmentSettingsFragment extends BaseSettingsFragment {
private void setupPTSafeMode() {
SwitchPreferenceEx ptSafeMode = (SwitchPreferenceEx) findPreference(settings.PT_SAFE_MODE.getId());
if (!Version.isBlackberry(app)) {
ptSafeMode.setDescription(getString(R.string.pt_native_development_descr));
ptSafeMode.setDescription("Switch to Java (safe) Public Transport routing calculation");
ptSafeMode.setIconSpaceReserved(false);
if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported()) || settings.NATIVE_RENDERING_FAILED.get()) {
ptSafeMode.setEnabled(false);
ptSafeMode.setChecked(true);
}
} else {
ptSafeMode.setVisible(false);
}
}

View file

@ -42,13 +42,11 @@ 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, R.string.pt_native_development, R.string.pt_native_development_descr);
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);
nativePTCheckbox.setEnabled(false);
nativePTCheckbox.setChecked(true);
}
cat.addPreference(nativeCheckbox);
cat.addPreference(nativePTCheckbox);