@@ -30,59 +30,71 @@ interface HasAndroidSettings extends HasSettings {
3030 * by the system), in an attempt to make things less confusing or faster.
3131 *
3232 * @param compress ignores unimportant views if true, doesn't ignore otherwise.
33+ * @return self instance for chaining
3334 */
34- default void ignoreUnimportantViews (Boolean compress ) {
35+ default HasAndroidSettings ignoreUnimportantViews (Boolean compress ) {
3536 setSetting (Setting .IGNORE_UNIMPORTANT_VIEWS , compress );
37+ return this ;
3638 }
3739
3840 /**
3941 * invoke {@code setWaitForIdleTimeout} in {@code com.android.uiautomator.core.Configurator}.
4042 *
4143 * @param timeout A negative value would reset to its default value. Minimum time unit
4244 * resolution is one millisecond
45+ * @return self instance for chaining
4346 */
44- default void configuratorSetWaitForIdleTimeout (Duration timeout ) {
47+ default HasAndroidSettings configuratorSetWaitForIdleTimeout (Duration timeout ) {
4548 setSetting (Setting .WAIT_FOR_IDLE_TIMEOUT , timeout .toMillis ());
49+ return this ;
4650 }
4751
4852 /**
4953 * invoke {@code setWaitForSelectorTimeout} in {@code com.android.uiautomator.core.Configurator}.
5054 *
5155 * @param timeout A negative value would reset to its default value. Minimum time unit
5256 * resolution is one millisecond
57+ * @return self instance for chaining
5358 */
54- default void configuratorSetWaitForSelectorTimeout (Duration timeout ) {
59+ default HasAndroidSettings configuratorSetWaitForSelectorTimeout (Duration timeout ) {
5560 setSetting (Setting .WAIT_FOR_SELECTOR_TIMEOUT , timeout .toMillis ());
61+ return this ;
5662 }
5763
5864 /**
5965 * invoke {@code setScrollAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator}.
6066 *
6167 * @param timeout A negative value would reset to its default value. Minimum time unit
6268 * resolution is one millisecond
69+ * @return self instance for chaining
6370 */
64- default void configuratorSetScrollAcknowledgmentTimeout (Duration timeout ) {
71+ default HasAndroidSettings configuratorSetScrollAcknowledgmentTimeout (Duration timeout ) {
6572 setSetting (Setting .WAIT_SCROLL_ACKNOWLEDGMENT_TIMEOUT , timeout .toMillis ());
73+ return this ;
6674 }
6775
6876 /**
6977 * invoke {@code configuratorSetKeyInjectionDelay} in {@code com.android.uiautomator.core.Configurator}.
7078 *
7179 * @param delay A negative value would reset to its default value. Minimum time unit
7280 * resolution is one millisecond
81+ * @return self instance for chaining
7382 */
74- default void configuratorSetKeyInjectionDelay (Duration delay ) {
83+ default HasAndroidSettings configuratorSetKeyInjectionDelay (Duration delay ) {
7584 setSetting (Setting .KEY_INJECTION_DELAY , delay .toMillis ());
85+ return this ;
7686 }
7787
7888 /**
7989 * invoke {@code setActionAcknowledgmentTimeout} in {@code com.android.uiautomator.core.Configurator}.
8090 *
8191 * @param timeout A negative value would reset to its default value. Minimum time unit
8292 * resolution is one millisecond
93+ * @return self instance for chaining
8394 */
84- default void configuratorSetActionAcknowledgmentTimeout (Duration timeout ) {
95+ default HasAndroidSettings configuratorSetActionAcknowledgmentTimeout (Duration timeout ) {
8596 setSetting (Setting .WAIT_ACTION_ACKNOWLEDGMENT_TIMEOUT , timeout .toMillis ());
97+ return this ;
8698 }
8799
88100 /**
@@ -93,10 +105,64 @@ default void configuratorSetActionAcknowledgmentTimeout(Duration timeout) {
93105 * XML parsing exceptions caused by XPath lookup.
94106 * The Unicode to ASCII transliteration is based on
95107 * JUnidecode library (https://github.com/gcardone/junidecode).
108+ * Works for UIAutomator2 only.
96109 *
97110 * @param enabled Either true or false. The default value if false.
111+ * @return self instance for chaining
98112 */
99- default void normalizeTagNames (boolean enabled ) {
113+ default HasAndroidSettings normalizeTagNames (boolean enabled ) {
100114 setSetting (Setting .NORMALIZE_TAG_NAMES , enabled );
115+ return this ;
116+ }
117+
118+ /**
119+ * Whether to return compact (standards-compliant) and faster responses in find element/s
120+ * (the default setting). If set to false then the response may also contain other
121+ * available element attributes.
122+ *
123+ * @param enabled Either true or false. The default value if true.
124+ * @return self instance for chaining
125+ */
126+ default HasAndroidSettings setShouldUseCompactResponses (boolean enabled ) {
127+ setSetting (Setting .SHOULD_USE_COMPACT_RESPONSES , enabled );
128+ return this ;
129+ }
130+
131+ /**
132+ * Which attributes should be returned if compact responses are disabled.
133+ * It works only if shouldUseCompactResponses is false. Defaults to "type,label" string.
134+ *
135+ * @param attrNames The comma-separated list of fields to return with each element.
136+ * @return self instance for chaining
137+ */
138+ default HasAndroidSettings setElementResponseAttributes (String attrNames ) {
139+ setSetting (Setting .ELEMENT_RESPONSE_ATTRIBUTES , attrNames );
140+ return this ;
141+ }
142+
143+ /**
144+ * Set whether the source output/xpath search should consider all elements, visible and invisible.
145+ * Disabling this setting speeds up source and xml search. Works for UIAutomator2 only.
146+ *
147+ * @param enabled Either true or false. The default value if false.
148+ * @return self instance for chaining
149+ */
150+ default HasAndroidSettings allowInvisibleElements (boolean enabled ) {
151+ setSetting (Setting .ALLOW_INVISIBLE_ELEMENTS , enabled );
152+ return this ;
153+ }
154+
155+ /**
156+ * Whether to enable or disable the notification listener.
157+ * No toast notifications are going to be added into page source output if
158+ * this setting is disabled.
159+ * Works for UIAutomator2 only.
160+ *
161+ * @param enabled Either true or false. The default value if true.
162+ * @return self instance for chaining
163+ */
164+ default HasAndroidSettings enableNotificationListener (boolean enabled ) {
165+ setSetting (Setting .ENABLE_NOTIFICATION_LISTENER , enabled );
166+ return this ;
101167 }
102168}
0 commit comments