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.setTitle(mContext.getString(R.string.stylus_textfield_handwriting));
|
||||||
pref.setIcon(R.drawable.ic_text_fields_alt);
|
pref.setIcon(R.drawable.ic_text_fields_alt);
|
||||||
pref.setOnPreferenceClickListener(this);
|
pref.setOnPreferenceClickListener(this);
|
||||||
pref.setChecked(Settings.Global.getInt(mContext.getContentResolver(),
|
pref.setChecked(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 1);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||||
|
Secure.STYLUS_HANDWRITING_DEFAULT_VALUE) == 1);
|
||||||
pref.setVisible(currentInputMethodSupportsHandwriting());
|
pref.setVisible(currentInputMethodSupportsHandwriting());
|
||||||
return pref;
|
return pref;
|
||||||
}
|
}
|
||||||
@@ -157,8 +158,8 @@ public class StylusDevicesController extends AbstractPreferenceController implem
|
|||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case KEY_HANDWRITING:
|
case KEY_HANDWRITING:
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED,
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||||
((SwitchPreference) preference).isChecked() ? 1 : 0);
|
((SwitchPreference) preference).isChecked() ? 1 : 0);
|
||||||
|
|
||||||
if (((SwitchPreference) preference).isChecked()) {
|
if (((SwitchPreference) preference).isChecked()) {
|
||||||
|
@@ -45,8 +45,8 @@ class StylusHandwritingPreferenceController extends DeveloperOptionsPreferenceCo
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
final boolean isEnabled = (Boolean) newValue;
|
final boolean isEnabled = (Boolean) newValue;
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED,
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||||
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -54,16 +54,18 @@ class StylusHandwritingPreferenceController extends DeveloperOptionsPreferenceCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
final int enable = Settings.Global.getInt(mContext.getContentResolver(),
|
final int enable = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||||
|
Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
|
||||||
((SwitchPreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
|
((SwitchPreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDeveloperOptionsSwitchDisabled() {
|
protected void onDeveloperOptionsSwitchDisabled() {
|
||||||
super.onDeveloperOptionsSwitchDisabled();
|
super.onDeveloperOptionsSwitchDisabled();
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
|
||||||
|
Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
|
||||||
((SwitchPreference) mPreference).setChecked(false);
|
((SwitchPreference) mPreference).setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -286,8 +286,8 @@ public class StylusDevicesControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handwritingPreference_checkedWhenFlagTrue() {
|
public void handwritingPreference_checkedWhenFlagTrue() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
|
||||||
|
|
||||||
showScreen(mController);
|
showScreen(mController);
|
||||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||||
@@ -297,8 +297,8 @@ public class StylusDevicesControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handwritingPreference_uncheckedWhenFlagFalse() {
|
public void handwritingPreference_uncheckedWhenFlagFalse() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
|
||||||
|
|
||||||
showScreen(mController);
|
showScreen(mController);
|
||||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||||
@@ -308,22 +308,22 @@ public class StylusDevicesControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handwritingPreference_updatesFlagOnClick() {
|
public void handwritingPreference_updatesFlagOnClick() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
|
||||||
showScreen(mController);
|
showScreen(mController);
|
||||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||||
|
|
||||||
handwritingPref.performClick();
|
handwritingPref.performClick();
|
||||||
|
|
||||||
assertThat(handwritingPref.isChecked()).isEqualTo(true);
|
assertThat(handwritingPref.isChecked()).isEqualTo(true);
|
||||||
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handwritingPreference_startsHandwritingSettingsOnClickIfChecked() {
|
public void handwritingPreference_startsHandwritingSettingsOnClickIfChecked() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
|
||||||
showScreen(mController);
|
showScreen(mController);
|
||||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||||
|
|
||||||
@@ -335,8 +335,8 @@ public class StylusDevicesControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handwritingPreference_doesNotStartHandwritingSettingsOnClickIfNotChecked() {
|
public void handwritingPreference_doesNotStartHandwritingSettingsOnClickIfNotChecked() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
|
||||||
showScreen(mController);
|
showScreen(mController);
|
||||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||||
|
|
||||||
@@ -350,8 +350,8 @@ public class StylusDevicesControllerTest {
|
|||||||
public void handwritingPreference_doesNotStartHandwritingSettingsIfNoIntent() {
|
public void handwritingPreference_doesNotStartHandwritingSettingsIfNoIntent() {
|
||||||
when(mInputMethodInfo.createStylusHandwritingSettingsActivityIntent())
|
when(mInputMethodInfo.createStylusHandwritingSettingsActivityIntent())
|
||||||
.thenReturn(null);
|
.thenReturn(null);
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
|
||||||
showScreen(mController);
|
showScreen(mController);
|
||||||
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
|
||||||
|
|
||||||
|
@@ -63,8 +63,8 @@ public class StylusHandwritingPreferenceControllerTest {
|
|||||||
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOn() {
|
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOn() {
|
||||||
mController.onPreferenceChange(mPreference, true /* new value */);
|
mController.onPreferenceChange(mPreference, true /* new value */);
|
||||||
|
|
||||||
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
|
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
||||||
|
|
||||||
assertThat(mode).isEqualTo(SETTING_VALUE_ON);
|
assertThat(mode).isEqualTo(SETTING_VALUE_ON);
|
||||||
}
|
}
|
||||||
@@ -73,16 +73,16 @@ public class StylusHandwritingPreferenceControllerTest {
|
|||||||
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOff() {
|
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOff() {
|
||||||
mController.onPreferenceChange(mPreference, false /* new value */);
|
mController.onPreferenceChange(mPreference, false /* new value */);
|
||||||
|
|
||||||
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
|
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
|
||||||
|
|
||||||
assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
|
assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
|
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setChecked(false);
|
verify(mPreference).setChecked(false);
|
||||||
@@ -90,22 +90,11 @@ public class StylusHandwritingPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_settingEnabled_preferenceShouldBeChecked() {
|
public void updateState_settingEnabled_preferenceShouldBeChecked() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
|
Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setChecked(true);
|
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