From ba5b407cea5efff921390779ec525e9cbd76819c Mon Sep 17 00:00:00 2001 From: sergosm Date: Tue, 6 Oct 2020 16:51:45 +0300 Subject: [PATCH] Move development settings Preview --- OsmAnd/res/values/strings.xml | 10 ++- OsmAnd/res/xml/development_settings.xml | 35 --------- .../DevelopmentSettingsFragment.java | 54 +++---------- .../SettingsDevelopmentActivity.java | 37 +++------ .../plus/settings/backend/OsmandSettings.java | 10 +-- .../fragments/RouteParametersFragment.java | 76 ++++++++++++++++++- 6 files changed, 111 insertions(+), 111 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 086a7470d5..b01a0ef58c 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,14 @@ Thx - Hardy --> + Switch to Java (safe) Public Transport routing calculation + Native Public Transport development + Recalculates only the initial part of the route. Can be used for long trips. + Two-phase routing for car navigation. + Complex routing + OsmAnd Live data + OsmAnd Live data + Development Start/finish icons Name: A – Z Name: Z – A @@ -2463,7 +2471,6 @@ Specify the speech rate for text-to-speech. Speech Rate Fast route calculation failed (%s), fallback to slow calculation. - Disable two-phase routing for car navigation. Disable complex routing Seamark Select shown profiles. @@ -3657,7 +3664,6 @@ You need to be online to install this plugin. Get Smart route recalculation - For long trips, only recalculate the initial part of the route. Do you like OsmAnd? Your opinion and feedback is valued. Rate this app diff --git a/OsmAnd/res/xml/development_settings.xml b/OsmAnd/res/xml/development_settings.xml index d01a1f169d..231bd469bc 100644 --- a/OsmAnd/res/xml/development_settings.xml +++ b/OsmAnd/res/xml/development_settings.xml @@ -25,46 +25,11 @@ android:summaryOn="@string/shared_string_enabled" android:title="@string/safe_mode" /> - - - - - - - - - - MAPILLARY_FILTER_TO_DATE = new LongPreference("mapillary_filter_to_date", 0).makeGlobal(); public final CommonPreference MAPILLARY_FILTER_PANO = new BooleanPreference("mapillary_filter_pano", false).makeGlobal(); - public final CommonPreference USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeGlobal().cache(); + public final CommonPreference USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeProfile().cache(); public final CommonPreference FORCE_PRIVATE_ACCESS_ROUTING_ASKED = new BooleanPreference("force_private_access_routing", false).makeProfile().cache(); public final CommonPreference SHOW_CARD_TO_CHOOSE_DRAWER = new BooleanPreference("show_card_to_choose_drawer", false).makeGlobal(); @@ -2117,7 +2117,7 @@ public class OsmandSettings { // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference FAST_ROUTE_MODE = new BooleanPreference("fast_route_mode", true).makeProfile(); // dev version - public final CommonPreference DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeGlobal(); + public final CommonPreference DISABLE_COMPLEX_ROUTING = new BooleanPreference("disable_complex_routing", false).makeProfile(); public final CommonPreference ENABLE_TIME_CONDITIONAL_ROUTING = new BooleanPreference("enable_time_conditional_routing", true).makeProfile(); public boolean simulateNavigation = false; @@ -3852,9 +3852,9 @@ public class OsmandSettings { public final CommonPreference ROUTE_RECALCULATION_DISTANCE = new FloatPreference("routing_recalc_distance", 0.f).makeProfile(); public final CommonPreference ROUTE_STRAIGHT_ANGLE = new FloatPreference("routing_straight_angle", 30.f).makeProfile(); - public final OsmandPreference USE_OSM_LIVE_FOR_ROUTING = new BooleanPreference("enable_osmc_routing", true).makeGlobal(); + public final OsmandPreference USE_OSM_LIVE_FOR_ROUTING = new BooleanPreference("enable_osmc_routing", true).makeProfile(); - public final OsmandPreference USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT = new BooleanPreference("enable_osmc_public_transport", false).makeGlobal(); + public final OsmandPreference USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT = new BooleanPreference("enable_osmc_public_transport", false).makeProfile(); public final OsmandPreference VOICE_MUTE = new BooleanPreference("voice_mute", false).makeProfile().cache(); @@ -3863,7 +3863,7 @@ public class OsmandSettings { // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference SAFE_MODE = new BooleanPreference("safe_mode", false).makeGlobal(); - public final OsmandPreference PT_SAFE_MODE = new BooleanPreference("pt_safe_mode", false).makeGlobal(); + public final OsmandPreference PT_SAFE_MODE = new BooleanPreference("pt_safe_mode", false).makeProfile(); public final OsmandPreference NATIVE_RENDERING_FAILED = new BooleanPreference("native_rendering_failed_init", false).makeGlobal(); public final OsmandPreference USE_OPENGL_RENDER = new BooleanPreference("use_opengl_render", diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java index 198e6e13eb..70dc81c23e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java @@ -6,6 +6,7 @@ import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; +import android.preference.CheckBoxPreference; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -25,6 +26,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.slider.Slider; import net.osmand.StateChangedListener; +import net.osmand.plus.Version; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; @@ -155,6 +157,60 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP getPreferenceScreen().addPreference(timeConditionalRouting); } + private void setupOsmLiveForPublicTransportPref() { + SwitchPreferenceEx useOsmLiveForPublicTransport = createSwitchPreferenceEx(settings.USE_OSM_LIVE_FOR_PUBLIC_TRANSPORT.getId(), + R.string.use_live_public_transport, R.layout.preference_with_descr_dialog_and_switch); + useOsmLiveForPublicTransport.setDescription(getString(R.string.use_osm_live_public_transport_description)); + useOsmLiveForPublicTransport.setSummaryOn(R.string.shared_string_enabled); + useOsmLiveForPublicTransport.setSummaryOff(R.string.shared_string_disabled); + useOsmLiveForPublicTransport.setIconSpaceReserved(true); + getPreferenceScreen().addPreference(useOsmLiveForPublicTransport); + } + + private void setupNativePublicTransport() { + SwitchPreferenceEx setupNativePublicTransport = createSwitchPreferenceEx(settings.PT_SAFE_MODE.getId(), + R.string.use_native_pt, R.layout.preference_with_descr_dialog_and_switch); + if (!Version.isBlackberry(app)) { + setupNativePublicTransport.setDescription(getString(R.string.use_native_pt_desc)); + setupNativePublicTransport.setSummaryOn(R.string.shared_string_enabled); + setupNativePublicTransport.setSummaryOff(R.string.shared_string_disabled); + setupNativePublicTransport.setIconSpaceReserved(true); + getPreferenceScreen().addPreference(setupNativePublicTransport); + } else { + setupNativePublicTransport.setVisible(false); + } + } + + private void setupOsmLiveForRoutingPref() { + SwitchPreferenceEx useOsmLiveForRouting = createSwitchPreferenceEx(settings.USE_OSM_LIVE_FOR_ROUTING.getId(), + R.string.use_live_routing, R.layout.preference_with_descr_dialog_and_switch); + useOsmLiveForRouting.setDescription(getString(R.string.use_osm_live_routing_description)); + useOsmLiveForRouting.setSummaryOn(R.string.shared_string_enabled); + useOsmLiveForRouting.setSummaryOff(R.string.shared_string_disabled); + useOsmLiveForRouting.setIconSpaceReserved(true); + getPreferenceScreen().addPreference(useOsmLiveForRouting); + } + + private void setupDisableComplexRoutingPref() { + SwitchPreferenceEx disableComplexRouting = createSwitchPreferenceEx(settings.DISABLE_COMPLEX_ROUTING.getId(), + R.string.use_complex_routing, R.layout.preference_with_descr_dialog_and_switch); + disableComplexRouting.setDescription(getString(R.string.disable_complex_routing_descr)); + disableComplexRouting.setSummaryOn(R.string.shared_string_enabled); + disableComplexRouting.setSummaryOff(R.string.shared_string_disabled); + disableComplexRouting.setIconSpaceReserved(true); + getPreferenceScreen().addPreference(disableComplexRouting); + } + + private void setupFastRecalculationPref() { + SwitchPreferenceEx useFastRecalculation = createSwitchPreferenceEx(settings.USE_FAST_RECALCULATION.getId(), + R.string.use_fast_recalculation, R.layout.preference_with_descr_dialog_and_switch); + useFastRecalculation.setDescription(getString(R.string.use_fast_recalculation_desc)); + useFastRecalculation.setSummaryOn(R.string.shared_string_enabled); + useFastRecalculation.setSummaryOff(R.string.shared_string_disabled); + useFastRecalculation.setIconSpaceReserved(true); + getPreferenceScreen().addPreference(useFastRecalculation); + } + private void setupRoutingPrefs() { OsmandApplication app = getMyApplication(); if (app == null) { @@ -170,7 +226,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP fastRoute.setSummaryOn(R.string.shared_string_on); fastRoute.setSummaryOff(R.string.shared_string_off); - if (am.getRouteService() == RouteProvider.RouteService.OSMAND){ + if (am.getRouteService() == RouteProvider.RouteService.OSMAND) { GeneralRouter router = app.getRouter(am); clearParameters(); if (router != null) { @@ -273,6 +329,17 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP setupRouteRecalcHeader(screen); setupSelectRouteRecalcDistance(screen); setupReverseDirectionRecalculation(screen); + addDivider(screen); + setupDevelopmentcategoryHeader(screen); + if (am.isDerivedRoutingFrom(ApplicationMode.PUBLIC_TRANSPORT)) { + setupOsmLiveForPublicTransportPref(); + setupNativePublicTransport(); + } + if (am.isDerivedRoutingFrom(ApplicationMode.CAR)) { + setupOsmLiveForRoutingPref(); + setupDisableComplexRoutingPref(); + } + setupFastRecalculationPref(); } private void addDivider(PreferenceScreen screen) { @@ -300,6 +367,13 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP screen.addPreference(routingCategory); } + private void setupDevelopmentcategoryHeader (PreferenceScreen screen) { + PreferenceCategory developmentCategory = new PreferenceCategory(requireContext()); + developmentCategory.setLayoutResource(R.layout.preference_category_with_descr); + developmentCategory.setTitle(R.string.development); + screen.addPreference(developmentCategory); + } + @Override public boolean onPreferenceClick(Preference preference) { if (preference.getKey().equals(settings.ROUTE_STRAIGHT_ANGLE.getId())) {