am 79beb223: Merge "Refactor keyboard accessibility delegate classes"

* commit '79beb223fccdc81d48026ab5d620626264e75bb1':
  Refactor keyboard accessibility delegate classes
main
Tadashi G. Takaoka 2014-06-27 06:16:02 +00:00 committed by Android Git Automerger
commit 617ce71b79
5 changed files with 11 additions and 25 deletions

View File

@ -19,7 +19,6 @@ package com.android.inputmethod.accessibility;
import android.content.Context; import android.content.Context;
import android.support.v4.view.AccessibilityDelegateCompat; import android.support.v4.view.AccessibilityDelegateCompat;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -31,7 +30,6 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.PointerTracker;
/** /**
* This class represents a delegate that can be registered in a class that extends * This class represents a delegate that can be registered in a class that extends
@ -264,33 +262,16 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
} }
/** /**
* Simulating a touch event by injecting a synthesized touch event into {@link PointerTracker}. * Simulating a touch event by injecting a synthesized touch event into {@link KeyboardView}.
* *
* @param touchAction The action of the synthesizing touch event. * @param touchAction The action of the synthesizing touch event.
* @param hoverEvent The base hover event from that the touch event is synthesized. * @param hoverEvent The base hover event from that the touch event is synthesized.
*/ */
protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) { protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) {
final MotionEvent touchEvent = synthesizeTouchEvent(touchAction, hoverEvent);
final int actionIndex = touchEvent.getActionIndex();
final int pointerId = touchEvent.getPointerId(actionIndex);
final PointerTracker tracker = PointerTracker.getPointerTracker(pointerId);
tracker.processMotionEvent(touchEvent, mKeyDetector);
touchEvent.recycle();
}
/**
* Synthesize a touch event from a hover event.
*
* @param touchAction The action of the synthesizing touch event.
* @param hoverEvent The base hover event from that the touch event is synthesized.
* @return The synthesized touch event of <code>touchAction</code> that has pointer information
* of <code>event</code>.
*/
protected static MotionEvent synthesizeTouchEvent(final int touchAction,
final MotionEvent hoverEvent) {
final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent); final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent);
touchEvent.setAction(touchAction); touchEvent.setAction(touchAction);
return touchEvent; mKeyboardView.onTouchEvent(touchEvent);
touchEvent.recycle();
} }
/** /**

View File

@ -68,7 +68,7 @@ final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderC
/** The virtual view identifier for the hovering node. */ /** The virtual view identifier for the hovering node. */
private int mHoveringNodeId = UNDEFINED; private int mHoveringNodeId = UNDEFINED;
/** The current keyboard view. */ /** The keyboard view to provide an accessibility node info. */
private final KeyboardView mKeyboardView; private final KeyboardView mKeyboardView;
/** The current keyboard. */ /** The current keyboard. */

View File

@ -28,9 +28,11 @@ public final class MoreSuggestionsAccessibilityDelegate
super(moreKeysKeyboardView, keyDetector); super(moreKeysKeyboardView, keyDetector);
} }
// TODO: Remove redundant override method.
@Override @Override
protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) { protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) {
final MotionEvent touchEvent = synthesizeTouchEvent(touchAction, hoverEvent); final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent);
touchEvent.setAction(touchAction);
mKeyboardView.onTouchEvent(touchEvent); mKeyboardView.onTouchEvent(touchEvent);
touchEvent.recycle(); touchEvent.recycle();
} }

View File

@ -65,9 +65,11 @@ final class EmojiPageKeyboardView extends KeyboardView implements
super(keyboardView, keyDetector); super(keyboardView, keyDetector);
} }
// TODO: Remove redundant override method.
@Override @Override
protected void simulateTouchEvent(int touchAction, MotionEvent hoverEvent) { protected void simulateTouchEvent(int touchAction, MotionEvent hoverEvent) {
final MotionEvent touchEvent = synthesizeTouchEvent(touchAction, hoverEvent); final MotionEvent touchEvent = MotionEvent.obtain(hoverEvent);
touchEvent.setAction(touchAction);
mKeyboardView.onTouchEvent(touchEvent); mKeyboardView.onTouchEvent(touchEvent);
touchEvent.recycle(); touchEvent.recycle();
} }

View File

@ -51,6 +51,7 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
super(context, attrs, defStyle); super(context, attrs, defStyle);
} }
// TODO: Remove redundant override method.
@Override @Override
public void setKeyboard(final Keyboard keyboard) { public void setKeyboard(final Keyboard keyboard) {
super.setKeyboard(keyboard); super.setKeyboard(keyboard);