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 08528fe019..3d856d1113 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java @@ -33,8 +33,10 @@ import static net.osmand.plus.OsmandSettings.MONTHLY_DIRECTORY; import static net.osmand.plus.OsmandSettings.REC_DIRECTORY; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; +import static net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet.*; -public class MonitoringSettingsFragment extends BaseSettingsFragment implements CopyAppModePrefsListener, ResetAppModePrefsListener { +public class MonitoringSettingsFragment extends BaseSettingsFragment + implements CopyAppModePrefsListener, ResetAppModePrefsListener, OnApplyChanges { private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings"; private static final String RESET_TO_DEFAULT = "reset_to_default"; @@ -85,6 +87,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); } @@ -321,4 +329,18 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements updateAllSettings(); } } + + @Override + public void onApplySingleChange(String prefId) { + if (settings.SAVE_GLOBAL_TRACK_INTERVAL.getId().equals(prefId)) { + app.getSettings().setPreference(settings.SAVE_GLOBAL_TRACK_REMEMBER.getId(), true, getSelectedAppMode()); + } + } + + @Override + public void onApplyAllChanges(String prefId) { + if (settings.SAVE_GLOBAL_TRACK_INTERVAL.getId().equals(prefId)) { + app.getSettings().setPreferenceForAllModes(settings.SAVE_GLOBAL_TRACK_REMEMBER.getId(), true); + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeGeneralProfilesPrefBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeGeneralProfilesPrefBottomSheet.java index ea0e0e914c..43986c3e5a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeGeneralProfilesPrefBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ChangeGeneralProfilesPrefBottomSheet.java @@ -55,6 +55,10 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh @Override public void onClick(View v) { app.getSettings().setPreferenceForAllModes(prefId, newValue); + Fragment target = getTargetFragment(); + if (target instanceof OnApplyChanges) { + ((OnApplyChanges) target).onApplyAllChanges(prefId); + } updateTargetSettings(false); dismiss(); } @@ -72,6 +76,10 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh @Override public void onClick(View v) { app.getSettings().setPreference(prefId, newValue, getAppMode()); + Fragment target = getTargetFragment(); + if (target instanceof OnApplyChanges) { + ((OnApplyChanges) target).onApplySingleChange(prefId); + } updateTargetSettings(false); dismiss(); } @@ -144,4 +152,12 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh LOG.error("showInstance", e); } } + + public interface OnApplyChanges { + + void onApplySingleChange(String prefId); + + void onApplyAllChanges(String prefId); + + } } \ No newline at end of file