diff --git a/OsmAnd/res/xml/monitoring_settings.xml b/OsmAnd/res/xml/monitoring_settings.xml index 6a1e03358d..d331163df4 100644 --- a/OsmAnd/res/xml/monitoring_settings.xml +++ b/OsmAnd/res/xml/monitoring_settings.xml @@ -37,6 +37,7 @@ android:key="save_global_track_interval" android:layout="@layout/preference_with_descr" android:title="@string/save_global_track_interval" + android:persistent="false" tools:icon="@drawable/ic_action_time_span" tools:summary="3 seconds" /> diff --git a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java index a99c2635b0..f1b46ac35c 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java @@ -39,7 +39,8 @@ import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; -public class MonitoringSettingsFragment extends BaseSettingsFragment implements CopyAppModePrefsListener, ResetAppModePrefsListener { +public class MonitoringSettingsFragment extends BaseSettingsFragment + implements CopyAppModePrefsListener, ResetAppModePrefsListener { private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings"; private static final String RESET_TO_DEFAULT = "reset_to_default"; @@ -90,6 +91,12 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_GLOBAL_TRACK_INTERVAL.getId()); saveTrackInterval.setEntries(entry.values().toArray(new String[0])); saveTrackInterval.setEntryValues(entry.keySet().toArray()); + ApplicationMode selectedAppMode = getSelectedAppMode(); + if (!settings.SAVE_GLOBAL_TRACK_REMEMBER.getModeValue(selectedAppMode)) { + saveTrackInterval.setValue(settings.SAVE_GLOBAL_TRACK_REMEMBER.getModeValue(selectedAppMode)); + } else { + saveTrackInterval.setValue(settings.SAVE_GLOBAL_TRACK_INTERVAL.getModeValue(selectedAppMode)); + } saveTrackInterval.setIcon(getActiveIcon(R.drawable.ic_action_time_span)); saveTrackInterval.setDescription(R.string.save_global_track_interval_descr); } @@ -333,4 +340,16 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements updateAllSettings(); } } + + @Override + public void applySetting(String prefId, boolean applyToAllProfiles) { + if (settings.SAVE_GLOBAL_TRACK_INTERVAL.getId().equals(prefId)) { + if (applyToAllProfiles) { + app.getSettings().setPreferenceForAllModes(settings.SAVE_GLOBAL_TRACK_REMEMBER.getId(), true); + } else { + app.getSettings().setPreference(settings.SAVE_GLOBAL_TRACK_REMEMBER.getId(), true, getSelectedAppMode()); + } + + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java index 66de62f708..954329b119 100644 --- a/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/BaseSettingsFragment.java @@ -545,6 +545,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl updateAllSettings(); } + public void applySetting(String prefId, boolean applyToAllProfiles){ + } + public void updateAllSettings() { PreferenceScreen screen = getPreferenceScreen(); if (screen != null) { diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeGeneralProfilesPrefBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeGeneralProfilesPrefBottomSheet.java index ea0e0e914c..d297382688 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeGeneralProfilesPrefBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeGeneralProfilesPrefBottomSheet.java @@ -55,7 +55,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh @Override public void onClick(View v) { app.getSettings().setPreferenceForAllModes(prefId, newValue); - updateTargetSettings(false); + updateTargetSettings(false, true); dismiss(); } }) @@ -72,7 +72,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh @Override public void onClick(View v) { app.getSettings().setPreference(prefId, newValue, getAppMode()); - updateTargetSettings(false); + updateTargetSettings(false, false); dismiss(); } }) @@ -86,7 +86,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - updateTargetSettings(true); + updateTargetSettings(true, false); dismiss(); } }) @@ -105,9 +105,12 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh outState.putSerializable(NEW_VALUE_KEY, newValue); } - private void updateTargetSettings(boolean discard) { + private void updateTargetSettings(boolean discard, boolean applyToAllProfiles) { BaseSettingsFragment target = (BaseSettingsFragment) getTargetFragment(); if (target != null) { + if (!discard) { + target.applySetting(getPrefId(), applyToAllProfiles); + } target.updateSetting(getPrefId()); if (!discard) { if (target.shouldDismissOnChange()) {