Fix accessibility bug where enter key adds the focused digit twice.
Bug: 8328641
Change-Id: I76fda040f709a9a5c0e88e67abfa106763b75ffb
diff --git a/src/com/android/dialer/dialpad/DialpadImageButton.java b/src/com/android/dialer/dialpad/DialpadImageButton.java
index 5512a0c..68fba1a 100644
--- a/src/com/android/dialer/dialpad/DialpadImageButton.java
+++ b/src/com/android/dialer/dialpad/DialpadImageButton.java
@@ -18,10 +18,12 @@
import android.content.Context;
import android.graphics.Rect;
+import android.os.Bundle;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageButton;
/**
@@ -81,20 +83,13 @@
}
@Override
- public boolean performClick() {
- // When accessibility is on, simulate press and release to preserve the
- // semantic meaning of performClick(). Required for Braille support.
- if (mAccessibilityManager.isEnabled()) {
- // Checking the press state prevents double activation.
- if (!isPressed()) {
- setPressed(true);
- setPressed(false);
- }
-
+ public boolean performAccessibilityAction(int action, Bundle arguments) {
+ if (action == AccessibilityNodeInfo.ACTION_CLICK) {
+ simulateClickForAccessibility();
return true;
}
- return super.performClick();
+ return super.performAccessibilityAction(action, arguments);
}
@Override
@@ -110,7 +105,7 @@
break;
case MotionEvent.ACTION_HOVER_EXIT:
if (mHoverBounds.contains((int) event.getX(), (int) event.getY())) {
- performClick();
+ simulateClickForAccessibility();
}
setClickable(true);
break;
@@ -119,4 +114,18 @@
return super.onHoverEvent(event);
}
+
+ /**
+ * When accessibility is on, simulate press and release to preserve the
+ * semantic meaning of performClick(). Required for Braille support.
+ */
+ private void simulateClickForAccessibility() {
+ // Checking the press state prevents double activation.
+ if (isPressed()) {
+ return;
+ }
+
+ setPressed(true);
+ setPressed(false);
+ }
}