diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2013-03-08 19:20:26 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-03-08 19:20:26 +0000 |
commit | 4a0ae0bdce4747ca497f5ce0a6120844a5d119f3 (patch) | |
tree | e26df2198c7def03f58b119c4e6ac372476b57cd | |
parent | a717fa7aec389df650c4ab4e1c37f3dfdfb2d16f (diff) | |
parent | 25f258fabacd275a290b6f5ca77b6056a51a5119 (diff) |
Merge "Fix accessibility bug where enter key adds the focused digit twice." into jb-mr2-dev
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadImageButton.java | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadImageButton.java b/src/com/android/dialer/dialpad/DialpadImageButton.java index 5512a0c25..68fba1a56 100644 --- a/src/com/android/dialer/dialpad/DialpadImageButton.java +++ b/src/com/android/dialer/dialpad/DialpadImageButton.java @@ -18,10 +18,12 @@ package com.android.dialer.dialpad; 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 @@ public class DialpadImageButton extends ImageButton { } @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 @@ public class DialpadImageButton extends ImageButton { break; case MotionEvent.ACTION_HOVER_EXIT: if (mHoverBounds.contains((int) event.getX(), (int) event.getY())) { - performClick(); + simulateClickForAccessibility(); } setClickable(true); break; @@ -119,4 +114,18 @@ public class DialpadImageButton extends ImageButton { 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); + } } |