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/BinaryDictionary.java8
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java54
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java6
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java81
-rw-r--r--java/src/com/android/inputmethod/latin/settings/Settings.java32
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsValues.java4
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SpacingAndPunctuations.java5
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java5
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java5
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java13
10 files changed, 126 insertions, 87 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 544fd0319..0aa34e82e 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -161,9 +161,9 @@ public final class BinaryDictionary extends Dictionary {
private static native int getNextWordNative(long dict, int token, int[] outCodePoints);
private static native void getSuggestionsNative(long dict, long proximityInfo,
long traverseSession, int[] xCoordinates, int[] yCoordinates, int[] times,
- int[] pointerIds, int[] inputCodePoints, int inputSize, int commitPoint,
- int[] suggestOptions, int[] prevWordCodePointArray, int[] outputSuggestionCount,
- int[] outputCodePoints, int[] outputScores, int[] outputIndices, int[] outputTypes,
+ int[] pointerIds, int[] inputCodePoints, int inputSize, int[] suggestOptions,
+ int[] prevWordCodePointArray, int[] outputSuggestionCount, int[] outputCodePoints,
+ int[] outputScores, int[] outputIndices, int[] outputTypes,
int[] outputAutoCommitFirstWordConfidence);
private static native void addUnigramWordNative(long dict, int[] word, int probability,
int[] shortcutTarget, int shortcutProbability, boolean isNotAWord,
@@ -262,7 +262,7 @@ public final class BinaryDictionary extends Dictionary {
getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(),
getTraverseSession(sessionId).getSession(), ips.getXCoordinates(),
ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), mInputCodePoints,
- inputSize, 0 /* commitPoint */, mNativeSuggestOptions.getOptions(),
+ inputSize, mNativeSuggestOptions.getOptions(),
prevWordCodePointArray, mOutputSuggestionCount, mOutputCodePoints, mOutputScores,
mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence);
final int count = mOutputSuggestionCount[0];
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 4a18c2b3c..38e386493 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -169,8 +169,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private int mDelayUpdateSuggestions;
private int mDelayUpdateShiftState;
- private long mDoubleSpacePeriodTimeout;
- private long mDoubleSpacePeriodTimerStart;
public UIHandler(final LatinIME ownerInstance) {
super(ownerInstance);
@@ -184,8 +182,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final Resources res = latinIme.getResources();
mDelayUpdateSuggestions = res.getInteger(R.integer.config_delay_update_suggestions);
mDelayUpdateShiftState = res.getInteger(R.integer.config_delay_update_shift_state);
- mDoubleSpacePeriodTimeout =
- res.getInteger(R.integer.config_double_space_period_timeout);
}
@Override
@@ -286,10 +282,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
sendMessageDelayed(obtainMessage(MSG_UPDATE_SHIFT_STATE), mDelayUpdateShiftState);
}
- public void cancelUpdateShiftState() {
- removeMessages(MSG_UPDATE_SHIFT_STATE);
- }
-
@UsedForTesting
public void removeAllMessages() {
for (int i = 0; i <= MSG_LAST; ++i) {
@@ -317,19 +309,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
obtainMessage(MSG_ON_END_BATCH_INPUT, suggestedWords).sendToTarget();
}
- public void startDoubleSpacePeriodTimer() {
- mDoubleSpacePeriodTimerStart = SystemClock.uptimeMillis();
- }
-
- public void cancelDoubleSpacePeriodTimer() {
- mDoubleSpacePeriodTimerStart = 0;
- }
-
- public boolean isAcceptingDoubleSpacePeriod() {
- return SystemClock.uptimeMillis() - mDoubleSpacePeriodTimerStart
- < mDoubleSpacePeriodTimeout;
- }
-
// Working variables for the following methods.
private boolean mIsOrientationChanging;
private boolean mPendingSuccessiveImsCallback;
@@ -885,7 +864,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
setNeutralSuggestionStrip();
mHandler.cancelUpdateSuggestionStrip();
- mHandler.cancelDoubleSpacePeriodTimer();
mainKeyboardView.setMainDictionaryAvailability(null != suggest
? suggest.mDictionaryFacilitator.hasMainDictionary() : false);
@@ -1276,15 +1254,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final InputTransaction completeInputTransaction =
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
- switch (completeInputTransaction.getRequiredShiftUpdate()) {
- case InputTransaction.SHIFT_UPDATE_LATER:
- mHandler.postUpdateShiftState();
- break;
- case InputTransaction.SHIFT_UPDATE_NOW:
- mKeyboardSwitcher.updateShiftState();
- break;
- default: // SHIFT_NO_UPDATE
- }
+ updateShiftModeAfterInputTransaction(completeInputTransaction.getRequiredShiftUpdate());
mKeyboardSwitcher.onCodeInput(codePoint);
}
@@ -1307,7 +1277,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Called from PointerTracker through the KeyboardActionListener interface
@Override
public void onTextInput(final String rawText) {
- mInputLogic.onTextInput(mSettings.getCurrent(), rawText, mHandler);
+ // TODO: have the keyboard pass the correct key code when we need it.
+ final Event event = Event.createSoftwareTextEvent(rawText, Event.NOT_A_KEY_CODE);
+ mInputLogic.onTextInput(mSettings.getCurrent(), event, mHandler);
mKeyboardSwitcher.updateShiftState();
mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT);
}
@@ -1500,8 +1472,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// interface
@Override
public void pickSuggestionManually(final int index, final SuggestedWordInfo suggestionInfo) {
- mInputLogic.onPickSuggestionManually(mSettings.getCurrent(), index, suggestionInfo,
- mHandler, mKeyboardSwitcher);
+ final InputTransaction completeInputTransaction = mInputLogic.onPickSuggestionManually(
+ mSettings.getCurrent(), index, suggestionInfo,
+ mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
+ updateShiftModeAfterInputTransaction(completeInputTransaction.getRequiredShiftUpdate());
}
@Override
@@ -1539,6 +1513,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
+ private void updateShiftModeAfterInputTransaction(final int requiredShiftUpdate) {
+ switch (requiredShiftUpdate) {
+ case InputTransaction.SHIFT_UPDATE_LATER:
+ mHandler.postUpdateShiftState();
+ break;
+ case InputTransaction.SHIFT_UPDATE_NOW:
+ mKeyboardSwitcher.updateShiftState();
+ break;
+ default: // SHIFT_NO_UPDATE
+ }
+ }
+
private void hapticAndAudioFeedback(final int code, final int repeatCount) {
final MainKeyboardView keyboardView = mKeyboardSwitcher.getMainKeyboardView();
if (keyboardView != null && keyboardView.isInDraggingFinger()) {
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 2ac11aa29..29382fea4 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -16,6 +16,7 @@
package com.android.inputmethod.latin;
+import com.android.inputmethod.event.CombinerChain;
import com.android.inputmethod.event.Event;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils;
@@ -40,6 +41,8 @@ public final class WordComposer {
public static final int CAPS_MODE_AUTO_SHIFTED = 0x5;
public static final int CAPS_MODE_AUTO_SHIFT_LOCKED = 0x7;
+ private CombinerChain mCombinerChain;
+
// An array of code points representing the characters typed so far.
// The array is limited to MAX_WORD_LENGTH code points, but mTypedWord extends past that
// and mCodePointSize can go past that. If mCodePointSize is greater than MAX_WORD_LENGTH,
@@ -87,6 +90,7 @@ public final class WordComposer {
private boolean mIsFirstCharCapitalized;
public WordComposer() {
+ mCombinerChain = new CombinerChain();
mPrimaryKeyCodes = new int[MAX_WORD_LENGTH];
mEvents = CollectionUtils.newArrayList();
mTypedWord = new StringBuilder(MAX_WORD_LENGTH);
@@ -101,6 +105,7 @@ public final class WordComposer {
}
public WordComposer(final WordComposer source) {
+ mCombinerChain = source.mCombinerChain;
mPrimaryKeyCodes = Arrays.copyOf(source.mPrimaryKeyCodes, source.mPrimaryKeyCodes.length);
mEvents = new ArrayList<Event>(source.mEvents);
mTypedWord = new StringBuilder(source.mTypedWord);
@@ -187,6 +192,7 @@ public final class WordComposer {
final int keyX = event.mX;
final int keyY = event.mY;
final int newIndex = size();
+ mCombinerChain.processEvent(mEvents, event);
mTypedWord.appendCodePoint(primaryCode);
mEvents.add(event);
refreshSize();
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index fa7c4b4fc..36b30eabe 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -28,7 +28,6 @@ import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.SuggestionSpanUtils;
import com.android.inputmethod.event.Event;
-import com.android.inputmethod.event.EventInterpreter;
import com.android.inputmethod.event.InputTransaction;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.latin.Constants;
@@ -96,6 +95,7 @@ public final class InputLogic {
// TODO: This boolean is persistent state and causes large side effects at unexpected times.
// Find a way to remove it for readability.
private boolean mIsAutoCorrectionIndicatorOn;
+ private long mDoubleSpacePeriodCountdownStart;
public InputLogic(final LatinIME latinIME,
final SuggestionStripViewAccessor suggestionStripViewAccessor) {
@@ -138,6 +138,7 @@ public final class InputLogic {
// In some cases (namely, after rotation of the device) editorInfo.initialSelStart is lying
// so we try using some heuristics to find out about these and fix them.
mConnection.tryFixLyingCursorPosition();
+ cancelDoubleSpacePeriodCountdown();
mInputLogicHandler = new InputLogicHandler(mLatinIME, this);
}
@@ -160,11 +161,12 @@ public final class InputLogic {
* some additional keys for example.
*
* @param settingsValues the current values of the settings.
- * @param rawText the text to input.
+ * @param event the input event containing the data.
*/
- public void onTextInput(final SettingsValues settingsValues, final String rawText,
+ public void onTextInput(final SettingsValues settingsValues, final Event event,
// TODO: remove this argument
final LatinIME.UIHandler handler) {
+ final String rawText = event.mText.toString();
mConnection.beginBatchEdit();
if (mWordComposer.isComposingWord()) {
commitCurrentAutoCorrection(settingsValues, rawText, handler);
@@ -196,13 +198,16 @@ public final class InputLogic {
* @param settingsValues the current values of the settings.
* @param index the index of the suggestion.
* @param suggestionInfo the suggestion info.
+ * @param keyboardShiftState the shift state of the keyboard, as returned by
+ * {@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
+ * @return the complete transaction object
*/
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
// interface
- public void onPickSuggestionManually(final SettingsValues settingsValues,
- final int index, final SuggestedWordInfo suggestionInfo,
- // TODO: remove these two arguments
- final LatinIME.UIHandler handler, final KeyboardSwitcher keyboardSwitcher) {
+ public InputTransaction onPickSuggestionManually(final SettingsValues settingsValues,
+ final int index, final SuggestedWordInfo suggestionInfo, final int keyboardShiftState,
+ // TODO: remove this argument
+ final LatinIME.UIHandler handler) {
final SuggestedWords suggestedWords = mSuggestedWords;
final String suggestion = suggestionInfo.mWord;
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
@@ -212,16 +217,26 @@ public final class InputLogic {
LatinImeLogger.logOnManualSuggestion("", suggestion, index, suggestedWords);
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
final int primaryCode = suggestion.charAt(0);
- final Event event = Event.createSoftwareKeypressEvent(primaryCode, Event.NOT_A_KEY_CODE,
- Constants.SUGGESTION_STRIP_COORDINATE, Constants.SUGGESTION_STRIP_COORDINATE);
- onCodeInput(settingsValues, event, keyboardSwitcher.getKeyboardShiftMode(), handler);
+ // TODO: we should be using createSuggestionPickedEvent here, but for legacy reasons,
+ // onCodeInput is expected a software keypress event for a suggested punctuation
+ // because the current code is descended from a time where this information used not
+ // to be available. Fix this.
+ final Event event = Event.createSoftwareKeypressEvent(primaryCode,
+ Event.NOT_A_KEY_CODE /* keyCode*/,
+ Constants.SUGGESTION_STRIP_COORDINATE /* x */,
+ Constants.SUGGESTION_STRIP_COORDINATE /* y */);
+ final InputTransaction completeTransaction = onCodeInput(settingsValues, event,
+ keyboardShiftState, handler);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_punctuationSuggestion(index, suggestion,
false /* isBatchMode */, suggestedWords.mIsPrediction);
}
- return;
+ return completeTransaction;
}
+ final Event event = Event.createSuggestionPickedEvent(suggestionInfo);
+ final InputTransaction inputTransaction = new InputTransaction(settingsValues,
+ event, SystemClock.uptimeMillis(), mSpaceState, keyboardShiftState);
mConnection.beginBatchEdit();
if (SpaceState.PHANTOM == mSpaceState && suggestion.length() > 0
// In the batch input mode, a manually picked suggested word should just replace
@@ -241,11 +256,11 @@ public final class InputLogic {
if (SuggestedWordInfo.KIND_APP_DEFINED == suggestionInfo.mKind) {
mSuggestedWords = SuggestedWords.EMPTY;
mSuggestionStripViewAccessor.setNeutralSuggestionStrip();
- keyboardSwitcher.updateShiftState();
+ inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
resetComposingState(true /* alsoResetLastComposedWord */);
mConnection.commitCompletion(suggestionInfo.mApplicationSpecifiedCompletionInfo);
mConnection.endBatchEdit();
- return;
+ return inputTransaction;
}
// We need to log before we commit, because the word composer will store away the user
@@ -264,7 +279,7 @@ public final class InputLogic {
mLastComposedWord.deactivate();
// Space state must be updated before calling updateShiftState
mSpaceState = SpaceState.PHANTOM;
- keyboardSwitcher.updateShiftState();
+ inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
// We should show the "Touch again to save" hint if the user pressed the first entry
// AND it's in none of our current dictionaries (main, user or otherwise).
@@ -290,6 +305,7 @@ public final class InputLogic {
// If we're not showing the "Touch again to save", then update the suggestion strip.
handler.postUpdateSuggestionStrip();
}
+ return inputTransaction;
}
/**
@@ -392,7 +408,7 @@ public final class InputLogic {
// TODO: Consolidate the double-space period timer, mLastKeyTime, and the space state.
if (event.mCodePoint != Constants.CODE_SPACE) {
- handler.cancelDoubleSpacePeriodTimer();
+ cancelDoubleSpacePeriodCountdown();
}
boolean didAutoCorrect = false;
@@ -833,7 +849,7 @@ public final class InputLogic {
if (Constants.CODE_SPACE == codePoint) {
if (inputTransaction.mSettingsValues.isSuggestionsRequested()) {
- if (maybeDoubleSpacePeriod(inputTransaction.mSettingsValues, handler)) {
+ if (maybeDoubleSpacePeriod(inputTransaction)) {
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
mSpaceState = SpaceState.DOUBLE;
} else if (!mSuggestedWords.isPunctuationSuggestions()) {
@@ -841,7 +857,7 @@ public final class InputLogic {
}
}
- handler.startDoubleSpacePeriodTimer();
+ startDoubleSpacePeriodCountdown(inputTransaction);
handler.postUpdateSuggestionStrip();
} else {
if (swapWeakSpace) {
@@ -938,7 +954,7 @@ public final class InputLogic {
return;
}
if (SpaceState.DOUBLE == inputTransaction.mSpaceState) {
- handler.cancelDoubleSpacePeriodTimer();
+ cancelDoubleSpacePeriodCountdown();
if (mConnection.revertDoubleSpacePeriod()) {
// No need to reset mSpaceState, it has already be done (that's why we
// receive it as a parameter)
@@ -1086,6 +1102,19 @@ public final class InputLogic {
return false;
}
+ public void startDoubleSpacePeriodCountdown(final InputTransaction inputTransaction) {
+ mDoubleSpacePeriodCountdownStart = inputTransaction.mTimestamp;
+ }
+
+ public void cancelDoubleSpacePeriodCountdown() {
+ mDoubleSpacePeriodCountdownStart = 0;
+ }
+
+ public boolean isDoubleSpacePeriodCountdownActive(final InputTransaction inputTransaction) {
+ return inputTransaction.mTimestamp - mDoubleSpacePeriodCountdownStart
+ < inputTransaction.mSettingsValues.mDoubleSpacePeriodTimeout;
+ }
+
/**
* Apply the double-space-to-period transformation if applicable.
*
@@ -1098,14 +1127,12 @@ public final class InputLogic {
* method applies the transformation and returns true. Otherwise, it does nothing and
* returns false.
*
- * @param settingsValues the current values of the settings.
+ * @param inputTransaction The transaction in progress.
* @return true if we applied the double-space-to-period transformation, false otherwise.
*/
- private boolean maybeDoubleSpacePeriod(final SettingsValues settingsValues,
- // TODO: remove this argument
- final LatinIME.UIHandler handler) {
- if (!settingsValues.mUseDoubleSpacePeriod) return false;
- if (!handler.isAcceptingDoubleSpacePeriod()) return false;
+ private boolean maybeDoubleSpacePeriod(final InputTransaction inputTransaction) {
+ if (!inputTransaction.mSettingsValues.mUseDoubleSpacePeriod) return false;
+ if (!isDoubleSpacePeriodCountdownActive(inputTransaction)) return false;
// We only do this when we see two spaces and an accepted code point before the cursor.
// The code point may be a surrogate pair but the two spaces may not, so we need 4 chars.
final CharSequence lastThree = mConnection.getTextBeforeCursor(4, 0);
@@ -1121,10 +1148,10 @@ public final class InputLogic {
Character.isSurrogatePair(lastThree.charAt(0), lastThree.charAt(1)) ?
Character.codePointAt(lastThree, 0) : lastThree.charAt(length - 3);
if (canBeFollowedByDoubleSpacePeriod(firstCodePoint)) {
- handler.cancelDoubleSpacePeriodTimer();
+ cancelDoubleSpacePeriodCountdown();
mConnection.deleteSurroundingText(2, 0);
- final String textToInsert =
- settingsValues.mSpacingAndPunctuations.mSentenceSeparatorAndSpace;
+ final String textToInsert = inputTransaction.mSettingsValues.mSpacingAndPunctuations
+ .mSentenceSeparatorAndSpace;
mConnection.commitText(textToInsert, 1);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert,
diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java
index b51c765f0..964bf2246 100644
--- a/java/src/com/android/inputmethod/latin/settings/Settings.java
+++ b/java/src/com/android/inputmethod/latin/settings/Settings.java
@@ -23,6 +23,7 @@ import android.content.res.Resources;
import android.preference.PreferenceManager;
import android.util.Log;
+import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.R;
@@ -270,25 +271,36 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
}
public static int readKeyboardThemeIndex(final SharedPreferences prefs, final Resources res) {
- final String defaultThemeIndex = res.getString(
- R.string.config_default_keyboard_theme_index);
- final String themeIndex = prefs.getString(PREF_KEYBOARD_LAYOUT, defaultThemeIndex);
+ final int defaultThemeIndex = readDefaultKeyboardThemeIndex(res);
+ final String themeIndexString = prefs.getString(PREF_KEYBOARD_LAYOUT, null);
try {
- return Integer.valueOf(themeIndex);
+ return Integer.parseInt(themeIndexString);
} catch (final NumberFormatException e) {
// Format error, returns default keyboard theme index.
- Log.e(TAG, "Illegal keyboard theme in preference: " + themeIndex + ", default to "
+ Log.e(TAG, "Illegal keyboard theme in preference: " + themeIndexString + ", default to "
+ defaultThemeIndex, e);
- return Integer.valueOf(defaultThemeIndex);
+ }
+ return defaultThemeIndex;
+ }
+
+ private static int readDefaultKeyboardThemeIndex(final Resources res) {
+ final String defaultThemeIndexString = res.getString(
+ R.string.config_default_keyboard_theme_index);
+ try {
+ return Integer.parseInt(defaultThemeIndexString);
+ } catch (final NumberFormatException e) {
+ final int defaultThemeIndex = KeyboardSwitcher.DEFAULT_THEME_INDEX;
+ Log.e(TAG, "Corrupted default keyoard theme in resource: " + defaultThemeIndexString
+ + ", default to " + defaultThemeIndex, e);
+ return defaultThemeIndex;
}
}
public static int resetAndGetDefaultKeyboardThemeIndex(final SharedPreferences prefs,
final Resources res) {
- final String defaultThemeIndex = res.getString(
- R.string.config_default_keyboard_theme_index);
- prefs.edit().putString(PREF_KEYBOARD_LAYOUT, defaultThemeIndex).apply();
- return Integer.valueOf(defaultThemeIndex);
+ final int defaultThemeIndex = readDefaultKeyboardThemeIndex(res);
+ prefs.edit().putString(PREF_KEYBOARD_LAYOUT, Integer.toString(defaultThemeIndex)).apply();
+ return defaultThemeIndex;
}
public static String readPrefAdditionalSubtypes(final SharedPreferences prefs,
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
index 50fbbb19f..d47a61ed1 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
@@ -50,6 +50,7 @@ public final class SettingsValues {
// From resources:
public final SpacingAndPunctuations mSpacingAndPunctuations;
public final int mDelayUpdateOldSuggestions;
+ public final long mDoubleSpacePeriodTimeout;
// From preferences, in the same order as xml/prefs.xml:
public final boolean mAutoCap;
@@ -132,6 +133,7 @@ public final class SettingsValues {
mBlockPotentiallyOffensive = Settings.readBlockPotentiallyOffensive(prefs, res);
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res);
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
+ mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
// Compute other readable settings
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
@@ -285,7 +287,7 @@ public final class SettingsValues {
// When autoCorrectionThreshold is greater than 1.0, it's like auto correction is off.
final float autoCorrectionThreshold;
try {
- final int arrayIndex = Integer.valueOf(currentAutoCorrectionSetting);
+ final int arrayIndex = Integer.parseInt(currentAutoCorrectionSetting);
if (arrayIndex >= 0 && arrayIndex < autoCorrectionThresholdValues.length) {
final String val = autoCorrectionThresholdValues[arrayIndex];
if (FLOAT_MAX_VALUE_MARKER_STRING.equals(val)) {
diff --git a/java/src/com/android/inputmethod/latin/settings/SpacingAndPunctuations.java b/java/src/com/android/inputmethod/latin/settings/SpacingAndPunctuations.java
index 5954758aa..796921f71 100644
--- a/java/src/com/android/inputmethod/latin/settings/SpacingAndPunctuations.java
+++ b/java/src/com/android/inputmethod/latin/settings/SpacingAndPunctuations.java
@@ -18,7 +18,6 @@ package com.android.inputmethod.latin.settings;
import android.content.res.Resources;
-import com.android.inputmethod.keyboard.internal.KeyboardTextsSet;
import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.PunctuationSuggestions;
@@ -61,10 +60,8 @@ public final class SpacingAndPunctuations {
// English variants. German rules (not "German typography") also have small gotchas.
mUsesAmericanTypography = Locale.ENGLISH.getLanguage().equals(locale.getLanguage());
mUsesGermanRules = Locale.GERMAN.getLanguage().equals(locale.getLanguage());
- final KeyboardTextsSet textsSet = new KeyboardTextsSet();
- textsSet.setLocale(locale);
final String[] suggestPuncsSpec = MoreKeySpec.splitKeySpecs(
- textsSet.resolveTextReference(res.getString(R.string.suggested_punctuations)));
+ res.getString(R.string.suggested_punctuations));
mSuggestPuncList = PunctuationSuggestions.newPunctuationSuggestions(suggestPuncsSpec);
}
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
index c26e223c9..1d84bb59f 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
@@ -507,7 +507,7 @@ final class SuggestionStripLayoutHelper {
hintView, 1.0f - mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
}
- public void layoutImportantNotice(final View importantNoticeStrip, final int stripWidth,
+ public void layoutImportantNotice(final View importantNoticeStrip,
final String importantNoticeTitle) {
final TextView titleView = (TextView)importantNoticeStrip.findViewById(
R.id.important_notice_title);
@@ -516,8 +516,7 @@ final class SuggestionStripLayoutHelper {
titleView.setTextColor(mColorAutoCorrect);
titleView.setText(importantNoticeTitle);
titleView.setTextScaleX(1.0f); // Reset textScaleX.
- final float titleScaleX = getTextScaleX(
- importantNoticeTitle, width, titleView.getPaint());
+ final float titleScaleX = getTextScaleX(importantNoticeTitle, width, titleView.getPaint());
titleView.setTextScaleX(titleScaleX);
}
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index 43cb11b14..3cdd07361 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -232,8 +232,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
if (!ImportantNoticeUtils.shouldShowImportantNotice(getContext(), inputAttributes)) {
return false;
}
- final int width = getWidth();
- if (width <= 0) {
+ if (getWidth() <= 0) {
return false;
}
final String importantNoticeTitle = ImportantNoticeUtils.getNextImportantNoticeTitle(
@@ -241,7 +240,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
if (TextUtils.isEmpty(importantNoticeTitle)) {
return false;
}
- mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, width, importantNoticeTitle);
+ mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, importantNoticeTitle);
mStripVisibilityGroup.showImportantNoticeStrip();
mImportantNoticeStrip.setOnClickListener(this);
return true;
diff --git a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
index ca8bef397..7d937a9d2 100644
--- a/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ImportantNoticeUtils.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
+import android.text.TextUtils;
import android.util.Log;
import com.android.inputmethod.latin.InputAttributes;
@@ -82,7 +83,17 @@ public final class ImportantNoticeUtils {
if (inputAttributes == null || inputAttributes.mIsPasswordField) {
return false;
}
- return hasNewImportantNotice(context) && !isInSystemSetupWizard(context);
+ if (isInSystemSetupWizard(context)) {
+ return false;
+ }
+ if (!hasNewImportantNotice(context)) {
+ return false;
+ }
+ final String importantNoticeTitle = getNextImportantNoticeTitle(context);
+ if (TextUtils.isEmpty(importantNoticeTitle)) {
+ return false;
+ }
+ return true;
}
public static void updateLastImportantNoticeVersion(final Context context) {