Skip to content

Commit beb8c09

Browse files
Slider should announce disabled when interacting with (#335)
* To be continued * Check for action event and return true for hover event We are only to announce "disabled" if a Slider receives the onHover event and is disabled. Otherwise we do nothing to avoid spamming user with too many redundant messages. Also the Slider should return true as the event has been handled. The docs for this: https://developer.android.com/reference/android/view/View#onHoverEvent(android.view.MotionEvent) * Remove redundant call to `String.format` * Use touch event instead of hover * React on ACTION_DOWN instead of POINTER_DOWN
1 parent 22e2ce3 commit beb8c09

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.graphics.drawable.BitmapDrawable;
1313
import android.os.Build;
1414
import android.util.AttributeSet;
15+
import android.view.MotionEvent;
1516
import android.view.accessibility.AccessibilityEvent;
1617
import android.view.accessibility.AccessibilityManager;
1718
import androidx.appcompat.widget.AppCompatSeekBar;
@@ -142,6 +143,17 @@ public void run() {
142143
}
143144
}
144145

146+
@Override
147+
public boolean onTouchEvent(MotionEvent arg0) {
148+
super.onTouchEvent(arg0);
149+
150+
if (arg0.getActionMasked() == MotionEvent.ACTION_DOWN && this.isEnabled() == false) {
151+
announceForAccessibility("slider disabled");
152+
}
153+
// Returns: True if the view handled the hover event
154+
return true;
155+
}
156+
145157
public void setupAccessibility(int index) {
146158
if (mAccessibilityUnits != null && mAccessibilityIncrements != null && mAccessibilityIncrements.size() - 1 == (int)mMaxValue) {
147159
String sliderValue = mAccessibilityIncrements.get(index);

0 commit comments

Comments
 (0)