Merge "Always show WAIT/PAUSE in dialer overflow menu." into jb-mr2-dev
diff --git a/src/com/android/dialer/dialpad/DialpadImageButton.java b/src/com/android/dialer/dialpad/DialpadImageButton.java
index 5512a0c..8f9ea4d 100644
--- a/src/com/android/dialer/dialpad/DialpadImageButton.java
+++ b/src/com/android/dialer/dialpad/DialpadImageButton.java
@@ -18,10 +18,13 @@
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.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageButton;
/**
@@ -81,20 +84,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 +106,7 @@
break;
case MotionEvent.ACTION_HOVER_EXIT:
if (mHoverBounds.contains((int) event.getX(), (int) event.getY())) {
- performClick();
+ simulateClickForAccessibility();
}
setClickable(true);
break;
@@ -119,4 +115,23 @@
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);
+
+ // Stay consistent with performClick() by sending the event after
+ // setting the pressed state but before performing the action.
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
+
+ setPressed(false);
+ }
}
diff --git a/src/com/android/dialer/dialpad/DigitsEditText.java b/src/com/android/dialer/dialpad/DigitsEditText.java
index 6ad4df9..1a092be 100644
--- a/src/com/android/dialer/dialpad/DigitsEditText.java
+++ b/src/com/android/dialer/dialpad/DigitsEditText.java
@@ -21,7 +21,6 @@
import android.text.InputType;
import android.util.AttributeSet;
import android.view.MotionEvent;
-import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
@@ -56,31 +55,4 @@
}
return ret;
}
-
- @Override
- public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
- if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
- // Since we're replacing the text every time we add or remove a
- // character, only read the difference. (issue 5337550)
- final int added = event.getAddedCount();
- final int removed = event.getRemovedCount();
- final int length = event.getBeforeText().length();
- if (added > removed) {
- event.setRemovedCount(0);
- event.setAddedCount(1);
- event.setFromIndex(length);
- } else if (removed > added) {
- event.setRemovedCount(1);
- event.setAddedCount(0);
- event.setFromIndex(length - 1);
- } else {
- return;
- }
- } else if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
- // The parent EditText class lets tts read "edit box" when this View has a focus, which
- // confuses users on app launch (issue 5275935).
- return;
- }
- super.sendAccessibilityEventUnchecked(event);
- }
}