Fix #8303 ui logic changes

This commit is contained in:
Dima-1 2020-02-06 13:03:47 +02:00
parent 75594c5168
commit 2f0a7f48a0
3 changed files with 40 additions and 1 deletions

View file

@ -37,6 +37,7 @@
android:key="save_global_track_interval" android:key="save_global_track_interval"
android:layout="@layout/preference_with_descr" android:layout="@layout/preference_with_descr"
android:title="@string/save_global_track_interval" android:title="@string/save_global_track_interval"
android:persistent="false"
tools:icon="@drawable/ic_action_time_span" tools:icon="@drawable/ic_action_time_span"
tools:summary="3 seconds" /> tools:summary="3 seconds" />

View file

@ -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.OsmandSettings.REC_DIRECTORY;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; 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 COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
private static final String RESET_TO_DEFAULT = "reset_to_default"; 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()); ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_GLOBAL_TRACK_INTERVAL.getId());
saveTrackInterval.setEntries(entry.values().toArray(new String[0])); saveTrackInterval.setEntries(entry.values().toArray(new String[0]));
saveTrackInterval.setEntryValues(entry.keySet().toArray()); 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.setIcon(getActiveIcon(R.drawable.ic_action_time_span));
saveTrackInterval.setDescription(R.string.save_global_track_interval_descr); saveTrackInterval.setDescription(R.string.save_global_track_interval_descr);
} }
@ -321,4 +329,18 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment implements
updateAllSettings(); 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);
}
}
} }

View file

@ -55,6 +55,10 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
@Override @Override
public void onClick(View v) { public void onClick(View v) {
app.getSettings().setPreferenceForAllModes(prefId, newValue); app.getSettings().setPreferenceForAllModes(prefId, newValue);
Fragment target = getTargetFragment();
if (target instanceof OnApplyChanges) {
((OnApplyChanges) target).onApplyAllChanges(prefId);
}
updateTargetSettings(false); updateTargetSettings(false);
dismiss(); dismiss();
} }
@ -72,6 +76,10 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
@Override @Override
public void onClick(View v) { public void onClick(View v) {
app.getSettings().setPreference(prefId, newValue, getAppMode()); app.getSettings().setPreference(prefId, newValue, getAppMode());
Fragment target = getTargetFragment();
if (target instanceof OnApplyChanges) {
((OnApplyChanges) target).onApplySingleChange(prefId);
}
updateTargetSettings(false); updateTargetSettings(false);
dismiss(); dismiss();
} }
@ -144,4 +152,12 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
LOG.error("showInstance", e); LOG.error("showInstance", e);
} }
} }
public interface OnApplyChanges {
void onApplySingleChange(String prefId);
void onApplyAllChanges(String prefId);
}
} }