From 25f258fabacd275a290b6f5ca77b6056a51a5119 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 6 Mar 2013 12:07:11 -0800 Subject: Fix accessibility bug where enter key adds the focused digit twice. Bug: 8328641 Change-Id: I76fda040f709a9a5c0e88e67abfa106763b75ffb --- .../android/dialer/dialpad/DialpadImageButton.java | 33 ++++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src') 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); + } } -- cgit v1.2.3