use of com.android.inputmethod.keyboard.Key in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class KeyboardAccessibilityDelegate method onHoverMove.
/**
* Process {@link MotionEvent#ACTION_HOVER_MOVE} event.
*
* @param event A hover move event.
*/
protected void onHoverMove(final MotionEvent event) {
final Key lastKey = getLastHoverKey();
final Key key = getHoverKeyOf(event);
if (key != lastKey) {
if (lastKey != null) {
onHoverExitFrom(lastKey);
}
if (key != null) {
onHoverEnterTo(key);
}
}
if (key != null) {
onHoverMoveWithin(key);
}
setLastHoverKey(key);
}
use of com.android.inputmethod.keyboard.Key in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class KeyboardParams method removeRedundantMoreKeys.
public void removeRedundantMoreKeys() {
if (mAllowRedundantMoreKeys) {
return;
}
final MoreKeySpec.LettersOnBaseLayout lettersOnBaseLayout = new MoreKeySpec.LettersOnBaseLayout();
for (final Key key : mSortedKeys) {
lettersOnBaseLayout.addLetter(key);
}
final ArrayList<Key> allKeys = new ArrayList<>(mSortedKeys);
mSortedKeys.clear();
for (final Key key : allKeys) {
final Key filteredKey = Key.removeRedundantMoreKeys(key, lettersOnBaseLayout);
mSortedKeys.add(mUniqueKeysCache.getUniqueKey(filteredKey));
}
}
use of com.android.inputmethod.keyboard.Key in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class NonDistinctMultitouchHelper method processMotionEvent.
public void processMotionEvent(final MotionEvent me, final KeyDetector keyDetector) {
final int pointerCount = me.getPointerCount();
final int oldPointerCount = mOldPointerCount;
mOldPointerCount = pointerCount;
// in multi-touch events.
if (pointerCount > 1 && oldPointerCount > 1) {
return;
}
// Use only main pointer tracker.
final PointerTracker mainTracker = PointerTracker.getPointerTracker(MAIN_POINTER_TRACKER_ID);
final int action = me.getActionMasked();
final int index = me.getActionIndex();
final long eventTime = me.getEventTime();
final long downTime = me.getDownTime();
// In single-touch.
if (oldPointerCount == 1 && pointerCount == 1) {
if (me.getPointerId(index) == mainTracker.mPointerId) {
mainTracker.processMotionEvent(me, keyDetector);
return;
}
// Inject a copied event.
injectMotionEvent(action, me.getX(index), me.getY(index), downTime, eventTime, mainTracker, keyDetector);
return;
}
// Single-touch to multi-touch transition.
if (oldPointerCount == 1 && pointerCount == 2) {
// Send an up event for the last pointer, be cause we can't trust the coordinates of
// this multi-touch event.
mainTracker.getLastCoordinates(mLastCoords);
final int x = CoordinateUtils.x(mLastCoords);
final int y = CoordinateUtils.y(mLastCoords);
mOldKey = mainTracker.getKeyOn(x, y);
// Inject an artifact up event for the old key.
injectMotionEvent(MotionEvent.ACTION_UP, x, y, downTime, eventTime, mainTracker, keyDetector);
return;
}
// Multi-touch to single-touch transition.
if (oldPointerCount == 2 && pointerCount == 1) {
// Send a down event for the latest pointer if the key is different from the previous
// key.
final int x = (int) me.getX(index);
final int y = (int) me.getY(index);
final Key newKey = mainTracker.getKeyOn(x, y);
if (mOldKey != newKey) {
// Inject an artifact down event for the new key.
// An artifact up event for the new key will usually be injected as a single-touch.
injectMotionEvent(MotionEvent.ACTION_DOWN, x, y, downTime, eventTime, mainTracker, keyDetector);
if (action == MotionEvent.ACTION_UP) {
// Inject an artifact up event for the new key also.
injectMotionEvent(MotionEvent.ACTION_UP, x, y, downTime, eventTime, mainTracker, keyDetector);
}
}
return;
}
Log.w(TAG, "Unknown touch panel behavior: pointer count is " + pointerCount + " (previously " + oldPointerCount + ")");
}
use of com.android.inputmethod.keyboard.Key in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class KeyboardBuilder method parseKey.
private void parseKey(final XmlPullParser parser, final KeyboardRow row, final boolean skip) throws XmlPullParserException, IOException {
if (skip) {
XmlParseUtils.checkEndTag(TAG_KEY, parser);
if (DEBUG)
startEndTag("<%s /> skipped", TAG_KEY);
return;
}
final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard_Key);
final KeyStyle keyStyle = mParams.mKeyStyles.getKeyStyle(keyAttr, parser);
final String keySpec = keyStyle.getString(keyAttr, R.styleable.Keyboard_Key_keySpec);
if (TextUtils.isEmpty(keySpec)) {
throw new ParseException("Empty keySpec", parser);
}
final Key key = new Key(keySpec, keyAttr, keyStyle, mParams, row);
keyAttr.recycle();
if (DEBUG) {
startEndTag("<%s%s %s moreKeys=%s />", TAG_KEY, (key.isEnabled() ? "" : " disabled"), key, Arrays.toString(key.getMoreKeys()));
}
XmlParseUtils.checkEndTag(TAG_KEY, parser);
endKey(key);
}
use of com.android.inputmethod.keyboard.Key in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class KeyboardBuilder method parseSpacer.
private void parseSpacer(final XmlPullParser parser, final KeyboardRow row, final boolean skip) throws XmlPullParserException, IOException {
if (skip) {
XmlParseUtils.checkEndTag(TAG_SPACER, parser);
if (DEBUG)
startEndTag("<%s /> skipped", TAG_SPACER);
return;
}
final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard_Key);
final KeyStyle keyStyle = mParams.mKeyStyles.getKeyStyle(keyAttr, parser);
final Key spacer = new Key.Spacer(keyAttr, keyStyle, mParams, row);
keyAttr.recycle();
if (DEBUG)
startEndTag("<%s />", TAG_SPACER);
XmlParseUtils.checkEndTag(TAG_SPACER, parser);
endKey(spacer);
}
Aggregations