Fix 8303 ui logic changes fix remarks
This commit is contained in:
parent
0599252870
commit
5d74129edd
3 changed files with 17 additions and 30 deletions
|
@ -37,11 +37,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.*;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||
|
||||
public class MonitoringSettingsFragment extends BaseSettingsFragment
|
||||
implements CopyAppModePrefsListener, ResetAppModePrefsListener, OnApplyChanges {
|
||||
implements CopyAppModePrefsListener, ResetAppModePrefsListener {
|
||||
|
||||
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
|
||||
private static final String RESET_TO_DEFAULT = "reset_to_default";
|
||||
|
@ -343,16 +342,14 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onApplySingleChange(String prefId) {
|
||||
public void applySetting(String prefId, boolean applyToAllProfiles) {
|
||||
if (settings.SAVE_GLOBAL_TRACK_INTERVAL.getId().equals(prefId)) {
|
||||
app.getSettings().setPreference(settings.SAVE_GLOBAL_TRACK_REMEMBER.getId(), true, getSelectedAppMode());
|
||||
}
|
||||
}
|
||||
if (applyToAllProfiles) {
|
||||
app.getSettings().setPreferenceForAllModes(settings.SAVE_GLOBAL_TRACK_REMEMBER.getId(), true);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -55,11 +55,7 @@ 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);
|
||||
updateTargetSettings(false, true);
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
|
@ -76,11 +72,7 @@ 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);
|
||||
updateTargetSettings(false, false);
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
|
@ -94,7 +86,7 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
|||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
updateTargetSettings(true);
|
||||
updateTargetSettings(true, false);
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
|
@ -113,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()) {
|
||||
|
@ -152,12 +147,4 @@ public class ChangeGeneralProfilesPrefBottomSheet extends BasePreferenceBottomSh
|
|||
LOG.error("showInstance", e);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnApplyChanges {
|
||||
|
||||
void onApplySingleChange(String prefId);
|
||||
|
||||
void onApplyAllChanges(String prefId);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue