aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java146
-rw-r--r--java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java8
-rw-r--r--java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java23
-rw-r--r--java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java7
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java4
-rw-r--r--java/src/com/android/inputmethod/latin/CollectionUtils.java5
-rw-r--r--java/src/com/android/inputmethod/latin/Constants.java2
-rw-r--r--java/src/com/android/inputmethod/latin/InputPointers.java22
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java4
-rw-r--r--java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java38
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java11
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsFragment.java31
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java2
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeLocale.java43
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java3
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java23
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java4
-rw-r--r--java/src/com/android/inputmethod/research/FeedbackFragment.java14
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java46
21 files changed, 276 insertions, 166 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 670564c39..4dab50fd8 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -169,11 +169,11 @@ public class KeyboardView extends View {
public void setKeyboard(final Keyboard keyboard) {
mKeyboard = keyboard;
LatinImeLogger.onSetKeyboard(keyboard);
- requestLayout();
- invalidateAllKeys();
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes);
mKeyDrawParams.updateParams(keyHeight, keyboard.mKeyVisualAttributes);
+ invalidateAllKeys();
+ requestLayout();
}
/**
@@ -638,7 +638,6 @@ public class KeyboardView extends View {
public void closing() {
mInvalidateAllKeys = true;
mKeyboard = null;
- requestLayout();
}
@Override
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index d8ff5c265..cf89ef210 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -65,6 +65,7 @@ import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.ResourceUtils;
+import com.android.inputmethod.latin.Settings;
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeLocale;
@@ -174,9 +175,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
// More keys keyboard
private final Paint mBackgroundDimAlphaPaint = new Paint();
private boolean mNeedsToDimEntireKeyboard;
- private final WeakHashMap<Key, MoreKeysPanel> mMoreKeysPanelCache =
- new WeakHashMap<Key, MoreKeysPanel>();
- private final int mMoreKeysLayout;
+ private final View mMoreKeysKeyboardContainer;
+ private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache =
+ CollectionUtils.newWeakHashMap();
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
// More keys panel (used by both more keys keyboard and more suggestions view)
// TODO: Consider extending to support multiple more keys panels
@@ -205,8 +206,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private final int mKeyRepeatStartTimeout;
private final int mKeyRepeatInterval;
- private final int mLongPressKeyTimeout;
- private final int mLongPressShiftKeyTimeout;
+ private final int mLongPressShiftLockTimeout;
private final int mIgnoreAltCodeKeyTimeout;
private final int mGestureRecognitionUpdateTime;
@@ -218,10 +218,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
R.styleable.MainKeyboardView_keyRepeatStartTimeout, 0);
mKeyRepeatInterval = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_keyRepeatInterval, 0);
- mLongPressKeyTimeout = mainKeyboardViewAttr.getInt(
- R.styleable.MainKeyboardView_longPressKeyTimeout, 0);
- mLongPressShiftKeyTimeout = mainKeyboardViewAttr.getInt(
- R.styleable.MainKeyboardView_longPressShiftKeyTimeout, 0);
+ mLongPressShiftLockTimeout = mainKeyboardViewAttr.getInt(
+ R.styleable.MainKeyboardView_longPressShiftLockTimeout, 0);
mIgnoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
mGestureRecognitionUpdateTime = mainKeyboardViewAttr.getInt(
@@ -245,7 +243,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
break;
case MSG_LONGPRESS_KEY:
if (tracker != null) {
- keyboardView.openMoreKeysKeyboardIfRequired(tracker.getKey(), tracker);
+ keyboardView.onLongPress(tracker);
} else {
KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
}
@@ -285,7 +283,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
final int delay;
switch (code) {
case Constants.CODE_SHIFT:
- delay = mLongPressShiftKeyTimeout;
+ delay = mLongPressShiftLockTimeout;
break;
default:
delay = 0;
@@ -306,15 +304,17 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
final int delay;
switch (key.mCode) {
case Constants.CODE_SHIFT:
- delay = mLongPressShiftKeyTimeout;
+ delay = mLongPressShiftLockTimeout;
break;
default:
+ final int longpressTimeout =
+ Settings.getInstance().getCurrent().mKeyLongpressTimeout;
if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) {
// We use longer timeout for sliding finger input started from the symbols
// mode key.
- delay = mLongPressKeyTimeout * 3;
+ delay = longpressTimeout * 3;
} else {
- delay = mLongPressKeyTimeout;
+ delay = longpressTimeout;
}
break;
}
@@ -544,7 +544,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
if (mKeyPreviewLayoutId == 0) {
mShowKeyPreviewPopup = false;
}
- mMoreKeysLayout = mainKeyboardViewAttr.getResourceId(
+ final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
@@ -566,6 +566,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mPreviewPlacerView.addPreview(mSlidingKeyInputPreview);
mainKeyboardViewAttr.recycle();
+ mMoreKeysKeyboardContainer = LayoutInflater.from(getContext())
+ .inflate(moreKeysKeyboardLayoutId, null);
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(
languageOnSpacebarFadeoutAnimatorResId, this);
mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator(
@@ -653,7 +655,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection);
PointerTracker.setKeyDetector(mKeyDetector);
mTouchScreenRegulator.setKeyboardGeometry(keyboard.mOccupiedWidth);
- mMoreKeysPanelCache.clear();
+ mMoreKeysKeyboardCache.clear();
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
mSpaceIcon = (mSpaceKey != null)
@@ -942,123 +944,105 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
}
- private boolean openMoreKeysKeyboardIfRequired(final Key parentKey,
- final PointerTracker tracker) {
- // Check if we have a popup layout specified first.
- if (mMoreKeysLayout == 0) {
- return false;
- }
-
- // Check if we are already displaying popup panel.
- if (mMoreKeysPanel != null) {
- return false;
- }
- if (parentKey == null) {
- return false;
- }
- return onLongPress(parentKey, tracker);
- }
-
- private MoreKeysPanel onCreateMoreKeysPanel(final Key parentKey) {
- if (parentKey.mMoreKeys == null) {
+ private MoreKeysPanel onCreateMoreKeysPanel(final Key key, final Context context) {
+ if (key.mMoreKeys == null) {
return null;
}
-
- final View container = LayoutInflater.from(getContext()).inflate(mMoreKeysLayout, null);
- if (container == null) {
- throw new NullPointerException();
+ Keyboard moreKeysKeyboard = mMoreKeysKeyboardCache.get(key);
+ if (moreKeysKeyboard == null) {
+ moreKeysKeyboard = new MoreKeysKeyboard.Builder(
+ context, key, this, mKeyPreviewDrawParams).build();
+ mMoreKeysKeyboardCache.put(key, moreKeysKeyboard);
}
+ final View container = mMoreKeysKeyboardContainer;
final MoreKeysKeyboardView moreKeysKeyboardView =
(MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view);
- final Keyboard moreKeysKeyboard = new MoreKeysKeyboard.Builder(
- container, parentKey, this, mKeyPreviewDrawParams)
- .build();
moreKeysKeyboardView.setKeyboard(moreKeysKeyboard);
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-
return moreKeysKeyboardView;
}
/**
* Called when a key is long pressed.
- * @param parentKey the key that was long pressed
* @param tracker the pointer tracker which pressed the parent key
* @return true if the long press is handled, false otherwise. Subclasses should call the
* method on the base class if the subclass doesn't wish to handle the call.
*/
- private boolean onLongPress(final Key parentKey, final PointerTracker tracker) {
+ private boolean onLongPress(final PointerTracker tracker) {
+ if (isShowingMoreKeysPanel()) {
+ return false;
+ }
+ final Key key = tracker.getKey();
+ if (key == null) {
+ return false;
+ }
if (ProductionFlag.IS_EXPERIMENTAL) {
ResearchLogger.mainKeyboardView_onLongPress();
}
- final int primaryCode = parentKey.mCode;
- if (parentKey.hasEmbeddedMoreKey()) {
- final int embeddedCode = parentKey.mMoreKeys[0].mCode;
+ final int code = key.mCode;
+ if (key.hasEmbeddedMoreKey()) {
+ final int embeddedCode = key.mMoreKeys[0].mCode;
tracker.onLongPressed();
invokeCodeInput(embeddedCode);
- invokeReleaseKey(primaryCode);
- KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode);
+ invokeReleaseKey(code);
+ KeyboardSwitcher.getInstance().hapticAndAudioFeedback(code);
return true;
}
- if (primaryCode == Constants.CODE_SPACE || primaryCode == Constants.CODE_LANGUAGE_SWITCH) {
+ if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) {
// Long pressing the space key invokes IME switcher dialog.
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
tracker.onLongPressed();
- invokeReleaseKey(primaryCode);
+ invokeReleaseKey(code);
return true;
}
}
- return openMoreKeysPanel(parentKey, tracker);
+ return openMoreKeysPanel(key, tracker);
}
- private boolean invokeCustomRequest(final int code) {
- return mKeyboardActionListener.onCustomRequest(code);
+ private boolean invokeCustomRequest(final int requestCode) {
+ return mKeyboardActionListener.onCustomRequest(requestCode);
}
- private void invokeCodeInput(final int primaryCode) {
+ private void invokeCodeInput(final int code) {
mKeyboardActionListener.onCodeInput(
- primaryCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
+ code, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
}
- private void invokeReleaseKey(final int primaryCode) {
- mKeyboardActionListener.onReleaseKey(primaryCode, false);
+ private void invokeReleaseKey(final int code) {
+ mKeyboardActionListener.onReleaseKey(code, false);
}
- private boolean openMoreKeysPanel(final Key parentKey, final PointerTracker tracker) {
- MoreKeysPanel moreKeysPanel = mMoreKeysPanelCache.get(parentKey);
+ private boolean openMoreKeysPanel(final Key key, final PointerTracker tracker) {
+ final MoreKeysPanel moreKeysPanel = onCreateMoreKeysPanel(key, getContext());
if (moreKeysPanel == null) {
- moreKeysPanel = onCreateMoreKeysPanel(parentKey);
- if (moreKeysPanel == null) {
- return false;
- }
- mMoreKeysPanelCache.put(parentKey, moreKeysPanel);
+ return false;
}
final int[] lastCoords = CoordinateUtils.newInstance();
tracker.getLastCoordinates(lastCoords);
- final boolean keyPreviewEnabled = isKeyPreviewPopupEnabled() && !parentKey.noKeyPreview();
+ final boolean keyPreviewEnabled = isKeyPreviewPopupEnabled() && !key.noKeyPreview();
// The more keys keyboard is usually horizontally aligned with the center of the parent key.
// If showMoreKeysKeyboardAtTouchedPoint is true and the key preview is disabled, the more
// keys keyboard is placed at the touch point of the parent key.
final int pointX = (mConfigShowMoreKeysKeyboardAtTouchedPoint && !keyPreviewEnabled)
? CoordinateUtils.x(lastCoords)
- : parentKey.mX + parentKey.mWidth / 2;
+ : key.mX + key.mWidth / 2;
// The more keys keyboard is usually vertically aligned with the top edge of the parent key
// (plus vertical gap). If the key preview is enabled, the more keys keyboard is vertically
// aligned with the bottom edge of the visible part of the key preview.
// {@code mPreviewVisibleOffset} has been set appropriately in
// {@link KeyboardView#showKeyPreview(PointerTracker)}.
- final int pointY = parentKey.mY + mKeyPreviewDrawParams.mPreviewVisibleOffset;
+ final int pointY = key.mY + mKeyPreviewDrawParams.mPreviewVisibleOffset;
moreKeysPanel.showMoreKeysPanel(this, this, pointX, pointY, mKeyboardActionListener);
final int translatedX = moreKeysPanel.translateX(CoordinateUtils.x(lastCoords));
final int translatedY = moreKeysPanel.translateY(CoordinateUtils.y(lastCoords));
tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel);
- dimEntireKeyboard(true /* dimmed */);
return true;
}
public boolean isInSlidingKeyInput() {
- if (mMoreKeysPanel != null) {
+ if (isShowingMoreKeysPanel()) {
return true;
}
return PointerTracker.isAnyInSlidingKeyInput();
@@ -1069,19 +1053,17 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
if (isShowingMoreKeysPanel()) {
onDismissMoreKeysPanel();
}
+ mPreviewPlacerView.addView(panel.getContainerView());
mMoreKeysPanel = panel;
- mPreviewPlacerView.addView(mMoreKeysPanel.getContainerView());
+ dimEntireKeyboard(true /* dimmed */);
}
public boolean isShowingMoreKeysPanel() {
- return (mMoreKeysPanel != null);
+ return mMoreKeysPanel != null && mMoreKeysPanel.isShowingInParent();
}
@Override
public void onCancelMoreKeysPanel() {
- if (isShowingMoreKeysPanel()) {
- mMoreKeysPanel.dismissMoreKeysPanel();
- }
PointerTracker.dismissAllMoreKeysPanels();
}
@@ -1254,9 +1236,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
public void closing() {
dismissAllKeyPreviews();
cancelAllMessages();
+ onDismissMoreKeysPanel();
+ mMoreKeysKeyboardCache.clear();
super.closing();
- onCancelMoreKeysPanel();
- mMoreKeysPanelCache.clear();
}
/**
@@ -1331,7 +1313,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
invalidateKey(mSpaceKey);
}
- public void dimEntireKeyboard(final boolean dimmed) {
+ private void dimEntireKeyboard(final boolean dimmed) {
final boolean needsRedrawing = mNeedsToDimEntireKeyboard != dimmed;
mNeedsToDimEntireKeyboard = dimmed;
if (needsRedrawing) {
@@ -1389,7 +1371,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype,
final int width) {
// Choose appropriate language name to fit into the width.
- final String fullText = getFullDisplayName(subtype, getResources());
+ final String fullText = getFullDisplayName(subtype);
if (fitsTextIntoWidth(width, fullText, paint)) {
return fullText;
}
@@ -1463,12 +1445,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
// zz azerty T AZERTY AZERTY
// Get InputMethodSubtype's full display name in its locale.
- static String getFullDisplayName(final InputMethodSubtype subtype, final Resources res) {
+ static String getFullDisplayName(final InputMethodSubtype subtype) {
if (SubtypeLocale.isNoLanguage(subtype)) {
return SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype);
}
- return SubtypeLocale.getSubtypeDisplayName(subtype, res);
+ return SubtypeLocale.getSubtypeDisplayName(subtype);
}
// Get InputMethodSubtype's short display name in its locale.
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
index 6df883e41..66c30149c 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
@@ -16,9 +16,9 @@
package com.android.inputmethod.keyboard;
+import android.content.Context;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
-import android.view.View;
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
@@ -260,15 +260,15 @@ public final class MoreKeysKeyboard extends Keyboard {
/**
* The builder of MoreKeysKeyboard.
- * @param containerView the container of {@link MoreKeysKeyboardView}.
+ * @param context the context of {@link MoreKeysKeyboardView}.
* @param parentKey the {@link Key} that invokes more keys keyboard.
* @param parentKeyboardView the {@link KeyboardView} that contains the parentKey.
* @param keyPreviewDrawParams the parameter to place key preview.
*/
- public Builder(final View containerView, final Key parentKey,
+ public Builder(final Context context, final Key parentKey,
final MainKeyboardView parentKeyboardView,
final KeyPreviewDrawParams keyPreviewDrawParams) {
- super(containerView.getContext(), new MoreKeysKeyboardParams());
+ super(context, new MoreKeysKeyboardParams());
final Keyboard parentKeyboard = parentKeyboardView.getKeyboard();
load(parentKeyboard.mMoreKeysTemplate, parentKeyboard.mId);
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
index 0d42ab2fe..9e75f8b8a 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboardView.java
@@ -174,6 +174,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
@Override
public boolean dismissMoreKeysPanel() {
+ super.closing();
if (mController == null) return false;
return mController.onDismissMoreKeysPanel();
}
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 29c65f19b..32cee734a 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -30,8 +30,7 @@ public final class ProximityInfo {
private static final String TAG = ProximityInfo.class.getSimpleName();
private static final boolean DEBUG = false;
- /** MAX_PROXIMITY_CHARS_SIZE must be the same as MAX_PROXIMITY_CHARS_SIZE_INTERNAL
- * in defines.h */
+ // Must be equal to MAX_PROXIMITY_CHARS_SIZE in native/jni/src/defines.h
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
/** Number of key widths from current touch point to search for nearest keys. */
private static final float SEARCH_DISTANCE = 1.2f;
@@ -88,9 +87,13 @@ public final class ProximityInfo {
final int rowSize, final int gridWidth, final int gridHeight) {
final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo();
spellCheckerProximityInfo.mNativeProximityInfo =
- spellCheckerProximityInfo.setProximityInfoNative("",
- rowSize, gridWidth, gridHeight, gridWidth, gridHeight,
- 1, proximityCharsArray, 0, null, null, null, null, null, null, null, null);
+ spellCheckerProximityInfo.setProximityInfoNative("" /* locale */,
+ gridWidth /* displayWidth */, gridHeight /* displayHeight */,
+ gridWidth, gridHeight, 1 /* mostCommonKeyWidth */, proximityCharsArray,
+ 0 /* keyCount */, null /*keyXCoordinates */, null /* keyYCoordinates */,
+ null /* keyWidths */, null /* keyHeights */, null /* keyCharCodes */,
+ null /* sweetSpotCenterXs */, null /* sweetSpotCenterYs */,
+ null /* sweetSpotRadii */);
return spellCheckerProximityInfo;
}
@@ -100,11 +103,11 @@ public final class ProximityInfo {
}
// TODO: Stop passing proximityCharsArray
- private static native long setProximityInfoNative(String locale, int maxProximityCharsSize,
+ private static native long setProximityInfoNative(String locale,
int displayWidth, int displayHeight, int gridWidth, int gridHeight,
int mostCommonKeyWidth, int[] proximityCharsArray, int keyCount, int[] keyXCoordinates,
int[] keyYCoordinates, int[] keyWidths, int[] keyHeights, int[] keyCharCodes,
- float[] sweetSpotCenterX, float[] sweetSpotCenterY, float[] sweetSpotRadii);
+ float[] sweetSpotCenterXs, float[] sweetSpotCenterYs, float[] sweetSpotRadii);
private static native void releaseProximityInfoNative(long nativeProximityInfo);
@@ -230,9 +233,9 @@ public final class ProximityInfo {
}
// TODO: Stop passing proximityCharsArray
- return setProximityInfoNative(mLocaleStr, MAX_PROXIMITY_CHARS_SIZE, mKeyboardMinWidth,
- mKeyboardHeight, mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray,
- keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
+ return setProximityInfoNative(mLocaleStr, mKeyboardMinWidth, mKeyboardHeight,
+ mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray, keyCount,
+ keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
}
diff --git a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
index 9e5e18353..a56c78bcd 100644
--- a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
+++ b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
@@ -103,7 +103,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
if (DEBUG_SUBTYPE_ID) {
android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s",
subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
- SubtypeLocale.getSubtypeDisplayName(subtype, context.getResources())));
+ SubtypeLocale.getSubtypeDisplayName(subtype)));
}
if (subtype.containsExtraValueKey(ASCII_CAPABLE)) {
items.add(createItem(context, subtype.getLocale()));
@@ -205,8 +205,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
setDialogTitle(R.string.add_style);
setKey(KEY_NEW_SUBTYPE);
} else {
- final String displayName = SubtypeLocale.getSubtypeDisplayName(
- subtype, getContext().getResources());
+ final String displayName = SubtypeLocale.getSubtypeDisplayName(subtype);
setTitle(displayName);
setDialogTitle(displayName);
setKey(KEY_PREFIX + subtype.getLocale() + "_"
@@ -498,7 +497,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
final Context context = getActivity();
final Resources res = context.getResources();
final String message = res.getString(R.string.custom_input_style_already_exists,
- SubtypeLocale.getSubtypeDisplayName(subtype, res));
+ SubtypeLocale.getSubtypeDisplayName(subtype));
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 59d51b0b9..ad3163347 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -35,9 +35,9 @@ public final class BinaryDictionary extends Dictionary {
public static final String DICTIONARY_PACK_AUTHORITY =
"com.android.inputmethod.latin.dictionarypack";
- // Must be identical to MAX_WORD_LENGTH in native/jni/src/defines.h
+ // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
- // Must be identical to MAX_RESULTS in native/jni/src/defines.h
+ // Must be equal to MAX_RESULTS in native/jni/src/defines.h
private static final int MAX_RESULTS = 18;
private long mNativeDict;
diff --git a/java/src/com/android/inputmethod/latin/CollectionUtils.java b/java/src/com/android/inputmethod/latin/CollectionUtils.java
index c75f2df5c..a8623cc63 100644
--- a/java/src/com/android/inputmethod/latin/CollectionUtils.java
+++ b/java/src/com/android/inputmethod/latin/CollectionUtils.java
@@ -27,6 +27,7 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
+import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -39,6 +40,10 @@ public final class CollectionUtils {
return new HashMap<K,V>();
}
+ public static <K, V> WeakHashMap<K, V> newWeakHashMap() {
+ return new WeakHashMap<K, V>();
+ }
+
public static <K,V> TreeMap<K,V> newTreeMap() {
return new TreeMap<K,V>();
}
diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java
index 748900b3a..85cc55232 100644
--- a/java/src/com/android/inputmethod/latin/Constants.java
+++ b/java/src/com/android/inputmethod/latin/Constants.java
@@ -127,7 +127,7 @@ public final class Constants {
}
public static final class Dictionary {
- // Must be identical to MAX_WORD_LENGTH in native/jni/src/defines.h
+ // Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
public static final int MAX_WORD_LENGTH = 48;
private Dictionary() {
diff --git a/java/src/com/android/inputmethod/latin/InputPointers.java b/java/src/com/android/inputmethod/latin/InputPointers.java
index 4d6c4f356..81c833000 100644
--- a/java/src/com/android/inputmethod/latin/InputPointers.java
+++ b/java/src/com/android/inputmethod/latin/InputPointers.java
@@ -18,8 +18,11 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.annotations.UsedForTesting;
+import android.util.Log;
+
// TODO: This class is not thread-safe.
public final class InputPointers {
+ private static final String TAG = InputPointers.class.getSimpleName();
private final int mDefaultCapacity;
private final ResizableIntArray mXCoordinates;
private final ResizableIntArray mYCoordinates;
@@ -126,6 +129,11 @@ public final class InputPointers {
}
public int[] getTimes() {
+ if (LatinImeLogger.sDBG) {
+ if (!isValidTimeStamps()) {
+ throw new RuntimeException("Time stamps are invalid.");
+ }
+ }
return mTimes.getPrimitiveArray();
}
@@ -134,4 +142,18 @@ public final class InputPointers {
return "size=" + getPointerSize() + " id=" + mPointerIds + " time=" + mTimes
+ " x=" + mXCoordinates + " y=" + mYCoordinates;
}
+
+ private boolean isValidTimeStamps() {
+ final int[] times = mTimes.getPrimitiveArray();
+ for (int i = 1; i < getPointerSize(); ++i) {
+ if (times[i] < times[i - 1]) {
+ // dump
+ for (int j = 0; j < times.length; ++j) {
+ Log.d(TAG, "--- (" + j + ") " + times[j]);
+ }
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 6085cb4ab..70eb6e657 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2491,7 +2491,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
private void launchSubActivity(final Class<? extends Activity> activityClass) {
Intent intent = new Intent();
intent.setClass(LatinIME.this, activityClass);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
diff --git a/java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java b/java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java
index 604156408..9819a02ef 100644
--- a/java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java
+++ b/java/src/com/android/inputmethod/latin/SeekBarDialogPreference.java
@@ -37,6 +37,8 @@ public final class SeekBarDialogPreference extends DialogPreference
private final int mValueFormatResId;
private final int mMaxValue;
+ private final int mMinValue;
+ private final int mStepValue;
private TextView mValueView;
private SeekBar mSeekBar;
@@ -49,6 +51,8 @@ public final class SeekBarDialogPreference extends DialogPreference
attrs, R.styleable.SeekBarDialogPreference, 0, 0);
mValueFormatResId = a.getResourceId(R.styleable.SeekBarDialogPreference_valueFormatText, 0);
mMaxValue = a.getInt(R.styleable.SeekBarDialogPreference_maxValue, 0);
+ mMinValue = a.getInt(R.styleable.SeekBarDialogPreference_minValue, 0);
+ mStepValue = a.getInt(R.styleable.SeekBarDialogPreference_stepValue, 0);
a.recycle();
setDialogLayoutResource(R.layout.seek_bar_dialog);
}
@@ -70,22 +74,42 @@ public final class SeekBarDialogPreference extends DialogPreference
protected View onCreateDialogView() {
final View view = super.onCreateDialogView();
mSeekBar = (SeekBar)view.findViewById(R.id.seek_bar_dialog_bar);
- mSeekBar.setMax(mMaxValue);
+ mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);
mValueView = (TextView)view.findViewById(R.id.seek_bar_dialog_value);
return view;
}
+ private int getProgressFromValue(final int value) {
+ return value - mMinValue;
+ }
+
+ private int getValueFromProgress(final int progress) {
+ return progress + mMinValue;
+ }
+
+ private int clipValue(final int value) {
+ final int clippedValue = Math.min(mMaxValue, Math.max(mMinValue, value));
+ if (mStepValue <= 1) {
+ return clippedValue;
+ }
+ return clippedValue - (clippedValue % mStepValue);
+ }
+
+ private int getClippedValueFromProgress(final int progress) {
+ return clipValue(getValueFromProgress(progress));
+ }
+
private void setValue(final int value, final boolean fromUser) {
mValueView.setText(getValueText(value));
if (!fromUser) {
- mSeekBar.setProgress(value);
+ mSeekBar.setProgress(getProgressFromValue(value));
}
}
@Override
protected void onBindDialogView(final View view) {
- setValue(mValueProxy.readValue(getKey()), false /* fromUser */);
+ setValue(clipValue(mValueProxy.readValue(getKey())), false /* fromUser */);
}
@Override
@@ -99,18 +123,18 @@ public final class SeekBarDialogPreference extends DialogPreference
public void onClick(final DialogInterface dialog, final int which) {
super.onClick(dialog, which);
if (which == DialogInterface.BUTTON_NEUTRAL) {
- setValue(mValueProxy.readDefaultValue(getKey()), false /* fromUser */);
+ setValue(clipValue(mValueProxy.readDefaultValue(getKey())), false /* fromUser */);
}
if (which != DialogInterface.BUTTON_NEGATIVE) {
setSummary(mValueView.getText());
- mValueProxy.writeValue(mSeekBar.getProgress(), getKey());
+ mValueProxy.writeValue(getClippedValueFromProgress(mSeekBar.getProgress()), getKey());
}
}
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress,
final boolean fromUser) {
- setValue(progress, fromUser);
+ setValue(getClippedValueFromProgress(progress), fromUser);
}
@Override
@@ -118,6 +142,6 @@ public final class SeekBarDialogPreference extends DialogPreference
@Override
public void onStopTrackingTouch(final SeekBar seekBar) {
- mValueProxy.feedbackValue(seekBar.getProgress());
+ mValueProxy.feedbackValue(getClippedValueFromProgress(seekBar.getProgress()));
}
}
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index aa705da56..408ea4a49 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -55,6 +55,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction";
public static final String PREF_GESTURE_SETTINGS = "gesture_typing_settings";
public static final String PREF_GESTURE_INPUT = "gesture_input";
+ public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout";
public static final String PREF_VIBRATION_DURATION_SETTINGS =
"pref_vibration_duration_settings";
public static final String PREF_KEYPRESS_SOUND_VOLUME =
@@ -175,6 +176,16 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
ResourceUtils.getDeviceOverrideValue(res, R.array.keypress_volumes));
}
+ public static int readKeyLongpressTimeout(final SharedPreferences prefs,
+ final Resources res) {
+ final int ms = prefs.getInt(PREF_KEY_LONGPRESS_TIMEOUT, -1);
+ return (ms >= 0) ? ms : readDefaultKeyLongpressTimeout(res);
+ }
+
+ public static int readDefaultKeyLongpressTimeout(final Resources res) {
+ return res.getInteger(R.integer.config_default_longpress_key_timeout);
+ }
+
public static int readKeypressVibrationDuration(final SharedPreferences prefs,
final Resources res) {
final int ms = prefs.getInt(PREF_VIBRATION_DURATION_SETTINGS, -1);
diff --git a/java/src/com/android/inputmethod/latin/SettingsFragment.java b/java/src/com/android/inputmethod/latin/SettingsFragment.java
index afe6f3594..3ba24fb65 100644
--- a/java/src/com/android/inputmethod/latin/SettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/SettingsFragment.java
@@ -164,6 +164,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
getPreferenceScreen().removePreference(gestureTypingSettings);
}
+ setupKeyLongpressTimeoutSettings(prefs, res);
setupKeypressVibrationDurationSettings(prefs, res);
setupKeypressSoundVolumeSettings(prefs, res);
refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, res);
@@ -236,7 +237,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
final StringBuilder styles = new StringBuilder();
for (final InputMethodSubtype subtype : subtypes) {
if (styles.length() > 0) styles.append(", ");
- styles.append(SubtypeLocale.getSubtypeDisplayName(subtype, res));
+ styles.append(SubtypeLocale.getSubtypeDisplayName(subtype));
}
customInputStyles.setSummary(styles);
}
@@ -298,6 +299,34 @@ public final class SettingsFragment extends InputMethodSettingsFragment
});
}
+ private void setupKeyLongpressTimeoutSettings(final SharedPreferences sp,
+ final Resources res) {
+ final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(
+ Settings.PREF_KEY_LONGPRESS_TIMEOUT);
+ if (pref == null) {
+ return;
+ }
+ pref.setInterface(new SeekBarDialogPreference.ValueProxy() {
+ @Override
+ public void writeValue(final int value, final String key) {
+ sp.edit().putInt(key, value).apply();
+ }
+
+ @Override
+ public int readValue(final String key) {
+ return Settings.readKeyLongpressTimeout(sp, res);
+ }
+
+ @Override
+ public int readDefaultValue(final String key) {
+ return Settings.readDefaultKeyLongpressTimeout(res);
+ }
+
+ @Override
+ public void feedbackValue(final int value) {}
+ });
+ }
+
private void setupKeypressSoundVolumeSettings(final SharedPreferences sp, final Resources res) {
final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(
Settings.PREF_KEYPRESS_SOUND_VOLUME);
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index d6556d617..29e79e4cc 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -59,6 +59,7 @@ public final class SettingsValues {
public final boolean mGestureInputEnabled;
public final boolean mGesturePreviewTrailEnabled;
public final boolean mGestureFloatingPreviewTextEnabled;
+ public final int mKeyLongpressTimeout;
// From the input box
public final InputAttributes mInputAttributes;
@@ -121,6 +122,7 @@ public final class SettingsValues {
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
// Compute other readable settings
+ mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);
mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res);
mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res);
diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
index 370a6594b..068c34ed6 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
@@ -42,6 +42,7 @@ public final class SubtypeLocale {
public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic;
private static boolean sInitialized = false;
+ private static Resources sResources;
private static String[] sPredefinedKeyboardLayoutSet;
// Keyboard layout to its display name map.
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap =
@@ -71,10 +72,11 @@ public final class SubtypeLocale {
}
// Note that this initialization method can be called multiple times.
- public static synchronized void init(Context context) {
+ public static synchronized void init(final Context context) {
if (sInitialized) return;
final Resources res = context.getResources();
+ sResources = res;
final String[] predefinedLayoutSet = res.getStringArray(R.array.predefined_layouts);
sPredefinedKeyboardLayoutSet = predefinedLayoutSet;
@@ -121,15 +123,15 @@ public final class SubtypeLocale {
return sPredefinedKeyboardLayoutSet;
}
- public static boolean isExceptionalLocale(String localeString) {
+ public static boolean isExceptionalLocale(final String localeString) {
return sExceptionalLocaleToWithLayoutNameIdsMap.containsKey(localeString);
}
- private static final String getNoLanguageLayoutKey(String keyboardLayoutName) {
+ private static final String getNoLanguageLayoutKey(final String keyboardLayoutName) {
return NO_LANGUAGE + "_" + keyboardLayoutName;
}
- public static int getSubtypeNameId(String localeString, String keyboardLayoutName) {
+ public static int getSubtypeNameId(final String localeString, final String keyboardLayoutName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& isExceptionalLocale(localeString)) {
return sExceptionalLocaleToWithLayoutNameIdsMap.get(localeString);
@@ -141,7 +143,7 @@ public final class SubtypeLocale {
return nameId == null ? UNKNOWN_KEYBOARD_LAYOUT : nameId;
}
- public static String getSubtypeLocaleDisplayName(String localeString) {
+ public static String getSubtypeLocaleDisplayName(final String localeString) {
final String exceptionalValue = sExceptionalDisplayNamesMap.get(localeString);
if (exceptionalValue != null) {
return exceptionalValue;
@@ -166,12 +168,17 @@ public final class SubtypeLocale {
// en_US azerty T English (US) (AZERTY)
// zz azerty T No language (AZERTY) in system locale
- public static String getSubtypeDisplayName(final InputMethodSubtype subtype, Resources res) {
- final String replacementString =
- (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
- && subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME))
- ? subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)
- : getSubtypeLocaleDisplayName(subtype.getLocale());
+ private static String getReplacementString(final InputMethodSubtype subtype) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
+ && subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
+ return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
+ } else {
+ return getSubtypeLocaleDisplayName(subtype.getLocale());
+ }
+ }
+
+ public static String getSubtypeDisplayName(final InputMethodSubtype subtype) {
+ final String replacementString = getReplacementString(subtype);
final int nameResId = subtype.getNameResId();
final RunInLocale<String> getSubtypeName = new RunInLocale<String>() {
@Override
@@ -190,30 +197,30 @@ public final class SubtypeLocale {
}
};
final Locale locale = isNoLanguage(subtype)
- ? res.getConfiguration().locale : getSubtypeLocale(subtype);
- return getSubtypeName.runInLocale(res, locale);
+ ? sResources.getConfiguration().locale : getSubtypeLocale(subtype);
+ return getSubtypeName.runInLocale(sResources, locale);
}
- public static boolean isNoLanguage(InputMethodSubtype subtype) {
+ public static boolean isNoLanguage(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale();
return localeString.equals(NO_LANGUAGE);
}
- public static Locale getSubtypeLocale(InputMethodSubtype subtype) {
+ public static Locale getSubtypeLocale(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale();
return LocaleUtils.constructLocaleFromString(localeString);
}
- public static String getKeyboardLayoutSetDisplayName(InputMethodSubtype subtype) {
+ public static String getKeyboardLayoutSetDisplayName(final InputMethodSubtype subtype) {
final String layoutName = getKeyboardLayoutSetName(subtype);
return getKeyboardLayoutSetDisplayName(layoutName);
}
- public static String getKeyboardLayoutSetDisplayName(String layoutName) {
+ public static String getKeyboardLayoutSetDisplayName(final String layoutName) {
return sKeyboardLayoutToDisplayNameMap.get(layoutName);
}
- public static String getKeyboardLayoutSetName(InputMethodSubtype subtype) {
+ public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
if (keyboardLayoutSet == null) {
// This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index eb0ec3990..2f9e34ff1 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -151,8 +151,7 @@ public final class SubtypeSwitcher {
// Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function.
public void onSubtypeChanged(final InputMethodSubtype newSubtype) {
if (DBG) {
- Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeDisplayName(
- newSubtype, mResources));
+ Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeDisplayName(newSubtype));
}
final Locale newLocale = SubtypeLocale.getSubtypeLocale(newSubtype);
diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
index 26a304ef8..438820d17 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
@@ -19,7 +19,6 @@ package com.android.inputmethod.latin.suggestions;
import android.content.Context;
import android.util.AttributeSet;
-import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.MoreKeysKeyboardView;
import com.android.inputmethod.latin.R;
@@ -28,7 +27,6 @@ import com.android.inputmethod.latin.R;
* key presses and touch movements.
*/
public final class MoreSuggestionsView extends MoreKeysKeyboardView {
-
public MoreSuggestionsView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.moreSuggestionsViewStyle);
}
@@ -44,32 +42,15 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
return pane.mOccupiedWidth / 2;
}
- @Override
- protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
- final Keyboard keyboard = getKeyboard();
- if (keyboard != null) {
- final int width = keyboard.mOccupiedWidth + getPaddingLeft() + getPaddingRight();
- final int height = keyboard.mOccupiedHeight + getPaddingTop() + getPaddingBottom();
- setMeasuredDimension(width, height);
- } else {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
- }
-
public void updateKeyboardGeometry(final int keyHeight) {
mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes);
}
@Override
- public void onCodeInput(final int primaryCode, final int x, final int y) {
- final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE;
+ public void onCodeInput(final int code, final int x, final int y) {
+ final int index = code - MoreSuggestions.SUGGESTION_CODE_BASE;
if (index >= 0 && index < SuggestionStripView.MAX_SUGGESTIONS) {
mListener.onCustomRequest(index);
}
}
-
- @Override
- public boolean isShowingInParent() {
- return (getContainerView().getParent() != null);
- }
}
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index 92b96e754..bc51d5d62 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -676,12 +676,11 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
new MoreKeysPanel.Controller() {
@Override
public boolean onDismissMoreKeysPanel() {
- mMainKeyboardView.dimEntireKeyboard(false /* dimmed */);
return mMainKeyboardView.onDismissMoreKeysPanel();
}
@Override
- public void onShowMoreKeysPanel(MoreKeysPanel panel) {
+ public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
mMainKeyboardView.onShowMoreKeysPanel(panel);
}
@@ -728,7 +727,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
mOriginX = mLastX;
mOriginY = mLastY;
- mMainKeyboardView.dimEntireKeyboard(true /* dimmed */);
for (int i = 0; i < params.mSuggestionsCountInStrip; i++) {
mWords.get(i).setPressed(false);
}
diff --git a/java/src/com/android/inputmethod/research/FeedbackFragment.java b/java/src/com/android/inputmethod/research/FeedbackFragment.java
index a9adbb73d..fee61a923 100644
--- a/java/src/com/android/inputmethod/research/FeedbackFragment.java
+++ b/java/src/com/android/inputmethod/research/FeedbackFragment.java
@@ -32,7 +32,8 @@ import com.android.inputmethod.latin.R;
public class FeedbackFragment extends Fragment {
private EditText mEditText;
- private CheckBox mCheckBox;
+ private CheckBox mIncludingHistoryCheckBox;
+ private CheckBox mIncludingAccountNameCheckBox;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -40,7 +41,10 @@ public class FeedbackFragment extends Fragment {
final View view = inflater.inflate(R.layout.research_feedback_fragment_layout, container,
false);
mEditText = (EditText) view.findViewById(R.id.research_feedback_contents);
- mCheckBox = (CheckBox) view.findViewById(R.id.research_feedback_include_history);
+ mIncludingHistoryCheckBox = (CheckBox) view.findViewById(
+ R.id.research_feedback_include_history);
+ mIncludingAccountNameCheckBox = (CheckBox) view.findViewById(
+ R.id.research_feedback_include_account_name);
final Button sendButton = (Button) view.findViewById(
R.id.research_feedback_send_button);
@@ -49,8 +53,10 @@ public class FeedbackFragment extends Fragment {
public void onClick(View v) {
final Editable editable = mEditText.getText();
final String feedbackContents = editable.toString();
- final boolean includeHistory = mCheckBox.isChecked();
- ResearchLogger.getInstance().sendFeedback(feedbackContents, includeHistory);
+ final boolean isIncludingHistory = mIncludingHistoryCheckBox.isChecked();
+ final boolean isIncludingAccountName = mIncludingAccountNameCheckBox.isChecked();
+ ResearchLogger.getInstance().sendFeedback(feedbackContents, isIncludingHistory,
+ isIncludingAccountName);
final Activity activity = FeedbackFragment.this.getActivity();
activity.finish();
ResearchLogger.getInstance().onLeavingSendFeedbackDialog();
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index 29bc70880..dbf2d2982 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -18,6 +18,8 @@ package com.android.inputmethod.research;
import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
+import android.accounts.Account;
+import android.accounts.AccountManager;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -30,6 +32,7 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@@ -115,6 +118,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private static final String PREF_RESEARCH_LOGGER_UUID_STRING = "pref_research_logger_uuid";
private static final ResearchLogger sInstance = new ResearchLogger();
+ private static String sAccountType = null;
+ private static String sAllowedAccountDomain = null;
// to write to a different filename, e.g., for testing, set mFile before calling start()
/* package */ File mFilesDir;
/* package */ String mUUIDString;
@@ -199,6 +204,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
e.apply();
}
}
+ final Resources res = latinIME.getResources();
+ sAccountType = res.getString(R.string.research_account_type);
+ sAllowedAccountDomain = res.getString(R.string.research_allowed_account_domain);
mLatinIME = latinIME;
mPrefs = prefs;
mUploadIntent = new Intent(mLatinIME, UploaderService.class);
@@ -593,6 +601,36 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
*/
+ /**
+ * Get the name of the first allowed account on the device.
+ *
+ * Allowed accounts must be in the domain given by ALLOWED_ACCOUNT_DOMAIN.
+ *
+ * @return The user's account name.
+ */
+ public String getAccountName() {
+ if (sAccountType == null || sAccountType.isEmpty()) {
+ return null;
+ }
+ if (sAllowedAccountDomain == null || sAllowedAccountDomain.isEmpty()) {
+ return null;
+ }
+ final AccountManager manager = AccountManager.get(mLatinIME);
+ // Filter first by account type.
+ final Account[] accounts = manager.getAccountsByType(sAccountType);
+
+ for (final Account account : accounts) {
+ if (DEBUG) {
+ Log.d(TAG, account.name);
+ }
+ final String[] parts = account.name.split("@");
+ if (parts.length > 1 && parts[1].equals(sAllowedAccountDomain)) {
+ return parts[0];
+ }
+ }
+ return null;
+ }
+
static class LogStatement {
final String mName;
@@ -626,8 +664,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
private static final LogStatement LOGSTATEMENT_FEEDBACK =
- new LogStatement("UserFeedback", false, false, "contents");
- public void sendFeedback(final String feedbackContents, final boolean includeHistory) {
+ new LogStatement("UserFeedback", false, false, "contents", "accountName");
+ public void sendFeedback(final String feedbackContents, final boolean includeHistory,
+ final boolean isIncludingAccountName) {
if (mSavedFeedbackLogBuffer == null) {
return;
}
@@ -635,8 +674,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
mSavedFeedbackLogBuffer.clear();
}
final LogUnit feedbackLogUnit = new LogUnit();
+ final String accountName = isIncludingAccountName ? getAccountName() : "";
feedbackLogUnit.addLogStatement(LOGSTATEMENT_FEEDBACK, SystemClock.uptimeMillis(),
- feedbackContents);
+ feedbackContents, accountName);
mFeedbackLogBuffer.shiftIn(feedbackLogUnit);
publishLogBuffer(mFeedbackLogBuffer, mSavedFeedbackLog, true /* isIncludingPrivateData */);
mSavedFeedbackLog.close(new Runnable() {