Merge "Invert STYLUS_BUTTONS_DISABLED to avoid double negatives."

This commit is contained in:
Vania Januar
2023-02-07 08:28:48 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 7 deletions

View File

@@ -140,7 +140,7 @@ public class StylusDevicesController extends AbstractPreferenceController implem
pref.setIcon(R.drawable.ic_block);
pref.setOnPreferenceClickListener(this);
pref.setChecked(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_BUTTONS_DISABLED, 0) == 1);
Settings.Secure.STYLUS_BUTTONS_ENABLED, 1) == 0);
return pref;
}
@@ -175,8 +175,8 @@ public class StylusDevicesController extends AbstractPreferenceController implem
break;
case KEY_IGNORE_BUTTON:
Settings.Secure.putInt(mContext.getContentResolver(),
Secure.STYLUS_BUTTONS_DISABLED,
((SwitchPreference) preference).isChecked() ? 1 : 0);
Secure.STYLUS_BUTTONS_ENABLED,
((SwitchPreference) preference).isChecked() ? 0 : 1);
break;
}
return true;

View File

@@ -364,7 +364,7 @@ public class StylusDevicesControllerTest {
@Test
public void buttonsPreference_checkedWhenFlagTrue() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_BUTTONS_DISABLED, 1);
Settings.Secure.STYLUS_BUTTONS_ENABLED, 0);
showScreen(mController);
SwitchPreference buttonsPref = (SwitchPreference) mPreferenceContainer.getPreference(2);
@@ -375,7 +375,7 @@ public class StylusDevicesControllerTest {
@Test
public void buttonsPreference_uncheckedWhenFlagFalse() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_BUTTONS_DISABLED, 0);
Settings.Secure.STYLUS_BUTTONS_ENABLED, 1);
showScreen(mController);
SwitchPreference buttonsPref = (SwitchPreference) mPreferenceContainer.getPreference(2);
@@ -386,7 +386,7 @@ public class StylusDevicesControllerTest {
@Test
public void buttonsPreference_updatesFlagOnClick() {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_BUTTONS_DISABLED, 1);
Settings.Secure.STYLUS_BUTTONS_ENABLED, 0);
showScreen(mController);
SwitchPreference buttonsPref = (SwitchPreference) mPreferenceContainer.getPreference(2);
@@ -394,7 +394,7 @@ public class StylusDevicesControllerTest {
assertThat(buttonsPref.isChecked()).isEqualTo(false);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Secure.STYLUS_BUTTONS_DISABLED, -1)).isEqualTo(0);
Secure.STYLUS_BUTTONS_ENABLED, -1)).isEqualTo(0);
}
private void showScreen(StylusDevicesController controller) {