aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/color/key_text_color_holo.xml48
-rw-r--r--java/res/raw/main_de.dictbin1605763 -> 1605763 bytes
-rw-r--r--java/res/raw/main_en.dictbin1070464 -> 1070464 bytes
-rw-r--r--java/res/raw/main_es.dictbin1138908 -> 1138908 bytes
-rw-r--r--java/res/raw/main_fr.dictbin1329188 -> 1329188 bytes
-rw-r--r--java/res/raw/main_it.dictbin1143338 -> 1143338 bytes
-rw-r--r--java/res/raw/main_pt_br.dictbin1092054 -> 1092054 bytes
-rw-r--r--java/res/raw/main_ru.dictbin2229479 -> 2229479 bytes
-rw-r--r--java/res/values/colors.xml4
-rw-r--r--java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java28
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java19
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java14
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java9
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java2
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java8
18 files changed, 47 insertions, 100 deletions
diff --git a/java/res/color/key_text_color_holo.xml b/java/res/color/key_text_color_holo.xml
deleted file mode 100644
index d034a945f..000000000
--- a/java/res/color/key_text_color_holo.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <!-- Functional keys. -->
- <item android:state_single="true" android:state_pressed="true"
- android:color="@color/key_text_color_functional_holo" />
- <item android:state_single="true"
- android:color="@color/key_text_color_functional_holo" />
-
- <!-- Action keys. -->
- <item android:state_active="true" android:state_pressed="true"
- android:color="@color/key_text_color_normal_holo" />
- <item android:state_active="true"
- android:color="@color/key_text_color_normal_holo" />
-
- <!-- Toggle keys. Use checkable/checked state. -->
- <item android:state_checkable="true" android:state_checked="true" android:state_pressed="true"
- android:color="@color/key_text_color_normal_holo" />
- <item android:state_checkable="true" android:state_pressed="true"
- android:color="@color/key_text_color_normal_holo" />
- <item android:state_checkable="true" android:state_checked="true"
- android:color="@color/key_text_color_normal_holo" />
- <item android:state_checkable="true"
- android:color="@color/key_text_color_normal_holo" />
-
- <!-- Empty background keys. -->
- <item android:state_empty="true"
- android:color="@color/key_text_color_normal_holo" />
-
- <!-- Normal keys. -->
- <item android:state_pressed="true"
- android:color="@color/key_text_color_normal_holo" />
- <item android:color="@color/key_text_color_normal_holo" />
-</selector>
diff --git a/java/res/raw/main_de.dict b/java/res/raw/main_de.dict
index c65698d7b..3cbf7105d 100644
--- a/java/res/raw/main_de.dict
+++ b/java/res/raw/main_de.dict
Binary files differ
diff --git a/java/res/raw/main_en.dict b/java/res/raw/main_en.dict
index 57f3fe7c1..49adc9a19 100644
--- a/java/res/raw/main_en.dict
+++ b/java/res/raw/main_en.dict
Binary files differ
diff --git a/java/res/raw/main_es.dict b/java/res/raw/main_es.dict
index 261ab8c87..fe24cd624 100644
--- a/java/res/raw/main_es.dict
+++ b/java/res/raw/main_es.dict
Binary files differ
diff --git a/java/res/raw/main_fr.dict b/java/res/raw/main_fr.dict
index c240d9665..94d1b9670 100644
--- a/java/res/raw/main_fr.dict
+++ b/java/res/raw/main_fr.dict
Binary files differ
diff --git a/java/res/raw/main_it.dict b/java/res/raw/main_it.dict
index 98135ce8e..ff11b9798 100644
--- a/java/res/raw/main_it.dict
+++ b/java/res/raw/main_it.dict
Binary files differ
diff --git a/java/res/raw/main_pt_br.dict b/java/res/raw/main_pt_br.dict
index 21bbe7c67..9fa50442a 100644
--- a/java/res/raw/main_pt_br.dict
+++ b/java/res/raw/main_pt_br.dict
Binary files differ
diff --git a/java/res/raw/main_ru.dict b/java/res/raw/main_ru.dict
index c2b1e67b3..0f08f1735 100644
--- a/java/res/raw/main_ru.dict
+++ b/java/res/raw/main_ru.dict
Binary files differ
diff --git a/java/res/values/colors.xml b/java/res/values/colors.xml
index 93f25a7f6..517174495 100644
--- a/java/res/values/colors.xml
+++ b/java/res/values/colors.xml
@@ -39,6 +39,7 @@
<color name="typed_word_color_ics">#D833B5E5</color>
<color name="suggested_word_color_ics">#B233B5E5</color>
<color name="highlight_translucent_color_ics">#9933B5E5</color>
+ <color name="key_text_color_holo">@android:color/white</color>
<color name="key_text_shadow_color_holo">@android:color/transparent</color>
<color name="key_text_inactivated_color_holo">#66E0E4E5</color>
<color name="key_hint_letter_color_holo">#80000000</color>
@@ -65,7 +66,4 @@
<!-- TODO: Color which should be included in the theme -->
<color name="emoji_key_background_color">#00000000</color>
<color name="emoji_key_pressed_background_color">#30FFFFFF</color>
-
- <color name="key_text_color_normal_holo">@android:color/white</color>
- <color name="key_text_color_functional_holo">@android:color/white</color>
</resources>
diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
index 4c53b528f..7fff46aaf 100644
--- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
+++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
@@ -25,7 +25,6 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
-import android.graphics.Typeface;
import android.os.Build;
import android.os.CountDownTimer;
import android.preference.PreferenceManager;
@@ -49,6 +48,8 @@ import android.widget.TextView;
import com.android.inputmethod.keyboard.internal.DynamicGridKeyboard;
import com.android.inputmethod.keyboard.internal.EmojiLayoutParams;
import com.android.inputmethod.keyboard.internal.EmojiPageKeyboardView;
+import com.android.inputmethod.keyboard.internal.KeyDrawParams;
+import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
@@ -634,20 +635,23 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
// TODO:
}
- // Hack: These parameters are hacky.
- public void startEmojiPalettes(final String switchToAlphaLabel, final int switchToAlphaColor,
- final float switchToAlphaSize, final Typeface switchToAlphaTypeface) {
+ private static void setupAlphabetKey(final TextView alphabetKey, final String label,
+ final KeyDrawParams params) {
+ alphabetKey.setText(label);
+ alphabetKey.setTextColor(params.mTextColor);
+ alphabetKey.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mLabelSize);
+ alphabetKey.setTypeface(params.mTypeface);
+ }
+
+ public void startEmojiPalettes(final String switchToAlphaLabel,
+ final KeyVisualAttributes keyVisualAttr) {
if (DEBUG_PAGER) {
Log.d(TAG, "allocate emoji palettes memory " + mCurrentPagerPosition);
}
- mAlphabetKeyLeft.setText(switchToAlphaLabel);
- mAlphabetKeyLeft.setTextColor(switchToAlphaColor);
- mAlphabetKeyLeft.setTextSize(TypedValue.COMPLEX_UNIT_PX, switchToAlphaSize);
- mAlphabetKeyLeft.setTypeface(switchToAlphaTypeface);
- mAlphabetKeyRight.setText(switchToAlphaLabel);
- mAlphabetKeyRight.setTextColor(switchToAlphaColor);
- mAlphabetKeyRight.setTextSize(TypedValue.COMPLEX_UNIT_PX, switchToAlphaSize);
- mAlphabetKeyRight.setTypeface(switchToAlphaTypeface);
+ final KeyDrawParams params = new KeyDrawParams();
+ params.updateParams(mEmojiLayoutParams.getActionBarHeight(), keyVisualAttr);
+ setupAlphabetKey(mAlphabetKeyLeft, switchToAlphaLabel, params);
+ setupAlphabetKey(mAlphabetKeyRight, switchToAlphaLabel, params);
mEmojiPager.setAdapter(mEmojiPalettesAdapter);
mEmojiPager.setCurrentItem(mCurrentPagerPosition);
}
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index ceda9ee9a..afaf2cc57 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -137,8 +137,6 @@ public class Key implements Comparable<Key> {
private final OptionalAttributes mOptionalAttributes;
- private static final int DEFAULT_TEXT_COLOR = 0xFFFFFFFF;
-
private static final class OptionalAttributes {
/** Text to output when pressed. This can be multiple characters, like ".com" */
public final String mOutputText;
@@ -585,22 +583,7 @@ public class Key implements Comparable<Key> {
}
public final int selectTextColor(final KeyDrawParams params) {
- if (isShiftedLetterActivated()) {
- return params.mTextInactivatedColor;
- }
- if (params.mTextColorStateList == null) {
- return DEFAULT_TEXT_COLOR;
- }
- final int[] state;
- // TODO: Hack!!!!!!!! Consider having a new attribute for the functional text labels.
- // Currently, we distinguish "input key" from "functional key" by checking the
- // length of the label( > 1) and "functional" attributes (= true).
- if (mLabel != null && mLabel.length() > 1) {
- state = getCurrentDrawableState();
- } else {
- state = KEY_STATE_NORMAL;
- }
- return params.mTextColorStateList.getColorForState(state, DEFAULT_TEXT_COLOR);
+ return isShiftedLetterActivated() ? params.mTextInactivatedColor : params.mTextColor;
}
public final int selectHintTextSize(final KeyDrawParams params) {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 6215e2710..f9758634e 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -19,7 +19,6 @@ package com.android.inputmethod.keyboard;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
-import android.graphics.Paint;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.ContextThemeWrapper;
@@ -31,7 +30,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException;
import com.android.inputmethod.keyboard.internal.KeyboardState;
-import com.android.inputmethod.latin.Constants;
+import com.android.inputmethod.keyboard.internal.KeyboardTextsSet;
import com.android.inputmethod.latin.InputView;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
@@ -81,8 +80,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private KeyboardState mState;
private KeyboardLayoutSet mKeyboardLayoutSet;
+ // TODO: The following {@link KeyboardTextsSet} should be in {@link KeyboardLayoutSet}.
+ private final KeyboardTextsSet mKeyboardTextsSet = new KeyboardTextsSet();
private SettingsValues mCurrentSettingsValues;
- private Key mSwitchToAlphaKey;
/** mIsAutoCorrectionActive indicates that auto corrected word will be input instead of
* what user actually typed. */
@@ -163,8 +163,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mCurrentSettingsValues = settingsValues;
try {
mState.onLoadKeyboard();
- final Keyboard symbols = mKeyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_SYMBOLS);
- mSwitchToAlphaKey = symbols.getKey(Constants.CODE_SWITCH_ALPHA_SYMBOL);
+ mKeyboardTextsSet.setLocale(mSubtypeSwitcher.getCurrentSubtypeLocale());
} catch (KeyboardLayoutSetException e) {
Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
LatinImeLogger.logOnException(e.mKeyboardId.toString(), e.getCause());
@@ -290,10 +289,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
@Override
public void setEmojiKeyboard() {
mMainKeyboardFrame.setVisibility(View.GONE);
- final Paint paint = mKeyboardView.newLabelPaint(mSwitchToAlphaKey);
mEmojiPalettesView.startEmojiPalettes(
- mSwitchToAlphaKey.getLabel(), paint.getColor(), paint.getTextSize(),
- paint.getTypeface());
+ mKeyboardTextsSet.getText(KeyboardTextsSet.SWITCH_TO_ALPHA_KEY_LABEL),
+ mKeyboardView.getKeyVisualAttribute());
mEmojiPalettesView.setVisibility(View.VISIBLE);
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index dd3ab9cce..18e51d392 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -146,6 +146,10 @@ public class KeyboardView extends View {
mPaint.setAntiAlias(true);
}
+ public KeyVisualAttributes getKeyVisualAttribute() {
+ return mKeyVisualAttributes;
+ }
+
private static void blendAlpha(final Paint paint, final int alpha) {
final int color = paint.getColor();
paint.setARGB((paint.getAlpha() * alpha) / Constants.Color.ALPHA_OPAQUE,
diff --git a/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java b/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
index 12e063261..d57ea5a94 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/EmojiLayoutParams.java
@@ -73,9 +73,13 @@ public class EmojiLayoutParams {
ll.setLayoutParams(lp);
}
+ public int getActionBarHeight() {
+ return mEmojiActionBarHeight - mBottomPadding;
+ }
+
public void setActionBarProperties(final LinearLayout ll) {
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
- lp.height = mEmojiActionBarHeight - mBottomPadding;
+ lp.height = getActionBarHeight();
ll.setLayoutParams(lp);
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java
index b528b692e..1716fa049 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java
@@ -16,7 +16,6 @@
package com.android.inputmethod.keyboard.internal;
-import android.content.res.ColorStateList;
import android.graphics.Typeface;
import com.android.inputmethod.latin.utils.ResourceUtils;
@@ -33,7 +32,7 @@ public final class KeyDrawParams {
public int mHintLabelSize;
public int mPreviewTextSize;
- public ColorStateList mTextColorStateList;
+ public int mTextColor;
public int mTextInactivatedColor;
public int mTextShadowColor;
public int mHintLetterColor;
@@ -58,7 +57,7 @@ public final class KeyDrawParams {
mHintLabelSize = copyFrom.mHintLabelSize;
mPreviewTextSize = copyFrom.mPreviewTextSize;
- mTextColorStateList = copyFrom.mTextColorStateList;
+ mTextColor = copyFrom.mTextColor;
mTextInactivatedColor = copyFrom.mTextInactivatedColor;
mTextShadowColor = copyFrom.mTextShadowColor;
mHintLetterColor = copyFrom.mHintLetterColor;
@@ -90,8 +89,8 @@ public final class KeyDrawParams {
attr.mShiftedLetterHintRatio, mShiftedLetterHintSize);
mHintLabelSize = selectTextSize(keyHeight, attr.mHintLabelRatio, mHintLabelSize);
mPreviewTextSize = selectTextSize(keyHeight, attr.mPreviewTextRatio, mPreviewTextSize);
- mTextColorStateList =
- attr.mTextColorStateList != null ? attr.mTextColorStateList : mTextColorStateList;
+
+ mTextColor = selectColor(attr.mTextColor, mTextColor);
mTextInactivatedColor = selectColor(attr.mTextInactivatedColor, mTextInactivatedColor);
mTextShadowColor = selectColor(attr.mTextShadowColor, mTextShadowColor);
mHintLetterColor = selectColor(attr.mHintLetterColor, mHintLetterColor);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java b/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java
index c3e0aa685..df386fce4 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java
@@ -16,7 +16,6 @@
package com.android.inputmethod.keyboard.internal;
-import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.SparseIntArray;
@@ -38,7 +37,7 @@ public final class KeyVisualAttributes {
public final float mHintLabelRatio;
public final float mPreviewTextRatio;
- public final ColorStateList mTextColorStateList;
+ public final int mTextColor;
public final int mTextInactivatedColor;
public final int mTextShadowColor;
public final int mHintLetterColor;
@@ -119,7 +118,7 @@ public final class KeyVisualAttributes {
mPreviewTextRatio = ResourceUtils.getFraction(keyAttr,
R.styleable.Keyboard_Key_keyPreviewTextRatio);
- mTextColorStateList = keyAttr.getColorStateList(R.styleable.Keyboard_Key_keyTextColor);
+ mTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextColor, 0);
mTextInactivatedColor = keyAttr.getColor(
R.styleable.Keyboard_Key_keyTextInactivatedColor, 0);
mTextShadowColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextShadowColor, 0);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
index 89221ba24..976038c10 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
@@ -29,6 +29,8 @@ import java.util.Locale;
public final class KeyboardTextsSet {
public static final String PREFIX_TEXT = "!text/";
+ public static final String SWITCH_TO_ALPHA_KEY_LABEL = "label_to_alpha_key";
+
private static final char BACKSLASH = Constants.CODE_BACKSLASH;
private static final int MAX_STRING_REFERENCE_INDIRECTION = 10;
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 30b20a335..323256d1c 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -483,12 +483,16 @@ public final class RichInputConnection {
*
* @param start the character index where the selection should start.
* @param end the character index where the selection should end.
- * @return Returns true on success, false if the input connection is no longer valid either when
- * setting the selection or when retrieving the text cache at that point.
+ * @return Returns true on success, false on failure: either the input connection is no longer
+ * valid when setting the selection or when retrieving the text cache at that point, or
+ * invalid arguments were passed.
*/
public boolean setSelection(final int start, final int end) {
if (DEBUG_BATCH_NESTING) checkBatchEdit();
if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
+ if (start < 0 || end < 0) {
+ return false;
+ }
mExpectedSelStart = start;
mExpectedSelEnd = end;
if (null != mIC) {