Invert setting value in preference bottom sheet
This commit is contained in:
parent
8ff6eff178
commit
33c5c562d9
1 changed files with 9 additions and 2 deletions
|
@ -66,7 +66,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
? getString(R.string.shared_string_disabled) : summaryOff.toString();
|
||||
final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic);
|
||||
final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary);
|
||||
boolean checked = pref.getModeValue(getAppMode());
|
||||
boolean checked = isPreferenceChecked(pref, app);
|
||||
|
||||
final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1];
|
||||
preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
|
@ -77,7 +77,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean newValue = !pref.getModeValue(getAppMode());
|
||||
boolean newValue = !isPreferenceChecked(pref, app);
|
||||
Fragment targetFragment = getTargetFragment();
|
||||
if (targetFragment instanceof OnConfirmPreferenceChange) {
|
||||
ApplyQueryType applyQueryType = getApplyQueryType();
|
||||
|
@ -156,6 +156,13 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
return (SwitchPreferenceEx) getPreference();
|
||||
}
|
||||
|
||||
private boolean isPreferenceChecked(BooleanPreference preference, OsmandApplication app) {
|
||||
boolean checked = preference.getModeValue(getAppMode());
|
||||
boolean shouldInvertSetting = app.getSettings().DISABLE_COMPLEX_ROUTING.getId()
|
||||
.equals(preference.getId());
|
||||
return checked != shouldInvertSetting;
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target, boolean usedOnMap,
|
||||
@Nullable ApplicationMode appMode, ApplyQueryType applyQueryType,
|
||||
boolean profileDependent) {
|
||||
|
|
Loading…
Reference in a new issue