@ -1,8 +1,12 @@
package com.henninghall.date_picker.ui ;
import android.content.Context ;
import android.os.Build ;
import android.view.View ;
import android.view.accessibility.AccessibilityEvent ;
import android.view.accessibility.AccessibilityManager ;
import com.henninghall.date_picker.DatePickerManager ;
import com.henninghall.date_picker.State ;
import com.henninghall.date_picker.Utils ;
import com.henninghall.date_picker.wheelFunctions.WheelFunction ;
@ -12,6 +16,30 @@ import java.util.Locale;
public class Accessibility {
private final static AccessibilityManager systemManager =
( AccessibilityManager ) DatePickerManager . context
. getApplicationContext ( )
. getSystemService ( Context . ACCESSIBILITY_SERVICE ) ;
/ * *
When TalkBack is active , user can use one finger to explore the screen
and set focus to elements . Then user can proceed to use second finger
to scroll contents of focused element .
When there ' s multiple pickers next to each other horizontally ,
it ' s easy to accidentally scroll more than one picker at a time .
Following code aims to fix this issue .
* /
public static boolean shouldAllowScroll ( View view ) {
/ / If TalkBack isn ' t active , always proceed without suppressing touch events
if ( ! systemManager . isTouchExplorationEnabled ( ) ) {
return true ;
}
if ( Build . VERSION . SDK_INT > = 21 ) {
return view . isAccessibilityFocused ( ) ;
}
return false ;
}
public static class SetAccessibilityDelegate implements WheelFunction {
private final Locale locale ;