Merge "[Settings] Make scribe setting default_on and secure" into udc-dev am: a6c79eb283
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/21677959 Change-Id: Ic21d98e55a56e75a1d07f050905474931f4f8969 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -127,8 +127,9 @@ public class StylusDevicesController extends AbstractPreferenceController implem
|
||||
pref.setTitle(mContext.getString(R.string.stylus_textfield_handwriting));
|
||||
pref.setIcon(R.drawable.ic_text_fields_alt);
|
||||
pref.setOnPreferenceClickListener(this);
|
||||
pref.setChecked(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 1);
|
||||
pref.setChecked(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||
Secure.STYLUS_HANDWRITING_DEFAULT_VALUE) == 1);
|
||||
pref.setVisible(currentInputMethodSupportsHandwriting());
|
||||
return pref;
|
||||
}
|
||||
@@ -157,8 +158,8 @@ public class StylusDevicesController extends AbstractPreferenceController implem
|
||||
mContext.startActivity(intent);
|
||||
break;
|
||||
case KEY_HANDWRITING:
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||
((SwitchPreference) preference).isChecked() ? 1 : 0);
|
||||
|
||||
if (((SwitchPreference) preference).isChecked()) {
|
||||
|
@@ -45,8 +45,8 @@ class StylusHandwritingPreferenceController extends DeveloperOptionsPreferenceCo
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final boolean isEnabled = (Boolean) newValue;
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED,
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
||||
|
||||
return true;
|
||||
@@ -54,16 +54,18 @@ class StylusHandwritingPreferenceController extends DeveloperOptionsPreferenceCo
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final int enable = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
|
||||
final int enable = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||
Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
|
||||
((SwitchPreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchDisabled() {
|
||||
super.onDeveloperOptionsSwitchDisabled();
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||
Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
|
||||
((SwitchPreference) mPreference).setChecked(false);
|
||||
}
|
||||
}
|
||||
|
@@ -286,8 +286,8 @@ public class StylusDevicesControllerTest {
|
||||
|
||||
@Test
|
||||
public void handwritingPreference_checkedWhenFlagTrue() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
|
||||
|
||||
showScreen(mController);
|
||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||
@@ -297,8 +297,8 @@ public class StylusDevicesControllerTest {
|
||||
|
||||
@Test
|
||||
public void handwritingPreference_uncheckedWhenFlagFalse() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
|
||||
|
||||
showScreen(mController);
|
||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||
@@ -308,22 +308,22 @@ public class StylusDevicesControllerTest {
|
||||
|
||||
@Test
|
||||
public void handwritingPreference_updatesFlagOnClick() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
|
||||
showScreen(mController);
|
||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||
|
||||
handwritingPref.performClick();
|
||||
|
||||
assertThat(handwritingPref.isChecked()).isEqualTo(true);
|
||||
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handwritingPreference_startsHandwritingSettingsOnClickIfChecked() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
|
||||
showScreen(mController);
|
||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||
|
||||
@@ -335,8 +335,8 @@ public class StylusDevicesControllerTest {
|
||||
|
||||
@Test
|
||||
public void handwritingPreference_doesNotStartHandwritingSettingsOnClickIfNotChecked() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
|
||||
showScreen(mController);
|
||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||
|
||||
@@ -350,8 +350,8 @@ public class StylusDevicesControllerTest {
|
||||
public void handwritingPreference_doesNotStartHandwritingSettingsIfNoIntent() {
|
||||
when(mInputMethodInfo.createStylusHandwritingSettingsActivityIntent())
|
||||
.thenReturn(null);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
|
||||
showScreen(mController);
|
||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||
|
||||
|
@@ -63,8 +63,8 @@ public class StylusHandwritingPreferenceControllerTest {
|
||||
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOn() {
|
||||
mController.onPreferenceChange(mPreference, true /* new value */);
|
||||
|
||||
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
||||
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
||||
|
||||
assertThat(mode).isEqualTo(SETTING_VALUE_ON);
|
||||
}
|
||||
@@ -73,16 +73,16 @@ public class StylusHandwritingPreferenceControllerTest {
|
||||
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOff() {
|
||||
mController.onPreferenceChange(mPreference, false /* new value */);
|
||||
|
||||
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
||||
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
||||
|
||||
assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
@@ -90,22 +90,11 @@ public class StylusHandwritingPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_settingEnabled_preferenceShouldBeChecked() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
|
||||
mController.onDeveloperOptionsSwitchDisabled();
|
||||
|
||||
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
||||
|
||||
assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
|
||||
verify(mPreference).setChecked(false);
|
||||
verify(mPreference).setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user