Stylus: Introduce Show Stylus Hover Pointer Setting (2/2)
Currently, the stylus hover icon can only be shown when config_enableStylusPointerIcon is set to true. This means that the users do not have a choice of turning the feature on or off. This CL introduces the capability to do the same. This CL adds the toggle in the StylusDevicesController to be shown when stylus is connected. The toggle is mapped to the STYLUS_POINTER_ENABLED secure setting which InputManagerService listens to turn on and off the stylus pointer icon. Test: manual Steps: 1. Change the value of config_enableStylusPointerIcon as true. 2. Build the images and flash it to a stylus supporting device. 3. After the device is booted, hover over the screen, the stylus pointer should appear. 4. Go to Settings > Connected Devices > Stylus and tap on "Show pointer while hovering" toggle. 5. Try hovering over the screen, check no pointer icon is shown 6. Repeat Step#4, check that stylus pointer appears. Run - make RunSettingsRoboTests \ ROBOTEST_FILTER=StylusDevicesControllerTest - atest SettingsProviderTest Change-Id: Idfff9b4307370cc510a5f94bd57777c30c96e854
This commit is contained in:
committed by
Prabir Pradhan
parent
ca4565083f
commit
e221abaa48
@@ -221,7 +221,7 @@ public class StylusDevicesControllerTest {
|
||||
|
||||
showScreen(controller);
|
||||
|
||||
assertThat(mPreferenceContainer.getPreferenceCount()).isEqualTo(3);
|
||||
assertThat(mPreferenceContainer.getPreferenceCount()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -249,11 +249,12 @@ public class StylusDevicesControllerTest {
|
||||
@Test
|
||||
public void btStylusInputDevice_showsAllPreferences() {
|
||||
showScreen(mController);
|
||||
|
||||
Preference defaultNotesPref = mPreferenceContainer.getPreference(0);
|
||||
Preference handwritingPref = mPreferenceContainer.getPreference(1);
|
||||
Preference buttonPref = mPreferenceContainer.getPreference(2);
|
||||
Preference stylusPointerIconPref = mPreferenceContainer.getPreference(3);
|
||||
|
||||
assertThat(mPreferenceContainer.getPreferenceCount()).isEqualTo(3);
|
||||
assertThat(defaultNotesPref.getTitle().toString()).isEqualTo(
|
||||
mContext.getString(R.string.stylus_default_notes_app));
|
||||
assertThat(defaultNotesPref.isVisible()).isTrue();
|
||||
@@ -263,6 +264,9 @@ public class StylusDevicesControllerTest {
|
||||
assertThat(buttonPref.getTitle().toString()).isEqualTo(
|
||||
mContext.getString(R.string.stylus_ignore_button));
|
||||
assertThat(buttonPref.isVisible()).isTrue();
|
||||
assertThat(stylusPointerIconPref.getTitle().toString()).isEqualTo(
|
||||
mContext.getString(R.string.show_stylus_pointer_icon));
|
||||
assertThat(stylusPointerIconPref.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -551,6 +555,46 @@ public class StylusDevicesControllerTest {
|
||||
Secure.STYLUS_BUTTONS_ENABLED, -1)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stylusPointerIconPreference_checkedWhenFlagTrue() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_POINTER_ICON_ENABLED, 1);
|
||||
|
||||
showScreen(mController);
|
||||
SwitchPreferenceCompat stylusPointerIconPref =
|
||||
(SwitchPreferenceCompat) mPreferenceContainer.getPreference(3);
|
||||
|
||||
assertThat(stylusPointerIconPref.isChecked()).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stylusPointerIconPreference_uncheckedWhenFlagFalse() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_POINTER_ICON_ENABLED, 0);
|
||||
|
||||
showScreen(mController);
|
||||
SwitchPreferenceCompat stylusPointerIconPref =
|
||||
(SwitchPreferenceCompat) mPreferenceContainer.getPreference(3);
|
||||
|
||||
assertThat(stylusPointerIconPref.isChecked()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stylusPointerIconPreference_updatesFlagOnClick() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.STYLUS_POINTER_ICON_ENABLED, 0);
|
||||
|
||||
showScreen(mController);
|
||||
SwitchPreferenceCompat stylusPointerIconPref =
|
||||
(SwitchPreferenceCompat) mPreferenceContainer.getPreference(3);
|
||||
|
||||
stylusPointerIconPref.performClick();
|
||||
|
||||
assertThat(stylusPointerIconPref.isChecked()).isEqualTo(true);
|
||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Secure.STYLUS_POINTER_ICON_ENABLED, -1)).isEqualTo(1);
|
||||
}
|
||||
|
||||
private void showScreen(StylusDevicesController controller) {
|
||||
controller.displayPreference(mScreen);
|
||||
}
|
||||
|
Reference in New Issue
Block a user