diff options
Diffstat (limited to 'java')
19 files changed, 162 insertions, 143 deletions
diff --git a/java/proguard.flags b/java/proguard.flags index a5a667987..701786a84 100644 --- a/java/proguard.flags +++ b/java/proguard.flags @@ -35,6 +35,14 @@ *; } +-keep class com.android.inputmethod.keyboard.LatinKeyboardView { + # Keep getter/setter methods for ObjectAnimator + int getLanguageOnSpacebarAnimAlpha(); + void setLanguageOnSpacebarAnimAlpha(int); + int getAltCodeKeyWhileTypingAnimAlhpa(); + void setAltCodeKeyWhileTypingAnimAlpha(int); +} + -keep class com.android.inputmethod.keyboard.MoreKeysKeyboard$Builder$MoreKeysKeyboardParams { <init>(...); } diff --git a/java/res/anim/alt_code_key_while_typing_fadein.xml b/java/res/anim/alt_code_key_while_typing_fadein.xml index 3f5fd5d48..f8caca313 100644 --- a/java/res/anim/alt_code_key_while_typing_fadein.xml +++ b/java/res/anim/alt_code_key_while_typing_fadein.xml @@ -18,8 +18,9 @@ */ --> -<animator +<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" + android:propertyName="altCodeKeyWhileTypingAnimAlpha" android:valueType="intType" android:duration="100" android:valueFrom="128" diff --git a/java/res/anim/alt_code_key_while_typing_fadeout.xml b/java/res/anim/alt_code_key_while_typing_fadeout.xml index ed4a6f298..bad1e7465 100644 --- a/java/res/anim/alt_code_key_while_typing_fadeout.xml +++ b/java/res/anim/alt_code_key_while_typing_fadeout.xml @@ -18,8 +18,9 @@ */ --> -<animator +<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" + android:propertyName="altCodeKeyWhileTypingAnimAlpha" android:valueType="intType" android:duration="70" android:valueFrom="255" diff --git a/java/res/anim/language_on_spacebar_fadeout.xml b/java/res/anim/language_on_spacebar_fadeout.xml index f66e1627b..531f440cc 100644 --- a/java/res/anim/language_on_spacebar_fadeout.xml +++ b/java/res/anim/language_on_spacebar_fadeout.xml @@ -18,10 +18,11 @@ */ --> -<animator +<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" + android:propertyName="languageOnSpacebarAnimAlpha" android:valueType="intType" android:startOffset="1200" android:duration="200" android:valueFrom="255" - android:valueTo="128" /> + android:valueTo="@integer/config_language_on_spacebar_final_alpha" /> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index e619ad0a8..cf55fbe4a 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -133,6 +133,7 @@ <attr name="spacebarTextColor" format="color" /> <attr name="spacebarTextShadowColor" format="color" /> <!-- Fadeout animator for spacebar language label. --> + <attr name="languageOnSpacebarFinalAlpha" format="integer" /> <attr name="languageOnSpacebarFadeoutAnimator" format="reference" /> <!-- Fadeout and fadein animator for altCodeWhileTyping keys. --> <attr name="altCodeKeyWhileTypingFadeoutAnimator" format="reference" /> diff --git a/java/res/values/config.xml b/java/res/values/config.xml index cccec635e..1aa0dffc9 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -38,6 +38,7 @@ <integer name="config_delay_update_suggestions">100</integer> <integer name="config_delay_update_old_suggestions">300</integer> <integer name="config_delay_update_shift_state">100</integer> + <integer name="config_language_on_spacebar_final_alpha">128</integer> <integer name="config_more_keys_keyboard_fadein_anim_time">0</integer> <integer name="config_more_keys_keyboard_fadeout_anim_time">100</integer> <integer name="config_keyboard_grid_width">32</integer> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 5628f271c..691f98ae2 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -78,6 +78,7 @@ <item name="longPressSpaceKeyTimeout">@integer/config_long_press_space_key_timeout</item> <item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item> <item name="showMoreKeysKeyboardAtTouchedPoint">@bool/config_show_more_keys_keyboard_at_touched_point</item> + <item name="languageOnSpacebarFinalAlpha">@integer/config_language_on_spacebar_final_alpha</item> <item name="languageOnSpacebarFadeoutAnimator">@anim/language_on_spacebar_fadeout</item> <item name="altCodeKeyWhileTypingFadeoutAnimator">@anim/alt_code_key_while_typing_fadeout</item> <item name="altCodeKeyWhileTypingFadeinAnimator">@anim/alt_code_key_while_typing_fadein</item> diff --git a/java/res/xml/rowkeys_georgian1.xml b/java/res/xml/rowkeys_georgian1.xml index b644cdfdd..6b24c29fe 100644 --- a/java/res/xml/rowkeys_georgian1.xml +++ b/java/res/xml/rowkeys_georgian1.xml @@ -23,7 +23,7 @@ > <switch> <case - latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted" + latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" > <Key latin:keyLabel="Q" diff --git a/java/res/xml/rowkeys_georgian2.xml b/java/res/xml/rowkeys_georgian2.xml index ddd375afa..f50e3d64b 100644 --- a/java/res/xml/rowkeys_georgian2.xml +++ b/java/res/xml/rowkeys_georgian2.xml @@ -23,7 +23,7 @@ > <switch> <case - latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted" + latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" > <Key latin:keyLabel="A" diff --git a/java/res/xml/rowkeys_georgian3.xml b/java/res/xml/rowkeys_georgian3.xml index ae8443a31..f908673af 100644 --- a/java/res/xml/rowkeys_georgian3.xml +++ b/java/res/xml/rowkeys_georgian3.xml @@ -23,7 +23,7 @@ > <switch> <case - latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted" + latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" > <!-- U+10EB: "ძ" GEORGIAN LETTER JIL --> <Key diff --git a/java/res/xml/rowkeys_hindi1.xml b/java/res/xml/rowkeys_hindi1.xml index 4f7a4148c..fe54d9ea9 100644 --- a/java/res/xml/rowkeys_hindi1.xml +++ b/java/res/xml/rowkeys_hindi1.xml @@ -23,7 +23,7 @@ > <switch> <case - latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted" + latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" > <!-- U+0914: "औ" DEVANAGARI LETTER AU U+0912/U+0902: "ऒं" DEVANAGARI LETTER SHORT O//DEVANAGARI SIGN ANUSVARA diff --git a/java/res/xml/rowkeys_hindi2.xml b/java/res/xml/rowkeys_hindi2.xml index 1bf6fd4df..95f488102 100644 --- a/java/res/xml/rowkeys_hindi2.xml +++ b/java/res/xml/rowkeys_hindi2.xml @@ -23,7 +23,7 @@ > <switch> <case - latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted" + latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" > <!-- U+0913: "ओ" DEVANAGARI LETTER O U+0913/U+0902: "ओं" DEVANAGARI LETTER O/DEVANAGARI SIGN ANUSVARA diff --git a/java/res/xml/rowkeys_hindi3.xml b/java/res/xml/rowkeys_hindi3.xml index e6b430f1b..7d43d57c7 100644 --- a/java/res/xml/rowkeys_hindi3.xml +++ b/java/res/xml/rowkeys_hindi3.xml @@ -23,7 +23,7 @@ > <switch> <case - latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted" + latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" > <!-- U+0911: "ऑ" DEVANAGARI LETTER CANDRA O --> <Key diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index da7d01af4..b66d1661d 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -16,11 +16,8 @@ package com.android.inputmethod.keyboard; -import android.animation.Animator; import android.animation.AnimatorInflater; -import android.animation.AnimatorListenerAdapter; -import android.animation.ValueAnimator; -import android.animation.ValueAnimator.AnimatorUpdateListener; +import android.animation.ObjectAnimator; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.TypedArray; @@ -54,7 +51,6 @@ import com.android.inputmethod.latin.StringUtils; import com.android.inputmethod.latin.SubtypeUtils; import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils; -import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils.LogGroup; import java.util.Locale; import java.util.WeakHashMap; @@ -70,9 +66,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke SuddenJumpingTouchEventHandler.ProcessMotionEvent { private static final String TAG = LatinKeyboardView.class.getSimpleName(); - // TODO: Kill process when the usability study mode was changed. - private static final boolean ENABLE_USABILITY_STUDY_LOG = LatinImeLogger.sUsabilityStudy; - /** Listener for {@link KeyboardActionListener}. */ private KeyboardActionListener mKeyboardActionListener; @@ -80,12 +73,12 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke private Key mSpaceKey; private Drawable mSpaceIcon; // Stuff to draw language name on spacebar. - private ValueAnimator mLanguageOnSpacebarFadeoutAnimator; - private int mFinalAlphaOfLanguageOnSpacebar; + private final int mLanguageOnSpacebarFinalAlpha; + private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator; private static final int ALPHA_OPAQUE = 255; private boolean mNeedsToDisplayLanguage; private Locale mSpacebarLocale; - private int mSpacebarTextAlpha = ALPHA_OPAQUE; + private int mLanguageOnSpacebarAnimAlpha = ALPHA_OPAQUE; private final float mSpacebarTextRatio; private float mSpacebarTextSize; private final int mSpacebarTextColor; @@ -100,8 +93,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke private static final int SPACE_LED_LENGTH_PERCENT = 80; // Stuff to draw altCodeWhileTyping keys. - private ValueAnimator mAltCodeKeyWhileTypingFadeoutAnimator; - private ValueAnimator mAltCodeKeyWhileTypingFadeinAnimator; + private ObjectAnimator mAltCodeKeyWhileTypingFadeoutAnimator; + private ObjectAnimator mAltCodeKeyWhileTypingFadeinAnimator; private int mAltCodeKeyWhileTypingAnimAlpha = ALPHA_OPAQUE; // More keys keyboard @@ -231,8 +224,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke removeMessages(MSG_LONGPRESS_KEY); } - private static void cancelAndStartAnimators(ValueAnimator animatorToCancel, - ValueAnimator animatorToStart) { + public static void cancelAndStartAnimators(ObjectAnimator animatorToCancel, + ObjectAnimator animatorToStart) { if (animatorToCancel != null && animatorToCancel.isStarted()) { animatorToCancel.cancel(); } @@ -366,6 +359,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboardView_spacebarTextColor, 0); mSpacebarTextShadowColor = a.getColor( R.styleable.LatinKeyboardView_spacebarTextShadowColor, 0); + mLanguageOnSpacebarFinalAlpha = a.getInt( + R.styleable.LatinKeyboardView_languageOnSpacebarFinalAlpha, ALPHA_OPAQUE); final int languageOnSpacebarFadeoutAnimatorResId = a.getResourceId( R.styleable.LatinKeyboardView_languageOnSpacebarFadeoutAnimator, 0); final int altCodeKeyWhileTypingFadeoutAnimatorResId = a.getResourceId( @@ -387,55 +382,41 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke PointerTracker.setParameters(mPointerTrackerParams); - final ValueAnimator animator = loadValueAnimator(languageOnSpacebarFadeoutAnimatorResId); + mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator( + languageOnSpacebarFadeoutAnimatorResId, this); + mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator( + altCodeKeyWhileTypingFadeoutAnimatorResId, this); + mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator( + altCodeKeyWhileTypingFadeinAnimatorResId, this); + } + + private ObjectAnimator loadObjectAnimator(int resId, Object target) { + if (resId == 0) return null; + final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator( + getContext(), resId); if (animator != null) { - animator.addUpdateListener(new AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { - mSpacebarTextAlpha = (Integer)animation.getAnimatedValue(); - invalidateKey(mSpaceKey); - } - }); - animator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator a) { - final ValueAnimator valueAnimator = (ValueAnimator)a; - mFinalAlphaOfLanguageOnSpacebar = (Integer)valueAnimator.getAnimatedValue(); - } - }); - // In order to get the final value of animator. - animator.end(); - } - mLanguageOnSpacebarFadeoutAnimator = animator; - - final ValueAnimator fadeout = loadValueAnimator(altCodeKeyWhileTypingFadeoutAnimatorResId); - if (fadeout != null) { - fadeout.addUpdateListener(new AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { - mAltCodeKeyWhileTypingAnimAlpha = (Integer)animation.getAnimatedValue(); - updateAltCodeKeyWhileTyping(); - } - }); + animator.setTarget(target); } - mAltCodeKeyWhileTypingFadeoutAnimator = fadeout; + return animator; + } - final ValueAnimator fadein = loadValueAnimator(altCodeKeyWhileTypingFadeinAnimatorResId); - if (fadein != null) { - fadein.addUpdateListener(new AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { - mAltCodeKeyWhileTypingAnimAlpha = (Integer)animation.getAnimatedValue(); - updateAltCodeKeyWhileTyping(); - } - }); - } - mAltCodeKeyWhileTypingFadeinAnimator = fadein; + // Getter/setter methods for {@link ObjectAnimator}. + public int getLanguageOnSpacebarAnimAlpha() { + return mLanguageOnSpacebarAnimAlpha; } - private ValueAnimator loadValueAnimator(int resId) { - if (resId == 0) return null; - return (ValueAnimator)AnimatorInflater.loadAnimator(getContext(), resId); + public void setLanguageOnSpacebarAnimAlpha(int alpha) { + mLanguageOnSpacebarAnimAlpha = alpha; + invalidateKey(mSpaceKey); + } + + public int getAltCodeKeyWhileTypingAnimAlpha() { + return mAltCodeKeyWhileTypingAnimAlpha; + } + + public void setAltCodeKeyWhileTypingAnimAlpha(int alpha) { + mAltCodeKeyWhileTypingAnimAlpha = alpha; + updateAltCodeKeyWhileTyping(); } public void setKeyboardActionListener(KeyboardActionListener listener) { @@ -672,6 +653,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final int index = me.getActionIndex(); final int id = me.getPointerId(index); final int x, y; + final float size = me.getSize(index); + final float pressure = me.getPressure(index); if (mMoreKeysPanel != null && id == mMoreKeysPanelPointerTrackerId) { x = mMoreKeysPanel.translateX((int)me.getX(index)); y = mMoreKeysPanel.translateY((int)me.getY(index)); @@ -679,32 +662,11 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke x = (int)me.getX(index); y = (int)me.getY(index); } - if (ENABLE_USABILITY_STUDY_LOG) { - final String eventTag; - switch (action) { - case MotionEvent.ACTION_UP: - eventTag = "[Up]"; - break; - case MotionEvent.ACTION_DOWN: - eventTag = "[Down]"; - break; - case MotionEvent.ACTION_POINTER_UP: - eventTag = "[PointerUp]"; - break; - case MotionEvent.ACTION_POINTER_DOWN: - eventTag = "[PointerDown]"; - break; - case MotionEvent.ACTION_MOVE: // Skip this as being logged below - eventTag = ""; - break; - default: - eventTag = "[Action" + action + "]"; - break; - } - if (!TextUtils.isEmpty(eventTag)) { - UsabilityStudyLogUtils.getInstance().write(LogGroup.MOTION_EVENT, - eventTag + eventTime + "," + id + "," + x + "," + y + "," - + me.getSize(index) + "," + me.getPressure(index)); + if (LatinImeLogger.sUsabilityStudy) { + if (action != MotionEvent.ACTION_MOVE) { + // Skip ACTION_MOVE events as they are logged below + UsabilityStudyLogUtils.getInstance().writeMotionEvent(action, eventTime, id, x, + y, size, pressure); } } @@ -764,11 +726,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke py = (int)me.getY(i); } tracker.onMoveEvent(px, py, eventTime); - if (ENABLE_USABILITY_STUDY_LOG) { - UsabilityStudyLogUtils.getInstance().write( - LogGroup.MOTION_EVENT, - "[Move]" + eventTime + "," + me.getPointerId(i) + "," + px + "," + py - + "," + me.getSize(i) + "," + me.getPressure(i)); + if (LatinImeLogger.sUsabilityStudy) { + UsabilityStudyLogUtils.getInstance().writeMotionEvent(action, eventTime, id, + px, py, size, pressure); } } } else { @@ -861,19 +821,21 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke public void startDisplayLanguageOnSpacebar(boolean subtypeChanged, boolean needsToDisplayLanguage) { - final ValueAnimator animator = mLanguageOnSpacebarFadeoutAnimator; - if (animator != null) { - animator.cancel(); - } + final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator; mNeedsToDisplayLanguage = needsToDisplayLanguage; if (animator == null) { mNeedsToDisplayLanguage = false; } else { if (subtypeChanged && needsToDisplayLanguage) { - mSpacebarTextAlpha = ALPHA_OPAQUE; + setLanguageOnSpacebarAnimAlpha(ALPHA_OPAQUE); + if (animator.isStarted()) { + animator.cancel(); + } animator.start(); } else { - mSpacebarTextAlpha = mFinalAlphaOfLanguageOnSpacebar; + if (!animator.isStarted()) { + mLanguageOnSpacebarAnimAlpha = mLanguageOnSpacebarFinalAlpha; + } } } invalidateKey(mSpaceKey); @@ -967,10 +929,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final float textHeight = -paint.ascent() + descent; final float baseline = height / 2 + textHeight / 2; paint.setColor(mSpacebarTextShadowColor); - paint.setAlpha(mSpacebarTextAlpha); + paint.setAlpha(mLanguageOnSpacebarAnimAlpha); canvas.drawText(language, width / 2, baseline - descent - 1, paint); paint.setColor(mSpacebarTextColor); - paint.setAlpha(mSpacebarTextAlpha); + paint.setAlpha(mLanguageOnSpacebarAnimAlpha); canvas.drawText(language, width / 2, baseline - descent, paint); } diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index 442413c0c..aa499ed24 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -79,8 +79,10 @@ public class ProximityInfo { final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo(); spellCheckerProximityInfo.mNativeProximityInfo = spellCheckerProximityInfo.setProximityInfoNative("", - SpellCheckerProximityInfo.ROW_SIZE, 480, 300, 11, 3, (480 / 10), proximity, - 0, null, null, null, null, null, null, null, null); + SpellCheckerProximityInfo.ROW_SIZE, 480, 300, + SpellCheckerProximityInfo.PROXIMITY_GRID_WIDTH, + SpellCheckerProximityInfo.PROXIMITY_GRID_HEIGHT, + (480 / 10), proximity, 0, null, null, null, null, null, null, null, null); return spellCheckerProximityInfo; } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 98dfdda17..7903820f7 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -68,6 +68,7 @@ import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.LatinKeyboardView; +import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils; import com.android.inputmethod.latin.suggestions.SuggestionsView; import java.io.FileDescriptor; @@ -1266,6 +1267,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mDeleteCount = 0; } mLastKeyTime = when; + + if (LatinImeLogger.sUsabilityStudy) { + UsabilityStudyLogUtils.getInstance().writeKeyEvent(primaryCode, x, y); + } + final KeyboardSwitcher switcher = mKeyboardSwitcher; // The space state depends only on the last character pressed and its own previous // state. Here, we revert the space state to neutral if the key is actually modifying diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index e2ce08323..a3589da0a 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -31,7 +31,9 @@ import android.os.Process; import android.text.TextUtils; import android.text.format.DateUtils; import android.util.Log; +import android.view.MotionEvent; +import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import java.io.BufferedReader; @@ -138,9 +140,6 @@ public class Utils { // TODO: accept code points public void push(char c, int x, int y) { if (!mEnabled) return; - if (mUsabilityStudy) { - UsabilityStudyLogUtils.getInstance().writeChar(c, x, y); - } mCharBuf[mEnd] = c; mXBuf[mEnd] = x; mYBuf[mEnd] = y; @@ -279,30 +278,57 @@ public class Utils { } } - public static void writeBackSpace(int x, int y) { - UsabilityStudyLogUtils.getInstance().write( - LogGroup.KEY, "<backspace>\t" + x + "\t" + y); + public void writeMotionEvent(final int action, final long eventTime, final int id, + final int x, final int y, final float size, final float pressure) { + final String eventTag; + switch (action) { + case MotionEvent.ACTION_CANCEL: eventTag = "[Cancel]"; break; + case MotionEvent.ACTION_UP: eventTag = "[Up]"; break; + case MotionEvent.ACTION_DOWN: eventTag = "[Down]"; break; + case MotionEvent.ACTION_POINTER_UP: eventTag = "[PointerUp]"; break; + case MotionEvent.ACTION_POINTER_DOWN: eventTag = "[PointerDown]"; break; + case MotionEvent.ACTION_MOVE: eventTag = "[Move]"; break; + case MotionEvent.ACTION_OUTSIDE: eventTag = "[Outside]"; break; + default: eventTag = "[Action" + action + "]"; break; + } + if (!TextUtils.isEmpty(eventTag)) { + StringBuilder sb = new StringBuilder(); + sb.append(eventTag); + sb.append('\t'); sb.append(eventTime); + sb.append('\t'); sb.append(id); + sb.append('\t'); sb.append(x); + sb.append('\t'); sb.append(y); + sb.append('\t'); sb.append(size); + sb.append('\t'); sb.append(pressure); + write(LogGroup.MOTION_EVENT, sb.toString()); + } } - public void writeChar(char c, int x, int y) { - String inputChar = String.valueOf(c); - switch (c) { - case '\n': - inputChar = "<enter>"; - break; - case '\t': - inputChar = "<tab>"; - break; - case ' ': - inputChar = "<space>"; - break; - } - UsabilityStudyLogUtils.getInstance().write(LogGroup.KEY, - inputChar + "\t" + x + "\t" + y); + public void writeKeyEvent(int code, int x, int y) { + final StringBuilder sb = new StringBuilder(); + sb.append(Keyboard.printableCode(code)); + sb.append('\t'); sb.append(x); + sb.append('\t'); sb.append(y); + write(LogGroup.KEY, sb.toString()); + + // TODO: replace with a cleaner flush+retrieve mechanism LatinImeLogger.onPrintAllUsabilityStudyLogs(); } - public void write(final LogGroup logGroup, final String log) { + public void writeCorrection(String subgroup, String before, String after, int position) { + final StringBuilder sb = new StringBuilder(); + sb.append(subgroup); + sb.append('\t'); sb.append(before); + sb.append('\t'); sb.append(after); + sb.append('\t'); sb.append(position); + write(LogGroup.CORRECTION, sb.toString()); + } + + public void writeStateChange(String subgroup, String details) { + write(LogGroup.STATE_CHANGE, subgroup + "\t" + details); + } + + private void write(final LogGroup logGroup, final String log) { mLoggingHandler.post(new Runnable() { @Override public void run() { diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java index d19672181..e88ab685a 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java +++ b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java @@ -21,7 +21,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; -import java.util.List; /** * A dictionary that can fusion heads and tails of words for more compression. @@ -400,16 +399,11 @@ public class FusionDictionary implements Iterable<Word> { * is ignored. * This comparator imposes orderings that are inconsistent with equals. */ - static private class CharGroupComparator implements java.util.Comparator { - public int compare(Object o1, Object o2) { - final CharGroup c1 = (CharGroup)o1; - final CharGroup c2 = (CharGroup)o2; + static private class CharGroupComparator implements java.util.Comparator<CharGroup> { + public int compare(CharGroup c1, CharGroup c2) { if (c1.mChars[0] == c2.mChars[0]) return 0; return c1.mChars[0] < c2.mChars[0] ? -1 : 1; } - public boolean equals(Object o) { - return o instanceof CharGroupComparator; - } } final static private CharGroupComparator CHARGROUP_COMPARATOR = new CharGroupComparator(); @@ -417,7 +411,7 @@ public class FusionDictionary implements Iterable<Word> { * Finds the insertion index of a character within a node. */ private static int findInsertionIndex(final Node node, int character) { - final List data = node.mData; + final ArrayList<CharGroup> data = node.mData; final CharGroup reference = new CharGroup(new int[] { character }, null, null, 0, false /* isShortcutOnly */); int result = Collections.binarySearch(data, reference, CHARGROUP_COMPARATOR); diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java index db3544987..f4c66d04c 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java @@ -30,6 +30,11 @@ public class SpellCheckerProximityInfo { // as the size of the passed array afterwards so they can't be different. final public static int ROW_SIZE = ProximityInfo.MAX_PROXIMITY_CHARS_SIZE; + // The number of keys in a row of the grid used by the spell checker. + final public static int PROXIMITY_GRID_WIDTH = 11; + // The number of rows in the grid used by the spell checker. + final public static int PROXIMITY_GRID_HEIGHT = 3; + // Helper methods final protected static void buildProximityIndices(final int[] proximity, final TreeMap<Integer, Integer> indices) { @@ -64,6 +69,9 @@ public class SpellCheckerProximityInfo { // to English, many spelling errors consist of the last vowel of the word being wrong // because in English vowels tend to merge with each other in pronunciation. final static int[] PROXIMITY = { + // Proximity for row 1. This must have exactly ROW_SIZE entries for each letter, + // and exactly PROXIMITY_GRID_WIDTH letters for a row. Pad with NUL's. + // The number of rows must be exactly PROXIMITY_GRID_HEIGHT. 'q', 'w', 's', 'a', 'z', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'w', 'q', 'a', 's', 'd', 'e', 'x', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'e', 'w', 's', 'd', 'f', 'r', 'a', 'i', 'o', 'u', NUL, NUL, NUL, NUL, NUL, NUL, @@ -76,6 +84,7 @@ public class SpellCheckerProximityInfo { 'p', 'o', 'l', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, + // Proximity for row 2. See comment above about size. 'a', 'z', 'x', 's', 'w', 'q', 'e', 'i', 'o', 'u', NUL, NUL, NUL, NUL, NUL, NUL, 's', 'q', 'a', 'z', 'x', 'c', 'd', 'e', 'w', NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'd', 'w', 's', 'x', 'c', 'v', 'f', 'r', 'e', 'w', NUL, NUL, NUL, NUL, NUL, NUL, @@ -88,6 +97,7 @@ public class SpellCheckerProximityInfo { NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, + // Proximity for row 3. See comment above about size. 'z', 'a', 's', 'd', 'x', 't', 'g', 'h', 'j', 'u', 'q', 'e', NUL, NUL, NUL, NUL, 'x', 'z', 'a', 's', 'd', 'c', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'c', 'x', 's', 'd', 'f', 'v', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, @@ -109,9 +119,12 @@ public class SpellCheckerProximityInfo { private static class Cyrillic { final private static TreeMap<Integer, Integer> INDICES = new TreeMap<Integer, Integer>(); + // TODO: The following table is solely based on the keyboard layout. Consult with Russian + // speakers on commonly misspelled words/letters. final static int[] PROXIMITY = { - // TODO: This table is solely based on the keyboard layout. Consult with Russian - // speakers on commonly misspelled words/letters. + // Proximity for row 1. This must have exactly ROW_SIZE entries for each letter, + // and exactly PROXIMITY_GRID_WIDTH letters for a row. Pad with NUL's. + // The number of rows must be exactly PROXIMITY_GRID_HEIGHT. 'й', 'ц', 'ф', 'ы', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'ц', 'й', 'ф', 'ы', 'в', 'у', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'у', 'ц', 'ы', 'в', 'а', 'к', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, @@ -124,6 +137,7 @@ public class SpellCheckerProximityInfo { 'з', 'щ', 'д', 'ж', 'э', 'х', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'х', 'з', 'ж', 'э', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, + // Proximity for row 2. See comment above about size. 'ф', 'й', 'ц', 'ы', 'я', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'ы', 'й', 'ц', 'у', 'ф', 'в', 'я', 'ч', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'в', 'ц', 'у', 'к', 'ы', 'а', 'я', 'ч', 'с', NUL, NUL, NUL, NUL, NUL, NUL, NUL, @@ -136,6 +150,7 @@ public class SpellCheckerProximityInfo { 'ж', 'щ', 'з', 'х', 'д', 'э', 'б', 'ю', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'э', 'з', 'х', 'ю', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, + // Proximity for row 3. See comment above about size. 'я', 'ф', 'ы', 'в', 'ч', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'ч', 'ы', 'в', 'а', 'я', 'с', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, 'с', 'в', 'а', 'п', 'ч', 'м', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, |