From a01d9aea64b24117ee167b94f8bdc176082b8783 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 24 Jul 2012 18:51:44 +0900 Subject: Add Tagalog keyboard layout Bug: 6867914 Change-Id: I78ca6216cc74f8d34291950c05c810c800a3ddba --- .../keyboard/internal/KeyboardTextsSet.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java index d732fc061..1bf90003a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java @@ -2169,6 +2169,60 @@ public final class KeyboardTextsSet { /* 24 */ "\u00E6", }; + /* Language tl: Tagalog */ + private static final String[] LANGUAGE_tl = { + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + /* 0 */ "\u00E1,\u00E0,\u00E4,\u00E2,\u00E3,\u00E5,\u0105,\u00E6,\u0101,\u00AA", + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + /* 1 */ "\u00E9,\u00E8,\u00EB,\u00EA,\u0119,\u0117,\u0113", + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + /* 2 */ "\u00ED,\u00EF,\u00EC,\u00EE,\u012F,\u012B", + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + /* 3 */ "\u00F3,\u00F2,\u00F6,\u00F4,\u00F5,\u00F8,\u0153,\u014D,\u00BA", + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + /* 4 */ "\u00FA,\u00FC,\u00F9,\u00FB,\u016B", + /* 5 */ null, + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + /* 6 */ "\u00F1,\u0144", + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + /* 7 */ "\u00E7,\u0107,\u010D", + }; + /* Language tr: Turkish */ private static final String[] LANGUAGE_tr = { // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX @@ -2477,6 +2531,7 @@ public final class KeyboardTextsSet { "sl", LANGUAGE_sl, /* Slovenian */ "sr", LANGUAGE_sr, /* Serbian */ "sv", LANGUAGE_sv, /* Swedish */ + "tl", LANGUAGE_tl, /* Tagalog */ "tr", LANGUAGE_tr, /* Turkish */ "uk", LANGUAGE_uk, /* Ukrainian */ "vi", LANGUAGE_vi, /* Vietnamese */ -- cgit v1.2.3-83-g751a From 9ecf63468652b68ee1003d04ce167c1586e03748 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 24 Jul 2012 17:18:47 +0900 Subject: Add Seriban Latin keyboard layout as comments Bug: 6867914 Bug: 6867842 Change-Id: I3434434628e72fdb127d158de6c17fdfa77ee9c8 --- java/res/values/strings.xml | 9 +++++++++ java/res/xml/method.xml | 15 +++++++++++++++ .../keyboard/internal/KeyboardTextsSet.java | 19 +++++++++++++++++++ .../res/values-sr/donottranslate-more-keys.xml | 19 +++++++++++++++++++ 4 files changed, 62 insertions(+) (limited to 'java/src') diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 12abf8469..cb793cb4d 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -303,6 +303,15 @@ English (US) (%s) + No language diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 575bbf2c6..6994009a0 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -61,6 +61,7 @@ sk: Slovak/qwerty sl: Slovenian/qwerty sr: Serbian/south_slavic + (sr-Latn: Serbian/qwerty) # not yet implemented. sv: Swedish/nordic th: Thai/thai tl: Tagalog/spanish @@ -310,6 +311,20 @@ android:imeSubtypeMode="keyboard" android:imeSubtypeExtraValue="SupportTouchPositionCorrection" /> + š,ß,ś + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // č,ç,ć + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + // ď + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + // ž,ź,ż + // END: More keys definitions for Serbian (Latin) + // BEGIN: More keys definitions for Serbian (Cyrillic) // U+0437: "з" CYRILLIC SMALL LETTER ZE /* 35 */ "\u0437", // U+045B: "ћ" CYRILLIC SMALL LETTER TSHE @@ -2111,6 +2129,7 @@ public final class KeyboardTextsSet { // U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE /* 40 */ "\u045D", /* 41 */ null, + // END: More keys definitions for Serbian (Cyrillic) // U+2018: "‘" LEFT SINGLE QUOTATION MARK // U+2019: "’" RIGHT SINGLE QUOTATION MARK // U+201A: "‚" SINGLE LOW-9 QUOTATION MARK diff --git a/tools/maketext/res/values-sr/donottranslate-more-keys.xml b/tools/maketext/res/values-sr/donottranslate-more-keys.xml index e85d3d7a2..dcf0e857e 100644 --- a/tools/maketext/res/values-sr/donottranslate-more-keys.xml +++ b/tools/maketext/res/values-sr/donottranslate-more-keys.xml @@ -18,6 +18,24 @@ */ --> + + з @@ -30,6 +48,7 @@ ѐ ѝ + + + + + à,á,â,ä,æ,ã,å,ā + + è,é,ê,ë,ē + + î,ï,í,ī,ì + + ô,ö,ò,ó,œ,ø,ō,õ + + û,ü,ù,ú,ū + + ß + + ñ + + ç + g\' + -- cgit v1.2.3-83-g751a From 2f81757c3a5eb50d41ce19fb534f72cbf607a997 Mon Sep 17 00:00:00 2001 From: Tom Ouyang Date: Fri, 20 Jul 2012 21:01:44 +0900 Subject: Add dynamic floating preview for incremental gesture recognition. Change-Id: I7ba7ac24aa96a0ff19267997c5b58853079bc6dc --- java/res/values/dimens.xml | 8 + .../android/inputmethod/keyboard/KeyboardView.java | 70 ++------- .../inputmethod/keyboard/PointerTracker.java | 21 +-- .../keyboard/internal/GestureStroke.java | 7 - .../keyboard/internal/PreviewPlacerView.java | 172 +++++++++++++++++++++ .../com/android/inputmethod/latin/LatinIME.java | 4 + 6 files changed, 207 insertions(+), 75 deletions(-) create mode 100644 java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java (limited to 'java/src') diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 925eb55fa..b47897f3c 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -93,4 +93,12 @@ 27dp 3 36 + + + 2.5dp + 35dp + 75dp + 17.5dp + 7.5dp + 1.0dp diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index b9c591d4a..f1f942ccb 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -35,9 +35,9 @@ import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.RelativeLayout; import android.widget.TextView; +import com.android.inputmethod.keyboard.internal.PreviewPlacerView; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; @@ -97,9 +97,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { // The maximum key label width in the proportion to the key width. private static final float MAX_LABEL_RATIO = 0.90f; - private final static int GESTURE_DRAWING_WIDTH = 5; - private final static int GESTURE_DRAWING_COLOR = 0xff33b5e5; - // Main keyboard private Keyboard mKeyboard; protected final KeyDrawParams mKeyDrawParams; @@ -109,7 +106,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { protected final KeyPreviewDrawParams mKeyPreviewDrawParams; private boolean mShowKeyPreviewPopup = true; private int mDelayAfterPreview; - private ViewGroup mPreviewPlacer; + private PreviewPlacerView mPreviewPlacer; /** True if {@link KeyboardView} should handle gesture events. */ protected boolean mShouldHandleGesture; @@ -125,14 +122,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { private final HashSet mInvalidatedKeys = new HashSet(); /** The region of invalidated keys */ private final Rect mInvalidatedKeysRect = new Rect(); - /** The region of invalidated gestures */ - private final Rect mInvalidatedGesturesRect = new Rect(); /** The keyboard bitmap buffer for faster updates */ private Bitmap mBuffer; /** The canvas for the above mutable keyboard bitmap */ private Canvas mCanvas; private final Paint mPaint = new Paint(); - private final Paint mGesturePaint = new Paint(); private final Paint.FontMetrics mFontMetrics = new Paint.FontMetrics(); // This sparse array caches key label text height in pixel indexed by key label text size. private static final SparseArray sTextHeightCache = new SparseArray(); @@ -382,13 +376,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout; mPaint.setAntiAlias(true); - - // TODO: These paint parameters should be specified via attribute of the view and styleable. - mGesturePaint.setAntiAlias(true); - mGesturePaint.setStyle(Paint.Style.STROKE); - mGesturePaint.setStrokeJoin(Paint.Join.ROUND); - mGesturePaint.setColor(GESTURE_DRAWING_COLOR); - mGesturePaint.setStrokeWidth(GESTURE_DRAWING_WIDTH); } // Read fraction value in TypedArray as float. @@ -888,29 +875,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { mDrawingHandler.dismissKeyPreview(mDelayAfterPreview, tracker); } - private static class PreviewPlacerView extends RelativeLayout { - private final Paint mGesturePaint; - final int mCoordinateX; - final int mCoordinateY; - - public PreviewPlacerView(Context context, int coordinateX, int coordinateY, - Paint gesturePaint) { - super(context); - setWillNotDraw(false); - mGesturePaint = gesturePaint; - mCoordinateX = coordinateX; - mCoordinateY = coordinateY; - } - - @Override - public void onDraw(Canvas canvas) { - super.onDraw(canvas); - canvas.translate(mCoordinateX, mCoordinateY); - PointerTracker.drawGestureTrailForAllPointerTrackers(canvas, mGesturePaint); - canvas.translate(-mCoordinateX, -mCoordinateY); - } - } - private void addKeyPreview(TextView keyPreview) { if (mPreviewPlacer == null) { createPreviewPlacer(); @@ -920,31 +884,31 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } private void createPreviewPlacer() { - getLocationInWindow(mKeyPreviewDrawParams.mCoordinates); - mPreviewPlacer = new PreviewPlacerView(getContext(), mKeyPreviewDrawParams.mCoordinates[0], - mKeyPreviewDrawParams.mCoordinates[1], mGesturePaint); + mPreviewPlacer = new PreviewPlacerView(getContext()); + final int[] viewOrigin = new int[2]; + getLocationInWindow(viewOrigin); + mPreviewPlacer.setOrigin(viewOrigin[0], viewOrigin[1]); final ViewGroup windowContentView = (ViewGroup)getRootView().findViewById(android.R.id.content); windowContentView.addView(mPreviewPlacer); } + public void showGesturePreviewText(String gesturePreviewText) { + // TDOD: Add user settings option to control drawing gesture trail. + if (mPreviewPlacer == null) { + createPreviewPlacer(); + } + mPreviewPlacer.setGesturePreviewText(gesturePreviewText); + mPreviewPlacer.invalidate(); + } + @Override public void showGestureTrail(PointerTracker tracker) { + // TDOD: Add user settings option to control drawing gesture trail. if (mPreviewPlacer == null) { createPreviewPlacer(); } - final Rect r = tracker.getBoundingBox(); - if (!r.isEmpty()) { - // Invalidate the rectangular region encompassing the gesture. This is needed because - // past points along the gesture will fade and gradually disappear. - final KeyPreviewDrawParams params = mKeyPreviewDrawParams; - mInvalidatedGesturesRect.set(r); - mInvalidatedGesturesRect.offset(params.mCoordinates[0], params.mCoordinates[1]); - mInvalidatedGesturesRect.inset(-GESTURE_DRAWING_WIDTH, -GESTURE_DRAWING_WIDTH); - mPreviewPlacer.invalidate(mInvalidatedGesturesRect); - } else { - mPreviewPlacer.invalidate(); - } + mPreviewPlacer.invalidatePointer(tracker); } @SuppressWarnings("deprecation") // setBackgroundDrawable is replaced by setBackground in API16 diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 56c3d46b9..67857d111 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard; import android.graphics.Canvas; import android.graphics.Paint; -import android.graphics.Rect; import android.os.SystemClock; import android.util.Log; import android.view.MotionEvent; @@ -296,17 +295,6 @@ public class PointerTracker { sAggregratedPointers.reset(); } - // TODO: To handle multi-touch gestures we may want to move this method to - // {@link PointerTrackerQueue}. - public static void drawGestureTrailForAllPointerTrackers(Canvas canvas, Paint paint) { - final int trackersSize = sTrackers.size(); - for (int i = 0; i < trackersSize; ++i) { - final PointerTracker tracker = sTrackers.get(i); - tracker.mGestureStroke.drawGestureTrail(canvas, paint, tracker.getLastX(), - tracker.getLastY()); - } - } - private PointerTracker(int id, KeyEventHandler handler) { if (handler == null) throw new NullPointerException(); @@ -524,6 +512,12 @@ public class PointerTracker { mDrawingProxy.invalidateKey(key); } + public void drawGestureTrail(Canvas canvas, Paint paint) { + if (mInGesture) { + mGestureStroke.drawGestureTrail(canvas, paint, mLastX, mLastY); + } + } + public int getLastX() { return mLastX; } @@ -535,9 +529,6 @@ public class PointerTracker { public long getDownTime() { return mDownTime; } - public Rect getBoundingBox() { - return mGestureStroke.getBoundingBox(); - } private Key onDownKey(int x, int y, long eventTime) { mDownTime = eventTime; diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java index c16b70ef0..28d6c1d07 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java @@ -16,7 +16,6 @@ package com.android.inputmethod.keyboard.internal; import android.graphics.Canvas; import android.graphics.Paint; -import android.graphics.Rect; import android.util.FloatMath; import com.android.inputmethod.latin.Constants; @@ -41,7 +40,6 @@ public class GestureStroke { private int mMinGestureLength; private int mMinGestureLengthWhileInGesture; private int mMinGestureSampleLength; - private final Rect mDrawingRect = new Rect(); // TODO: Move some of these to resource. private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 1.0f; @@ -90,7 +88,6 @@ public class GestureStroke { mEventTimes.setLength(0); mXCoordinates.setLength(0); mYCoordinates.setLength(0); - mDrawingRect.setEmpty(); } private void updateLastPoint(final int x, final int y, final int time) { @@ -198,8 +195,4 @@ public class GestureStroke { } } } - - public Rect getBoundingBox() { - return mDrawingRect; - } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java new file mode 100644 index 000000000..2a53c59bb --- /dev/null +++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.internal; + +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Paint.Align; +import android.text.TextUtils; +import android.util.SparseArray; +import android.widget.RelativeLayout; + +import com.android.inputmethod.keyboard.PointerTracker; +import com.android.inputmethod.latin.R; + +public class PreviewPlacerView extends RelativeLayout { + // TODO: Move these parameters to attributes of {@link KeyboardView}. + private final static int GESTURE_DRAWING_COLOR = 0xff33b5e5; + private static final int GESTURE_PREVIEW_TEXT_COLOR = Color.WHITE; + private static final int GESTURE_PREVIEW_TEXT_SHADING_COLOR = 0xff33b5e5; + private static final int GESTURE_PREVIEW_TEXT_SHADOW_COLOR = 0xff252525; + private static final int GESTURE_PREVIEW_CONNECTOR_COLOR = Color.WHITE; + + private final Paint mGesturePaint; + private final int mGesturePreviewTraileWidth; + private final Paint mTextPaint; + private final int mGesturePreviewTextOffset; + private final int mGesturePreviewTextShadowBorder; + private final int mGesturePreviewTextShadingBorder; + private final int mGesturePreviewTextConnectorWidth; + + private int mXOrigin; + private int mYOrigin; + + private final SparseArray mPointers = new SparseArray(); + + private String mGesturePreviewText; + + public PreviewPlacerView(Context context) { + super(context); + setWillNotDraw(false); + + final Resources res = getResources(); + // TODO: Move these parameters to attributes of {@link KeyboardView}. + mGesturePreviewTraileWidth = res.getDimensionPixelSize( + R.dimen.gesture_preview_trail_width); + final int textSize = res.getDimensionPixelSize(R.dimen.gesture_preview_text_size); + mGesturePreviewTextOffset = res.getDimensionPixelSize( + R.dimen.gesture_preview_text_offset); + mGesturePreviewTextShadowBorder = res.getDimensionPixelOffset( + R.dimen.gesture_preview_text_shadow_border); + mGesturePreviewTextShadingBorder = res.getDimensionPixelOffset( + R.dimen.gesture_preview_text_shading_border); + mGesturePreviewTextConnectorWidth = res.getDimensionPixelOffset( + R.dimen.gesture_preview_text_connector_width); + + mGesturePaint = new Paint(); + mGesturePaint.setAntiAlias(true); + mGesturePaint.setStyle(Paint.Style.STROKE); + mGesturePaint.setStrokeJoin(Paint.Join.ROUND); + mGesturePaint.setColor(GESTURE_DRAWING_COLOR); + mGesturePaint.setStrokeWidth(mGesturePreviewTraileWidth); + + mTextPaint = new Paint(); + mTextPaint.setAntiAlias(true); + mTextPaint.setStrokeJoin(Paint.Join.ROUND); + mTextPaint.setTextAlign(Align.CENTER); + mTextPaint.setTextSize(textSize); + } + + public void setOrigin(int x, int y) { + mXOrigin = x; + mYOrigin = y; + } + + public void invalidatePointer(PointerTracker tracker) { + synchronized (mPointers) { + mPointers.put(tracker.mPointerId, tracker); + // TODO: Should narrow the invalidate region. + invalidate(); + } + } + + @Override + public void onDraw(Canvas canvas) { + super.onDraw(canvas); + // TDOD: Add user settings option to control drawing gesture trail and gesture preview. + synchronized (mPointers) { + canvas.translate(mXOrigin, mYOrigin); + final int trackerCount = mPointers.size(); + boolean floatingPreviewHasDrawn = false; + for (int index = 0; index < trackerCount; index++) { + final PointerTracker tracker = mPointers.valueAt(index); + tracker.drawGestureTrail(canvas, mGesturePaint); + // TODO: Figure out more cleaner way to draw gesture preview text. + if (!floatingPreviewHasDrawn) { + drawGesturePreviewText(canvas, tracker, mGesturePreviewText); + floatingPreviewHasDrawn = true; + } + } + canvas.translate(-mXOrigin, -mYOrigin); + } + } + + public void setGesturePreviewText(String gesturePreviewText) { + mGesturePreviewText = gesturePreviewText; + invalidate(); + } + + private void drawGesturePreviewText(Canvas canvas, PointerTracker tracker, + String gesturePreviewText) { + if (TextUtils.isEmpty(gesturePreviewText)) { + return; + } + + final Paint paint = mTextPaint; + final int lastX = tracker.getLastX(); + final int lastY = tracker.getLastY(); + final int textSize = (int)paint.getTextSize(); + final int canvasWidth = canvas.getWidth(); + + final int halfTextWidth = (int)paint.measureText(gesturePreviewText) / 2 + textSize; + final int textX = Math.min(Math.max(lastX, halfTextWidth), canvasWidth - halfTextWidth); + + int textY = Math.max(-textSize, lastY - mGesturePreviewTextOffset); + if (textY < 0) { + // Paint black text shadow if preview extends above keyboard region. + paint.setStyle(Paint.Style.FILL_AND_STROKE); + paint.setColor(GESTURE_PREVIEW_TEXT_SHADOW_COLOR); + paint.setStrokeWidth(mGesturePreviewTextShadowBorder); + canvas.drawText(gesturePreviewText, textX, textY, paint); + } + + // Paint the vertical line connecting the touch point to the preview text. + paint.setStyle(Paint.Style.STROKE); + paint.setColor(GESTURE_PREVIEW_CONNECTOR_COLOR); + paint.setStrokeWidth(mGesturePreviewTextConnectorWidth); + final int lineTopY = textY - textSize / 4; + canvas.drawLine(lastX, lastY, lastX, lineTopY, paint); + if (lastX != textX) { + // Paint the horizontal line connection the touch point to the preview text. + canvas.drawLine(lastX, lineTopY, textX, lineTopY, paint); + } + + // Paint the shading for the text preview + paint.setStyle(Paint.Style.FILL_AND_STROKE); + paint.setColor(GESTURE_PREVIEW_TEXT_SHADING_COLOR); + paint.setStrokeWidth(mGesturePreviewTextShadingBorder); + canvas.drawText(gesturePreviewText, textX, textY, paint); + + // Paint the text preview + paint.setColor(GESTURE_PREVIEW_TEXT_COLOR); + paint.setStyle(Paint.Style.FILL); + canvas.drawText(gesturePreviewText, textX, textY, paint); + } +} diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7d79886fa..9f9d07b3a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1343,6 +1343,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mWordComposer.setBatchInputPointers(batchPointers); final SuggestedWords suggestedWords = getSuggestedWords(); showSuggestionStrip(suggestedWords, null); + final String gesturePreviewText = (suggestedWords.size() > 0) + ? suggestedWords.getWord(0) : null; + mKeyboardSwitcher.getKeyboardView().showGesturePreviewText(gesturePreviewText); } @Override @@ -1350,6 +1353,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mWordComposer.setBatchInputPointers(batchPointers); final SuggestedWords suggestedWords = getSuggestedWords(); showSuggestionStrip(suggestedWords, null); + mKeyboardSwitcher.getKeyboardView().showGesturePreviewText(null); if (suggestedWords == null || suggestedWords.size() == 0) { return; } -- cgit v1.2.3-83-g751a From c4376db0f015e1c2f0eb6283cc275b2da03cbb19 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 25 Jul 2012 19:57:44 +0900 Subject: Remove unused setProximityCorrectionEnabled() methods Change-Id: I03aa6608ee435b36377de41684162b303740f571 --- .../com/android/inputmethod/keyboard/KeyDetector.java | 9 --------- .../android/inputmethod/keyboard/MainKeyboardView.java | 17 ----------------- java/src/com/android/inputmethod/latin/LatinIME.java | 1 - 3 files changed, 27 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java index 9abc79d3c..a3b7776b3 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java @@ -25,7 +25,6 @@ public class KeyDetector { private Keyboard mKeyboard; private int mCorrectionX; private int mCorrectionY; - private boolean mProximityCorrectOn; /** * This class handles key detection. @@ -64,14 +63,6 @@ public class KeyDetector { return mKeyboard; } - public void setProximityCorrectionEnabled(boolean enabled) { - mProximityCorrectOn = enabled; - } - - public boolean isProximityCorrectionEnabled() { - return mProximityCorrectOn; - } - public boolean alwaysAllowsSlidingInput() { return false; } diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 110f3c3e3..7b4a3d227 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -497,23 +497,6 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key mHasDistinctMultitouch = hasDistinctMultitouch; } - /** - * When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key - * codes for adjacent keys. When disabled, only the primary key code will be - * reported. - * @param enabled whether or not the proximity correction is enabled - */ - public void setProximityCorrectionEnabled(boolean enabled) { - mKeyDetector.setProximityCorrectionEnabled(enabled); - } - - /** - * Returns true if proximity correction is enabled. - */ - public boolean isProximityCorrectionEnabled() { - return mKeyDetector.isProximityCorrectionEnabled(); - } - @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7d79886fa..296132c0d 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -693,7 +693,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen inputView.setKeyPreviewPopupEnabled(mCurrentSettings.mKeyPreviewPopupOn, mCurrentSettings.mKeyPreviewPopupDismissDelay); - inputView.setProximityCorrectionEnabled(true); if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); } -- cgit v1.2.3-83-g751a From ba037c62acf3519ad224feaca696cc51f6de0818 Mon Sep 17 00:00:00 2001 From: alanv Date: Wed, 25 Jul 2012 11:03:41 -0700 Subject: Add accessibility descriptions for additional non-character keys. Bug: 6621009 Change-Id: I82fb2dc6af0fda795397e8be8c09a4f53b1656ab --- java/res/values/strings.xml | 6 ++++++ .../inputmethod/accessibility/KeyCodeDescriptionMapper.java | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'java/src') diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 12abf8469..9e8c59cd8 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -181,6 +181,12 @@ Search Dot + + Switch language + + Next + + Previous Shift enabled diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 5ffd94a43..9b74070af 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -60,10 +60,8 @@ public class KeyCodeDescriptionMapper { // Manual label substitutions for key labels with no string resource mKeyLabelMap.put(":-)", R.string.spoken_description_smiley); - // Symbols that most TTS engines can't speak - mKeyCodeMap.put(' ', R.string.spoken_description_space); - // Special non-character codes defined in Keyboard + mKeyCodeMap.put(Keyboard.CODE_SPACE, R.string.spoken_description_space); mKeyCodeMap.put(Keyboard.CODE_DELETE, R.string.spoken_description_delete); mKeyCodeMap.put(Keyboard.CODE_ENTER, R.string.spoken_description_return); mKeyCodeMap.put(Keyboard.CODE_SETTINGS, R.string.spoken_description_settings); @@ -71,6 +69,9 @@ public class KeyCodeDescriptionMapper { mKeyCodeMap.put(Keyboard.CODE_SHORTCUT, R.string.spoken_description_mic); mKeyCodeMap.put(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, R.string.spoken_description_to_symbol); mKeyCodeMap.put(Keyboard.CODE_TAB, R.string.spoken_description_tab); + mKeyCodeMap.put(Keyboard.CODE_LANGUAGE_SWITCH, R.string.spoken_description_language_switch); + mKeyCodeMap.put(Keyboard.CODE_ACTION_NEXT, R.string.spoken_description_action_next); + mKeyCodeMap.put(Keyboard.CODE_ACTION_PREVIOUS, R.string.spoken_description_action_previous); } /** @@ -274,8 +275,7 @@ public class KeyCodeDescriptionMapper { return context.getString(OBSCURED_KEY_RES_ID); } - final int resId = mKeyCodeMap.get(code); - if (resId != 0) { + if (mKeyCodeMap.indexOfKey(code) >= 0) { return context.getString(mKeyCodeMap.get(code)); } else if (isDefinedNonCtrl) { return Character.toString((char) code); -- cgit v1.2.3-83-g751a From e55d78ab0cf8d27d6c22fd5fbc78714af8d6cc12 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Thu, 26 Jul 2012 08:45:07 +0900 Subject: Stop swallowing an UnsatisfiedLinkError Change-Id: I37d61274e1527229befabae2c392fd78e279b807 --- java/src/com/android/inputmethod/latin/JniUtils.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/JniUtils.java b/java/src/com/android/inputmethod/latin/JniUtils.java index 4808b867a..86a3826d8 100644 --- a/java/src/com/android/inputmethod/latin/JniUtils.java +++ b/java/src/com/android/inputmethod/latin/JniUtils.java @@ -31,11 +31,7 @@ public class JniUtils { try { System.loadLibrary(JniLibName.JNI_LIB_NAME); } catch (UnsatisfiedLinkError ule) { - Log.e(TAG, "Could not load native library " + JniLibName.JNI_LIB_NAME); - if (LatinImeLogger.sDBG) { - throw new RuntimeException( - "Could not load native library " + JniLibName.JNI_LIB_NAME); - } + Log.e(TAG, "Could not load native library " + JniLibName.JNI_LIB_NAME, ule); } } } -- cgit v1.2.3-83-g751a From 55c01170c49cc8ebcb31ca70ac413ab469824e12 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 26 Jul 2012 12:38:47 +0900 Subject: Add Afrikaans keyboard layout Bug: 6867914 Change-Id: Ice35b20a0a51dda21c8271256064523bb5844952 --- java/res/xml/method.xml | 7 +++ .../keyboard/internal/KeyboardTextsSet.java | 54 +++++++++++++++++ .../res/values-af/donottranslate-more-keys.xml | 67 ++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 tools/maketext/res/values-af/donottranslate-more-keys.xml (limited to 'java/src') diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index b448e00a3..eb6dcf75a 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -22,6 +22,7 @@ + + + + â,ä,á,à,æ,ã,å,ā + + ê,ë,é,è,ę,ė,ē + + ì,ï,í,î,į,ī,ij + + ô,ö,ó,ò,õ,œ,ø,ō + + û,ü,ú,ù,ū + + ñ,ń + + ij + -- cgit v1.2.3-83-g751a From b90363e40cedcc75537f4c3c6ad378902ffa3ddf Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 26 Jul 2012 16:31:06 +0900 Subject: Fix Afrikaans more keys layout Bug: 6867914 Change-Id: I43178a729f4770743f9fea87bad539c54da045c5 --- .../keyboard/internal/KeyboardTextsSet.java | 29 +++++++-------- .../res/values-af/donottranslate-more-keys.xml | 42 +++++++++++----------- 2 files changed, 37 insertions(+), 34 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java index b6b6ffade..195223702 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java @@ -379,54 +379,55 @@ public final class KeyboardTextsSet { /* Language af: Afrikaans */ private static final String[] LANGUAGE_af = { - // This is the same as Dutch except promoting vowels with circumflex and diaeresis. + // This is the same as Dutch except more keys of y and demoting vowels with diaeresis. + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS - // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E6: "æ" LATIN SMALL LETTER AE // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON - /* 0 */ "\u00E2,\u00E4,\u00E1,\u00E0,\u00E6,\u00E3,\u00E5,\u0101", - // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX - // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + /* 0 */ "\u00E1,\u00E2,\u00E4,\u00E0,\u00E6,\u00E3,\u00E5,\u0101", // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON - /* 1 */ "\u00EA,\u00EB,\u00E9,\u00E8,\u0119,\u0117,\u0113", - // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX - // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + /* 1 */ "\u00E9,\u00E8,\u00EA,\u00EB,\u0119,\u0117,\u0113", // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON // U+0133: "ij" LATIN SMALL LIGATURE IJ - /* 2 */ "\u00EC,\u00EF,\u00ED,\u00EE,\u012F,\u012B,\u0133", + /* 2 */ "\u00ED,\u00EC,\u00EF,\u00EE,\u012F,\u012B,\u0133", + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS - // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE // U+0153: "œ" LATIN SMALL LIGATURE OE // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON - /* 3 */ "\u00F4,\u00F6,\u00F3,\u00F2,\u00F5,\u0153,\u00F8,\u014D", + /* 3 */ "\u00F3,\u00F4,\u00F6,\u00F2,\u00F5,\u0153,\u00F8,\u014D", + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS - // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON - /* 4 */ "\u00FB,\u00FC,\u00FA,\u00F9,\u016B", + /* 4 */ "\u00FA,\u00FB,\u00FC,\u00F9,\u016B", /* 5 */ null, // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE /* 6 */ "\u00F1,\u0144", /* 7 */ null, + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE // U+0133: "ij" LATIN SMALL LIGATURE IJ - /* 8 */ "\u0133", + /* 8 */ "\u00FD,\u0133", }; /* Language ar: Arabic */ diff --git a/tools/maketext/res/values-af/donottranslate-more-keys.xml b/tools/maketext/res/values-af/donottranslate-more-keys.xml index 15a281a44..ee96f442d 100644 --- a/tools/maketext/res/values-af/donottranslate-more-keys.xml +++ b/tools/maketext/res/values-af/donottranslate-more-keys.xml @@ -18,50 +18,52 @@ */ --> - - + - â,ä,á,à,æ,ã,å,ā - - ê,ë,é,è,ę,ė,ē - - ì,ï,í,î,į,ī,ij - - ô,ö,ó,ò,õ,œ,ø,ō - - û,ü,ú,ù,ū + ú,û,ü,ù,ū ñ,ń - - ij + ý,ŷ,ÿ,ij + + ý,ij -- cgit v1.2.3-83-g751a From c902dfeb8f8b889e885565a000556419e0d8307f Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 26 Jul 2012 13:04:31 +0900 Subject: Fix gesture detection when sliding key input is disabled Bug: 6867837 Change-Id: Icbfa69928c436343db545860a7d63171f52266b6 --- .../com/android/inputmethod/keyboard/PointerTracker.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 67857d111..bd896517b 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -794,13 +794,16 @@ public class PointerTracker { final int dx = x - lastX; final int dy = y - lastY; final int lastMoveSquared = dx * dx + dy * dy; + // TODO: Should find a way to balance gesture detection and this hack. if (sNeedsPhantomSuddenMoveEventHack - && lastMoveSquared >= mKeyQuarterWidthSquared) { + && lastMoveSquared >= mKeyQuarterWidthSquared + && !mIsPossibleGesture) { if (DEBUG_MODE) { Log.w(TAG, String.format("onMoveEvent:" + " phantom sudden move event is translated to " + "up[%d,%d]/down[%d,%d] events", lastX, lastY, x, y)); } + // TODO: This should be moved to outside of this nested if-clause? if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.pointerTracker_onMoveEvent(x, y, lastX, lastY); } @@ -816,7 +819,9 @@ public class PointerTracker { && !sPointerTrackerQueue.hasModifierKeyOlderThan(this)) { onUpEventInternal(x, y, eventTime); } - mKeyAlreadyProcessed = true; + if (!mIsPossibleGesture) { + mKeyAlreadyProcessed = true; + } setReleasedKeyGraphics(oldKey); } } @@ -832,7 +837,9 @@ public class PointerTracker { if (mIsAllowedSlidingKeyInput) { onMoveToNewKey(key, x, y); } else { - mKeyAlreadyProcessed = true; + if (!mIsPossibleGesture) { + mKeyAlreadyProcessed = true; + } } } } @@ -871,6 +878,7 @@ public class PointerTracker { private void onUpEventInternal(int x, int y, long eventTime) { mTimerProxy.cancelKeyTimers(); mIsInSlidingKeyInput = false; + mIsPossibleGesture = false; // Release the last pressed key. setReleasedKeyGraphics(mCurrentKey); if (mIsShowingMoreKeysPanel) { -- cgit v1.2.3-83-g751a From 97c8d288a8cdef93dbc9301e4f33e008345ae717 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 26 Jul 2012 16:35:15 +0900 Subject: Add Zulu keyboard Bug: 6867914 Change-Id: I13316ac2a554a8601f920e875d540e5375e12860 --- java/res/xml/method.xml | 7 +++ .../keyboard/internal/KeyboardTextsSet.java | 48 ++++++++++++++++ .../res/values-zu/donottranslate-more-keys.xml | 64 ++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 tools/maketext/res/values-zu/donottranslate-more-keys.xml (limited to 'java/src') diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index eb6dcf75a..acdf7645f 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -71,6 +71,7 @@ tr: Turkish/qwerty uk: Ukrainian/east_slavic vi: Vietnamese/qwerty + zu: Zulu/qwerty zz: QWERTY/qwerty --> @@ -383,6 +384,12 @@ android:imeSubtypeMode="keyboard" android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,AsciiCapable" /> + + + + + + à,á,â,ä,æ,ã,å,ā + + è,é,ê,ë,ē + + î,ï,í,ī,ì + + ô,ö,ò,ó,œ,ø,ō,õ + + û,ü,ù,ú,ū + + ß + + ñ + + ç + -- cgit v1.2.3-83-g751a From aa906c36aa31f51a38083e337f4307b49f133054 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 25 Jul 2012 19:31:19 +0900 Subject: Handle correctly the restarting argument Bug: 6851364 Change-Id: Ie939a43b8527a76aec213b702d3d850717f22a81 --- .../com/android/inputmethod/latin/LatinIME.java | 46 ++++++++++++++-------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b390cc08c..6b5de486c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -659,35 +659,49 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen accessUtils.onStartInputViewInternal(editorInfo, restarting); } - mSubtypeSwitcher.updateParametersOnStartInputView(); + if (!restarting) { + mSubtypeSwitcher.updateParametersOnStartInputView(); + } // The EditorInfo might have a flag that affects fullscreen mode. // Note: This call should be done by InputMethodService? updateFullscreenMode(); - mLastSelectionStart = editorInfo.initialSelStart; - mLastSelectionEnd = editorInfo.initialSelEnd; mApplicationSpecifiedCompletions = null; - inputView.closing(); - mEnteredText = null; - resetComposingState(true /* alsoResetLastComposedWord */); - mDeleteCount = 0; - mSpaceState = SPACE_STATE_NONE; - - loadSettings(); + final boolean selectionChanged = mLastSelectionStart != editorInfo.initialSelStart + || mLastSelectionEnd != editorInfo.initialSelEnd; + if (!restarting || selectionChanged) { + // If the selection changed, we reset the input state. Essentially, we come here with + // restarting == true when the app called setText() or similar. We should reset the + // state if the app set the text to something else, but keep it if it set a suggestion + // or something. + mEnteredText = null; + resetComposingState(true /* alsoResetLastComposedWord */); + mDeleteCount = 0; + mSpaceState = SPACE_STATE_NONE; - if (mSuggest != null && mCurrentSettings.mCorrectionEnabled) { - mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold); + if (mSuggestionStripView != null) { + mSuggestionStripView.clear(); + } } - switcher.loadKeyboard(editorInfo, mCurrentSettings); - updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability(); + if (!restarting) { + inputView.closing(); + loadSettings(); - if (mSuggestionStripView != null) - mSuggestionStripView.clear(); + if (mSuggest != null && mCurrentSettings.mCorrectionEnabled) { + mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold); + } + + switcher.loadKeyboard(editorInfo, mCurrentSettings); + updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability(); + } setSuggestionStripShownInternal( isSuggestionsStripVisible(), /* needsInputViewShown */ false); + mLastSelectionStart = editorInfo.initialSelStart; + mLastSelectionEnd = editorInfo.initialSelEnd; + mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelDoubleSpacesTimer(); -- cgit v1.2.3-83-g751a From 99906b3fc2dcb447aafdd43dda0c4551513b293e Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 27 Jul 2012 14:25:53 +0900 Subject: Move SuddenJumpingTouchEventHandler to internal package Change-Id: Ifc9fb6322a2edbaac0b10e7134ee7e735f14937b --- .../inputmethod/keyboard/MainKeyboardView.java | 1 + .../keyboard/SuddenJumpingTouchEventHandler.java | 153 -------------------- .../internal/SuddenJumpingTouchEventHandler.java | 155 +++++++++++++++++++++ 3 files changed, 156 insertions(+), 153 deletions(-) delete mode 100644 java/src/com/android/inputmethod/keyboard/SuddenJumpingTouchEventHandler.java create mode 100644 java/src/com/android/inputmethod/keyboard/internal/SuddenJumpingTouchEventHandler.java (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 7b4a3d227..9c28419cf 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -43,6 +43,7 @@ import com.android.inputmethod.accessibility.AccessibilityUtils; import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy; import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy; import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; +import com.android.inputmethod.keyboard.internal.SuddenJumpingTouchEventHandler; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinImeLogger; diff --git a/java/src/com/android/inputmethod/keyboard/SuddenJumpingTouchEventHandler.java b/java/src/com/android/inputmethod/keyboard/SuddenJumpingTouchEventHandler.java deleted file mode 100644 index 2398c0850..000000000 --- a/java/src/com/android/inputmethod/keyboard/SuddenJumpingTouchEventHandler.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.android.inputmethod.keyboard; - -import android.content.Context; -import android.util.Log; -import android.view.MotionEvent; - -import com.android.inputmethod.latin.LatinImeLogger; -import com.android.inputmethod.latin.R; -import com.android.inputmethod.latin.Utils; -import com.android.inputmethod.latin.define.ProductionFlag; -import com.android.inputmethod.research.ResearchLogger; - -public class SuddenJumpingTouchEventHandler { - private static final String TAG = SuddenJumpingTouchEventHandler.class.getSimpleName(); - private static boolean DEBUG_MODE = LatinImeLogger.sDBG; - - public interface ProcessMotionEvent { - public boolean processMotionEvent(MotionEvent me); - } - - private final ProcessMotionEvent mView; - private final boolean mNeedsSuddenJumpingHack; - - /** Whether we've started dropping move events because we found a big jump */ - private boolean mDroppingEvents; - /** - * Whether multi-touch disambiguation needs to be disabled if a real multi-touch event has - * occured - */ - private boolean mDisableDisambiguation; - /** The distance threshold at which we start treating the touch session as a multi-touch */ - private int mJumpThresholdSquare = Integer.MAX_VALUE; - private int mLastX; - private int mLastY; - - public SuddenJumpingTouchEventHandler(Context context, ProcessMotionEvent view) { - mView = view; - mNeedsSuddenJumpingHack = Boolean.parseBoolean(Utils.getDeviceOverrideValue( - context.getResources(), R.array.sudden_jumping_touch_event_device_list, "false")); - } - - public void setKeyboard(Keyboard newKeyboard) { - // One-seventh of the keyboard width seems like a reasonable threshold - final int jumpThreshold = newKeyboard.mOccupiedWidth / 7; - mJumpThresholdSquare = jumpThreshold * jumpThreshold; - } - - /** - * This function checks to see if we need to handle any sudden jumps in the pointer location - * that could be due to a multi-touch being treated as a move by the firmware or hardware. - * Once a sudden jump is detected, all subsequent move events are discarded - * until an UP is received.

- * When a sudden jump is detected, an UP event is simulated at the last position and when - * the sudden moves subside, a DOWN event is simulated for the second key. - * @param me the motion event - * @return true if the event was consumed, so that it doesn't continue to be handled by - * {@link MainKeyboardView}. - */ - private boolean handleSuddenJumping(MotionEvent me) { - if (!mNeedsSuddenJumpingHack) - return false; - final int action = me.getAction(); - final int x = (int) me.getX(); - final int y = (int) me.getY(); - boolean result = false; - - // Real multi-touch event? Stop looking for sudden jumps - if (me.getPointerCount() > 1) { - mDisableDisambiguation = true; - } - if (mDisableDisambiguation) { - // If UP, reset the multi-touch flag - if (action == MotionEvent.ACTION_UP) mDisableDisambiguation = false; - return false; - } - - switch (action) { - case MotionEvent.ACTION_DOWN: - // Reset the "session" - mDroppingEvents = false; - mDisableDisambiguation = false; - break; - case MotionEvent.ACTION_MOVE: - // Is this a big jump? - final int distanceSquare = (mLastX - x) * (mLastX - x) + (mLastY - y) * (mLastY - y); - // Check the distance. - if (distanceSquare > mJumpThresholdSquare) { - // If we're not yet dropping events, start dropping and send an UP event - if (!mDroppingEvents) { - mDroppingEvents = true; - // Send an up event - MotionEvent translated = MotionEvent.obtain( - me.getEventTime(), me.getEventTime(), - MotionEvent.ACTION_UP, - mLastX, mLastY, me.getMetaState()); - mView.processMotionEvent(translated); - translated.recycle(); - } - result = true; - } else if (mDroppingEvents) { - // If moves are small and we're already dropping events, continue dropping - result = true; - } - break; - case MotionEvent.ACTION_UP: - if (mDroppingEvents) { - // Send a down event first, as we dropped a bunch of sudden jumps and assume that - // the user is releasing the touch on the second key. - MotionEvent translated = MotionEvent.obtain(me.getEventTime(), me.getEventTime(), - MotionEvent.ACTION_DOWN, - x, y, me.getMetaState()); - mView.processMotionEvent(translated); - translated.recycle(); - mDroppingEvents = false; - // Let the up event get processed as well, result = false - } - break; - } - // Track the previous coordinate - mLastX = x; - mLastY = y; - return result; - } - - public boolean onTouchEvent(MotionEvent me) { - // If there was a sudden jump, return without processing the actual motion event. - if (handleSuddenJumping(me)) { - if (DEBUG_MODE) - Log.w(TAG, "onTouchEvent: ignore sudden jump " + me); - if (ProductionFlag.IS_EXPERIMENTAL) { - ResearchLogger.suddenJumpingTouchEventHandler_onTouchEvent(me); - } - return true; - } - return mView.processMotionEvent(me); - } -} diff --git a/java/src/com/android/inputmethod/keyboard/internal/SuddenJumpingTouchEventHandler.java b/java/src/com/android/inputmethod/keyboard/internal/SuddenJumpingTouchEventHandler.java new file mode 100644 index 000000000..9e2cbec52 --- /dev/null +++ b/java/src/com/android/inputmethod/keyboard/internal/SuddenJumpingTouchEventHandler.java @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.android.inputmethod.keyboard.internal; + +import android.content.Context; +import android.util.Log; +import android.view.MotionEvent; + +import com.android.inputmethod.keyboard.Keyboard; +import com.android.inputmethod.keyboard.MainKeyboardView; +import com.android.inputmethod.latin.LatinImeLogger; +import com.android.inputmethod.latin.R; +import com.android.inputmethod.latin.Utils; +import com.android.inputmethod.latin.define.ProductionFlag; +import com.android.inputmethod.research.ResearchLogger; + +public class SuddenJumpingTouchEventHandler { + private static final String TAG = SuddenJumpingTouchEventHandler.class.getSimpleName(); + private static boolean DEBUG_MODE = LatinImeLogger.sDBG; + + public interface ProcessMotionEvent { + public boolean processMotionEvent(MotionEvent me); + } + + private final ProcessMotionEvent mView; + private final boolean mNeedsSuddenJumpingHack; + + /** Whether we've started dropping move events because we found a big jump */ + private boolean mDroppingEvents; + /** + * Whether multi-touch disambiguation needs to be disabled if a real multi-touch event has + * occured + */ + private boolean mDisableDisambiguation; + /** The distance threshold at which we start treating the touch session as a multi-touch */ + private int mJumpThresholdSquare = Integer.MAX_VALUE; + private int mLastX; + private int mLastY; + + public SuddenJumpingTouchEventHandler(Context context, ProcessMotionEvent view) { + mView = view; + mNeedsSuddenJumpingHack = Boolean.parseBoolean(Utils.getDeviceOverrideValue( + context.getResources(), R.array.sudden_jumping_touch_event_device_list, "false")); + } + + public void setKeyboard(Keyboard newKeyboard) { + // One-seventh of the keyboard width seems like a reasonable threshold + final int jumpThreshold = newKeyboard.mOccupiedWidth / 7; + mJumpThresholdSquare = jumpThreshold * jumpThreshold; + } + + /** + * This function checks to see if we need to handle any sudden jumps in the pointer location + * that could be due to a multi-touch being treated as a move by the firmware or hardware. + * Once a sudden jump is detected, all subsequent move events are discarded + * until an UP is received.

+ * When a sudden jump is detected, an UP event is simulated at the last position and when + * the sudden moves subside, a DOWN event is simulated for the second key. + * @param me the motion event + * @return true if the event was consumed, so that it doesn't continue to be handled by + * {@link MainKeyboardView}. + */ + private boolean handleSuddenJumping(MotionEvent me) { + if (!mNeedsSuddenJumpingHack) + return false; + final int action = me.getAction(); + final int x = (int) me.getX(); + final int y = (int) me.getY(); + boolean result = false; + + // Real multi-touch event? Stop looking for sudden jumps + if (me.getPointerCount() > 1) { + mDisableDisambiguation = true; + } + if (mDisableDisambiguation) { + // If UP, reset the multi-touch flag + if (action == MotionEvent.ACTION_UP) mDisableDisambiguation = false; + return false; + } + + switch (action) { + case MotionEvent.ACTION_DOWN: + // Reset the "session" + mDroppingEvents = false; + mDisableDisambiguation = false; + break; + case MotionEvent.ACTION_MOVE: + // Is this a big jump? + final int distanceSquare = (mLastX - x) * (mLastX - x) + (mLastY - y) * (mLastY - y); + // Check the distance. + if (distanceSquare > mJumpThresholdSquare) { + // If we're not yet dropping events, start dropping and send an UP event + if (!mDroppingEvents) { + mDroppingEvents = true; + // Send an up event + MotionEvent translated = MotionEvent.obtain( + me.getEventTime(), me.getEventTime(), + MotionEvent.ACTION_UP, + mLastX, mLastY, me.getMetaState()); + mView.processMotionEvent(translated); + translated.recycle(); + } + result = true; + } else if (mDroppingEvents) { + // If moves are small and we're already dropping events, continue dropping + result = true; + } + break; + case MotionEvent.ACTION_UP: + if (mDroppingEvents) { + // Send a down event first, as we dropped a bunch of sudden jumps and assume that + // the user is releasing the touch on the second key. + MotionEvent translated = MotionEvent.obtain(me.getEventTime(), me.getEventTime(), + MotionEvent.ACTION_DOWN, + x, y, me.getMetaState()); + mView.processMotionEvent(translated); + translated.recycle(); + mDroppingEvents = false; + // Let the up event get processed as well, result = false + } + break; + } + // Track the previous coordinate + mLastX = x; + mLastY = y; + return result; + } + + public boolean onTouchEvent(MotionEvent me) { + // If there was a sudden jump, return without processing the actual motion event. + if (handleSuddenJumping(me)) { + if (DEBUG_MODE) + Log.w(TAG, "onTouchEvent: ignore sudden jump " + me); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.suddenJumpingTouchEventHandler_onTouchEvent(me); + } + return true; + } + return mView.processMotionEvent(me); + } +} -- cgit v1.2.3-83-g751a From 105767088196b9539c373ddcc7f3ff9d8e3e54fc Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 27 Jul 2012 19:32:47 +0900 Subject: Make PreviewPlacerView final This is a groundwork for the bug. Bug: 6883053 Change-Id: I51e9235d3bc7021790a88a44596c4314125a1ab3 --- .../android/inputmethod/keyboard/KeyboardView.java | 40 ++++++++++------------ 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index f1f942ccb..9c6543b61 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -106,7 +106,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { protected final KeyPreviewDrawParams mKeyPreviewDrawParams; private boolean mShowKeyPreviewPopup = true; private int mDelayAfterPreview; - private PreviewPlacerView mPreviewPlacer; + private final PreviewPlacerView mPreviewPlacerView; /** True if {@link KeyboardView} should handle gesture events. */ protected boolean mShouldHandleGesture; @@ -376,6 +376,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout; mPaint.setAntiAlias(true); + + mPreviewPlacerView = new PreviewPlacerView(context); } // Read fraction value in TypedArray as float. @@ -876,39 +878,35 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } private void addKeyPreview(TextView keyPreview) { - if (mPreviewPlacer == null) { - createPreviewPlacer(); - } - mPreviewPlacer.addView( - keyPreview, ViewLayoutUtils.newLayoutParam(mPreviewPlacer, 0, 0)); + locatePreviewPlacerView(); + mPreviewPlacerView.addView( + keyPreview, ViewLayoutUtils.newLayoutParam(mPreviewPlacerView, 0, 0)); } - private void createPreviewPlacer() { - mPreviewPlacer = new PreviewPlacerView(getContext()); + private void locatePreviewPlacerView() { + if (mPreviewPlacerView.getParent() != null) { + return; + } final int[] viewOrigin = new int[2]; getLocationInWindow(viewOrigin); - mPreviewPlacer.setOrigin(viewOrigin[0], viewOrigin[1]); + mPreviewPlacerView.setOrigin(viewOrigin[0], viewOrigin[1]); final ViewGroup windowContentView = (ViewGroup)getRootView().findViewById(android.R.id.content); - windowContentView.addView(mPreviewPlacer); + windowContentView.addView(mPreviewPlacerView); } public void showGesturePreviewText(String gesturePreviewText) { // TDOD: Add user settings option to control drawing gesture trail. - if (mPreviewPlacer == null) { - createPreviewPlacer(); - } - mPreviewPlacer.setGesturePreviewText(gesturePreviewText); - mPreviewPlacer.invalidate(); + locatePreviewPlacerView(); + mPreviewPlacerView.setGesturePreviewText(gesturePreviewText); + mPreviewPlacerView.invalidate(); } @Override public void showGestureTrail(PointerTracker tracker) { // TDOD: Add user settings option to control drawing gesture trail. - if (mPreviewPlacer == null) { - createPreviewPlacer(); - } - mPreviewPlacer.invalidatePointer(tracker); + locatePreviewPlacerView(); + mPreviewPlacerView.invalidatePointer(tracker); } @SuppressWarnings("deprecation") // setBackgroundDrawable is replaced by setBackground in API16 @@ -1051,9 +1049,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { protected void onDetachedFromWindow() { super.onDetachedFromWindow(); closing(); - if (mPreviewPlacer != null) { - mPreviewPlacer.removeAllViews(); - } + mPreviewPlacerView.removeAllViews(); if (mBuffer != null) { mBuffer.recycle(); mBuffer = null; -- cgit v1.2.3-83-g751a From 6fc72cae206b67e2dbcc4c6a853a355995d068be Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 27 Jul 2012 03:45:42 +0900 Subject: Fix a bug with autocaps Port of Iece016f4 Bug: 6886405 Change-Id: I148c296d8a3841c40b6748e73ed2b0fff473b627 --- java/src/com/android/inputmethod/latin/LatinIME.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 6b5de486c..1aac734ba 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -701,6 +701,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mLastSelectionStart = editorInfo.initialSelStart; mLastSelectionEnd = editorInfo.initialSelEnd; + // If we come here something in the text state is very likely to have changed. + // We should update the shift state regardless of whether we are restarting or not, because + // this is not perceived as a layout change that may be disruptive like we may have with + // switcher.loadKeyboard; in apps like Talk, we come here when the text is sent and the + // field gets emptied and we need to re-evaluate the shift state, but not the whole layout + // which would be disruptive. + mKeyboardSwitcher.updateShiftState(); mHandler.cancelUpdateSuggestionStrip(); mHandler.cancelDoubleSpacesTimer(); -- cgit v1.2.3-83-g751a From e7c471a52f38c48cd38e412d88901bddb6f903a9 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 27 Jul 2012 23:13:28 +0900 Subject: Don't auto-correct when there are digits. Bug: 6667462 Change-Id: I796655f57c71c9f50ae6e38dd08b71df3998dbcf --- java/src/com/android/inputmethod/latin/Suggest.java | 2 +- java/src/com/android/inputmethod/latin/WordComposer.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 3e3cf76f1..5e2a04124 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -233,7 +233,7 @@ public class Suggest { // the current settings. It may also be useful to know, when the setting is off, whether // the word *would* have been auto-corrected. if (!isCorrectionEnabled || !allowsToBeAutoCorrected || !wordComposer.isComposingWord() - || suggestionsSet.isEmpty() + || suggestionsSet.isEmpty() || wordComposer.hasDigits() || wordComposer.isMostlyCaps() || wordComposer.isResumed() || !hasMainDictionary()) { // If we don't have a main dictionary, we never want to auto-correct. The reason for diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 6d346d179..5606a58e4 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -41,6 +41,7 @@ public class WordComposer { // Cache these values for performance private int mCapsCount; + private int mDigitsCount; private boolean mAutoCapitalized; private int mTrailingSingleQuotesCount; private int mCodePointSize; @@ -65,6 +66,7 @@ public class WordComposer { mTypedWord = new StringBuilder(source.mTypedWord); mInputPointers.copy(source.mInputPointers); mCapsCount = source.mCapsCount; + mDigitsCount = source.mDigitsCount; mIsFirstCharCapitalized = source.mIsFirstCharCapitalized; mAutoCapitalized = source.mAutoCapitalized; mTrailingSingleQuotesCount = source.mTrailingSingleQuotesCount; @@ -80,6 +82,7 @@ public class WordComposer { mTypedWord.setLength(0); mAutoCorrection = null; mCapsCount = 0; + mDigitsCount = 0; mIsFirstCharCapitalized = false; mTrailingSingleQuotesCount = 0; mIsResumed = false; @@ -141,6 +144,7 @@ public class WordComposer { mIsFirstCharCapitalized = isFirstCharCapitalized( newIndex, primaryCode, mIsFirstCharCapitalized); if (Character.isUpperCase(primaryCode)) mCapsCount++; + if (Character.isDigit(primaryCode)) mDigitsCount++; if (Keyboard.CODE_SINGLE_QUOTE == primaryCode) { ++mTrailingSingleQuotesCount; } else { @@ -213,6 +217,7 @@ public class WordComposer { mTypedWord.deleteCharAt(stringBuilderLength - 1); } if (Character.isUpperCase(lastChar)) mCapsCount--; + if (Character.isDigit(lastChar)) mDigitsCount--; refreshSize(); } // We may have deleted the last one. @@ -267,6 +272,13 @@ public class WordComposer { return mCapsCount > 1; } + /** + * Returns true if we have digits in the composing word. + */ + public boolean hasDigits() { + return mDigitsCount > 0; + } + /** * Saves the reason why the word is capitalized - whether it was automatic or * due to the user hitting shift in the middle of a sentence. @@ -322,6 +334,7 @@ public class WordComposer { lastComposedWord.deactivate(); } mCapsCount = 0; + mDigitsCount = 0; mIsBatchMode = false; mTypedWord.setLength(0); mTrailingSingleQuotesCount = 0; -- cgit v1.2.3-83-g751a From efd8b838ee9415ba4ed692ecf136a918cfa02c54 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 30 Jul 2012 15:04:27 +0900 Subject: Add MoreKeySpec.toString() method for debugging Change-Id: Icf9c6e15521849ffc51911c1e256c9815c1960f4 --- .../com/android/inputmethod/keyboard/internal/KeySpecParser.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java index 53261205d..099e56182 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java @@ -84,6 +84,15 @@ public class KeySpecParser { } mIconId = getIconId(moreKeySpec); } + + @Override + public String toString() { + final String label = (mIconId == KeyboardIconsSet.ICON_UNDEFINED ? mLabel + : PREFIX_ICON + KeyboardIconsSet.getIconName(mIconId)); + final String output = (mCode == Keyboard.CODE_OUTPUT_TEXT ? mOutputText + : String.format("0x%04x", mCode)); + return label + "/" + output; + } } private KeySpecParser() { -- cgit v1.2.3-83-g751a From 4731b67629e72d6c7cb391e3d188df78ceaff1e7 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 30 Jul 2012 13:35:06 +0900 Subject: Add device form factor to KeyboardId This is a groundword for optimizing keyboard parsing. Bug: 6860259 Change-Id: Ie65aa502b18c920e25cf2998b79120b3cc835952 --- java/res/values-sw600dp/config.xml | 2 ++ java/res/values-sw768dp/config.xml | 2 ++ java/res/values/config.xml | 2 ++ .../android/inputmethod/keyboard/KeyboardId.java | 29 +++++++++++++++++----- .../inputmethod/keyboard/KeyboardLayoutSet.java | 16 +++++++----- .../inputmethod/keyboard/KeyboardSwitcher.java | 5 ++-- 6 files changed, 42 insertions(+), 14 deletions(-) (limited to 'java/src') diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml index 619169c52..e296623b2 100644 --- a/java/res/values-sw600dp/config.xml +++ b/java/res/values-sw600dp/config.xml @@ -19,6 +19,8 @@ --> + + 1 false false false diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml index 27cb9ac21..346fa9979 100644 --- a/java/res/values-sw768dp/config.xml +++ b/java/res/values-sw768dp/config.xml @@ -19,6 +19,8 @@ --> + + 2 false false false diff --git a/java/res/values/config.xml b/java/res/values/config.xml index 50f46c3f5..e5575e7ae 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -19,6 +19,8 @@ --> + + 0 false true true diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index b54c72687..1e5277345 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -55,10 +55,15 @@ public class KeyboardId { public static final int ELEMENT_PHONE_SYMBOLS = 8; public static final int ELEMENT_NUMBER = 9; + public static final int FORM_FACTOR_PHONE = 0; + public static final int FORM_FACTOR_TABLET7 = 1; + public static final int FORM_FACTOR_TABLET10 = 2; + private static final int IME_ACTION_CUSTOM_LABEL = EditorInfo.IME_MASK_ACTION + 1; public final InputMethodSubtype mSubtype; public final Locale mLocale; + public final int mDeviceFormFactor; public final int mOrientation; public final int mWidth; public final int mMode; @@ -72,11 +77,12 @@ public class KeyboardId { private final int mHashCode; - public KeyboardId(int elementId, InputMethodSubtype subtype, int orientation, int width, - int mode, EditorInfo editorInfo, boolean clobberSettingsKey, boolean shortcutKeyEnabled, - boolean hasShortcutKey, boolean languageSwitchKeyEnabled) { + public KeyboardId(int elementId, InputMethodSubtype subtype, int deviceFormFactor, + int orientation, int width, int mode, EditorInfo editorInfo, boolean clobberSettingsKey, + boolean shortcutKeyEnabled, boolean hasShortcutKey, boolean languageSwitchKeyEnabled) { mSubtype = subtype; mLocale = SubtypeLocale.getSubtypeLocale(subtype); + mDeviceFormFactor = deviceFormFactor; mOrientation = orientation; mWidth = width; mMode = mode; @@ -94,6 +100,7 @@ public class KeyboardId { private static int computeHashCode(KeyboardId id) { return Arrays.hashCode(new Object[] { + id.mDeviceFormFactor, id.mOrientation, id.mElementId, id.mMode, @@ -115,7 +122,8 @@ public class KeyboardId { private boolean equals(KeyboardId other) { if (other == this) return true; - return other.mOrientation == mOrientation + return other.mDeviceFormFactor == mDeviceFormFactor + && other.mOrientation == mOrientation && other.mElementId == mElementId && other.mMode == mMode && other.mWidth == mWidth @@ -184,11 +192,11 @@ public class KeyboardId { @Override public String toString() { - return String.format("[%s %s:%s %s%d %s %s %s%s%s%s%s%s%s%s]", + return String.format("[%s %s:%s %s-%s:%d %s %s %s%s%s%s%s%s%s%s]", elementIdToName(mElementId), mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), - (mOrientation == 1 ? "port" : "land"), mWidth, + deviceFormFactor(mDeviceFormFactor), (mOrientation == 1 ? "port" : "land"), mWidth, modeName(mMode), imeAction(), (navigateNext() ? "navigateNext" : ""), @@ -226,6 +234,15 @@ public class KeyboardId { } } + public static String deviceFormFactor(int devoceFormFactor) { + switch (devoceFormFactor) { + case FORM_FACTOR_PHONE: return "phone"; + case FORM_FACTOR_TABLET7: return "tablet7"; + case FORM_FACTOR_TABLET10: return "tablet10"; + default: return null; + } + } + public static String modeName(int mode) { switch (mode) { case MODE_TEXT: return "text"; diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java index aab89a3e5..64b3f0952 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java @@ -115,6 +115,7 @@ public class KeyboardLayoutSet { boolean mNoSettingsKey; boolean mLanguageSwitchKeyEnabled; InputMethodSubtype mSubtype; + int mDeviceFormFactor; int mOrientation; int mWidth; // Sparse array of KeyboardLayoutSet element parameters indexed by element's id. @@ -211,9 +212,10 @@ public class KeyboardLayoutSet { final boolean noLanguage = SubtypeLocale.isNoLanguage(params.mSubtype); final boolean voiceKeyEnabled = params.mVoiceKeyEnabled && !noLanguage; final boolean hasShortcutKey = voiceKeyEnabled && (isSymbols != params.mVoiceKeyOnMain); - return new KeyboardId(keyboardLayoutSetElementId, params.mSubtype, params.mOrientation, - params.mWidth, params.mMode, params.mEditorInfo, params.mNoSettingsKey, - voiceKeyEnabled, hasShortcutKey, params.mLanguageSwitchKeyEnabled); + return new KeyboardId(keyboardLayoutSetElementId, params.mSubtype, params.mDeviceFormFactor, + params.mOrientation, params.mWidth, params.mMode, params.mEditorInfo, + params.mNoSettingsKey, voiceKeyEnabled, hasShortcutKey, + params.mLanguageSwitchKeyEnabled); } public static class Builder { @@ -239,9 +241,11 @@ public class KeyboardLayoutSet { mPackageName, NO_SETTINGS_KEY, mEditorInfo); } - public Builder setScreenGeometry(int orientation, int widthPixels) { - mParams.mOrientation = orientation; - mParams.mWidth = widthPixels; + public Builder setScreenGeometry(int deviceFormFactor, int orientation, int widthPixels) { + final Params params = mParams; + params.mDeviceFormFactor = deviceFormFactor; + params.mOrientation = orientation; + params.mWidth = widthPixels; return this; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index f27d79382..4d952098c 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -137,8 +137,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions { public void loadKeyboard(EditorInfo editorInfo, SettingsValues settingsValues) { final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder( mThemeContext, editorInfo); - builder.setScreenGeometry(mThemeContext.getResources().getConfiguration().orientation, - mThemeContext.getResources().getDisplayMetrics().widthPixels); + final Resources res = mThemeContext.getResources(); + builder.setScreenGeometry(res.getInteger(R.integer.config_device_form_factor), + res.getConfiguration().orientation, res.getDisplayMetrics().widthPixels); builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype()); builder.setOptions( settingsValues.isVoiceKeyEnabled(editorInfo), -- cgit v1.2.3-83-g751a From 75fb3ce1be3c879bb614097a2534f791c833dd7c Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 30 Jul 2012 15:51:41 +0900 Subject: More readable Key.toString() and MoreKeySpec.toString() Change-Id: Iee3c33dedd0c00ba259aa55e8b0c1c57b84eccdd --- java/src/com/android/inputmethod/keyboard/Key.java | 10 ++++++++-- .../android/inputmethod/keyboard/internal/KeySpecParser.java | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index e1e1ca9cf..178c9ff05 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -414,8 +414,14 @@ public class Key { @Override public String toString() { - return String.format("%s/%s %d,%d %dx%d %s/%s/%s", - Keyboard.printableCode(mCode), mLabel, mX, mY, mWidth, mHeight, mHintLabel, + final String label; + if (StringUtils.codePointCount(mLabel) == 1 && mLabel.codePointAt(0) == mCode) { + label = ""; + } else { + label = "/" + mLabel; + } + return String.format("%s%s %d,%d %dx%d %s/%s/%s", + Keyboard.printableCode(mCode), label, mX, mY, mWidth, mHeight, mHintLabel, KeyboardIconsSet.getIconName(mIconId), backgroundName(mBackgroundType)); } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java index 099e56182..94a7b826f 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java @@ -90,8 +90,12 @@ public class KeySpecParser { final String label = (mIconId == KeyboardIconsSet.ICON_UNDEFINED ? mLabel : PREFIX_ICON + KeyboardIconsSet.getIconName(mIconId)); final String output = (mCode == Keyboard.CODE_OUTPUT_TEXT ? mOutputText - : String.format("0x%04x", mCode)); - return label + "/" + output; + : Keyboard.printableCode(mCode)); + if (StringUtils.codePointCount(label) == 1 && label.codePointAt(0) == mCode) { + return output; + } else { + return label + "|" + output; + } } } -- cgit v1.2.3-83-g751a From 47e2bf329882ea45294ea6e6dd80b4d4eb3789e6 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 27 Jul 2012 15:32:29 +0900 Subject: Add advanced options to turn on/off the gesture trail and text preview Bug: 6883053 Change-Id: I601718afb37289108b45ef68626c7c315edca35d --- java/res/values/strings.xml | 8 ++- java/res/xml/prefs.xml | 23 ++++++-- .../android/inputmethod/keyboard/KeyboardView.java | 8 +-- .../inputmethod/keyboard/MainKeyboardView.java | 6 +- .../keyboard/internal/PreviewPlacerView.java | 19 ++++-- .../com/android/inputmethod/latin/LatinIME.java | 4 +- .../com/android/inputmethod/latin/Settings.java | 67 ++++++++++++++-------- .../android/inputmethod/latin/SettingsValues.java | 5 ++ 8 files changed, 98 insertions(+), 42 deletions(-) (limited to 'java/src') diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 25d982793..07b3f31c7 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -111,10 +111,16 @@ Based on previous word - + Gesture input Input a word by tracing the letters of a word + + Show gesture trail + + Show gesture word + + Show floating preview word with gesture %s : Saved diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index 4f11cb7e5..ef6be3eed 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -101,6 +101,12 @@ android:key="pref_advanced_settings" android:title="@string/advanced_settings" android:summary="@string/advanced_settings_summary"> + - + + diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 9c6543b61..e70c7a19e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -432,8 +432,11 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { return mShowKeyPreviewPopup; } - public void setGestureHandlingMode(boolean shouldHandleGesture) { + public void setGestureHandlingMode(boolean shouldHandleGesture, + boolean drawsGesturePreviewTrail, boolean drawsGestureFloatingPreviewText) { mShouldHandleGesture = shouldHandleGesture; + mPreviewPlacerView.setGesturePreviewMode( + drawsGesturePreviewTrail, drawsGestureFloatingPreviewText); } @Override @@ -896,15 +899,12 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } public void showGesturePreviewText(String gesturePreviewText) { - // TDOD: Add user settings option to control drawing gesture trail. locatePreviewPlacerView(); mPreviewPlacerView.setGesturePreviewText(gesturePreviewText); - mPreviewPlacerView.invalidate(); } @Override public void showGestureTrail(PointerTracker tracker) { - // TDOD: Add user settings option to control drawing gesture trail. locatePreviewPlacerView(); mPreviewPlacerView.invalidatePointer(tracker); } diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 9c28419cf..7ad552151 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -481,8 +481,10 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key } @Override - public void setGestureHandlingMode(final boolean shouldHandleGesture) { - super.setGestureHandlingMode(shouldHandleGesture); + public void setGestureHandlingMode(final boolean shouldHandleGesture, + boolean drawsGesturePreviewTrail, boolean drawsGestureFloatingPreviewText) { + super.setGestureHandlingMode(shouldHandleGesture, drawsGesturePreviewTrail, + drawsGestureFloatingPreviewText); PointerTracker.setKeyDetector(mKeyDetector, shouldHandleGesture); } diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java index 2a53c59bb..a400fda15 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java +++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java @@ -51,6 +51,8 @@ public class PreviewPlacerView extends RelativeLayout { private final SparseArray mPointers = new SparseArray(); private String mGesturePreviewText; + private boolean mDrawsGesturePreviewTrail; + private boolean mDrawsGestureFloatingPreviewText; public PreviewPlacerView(Context context) { super(context); @@ -89,6 +91,12 @@ public class PreviewPlacerView extends RelativeLayout { mYOrigin = y; } + public void setGesturePreviewMode(boolean drawsGesturePreviewTrail, + boolean drawsGestureFloatingPreviewText) { + mDrawsGesturePreviewTrail = drawsGesturePreviewTrail; + mDrawsGestureFloatingPreviewText = drawsGestureFloatingPreviewText; + } + public void invalidatePointer(PointerTracker tracker) { synchronized (mPointers) { mPointers.put(tracker.mPointerId, tracker); @@ -100,18 +108,19 @@ public class PreviewPlacerView extends RelativeLayout { @Override public void onDraw(Canvas canvas) { super.onDraw(canvas); - // TDOD: Add user settings option to control drawing gesture trail and gesture preview. synchronized (mPointers) { canvas.translate(mXOrigin, mYOrigin); final int trackerCount = mPointers.size(); - boolean floatingPreviewHasDrawn = false; + boolean hasDrawnFloatingPreviewText = false; for (int index = 0; index < trackerCount; index++) { final PointerTracker tracker = mPointers.valueAt(index); - tracker.drawGestureTrail(canvas, mGesturePaint); + if (mDrawsGesturePreviewTrail) { + tracker.drawGestureTrail(canvas, mGesturePaint); + } // TODO: Figure out more cleaner way to draw gesture preview text. - if (!floatingPreviewHasDrawn) { + if (mDrawsGestureFloatingPreviewText && !hasDrawnFloatingPreviewText) { drawGesturePreviewText(canvas, tracker, mGesturePreviewText); - floatingPreviewHasDrawn = true; + hasDrawnFloatingPreviewText = true; } } canvas.translate(-mXOrigin, -mYOrigin); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 1aac734ba..22213be5e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -2095,7 +2095,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (keyboardView != null) { final boolean shouldHandleGesture = mCurrentSettings.mGestureInputEnabled && mIsMainDictionaryAvailable; - keyboardView.setGestureHandlingMode(shouldHandleGesture); + keyboardView.setGestureHandlingMode(shouldHandleGesture, + mCurrentSettings.mGesturePreviewTrailEnabled, + mCurrentSettings.mGestureFloatingPreviewTextEnabled); } } diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 45608f439..6251c9acd 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -62,6 +62,7 @@ public class Settings extends InputMethodSettingsFragment public static final String PREF_LAST_USER_DICTIONARY_WRITE_TIME = "last_user_dictionary_write_time"; public static final String PREF_ADVANCED_SETTINGS = "pref_advanced_settings"; + public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict"; public static final String PREF_SUPPRESS_LANGUAGE_SWITCH_KEY = "pref_suppress_language_switch_key"; public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST = @@ -69,13 +70,15 @@ public class Settings extends InputMethodSettingsFragment public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles"; public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY = "pref_key_preview_popup_dismiss_delay"; - public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict"; public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction"; public static final String PREF_GESTURE_INPUT = "gesture_input"; public static final String PREF_VIBRATION_DURATION_SETTINGS = "pref_vibration_duration_settings"; public static final String PREF_KEYPRESS_SOUND_VOLUME = "pref_keypress_sound_volume"; + public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail"; + public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = + "pref_gesture_floating_preview_text"; public static final String PREF_INPUT_LANGUAGE = "input_language"; public static final String PREF_SELECTED_LANGUAGES = "selected_languages"; @@ -94,13 +97,17 @@ public class Settings extends InputMethodSettingsFragment private TextView mKeypressVibrationDurationSettingsTextView; private TextView mKeypressSoundVolumeSettingsTextView; + private static void setPreferenceEnabled(Preference preference, boolean enabled) { + if (preference != null) { + preference.setEnabled(enabled); + } + } + private void ensureConsistencyOfAutoCorrectionSettings() { final String autoCorrectionOff = getResources().getString( R.string.auto_correction_threshold_mode_index_off); final String currentSetting = mAutoCorrectionThresholdPreference.getValue(); - if (null != mBigramPrediction) { - mBigramPrediction.setEnabled(!currentSetting.equals(autoCorrectionOff)); - } + setPreferenceEnabled(mBigramPrediction, !currentSetting.equals(autoCorrectionOff)); } @Override @@ -180,13 +187,11 @@ public class Settings extends InputMethodSettingsFragment if (null == mKeyPreviewPopupDismissDelay.getValue()) { mKeyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue); } - mKeyPreviewPopupDismissDelay.setEnabled( + setPreferenceEnabled(mKeyPreviewPopupDismissDelay, SettingsValues.isKeyPreviewPopupEnabled(prefs, res)); } - final CheckBoxPreference includeOtherImesInLanguageSwitchList = - (CheckBoxPreference)findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST); - includeOtherImesInLanguageSwitchList.setEnabled( + setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST), !SettingsValues.isLanguageSwitchKeySupressed(prefs)); final PreferenceScreen dictionaryLink = @@ -200,10 +205,19 @@ public class Settings extends InputMethodSettingsFragment final boolean gestureInputEnabledByBuildConfig = res.getBoolean( R.bool.config_gesture_input_enabled_by_build_config); + final Preference gesturePreviewTrail = findPreference(PREF_GESTURE_PREVIEW_TRAIL); + final Preference gestureFloatingPreviewText = findPreference( + PREF_GESTURE_FLOATING_PREVIEW_TEXT); if (!gestureInputEnabledByBuildConfig) { - final Preference gestureInputPref = findPreference(PREF_GESTURE_INPUT); - miscSettings.removePreference(gestureInputPref); + miscSettings.removePreference(findPreference(PREF_GESTURE_INPUT)); + miscSettings.removePreference(gesturePreviewTrail); + miscSettings.removePreference(gestureFloatingPreviewText); + } else { + final boolean gestureInputEnabledByUser = prefs.getBoolean(PREF_GESTURE_INPUT, true); + setPreferenceEnabled(gesturePreviewTrail, gestureInputEnabledByUser); + setPreferenceEnabled(gestureFloatingPreviewText, gestureInputEnabledByUser); } + final boolean showUsabilityStudyModeOption = res.getBoolean(R.bool.config_enable_usability_study_mode_option) || ProductionFlag.IS_EXPERIMENTAL || ENABLE_EXPERIMENTAL_SETTINGS; @@ -277,17 +291,22 @@ public class Settings extends InputMethodSettingsFragment public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { (new BackupManager(getActivity())).dataChanged(); if (key.equals(PREF_POPUP_ON)) { - final ListPreference popupDismissDelay = - (ListPreference)findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY); - if (null != popupDismissDelay) { - popupDismissDelay.setEnabled(prefs.getBoolean(PREF_POPUP_ON, true)); - } + setPreferenceEnabled(findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY), + prefs.getBoolean(PREF_POPUP_ON, true)); } else if (key.equals(PREF_SUPPRESS_LANGUAGE_SWITCH_KEY)) { - final CheckBoxPreference includeOtherImesInLanguageSwicthList = - (CheckBoxPreference)findPreference( - PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST); - includeOtherImesInLanguageSwicthList.setEnabled( + setPreferenceEnabled(findPreference(PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST), !SettingsValues.isLanguageSwitchKeySupressed(prefs)); + } else if (key.equals(PREF_GESTURE_INPUT)) { + final boolean gestureInputEnabledByConfig = getResources().getBoolean( + R.bool.config_gesture_input_enabled_by_build_config); + if (gestureInputEnabledByConfig) { + final boolean gestureInputEnabledByUser = prefs.getBoolean( + PREF_GESTURE_INPUT, true); + setPreferenceEnabled(findPreference(PREF_GESTURE_PREVIEW_TRAIL), + gestureInputEnabledByUser); + setPreferenceEnabled(findPreference(PREF_GESTURE_FLOATING_PREVIEW_TEXT), + gestureInputEnabledByUser); + } } ensureConsistencyOfAutoCorrectionSettings(); updateVoiceModeSummary(); @@ -335,16 +354,18 @@ public class Settings extends InputMethodSettingsFragment private void refreshEnablingsOfKeypressSoundAndVibrationSettings( SharedPreferences sp, Resources res) { if (mKeypressVibrationDurationSettingsPref != null) { - final boolean hasVibrator = VibratorUtils.getInstance(getActivity()).hasVibrator(); - final boolean vibrateOn = hasVibrator && sp.getBoolean(Settings.PREF_VIBRATE_ON, + final boolean hasVibratorHardware = VibratorUtils.getInstance(getActivity()) + .hasVibrator(); + final boolean vibrateOnByUser = sp.getBoolean(Settings.PREF_VIBRATE_ON, res.getBoolean(R.bool.config_default_vibration_enabled)); - mKeypressVibrationDurationSettingsPref.setEnabled(vibrateOn); + setPreferenceEnabled(mKeypressVibrationDurationSettingsPref, + hasVibratorHardware && vibrateOnByUser); } if (mKeypressSoundVolumeSettingsPref != null) { final boolean soundOn = sp.getBoolean(Settings.PREF_SOUND_ON, res.getBoolean(R.bool.config_default_sound_enabled)); - mKeypressSoundVolumeSettingsPref.setEnabled(soundOn); + setPreferenceEnabled(mKeypressSoundVolumeSettingsPref, soundOn); } } diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index 3ed981375..0843bdbbc 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -84,6 +84,8 @@ public class SettingsValues { private final float mKeypressSoundVolumeRawValue; private final InputMethodSubtype[] mAdditionalSubtypes; public final boolean mGestureInputEnabled; + public final boolean mGesturePreviewTrailEnabled; + public final boolean mGestureFloatingPreviewTextEnabled; // From the input box private final InputAttributes mInputAttributes; @@ -174,6 +176,9 @@ public class SettingsValues { R.bool.config_gesture_input_enabled_by_build_config); mGestureInputEnabled = gestureInputEnabledByBuildConfig && prefs.getBoolean(Settings.PREF_GESTURE_INPUT, true); + mGesturePreviewTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true); + mGestureFloatingPreviewTextEnabled = prefs.getBoolean( + Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true); mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect; mSuggestionVisibility = createSuggestionVisibility(res); } -- cgit v1.2.3-83-g751a From edf7990e84bd05adefd1d9585dc1b3baf223cdd6 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 30 Jul 2012 16:50:03 +0900 Subject: Small fix to KeyboardView Change-Id: Ifb7500ec2e55b50bb7951aa847fd4fbf49e32f4e --- .../com/android/inputmethod/keyboard/KeyboardView.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 9c6543b61..51cd37544 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -255,10 +255,12 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } public void updateKeyHeight(int keyHeight) { - if (mKeyLetterRatio >= 0.0f) + if (mKeyLetterRatio >= 0.0f) { mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); - if (mKeyLabelRatio >= 0.0f) + } + if (mKeyLabelRatio >= 0.0f) { mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio); + } mKeyLargeLabelSize = (int)(keyHeight * mKeyLargeLabelRatio); mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio); mKeyHintLetterSize = (int)(keyHeight * mKeyHintLetterRatio); @@ -340,13 +342,16 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } public void updateKeyHeight(int keyHeight) { - mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio); - mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); + if (mPreviewTextRatio >= 0.0f) { + mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio); + } + if (mKeyLetterRatio >= 0.0f) { + mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio); + } } private static void setAlpha(Drawable drawable, int alpha) { - if (drawable == null) - return; + if (drawable == null) return; drawable.setAlpha(alpha); } } -- cgit v1.2.3-83-g751a From ca57f5ba40b587a7a7f8a023aca65e1b2127b2a6 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 30 Jul 2012 16:06:19 +0900 Subject: Move gesture preview parameters to KeyboardView attributes Change-Id: Iff9d6b485e202656fc869f3ff4d94575ad2c186f --- java/res/values/attrs.xml | 12 +++ java/res/values/dimens.xml | 10 +- java/res/values/styles.xml | 14 ++- .../android/inputmethod/keyboard/KeyboardView.java | 7 +- .../keyboard/internal/PreviewPlacerView.java | 104 +++++++++++---------- .../com/android/inputmethod/latin/LatinIME.java | 7 +- 6 files changed, 91 insertions(+), 63 deletions(-) (limited to 'java/src') diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 1d52e46bb..02e8eeb3b 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -118,6 +118,18 @@ + + + + + + + + + + + + diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index b47897f3c..c59bad302 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -96,9 +96,9 @@ 2.5dp - 35dp - 75dp - 17.5dp - 7.5dp - 1.0dp + 35dp + 75dp + 17.5dp + 7.5dp + 1.0dp diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 8797fd7aa..955a27631 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -14,7 +14,7 @@ limitations under the License. --> - +