aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java19
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardParser.java12
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java21
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboard.java54
-rw-r--r--java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java39
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java62
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java2
8 files changed, 122 insertions, 91 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 267abccb3..77a4cde55 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -16,15 +16,16 @@
package com.android.inputmethod.keyboard;
-import com.android.inputmethod.latin.R;
-
-import org.xmlpull.v1.XmlPullParserException;
-
import android.content.Context;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.Log;
+import com.android.inputmethod.latin.R;
+
+import org.xmlpull.v1.XmlPullParserException;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -146,6 +147,8 @@ public class Keyboard {
private final ProximityInfo mProximityInfo;
+ public final Drawable mPopupHintIcon;
+
/**
* Creates a keyboard from the given xml key layout file.
* @param context the application or service context
@@ -171,8 +174,14 @@ public class Keyboard {
mDefaultVerticalGap = 0;
mDefaultHeight = mDefaultWidth;
mId = id;
- loadKeyboard(context, xmlLayoutResId);
mProximityInfo = new ProximityInfo(GRID_WIDTH, GRID_HEIGHT);
+
+ final TypedArray attrs = context.obtainStyledAttributes(
+ null, R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard);
+ mPopupHintIcon = attrs.getDrawable(R.styleable.Keyboard_popupHintIcon);
+ attrs.recycle();
+
+ loadKeyboard(context, xmlLayoutResId);
}
public int getProximityInfo() {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
index c2db62a1c..07166b1db 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
@@ -16,12 +16,6 @@
package com.android.inputmethod.keyboard;
-import com.android.inputmethod.compat.EditorInfoCompatUtils;
-import com.android.inputmethod.latin.R;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -31,6 +25,12 @@ import android.util.TypedValue;
import android.util.Xml;
import android.view.InflateException;
+import com.android.inputmethod.compat.EditorInfoCompatUtils;
+import com.android.inputmethod.latin.R;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 8e9c7ef7e..50c61ffae 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -202,7 +202,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
final Locale savedLocale = Utils.setSystemLocale(res,
mSubtypeSwitcher.getInputLocale());
- keyboard = new LatinKeyboard(mInputMethodService, id, id.mWidth);
+ final Context themeContext = new ContextThemeWrapper(mInputMethodService,
+ KEYBOARD_THEMES[mThemeIndex]);
+ keyboard = new LatinKeyboard(themeContext, id, id.mWidth);
if (id.mEnableShiftLock) {
keyboard.enableShiftLock();
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index f8bce40b1..71826346b 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -16,9 +16,6 @@
package com.android.inputmethod.keyboard;
-import com.android.inputmethod.latin.LatinImeLogger;
-import com.android.inputmethod.latin.R;
-
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -50,6 +47,9 @@ import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
+import com.android.inputmethod.latin.LatinImeLogger;
+import com.android.inputmethod.latin.R;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.WeakHashMap;
@@ -176,10 +176,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private final float KEY_LABEL_VERTICAL_ADJUSTMENT_FACTOR_CENTER = 0.45f;
private final float KEY_LABEL_VERTICAL_PADDING_FACTOR = 1.60f;
private final String KEY_LABEL_REFERENCE_CHAR = "H";
- private final int KEY_LABEL_OPTION_ALIGN_LEFT = 1;
- private final int KEY_LABEL_OPTION_ALIGN_RIGHT = 2;
- private final int KEY_LABEL_OPTION_ALIGN_BOTTOM = 8;
- private final int KEY_LABEL_OPTION_FONT_NORMAL = 16;
+ private final int KEY_LABEL_OPTION_ALIGN_LEFT = 0x01;
+ private final int KEY_LABEL_OPTION_ALIGN_RIGHT = 0x02;
+ private final int KEY_LABEL_OPTION_ALIGN_BOTTOM = 0x08;
+ private final int KEY_LABEL_OPTION_FONT_NORMAL = 0x10;
+ private final int KEY_LABEL_OPTION_POPUP_HINT = 0x20;
private final int mKeyLabelHorizontalPadding;
private final UIHandler mHandler = new UIHandler();
@@ -333,6 +334,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mKeyLetterStyle = Typeface.defaultFromStyle(
a.getInt(R.styleable.KeyboardView_keyLetterStyle, Typeface.NORMAL));
mColorScheme = a.getInt(R.styleable.KeyboardView_colorScheme, COLOR_SCHEME_WHITE);
+ a.recycle();
final Resources res = getResources();
@@ -762,14 +764,15 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
}
// Draw hint icon.
- if (key.mHintIcon != null) {
+ if (key.mHintIcon != null || (key.mLabelOption & KEY_LABEL_OPTION_POPUP_HINT) != 0) {
final int drawableWidth = keyDrawWidth;
final int drawableHeight = key.mHeight;
final int drawableX = 0;
final int drawableY = HINT_ICON_VERTICAL_ADJUSTMENT_PIXEL;
Drawable hintIcon = (isManualTemporaryUpperCase
&& key.mManualTemporaryUpperCaseHintIcon != null)
- ? key.mManualTemporaryUpperCaseHintIcon : key.mHintIcon;
+ ? key.mManualTemporaryUpperCaseHintIcon
+ : (key.mHintIcon != null ? key.mHintIcon : mKeyboard.mPopupHintIcon);
drawIcon(canvas, hintIcon, drawableX, drawableY, drawableWidth, drawableHeight);
if (DEBUG_SHOW_ALIGN)
drawRectangle(canvas, drawableX, drawableY, drawableWidth, drawableHeight,
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
index fe27ab412..a6ac76751 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
@@ -57,9 +57,9 @@ public class LatinKeyboard extends Keyboard {
private final Drawable mSpaceIcon;
private final Drawable mSpacePreviewIcon;
private final int mSpaceKeyIndex;
- private final Drawable mSpaceAutoCorrectionIndicator;
- private final Drawable mButtonArrowLeftIcon;
- private final Drawable mButtonArrowRightIcon;
+ private final Drawable mAutoCorrectionSpacebarLedIcon;
+ private final Drawable mSpacebarArrowLeftIcon;
+ private final Drawable mSpacebarArrowRightIcon;
private final int mSpacebarTextColor;
private final int mSpacebarTextShadowColor;
private float mSpacebarTextFadeFactor = 0.0f;
@@ -90,7 +90,6 @@ public class LatinKeyboard extends Keyboard {
public LatinKeyboard(Context context, KeyboardId id, int width) {
super(context, id.getXmlId(), id, width);
- final Resources res = context.getResources();
mContext = context;
final List<Key> keys = getKeys();
@@ -118,19 +117,20 @@ public class LatinKeyboard extends Keyboard {
mShortcutKey = (shortcutKeyIndex >= 0) ? keys.get(shortcutKeyIndex) : null;
mEnabledShortcutIcon = (mShortcutKey != null) ? mShortcutKey.getIcon() : null;
- mSpacebarTextColor = res.getColor(R.color.latinkeyboard_bar_language_text);
- if (id.mColorScheme == KeyboardView.COLOR_SCHEME_BLACK) {
- mSpacebarTextShadowColor = res.getColor(
- R.color.latinkeyboard_bar_language_shadow_black);
- mDisabledShortcutIcon = res.getDrawable(R.drawable.sym_bkeyboard_voice_off);
- } else { // default color scheme is KeyboardView.COLOR_SCHEME_WHITE
- mSpacebarTextShadowColor = res.getColor(
- R.color.latinkeyboard_bar_language_shadow_white);
- mDisabledShortcutIcon = res.getDrawable(R.drawable.sym_keyboard_voice_off_holo);
- }
- mSpaceAutoCorrectionIndicator = res.getDrawable(R.drawable.sym_keyboard_space_led);
- mButtonArrowLeftIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_left);
- mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right);
+ final TypedArray a = context.obtainStyledAttributes(
+ null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
+ mAutoCorrectionSpacebarLedIcon = a.getDrawable(
+ R.styleable.LatinKeyboard_autoCorrectionSpacebarLedIcon);
+ mDisabledShortcutIcon = a.getDrawable(R.styleable.LatinKeyboard_disabledShortcutIcon);
+ mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0);
+ mSpacebarTextShadowColor = a.getColor(
+ R.styleable.LatinKeyboard_spacebarTextShadowColor, 0);
+ mSpacebarArrowLeftIcon = a.getDrawable(
+ R.styleable.LatinKeyboard_spacebarArrowLeftIcon);
+ mSpacebarArrowRightIcon = a.getDrawable(
+ R.styleable.LatinKeyboard_spacebarArrowRightIcon);
+ a.recycle();
+
// The threshold is "key width" x 1.25
mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4;
}
@@ -163,6 +163,10 @@ public class LatinKeyboard extends Keyboard {
view.invalidateKey(mShortcutKey);
}
+ public boolean needsAutoCorrectionSpacebarLed() {
+ return mAutoCorrectionSpacebarLedIcon != null;
+ }
+
/**
* @return a key which should be invalidated.
*/
@@ -282,7 +286,7 @@ public class LatinKeyboard extends Keyboard {
}
final String language = layoutSpacebar(paint, inputLocale,
- mButtonArrowLeftIcon, mButtonArrowRightIcon, width, height,
+ mSpacebarArrowLeftIcon, mSpacebarArrowRightIcon, width, height,
getTextSizeFromTheme(mContext.getTheme(), textStyle, defaultTextSize));
// Draw language text with shadow
@@ -303,21 +307,21 @@ public class LatinKeyboard extends Keyboard {
if (mSubtypeSwitcher.useSpacebarLanguageSwitcher()
&& mSubtypeSwitcher.getEnabledKeyboardLocaleCount() > 1
&& !(isPhoneKeyboard() || isNumberKeyboard())) {
- mButtonArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor));
- mButtonArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor));
- mButtonArrowLeftIcon.draw(canvas);
- mButtonArrowRightIcon.draw(canvas);
+ mSpacebarArrowLeftIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor));
+ mSpacebarArrowRightIcon.setColorFilter(getSpacebarDrawableFilter(textFadeFactor));
+ mSpacebarArrowLeftIcon.draw(canvas);
+ mSpacebarArrowRightIcon.draw(canvas);
}
}
// Draw the spacebar icon at the bottom
if (isAutoCorrection) {
final int iconWidth = width * SPACE_LED_LENGTH_PERCENT / 100;
- final int iconHeight = mSpaceAutoCorrectionIndicator.getIntrinsicHeight();
+ final int iconHeight = mAutoCorrectionSpacebarLedIcon.getIntrinsicHeight();
int x = (width - iconWidth) / 2;
int y = height - iconHeight;
- mSpaceAutoCorrectionIndicator.setBounds(x, y, x + iconWidth, y + iconHeight);
- mSpaceAutoCorrectionIndicator.draw(canvas);
+ mAutoCorrectionSpacebarLedIcon.setBounds(x, y, x + iconWidth, y + iconHeight);
+ mAutoCorrectionSpacebarLedIcon.draw(canvas);
} else if (mSpaceIcon != null) {
final int iconWidth = mSpaceIcon.getIntrinsicWidth();
final int iconHeight = mSpaceIcon.getIntrinsicHeight();
diff --git a/java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java b/java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java
index 5cf31cb14..a20bf1cd3 100644
--- a/java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java
+++ b/java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java
@@ -16,22 +16,21 @@
package com.android.inputmethod.keyboard;
-import com.android.inputmethod.latin.R;
-import com.android.inputmethod.latin.SubtypeSwitcher;
-
import android.content.Context;
-import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
-import android.graphics.PixelFormat;
import android.graphics.Paint.Align;
+import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.view.ViewConfiguration;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.SubtypeSwitcher;
+
/**
* Animation to be displayed on the spacebar preview popup when switching languages by swiping the
* spacebar. It draws the current, previous and next languages and moves them by the delta of touch
@@ -39,16 +38,16 @@ import android.view.ViewConfiguration;
*/
public class SlidingLocaleDrawable extends Drawable {
private static final int SLIDE_SPEED_MULTIPLIER_RATIO = 150;
- private final Context mContext;
- private final Resources mRes;
private final int mWidth;
private final int mHeight;
private final Drawable mBackground;
+ private final int mSpacebarTextColor;
private final TextPaint mTextPaint;
private final int mMiddleX;
private final Drawable mLeftDrawable;
private final Drawable mRightDrawable;
private final int mThreshold;
+
private int mDiff;
private boolean mHitThreshold;
private String mCurrentLanguage;
@@ -56,29 +55,31 @@ public class SlidingLocaleDrawable extends Drawable {
private String mPrevLanguage;
public SlidingLocaleDrawable(Context context, Drawable background, int width, int height) {
- mContext = context;
- mRes = context.getResources();
mBackground = background;
Keyboard.setDefaultBounds(mBackground);
mWidth = width;
mHeight = height;
final TextPaint textPaint = new TextPaint();
- textPaint.setTextSize(getTextSizeFromTheme(android.R.style.TextAppearance_Medium, 18));
+ textPaint.setTextSize(getTextSizeFromTheme(
+ context, android.R.style.TextAppearance_Medium, 18));
textPaint.setColor(Color.TRANSPARENT);
textPaint.setTextAlign(Align.CENTER);
textPaint.setAntiAlias(true);
mTextPaint = textPaint;
mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2;
- final Resources res = mRes;
- mLeftDrawable = res.getDrawable(
- R.drawable.sym_keyboard_feedback_language_arrows_left);
- mRightDrawable = res.getDrawable(
- R.drawable.sym_keyboard_feedback_language_arrows_right);
- mThreshold = ViewConfiguration.get(mContext).getScaledTouchSlop();
+
+ final TypedArray a = context.obtainStyledAttributes(
+ null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
+ mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboard_spacebarTextColor, 0);
+ mLeftDrawable = a.getDrawable(R.styleable.LatinKeyboard_spacebarArrowPreviewLeftIcon);
+ mRightDrawable = a.getDrawable(R.styleable.LatinKeyboard_spacebarArrowPreviewRightIcon);
+ a.recycle();
+
+ mThreshold = ViewConfiguration.get(context).getScaledTouchSlop();
}
- private int getTextSizeFromTheme(int style, int defValue) {
- TypedArray array = mContext.getTheme().obtainStyledAttributes(
+ private static int getTextSizeFromTheme(Context context, int style, int defValue) {
+ TypedArray array = context.getTheme().obtainStyledAttributes(
style, new int[] { android.R.attr.textSize });
int textSize = array.getDimensionPixelSize(array.getResourceId(0, 0), defValue);
return textSize;
@@ -118,7 +119,7 @@ public class SlidingLocaleDrawable extends Drawable {
// Draw language text with shadow
final float baseline = mHeight * LatinKeyboard.SPACEBAR_LANGUAGE_BASELINE
- paint.descent();
- paint.setColor(mRes.getColor(R.color.latinkeyboard_feedback_language_text));
+ paint.setColor(mSpacebarTextColor);
canvas.drawText(mCurrentLanguage, width / 2 + diff, baseline, paint);
canvas.drawText(mNextLanguage, diff - width / 2, baseline, paint);
canvas.drawText(mPrevLanguage, diff + width + width / 2, baseline, paint);
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index 481092c92..2a29e1f8f 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.latin;
import android.content.Context;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Handler;
@@ -38,6 +39,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
@@ -64,8 +66,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private static final boolean DBG = LatinImeLogger.sDBG;
private static final int NUM_CANDIDATES_IN_STRIP = 3;
- private final View mExpandCandidatesPane;
- private final View mCloseCandidatesPane;
+ private final ImageView mExpandCandidatesPane;
+ private final ImageView mCloseCandidatesPane;
private ViewGroup mCandidatesPane;
private ViewGroup mCandidatesPaneContainer;
private View mKeyboardView;
@@ -73,9 +75,12 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private final ArrayList<View> mDividers = new ArrayList<View>();
private final int mCandidatePadding;
private final int mCandidateStripHeight;
- private final boolean mConfigCandidateHighlightFontColorEnabled;
private final CharacterStyle mInvertedForegroundColorSpan;
private final CharacterStyle mInvertedBackgroundColorSpan;
+ private final int mAutoCorrectHighlight;
+ private static final int AUTO_CORRECT_BOLD = 0x01;
+ private static final int AUTO_CORRECT_UNDERLINE = 0x02;
+ private static final int AUTO_CORRECT_INVERT = 0x04;
private final int mColorTypedWord;
private final int mColorAutoCorrect;
private final int mColorSuggestedCandidate;
@@ -139,7 +144,11 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
* @param attrs
*/
public CandidateView(Context context, AttributeSet attrs) {
- super(context, attrs);
+ this(context, attrs, R.attr.candidateViewStyle);
+ }
+
+ public CandidateView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
Resources res = context.getResources();
LayoutInflater inflater = LayoutInflater.from(context);
@@ -151,13 +160,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
ViewGroup.LayoutParams.WRAP_CONTENT);
mPreviewPopup.setContentView(mPreviewText);
mPreviewPopup.setBackgroundDrawable(null);
- mConfigCandidateHighlightFontColorEnabled =
- res.getBoolean(R.bool.config_candidate_highlight_font_color_enabled);
- mColorTypedWord = res.getColor(R.color.candidate_typed_word);
- mColorAutoCorrect = res.getColor(R.color.candidate_auto_correct);
- mColorSuggestedCandidate = res.getColor(R.color.candidate_suggested);
- mInvertedForegroundColorSpan = new ForegroundColorSpan(mColorTypedWord ^ 0x00ffffff);
- mInvertedBackgroundColorSpan = new BackgroundColorSpan(mColorTypedWord);
mCandidatePadding = res.getDimensionPixelOffset(R.dimen.candidate_padding);
mCandidateStripHeight = res.getDimensionPixelOffset(R.dimen.candidate_strip_height);
@@ -192,20 +194,35 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
}
- mExpandCandidatesPane = findViewById(R.id.expand_candidates_pane);
+ final TypedArray a = context.obtainStyledAttributes(
+ attrs, R.styleable.CandidateView, defStyle, R.style.CandidateViewStyle);
+ mAutoCorrectHighlight = a.getInt(R.styleable.CandidateView_autoCorrectHighlight, 0);
+ mColorTypedWord = a.getColor(R.styleable.CandidateView_colorTypedWord, 0);
+ mColorAutoCorrect = a.getColor(R.styleable.CandidateView_colorAutoCorrect, 0);
+ mColorSuggestedCandidate = a.getColor(R.styleable.CandidateView_colorSuggested, 0);
+ mInvertedForegroundColorSpan = new ForegroundColorSpan(mColorTypedWord ^ 0x00ffffff);
+ mInvertedBackgroundColorSpan = new BackgroundColorSpan(mColorTypedWord);
+
+ mExpandCandidatesPane = (ImageView)findViewById(R.id.expand_candidates_pane);
+ mExpandCandidatesPane.setImageDrawable(
+ a.getDrawable(R.styleable.CandidateView_iconExpandPane));
mExpandCandidatesPane.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
expandCandidatesPane();
}
});
- mCloseCandidatesPane = findViewById(R.id.close_candidates_pane);
+ mCloseCandidatesPane = (ImageView)findViewById(R.id.close_candidates_pane);
+ mCloseCandidatesPane.setImageDrawable(
+ a.getDrawable(R.styleable.CandidateView_iconClosePane));
mCloseCandidatesPane.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
closeCandidatesPane();
}
});
+
+ a.recycle();
}
/**
@@ -244,19 +261,20 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private CharSequence getStyledCandidateWord(CharSequence word, boolean isAutoCorrect) {
if (!isAutoCorrect)
return word;
- final CharacterStyle style = mConfigCandidateHighlightFontColorEnabled ? BOLD_SPAN
- : UNDERLINE_SPAN;
final Spannable spannedWord = new SpannableString(word);
- spannedWord.setSpan(style, 0, word.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ if ((mAutoCorrectHighlight & AUTO_CORRECT_BOLD) != 0)
+ spannedWord.setSpan(BOLD_SPAN, 0, word.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+ if ((mAutoCorrectHighlight & AUTO_CORRECT_UNDERLINE) != 0)
+ spannedWord.setSpan(UNDERLINE_SPAN, 0, word.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
return spannedWord;
}
private int getCandidateTextColor(boolean isAutoCorrect, boolean isSuggestedCandidate,
SuggestedWordInfo info) {
final int color;
- if (isAutoCorrect && mConfigCandidateHighlightFontColorEnabled) {
+ if (isAutoCorrect) {
color = mColorAutoCorrect;
- } else if (isSuggestedCandidate && mConfigCandidateHighlightFontColorEnabled) {
+ } else if (isSuggestedCandidate) {
color = mColorSuggestedCandidate;
} else {
color = mColorTypedWord;
@@ -388,9 +406,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
public void onAutoCorrectionInverted(CharSequence autoCorrectedWord) {
- // Displaying auto corrected word as inverted is enabled only when highlighting candidate
- // with color is disabled.
- if (mConfigCandidateHighlightFontColorEnabled)
+ if ((mAutoCorrectHighlight & AUTO_CORRECT_INVERT) == 0)
return;
final TextView tv = mWords.get(1);
final Spannable word = new SpannableString(autoCorrectedWord);
@@ -403,10 +419,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mShowingAutoCorrectionInverted = true;
}
- public boolean isConfigCandidateHighlightFontColorEnabled() {
- return mConfigCandidateHighlightFontColorEnabled;
- }
-
public boolean isShowingAddToDictionaryHint() {
return mShowingAddToDictionary;
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 75bca9937..87912eb00 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1464,7 +1464,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (mCandidateView != null) {
mCandidateView.setSuggestions(words);
- if (mCandidateView.isConfigCandidateHighlightFontColorEnabled()) {
+ if (mKeyboardSwitcher.getLatinKeyboard().needsAutoCorrectionSpacebarLed()) {
mKeyboardSwitcher.onAutoCorrectionStateChanged(
words.hasWordAboveAutoCorrectionScoreThreshold());
}