aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/BaseKeyboard.java3
-rw-r--r--java/src/com/android/inputmethod/latin/BaseKeyboardView.java51
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java21
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIMESettings.java39
4 files changed, 58 insertions, 56 deletions
diff --git a/java/src/com/android/inputmethod/latin/BaseKeyboard.java b/java/src/com/android/inputmethod/latin/BaseKeyboard.java
index 00ed453c4..e2331f334 100644
--- a/java/src/com/android/inputmethod/latin/BaseKeyboard.java
+++ b/java/src/com/android/inputmethod/latin/BaseKeyboard.java
@@ -537,7 +537,8 @@ public class BaseKeyboard {
column = 0;
}
final Key key = new Key(row);
- key.x = x;
+ // Horizontal gap is divided equally to both sides of the key.
+ key.x = x + key.gap / 2;
key.y = y;
key.label = String.valueOf(c);
key.codes = new int[] { c };
diff --git a/java/src/com/android/inputmethod/latin/BaseKeyboardView.java b/java/src/com/android/inputmethod/latin/BaseKeyboardView.java
index 954f264bd..3193cd46e 100644
--- a/java/src/com/android/inputmethod/latin/BaseKeyboardView.java
+++ b/java/src/com/android/inputmethod/latin/BaseKeyboardView.java
@@ -170,9 +170,10 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
private static final int HINT_ICON_VERTICAL_ADJUSTMENT_PIXEL = -1;
// XML attribute
- private int mKeyTextSize;
+ private int mKeyLetterSize;
private int mKeyTextColor;
- private Typeface mKeyTextStyle = Typeface.DEFAULT;
+ private int mKeyTextColorDisabled;
+ private Typeface mKeyLetterStyle = Typeface.DEFAULT;
private int mLabelTextSize;
private int mColorScheme = COLOR_SCHEME_WHITE;
private int mShadowColor;
@@ -455,12 +456,15 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
case R.styleable.BaseKeyboardView_keyPreviewHeight:
mPreviewHeight = a.getDimensionPixelSize(attr, 80);
break;
- case R.styleable.BaseKeyboardView_keyTextSize:
- mKeyTextSize = a.getDimensionPixelSize(attr, 18);
+ case R.styleable.BaseKeyboardView_keyLetterSize:
+ mKeyLetterSize = a.getDimensionPixelSize(attr, 18);
break;
case R.styleable.BaseKeyboardView_keyTextColor:
mKeyTextColor = a.getColor(attr, 0xFF000000);
break;
+ case R.styleable.BaseKeyboardView_keyTextColorDisabled:
+ mKeyTextColorDisabled = a.getColor(attr, 0xFF000000);
+ break;
case R.styleable.BaseKeyboardView_labelTextSize:
mLabelTextSize = a.getDimensionPixelSize(attr, 14);
break;
@@ -477,20 +481,8 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
case R.styleable.BaseKeyboardView_backgroundDimAmount:
mBackgroundDimAmount = a.getFloat(attr, 0.5f);
break;
- //case android.R.styleable.
- case R.styleable.BaseKeyboardView_keyTextStyle:
- int textStyle = a.getInt(attr, 0);
- switch (textStyle) {
- case 0:
- mKeyTextStyle = Typeface.DEFAULT;
- break;
- case 1:
- mKeyTextStyle = Typeface.DEFAULT_BOLD;
- break;
- default:
- mKeyTextStyle = Typeface.defaultFromStyle(textStyle);
- break;
- }
+ case R.styleable.BaseKeyboardView_keyLetterStyle:
+ mKeyLetterStyle = Typeface.defaultFromStyle(a.getInt(attr, Typeface.NORMAL));
break;
case R.styleable.BaseKeyboardView_colorScheme:
mColorScheme = a.getInt(attr, COLOR_SCHEME_WHITE);
@@ -787,7 +779,6 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
final boolean isManualTemporaryUpperCase = (mKeyboard instanceof LatinKeyboard
&& ((LatinKeyboard)mKeyboard).isManualTemporaryUpperCase());
- paint.setColor(mKeyTextColor);
boolean drawSingleKey = false;
if (invalidKey != null && canvas.getClipBounds(clipRegion)) {
// TODO we should use Rect.inset and Rect.contains here.
@@ -820,7 +811,6 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
keyBackground.draw(canvas);
final int rowHeight = padding.top + key.height;
- boolean drawHintIcon = true;
// Draw key label
if (label != null) {
// For characters, use large font. For labels like "Done", use small font.
@@ -858,6 +848,11 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
if (DEBUG_SHOW_ALIGN && label.length() > 1)
drawVerticalLine(canvas, positionX, rowHeight, 0xc0008080, new Paint());
}
+ if (key.manualTemporaryUpperCaseHintIcon != null && isManualTemporaryUpperCase) {
+ paint.setColor(mKeyTextColorDisabled);
+ } else {
+ paint.setColor(mKeyTextColor);
+ }
// Set a drop shadow for the text
paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
canvas.drawText(label, positionX, baseline, paint);
@@ -892,7 +887,7 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
drawRectangle(canvas, drawableX, drawableY, drawableWidth, drawableHeight,
0x80c00000, new Paint());
}
- if (key.hintIcon != null && drawHintIcon) {
+ if (key.hintIcon != null) {
final int drawableWidth = key.width;
final int drawableHeight = key.height;
final int drawableX = 0;
@@ -954,18 +949,20 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
private int getLabelSizeAndSetPaint(CharSequence label, Key key, Paint paint) {
// For characters, use large font. For labels like "Done", use small font.
final int labelSize;
+ final Typeface labelStyle;
if (label.length() > 1 && key.codes.length < 2) {
labelSize = mLabelTextSize;
if ((key.labelOption & KEY_LABEL_OPTION_FONT_NORMAL) != 0) {
- paint.setTypeface(Typeface.DEFAULT);
+ labelStyle = Typeface.DEFAULT;
} else {
- paint.setTypeface(Typeface.DEFAULT_BOLD);
+ labelStyle = Typeface.DEFAULT_BOLD;
}
} else {
- labelSize = mKeyTextSize;
- paint.setTypeface(mKeyTextStyle);
+ labelSize = mKeyLetterSize;
+ labelStyle = mKeyLetterStyle;
}
paint.setTextSize(labelSize);
+ paint.setTypeface(labelStyle);
return labelSize;
}
@@ -1061,11 +1058,11 @@ public class BaseKeyboardView extends View implements PointerTracker.UIProxy {
mPreviewText.setCompoundDrawables(null, null, null, null);
mPreviewText.setText(adjustCase(tracker.getPreviewText(key)));
if (key.label.length() > 1 && key.codes.length < 2) {
- mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
+ mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyLetterSize);
mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
} else {
mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
- mPreviewText.setTypeface(mKeyTextStyle);
+ mPreviewText.setTypeface(mKeyLetterStyle);
}
} else {
mPreviewText.setCompoundDrawables(null, null, null,
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 4e02f84d9..95c773855 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -45,7 +45,6 @@ public class BinaryDictionary extends Dictionary {
private static final int MAX_BIGRAMS = 60;
private static final int TYPED_LETTER_MULTIPLIER = 2;
- private static final boolean ENABLE_MISSED_CHARACTERS = true;
private int mDicTypeId;
private int mNativeDict;
@@ -199,27 +198,11 @@ public class BinaryDictionary extends Dictionary {
Arrays.fill(mOutputChars, (char) 0);
Arrays.fill(mFrequencies, 0);
- int count = getSuggestionsNative(mNativeDict, mInputCodes, codesSize,
- mOutputChars, mFrequencies,
- MAX_WORD_LENGTH, MAX_WORDS, MAX_ALTERNATIVES, -1,
+ int count = getSuggestionsNative(mNativeDict, mInputCodes, codesSize, mOutputChars,
+ mFrequencies, MAX_WORD_LENGTH, MAX_WORDS, MAX_ALTERNATIVES, -1,
nextLettersFrequencies,
nextLettersFrequencies != null ? nextLettersFrequencies.length : 0);
- // If there aren't sufficient suggestions, search for words by allowing wild cards at
- // the different character positions. This feature is not ready for prime-time as we need
- // to figure out the best ranking for such words compared to proximity corrections and
- // completions.
- if (ENABLE_MISSED_CHARACTERS && count < 5) {
- for (int skip = 0; skip < codesSize; skip++) {
- int tempCount = getSuggestionsNative(mNativeDict, mInputCodes, codesSize,
- mOutputChars, mFrequencies,
- MAX_WORD_LENGTH, MAX_WORDS, MAX_ALTERNATIVES, skip,
- null, 0);
- count = Math.max(count, tempCount);
- if (tempCount > 0) break;
- }
- }
-
for (int j = 0; j < count; j++) {
if (mFrequencies[j] < 1) break;
int start = j * MAX_WORD_LENGTH;
diff --git a/java/src/com/android/inputmethod/latin/LatinIMESettings.java b/java/src/com/android/inputmethod/latin/LatinIMESettings.java
index 669192f59..ae6646113 100644
--- a/java/src/com/android/inputmethod/latin/LatinIMESettings.java
+++ b/java/src/com/android/inputmethod/latin/LatinIMESettings.java
@@ -32,7 +32,10 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.speech.SpeechRecognizer;
import android.text.AutoText;
+import android.text.TextUtils;
+import android.text.method.LinkMovementMethod;
import android.util.Log;
+import android.widget.TextView;
import java.util.Locale;
@@ -60,6 +63,8 @@ public class LatinIMESettings extends PreferenceActivity
private CheckBoxPreference mBigramSuggestion;
private boolean mVoiceOn;
+ private AlertDialog mDialog;
+
private VoiceInputLogger mLogger;
private boolean mOkClicked = false;
@@ -91,8 +96,15 @@ public class LatinIMESettings extends PreferenceActivity
final boolean showSettingsKeyOption = getResources().getBoolean(
R.bool.config_enable_show_settings_key_option);
- if (!showSettingsKeyOption)
+ if (!showSettingsKeyOption) {
getPreferenceScreen().removePreference(mSettingsKeyPreference);
+ }
+
+ final boolean showVoiceKeyOption = getResources().getBoolean(
+ R.bool.config_enable_show_voice_key_option);
+ if (!showVoiceKeyOption) {
+ getPreferenceScreen().removePreference(mVoicePreference);
+ }
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
if (vibrator == null || !vibrator.hasVibrator()) {
@@ -149,6 +161,13 @@ public class LatinIMESettings extends PreferenceActivity
private void showVoiceConfirmation() {
mOkClicked = false;
showDialog(VOICE_INPUT_CONFIRM_DIALOG);
+ // Make URL in the dialog message clickable
+ if (mDialog != null) {
+ TextView textView = (TextView) mDialog.findViewById(android.R.id.message);
+ if (textView != null) {
+ textView.setMovementMethod(LinkMovementMethod.getInstance());
+ }
+ }
}
private void updateVoiceModeSummary() {
@@ -184,18 +203,20 @@ public class LatinIMESettings extends PreferenceActivity
boolean localeSupported = SubtypeSwitcher.getInstance().isVoiceSupported(
Locale.getDefault().toString());
+ final CharSequence message;
if (localeSupported) {
- String message = getString(R.string.voice_warning_may_not_understand) + "\n\n" +
- getString(R.string.voice_hint_dialog_message);
- builder.setMessage(message);
+ message = TextUtils.concat(
+ getText(R.string.voice_warning_may_not_understand), "\n\n",
+ getText(R.string.voice_hint_dialog_message));
} else {
- String message = getString(R.string.voice_warning_locale_not_supported) +
- "\n\n" + getString(R.string.voice_warning_may_not_understand) + "\n\n" +
- getString(R.string.voice_hint_dialog_message);
- builder.setMessage(message);
+ message = TextUtils.concat(
+ getText(R.string.voice_warning_locale_not_supported), "\n\n",
+ getText(R.string.voice_warning_may_not_understand), "\n\n",
+ getText(R.string.voice_hint_dialog_message));
}
-
+ builder.setMessage(message);
AlertDialog dialog = builder.create();
+ mDialog = dialog;
dialog.setOnDismissListener(this);
mLogger.settingsWarningDialogShown();
return dialog;