Use MoreKeysDetector for accessibility

A more keys keyboard may have a divider on it. The MoreKeysDetector
should be used even with accessibility mode on to be able to handle a
divider.

Bug: 15583354
Change-Id: Ife2cf8304496c4c330127fde8ca1f34c2f0838e2
This commit is contained in:
Tadashi G. Takaoka 2014-06-13 11:15:38 +09:00
parent c1cb930dde
commit 1dbeb251b2
2 changed files with 4 additions and 13 deletions

View file

@ -23,7 +23,6 @@ import android.view.MotionEvent;
import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.MoreKeysKeyboardView; import com.android.inputmethod.keyboard.MoreKeysKeyboardView;
import com.android.inputmethod.latin.Constants;
/** /**
* This class represents a delegate that can be registered in {@link MoreKeysKeyboardView} to * This class represents a delegate that can be registered in {@link MoreKeysKeyboardView} to
@ -107,8 +106,7 @@ public class MoreKeysKeyboardAccessibilityDelegate
return; return;
} }
// Close the more keys keyboard. // Close the more keys keyboard.
mKeyboardView.onMoveEvent( mKeyboardView.dismissMoreKeysPanel();
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, pointerId, eventTime);
sendWindowStateChanged(mCloseAnnounceResId); sendWindowStateChanged(mCloseAnnounceResId);
} }
} }

View file

@ -35,7 +35,7 @@ import com.android.inputmethod.latin.utils.CoordinateUtils;
public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel { public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel {
private final int[] mCoordinates = CoordinateUtils.newInstance(); private final int[] mCoordinates = CoordinateUtils.newInstance();
protected KeyDetector mKeyDetector; protected final KeyDetector mKeyDetector;
private Controller mController = EMPTY_CONTROLLER; private Controller mController = EMPTY_CONTROLLER;
protected KeyboardActionListener mListener; protected KeyboardActionListener mListener;
private int mOriginX; private int mOriginX;
@ -72,13 +72,10 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
@Override @Override
public void setKeyboard(final Keyboard keyboard) { public void setKeyboard(final Keyboard keyboard) {
super.setKeyboard(keyboard); super.setKeyboard(keyboard);
mKeyDetector.setKeyboard(
keyboard, -getPaddingLeft(), -getPaddingTop() + getVerticalCorrection());
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) { if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
// With accessibility mode on, any hover event outside {@link MoreKeysKeyboardView} is
// discarded at {@link InputView#dispatchHoverEvent(MotionEvent)}. Because only a hover
// event that is on this view is dispatched by the platform, we should use a
// {@link KeyDetector} that has no sliding allowance and no hysteresis.
if (mAccessibilityDelegate == null) { if (mAccessibilityDelegate == null) {
mKeyDetector = new KeyDetector();
mAccessibilityDelegate = new MoreKeysKeyboardAccessibilityDelegate( mAccessibilityDelegate = new MoreKeysKeyboardAccessibilityDelegate(
this, mKeyDetector); this, mKeyDetector);
mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_more_keys_keyboard); mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_more_keys_keyboard);
@ -86,12 +83,8 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
} }
mAccessibilityDelegate.setKeyboard(keyboard); mAccessibilityDelegate.setKeyboard(keyboard);
} else { } else {
mKeyDetector = new MoreKeysDetector(getResources().getDimension(
R.dimen.config_more_keys_keyboard_slide_allowance));
mAccessibilityDelegate = null; mAccessibilityDelegate = null;
} }
mKeyDetector.setKeyboard(
keyboard, -getPaddingLeft(), -getPaddingTop() + getVerticalCorrection());
} }
@Override @Override