diff options
Diffstat (limited to 'java/src')
6 files changed, 69 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d5bfe43b2..0f9915778 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -110,7 +110,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ImportantNoticeDialog.ImportantNoticeDialogListener { static final String TAG = LatinIME.class.getSimpleName(); private static final boolean TRACE = false; - private static boolean DEBUG = false; private static final int EXTENDED_TOUCHABLE_REGION_HEIGHT = 100; private static final int PERIOD_FOR_AUDIO_AND_HAPTIC_FEEDBACK_IN_KEY_REPEAT = 2; @@ -557,7 +556,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen super.onCreate(); mHandler.onCreate(); - DEBUG = DebugFlags.DEBUG_ENABLED; // TODO: Resolve mutual dependencies of {@link #loadSettings()} and // {@link #resetDictionaryFacilitatorIfNecessary()}. @@ -823,7 +821,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } return; } - if (DEBUG) { + if (DebugFlags.DEBUG_ENABLED) { Log.d(TAG, "onStartInputView: editorInfo:" + String.format("inputType=0x%08x imeOptions=0x%08x", editorInfo.inputType, editorInfo.imeOptions)); @@ -1011,7 +1009,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final int composingSpanStart, final int composingSpanEnd) { super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd, composingSpanStart, composingSpanEnd); - if (DEBUG) { + if (DebugFlags.DEBUG_ENABLED) { Log.i(TAG, "onUpdateSelection: oss=" + oldSelStart + ", ose=" + oldSelEnd + ", nss=" + newSelStart + ", nse=" + newSelEnd + ", cs=" + composingSpanStart + ", ce=" + composingSpanEnd); @@ -1079,7 +1077,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @Override public void onDisplayCompletions(final CompletionInfo[] applicationSpecifiedCompletions) { - if (DEBUG) { + if (DebugFlags.DEBUG_ENABLED) { Log.i(TAG, "Received completions:"); if (applicationSpecifiedCompletions != null) { for (int i = 0; i < applicationSpecifiedCompletions.length; i++) { @@ -1780,7 +1778,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen @UsedForTesting /* package for test */ SuggestedWords getSuggestedWordsForTest() { // You may not use this method for anything else than debug - return DEBUG ? mInputLogic.mSuggestedWords : null; + return DebugFlags.DEBUG_ENABLED ? mInputLogic.mSuggestedWords : null; } // DO NOT USE THIS for any other purpose than testing. This is information private to LatinIME. diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java index c8e0b93bf..602205b59 100644 --- a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java +++ b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java @@ -46,6 +46,7 @@ import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Enrichment class for InputMethodManager to simplify interaction and add functionality. @@ -329,7 +330,7 @@ public class RichInputMethodManager { @UsedForTesting static void forceSubtype(@Nonnull final InputMethodSubtype subtype) { - sForcedSubtypeForTesting = new RichInputMethodSubtype(subtype); + sForcedSubtypeForTesting = RichInputMethodSubtype.getRichInputMethodSubtype(subtype); } @Nonnull @@ -488,8 +489,8 @@ public class RichInputMethodManager { return true; } - private void updateCurrentSubtype(@Nonnull final InputMethodSubtype subtype) { - mCurrentRichInputMethodSubtype = new RichInputMethodSubtype(subtype); + private void updateCurrentSubtype(@Nullable final InputMethodSubtype subtype) { + mCurrentRichInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype); } private void updateShortcutIme() { diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java b/java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java index ea8d4a210..8734e5925 100644 --- a/java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java +++ b/java/src/com/android/inputmethod/latin/RichInputMethodSubtype.java @@ -30,6 +30,7 @@ import java.util.Arrays; import java.util.Locale; import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Enrichment class for InputMethodSubtype to enable concurrent multi-lingual input. @@ -147,6 +148,15 @@ public final class RichInputMethodSubtype { return SubtypeLocaleUtils.getKeyboardLayoutSetName(mSubtype); } + public static RichInputMethodSubtype getRichInputMethodSubtype( + @Nullable final InputMethodSubtype subtype) { + if (subtype == null) { + return getNoLanguageSubtype(); + } else { + return new RichInputMethodSubtype(subtype); + } + } + // Dummy no language QWERTY subtype. See {@link R.xml.method}. private static final int SUBTYPE_ID_OF_DUMMY_NO_LANGUAGE_SUBTYPE = 0xdde0bfd3; private static final String EXTRA_VALUE_OF_DUMMY_NO_LANGUAGE_SUBTYPE = diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 92bd60658..934da7ac7 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -1027,6 +1027,20 @@ public final class InputLogic { revertCommit(inputTransaction, inputTransaction.mSettingsValues); StatsUtils.onRevertAutoCorrect(); StatsUtils.onWordCommitUserTyped(lastComposedWord, mWordComposer.isBatchMode()); + // Restart suggestions when backspacing into a reverted word. This is required for + // the final corrected word to be learned, as learning only occurs when suggestions + // are active. + // + // Note: restartSuggestionsOnWordTouchedByCursor is already called for normal + // (non-revert) backspace handling. + if (inputTransaction.mSettingsValues.isSuggestionsEnabledPerUserSettings() + && inputTransaction.mSettingsValues.mSpacingAndPunctuations + .mCurrentLanguageHasSpaces + && !mConnection.isCursorFollowedByWordCharacter( + inputTransaction.mSettingsValues.mSpacingAndPunctuations)) { + restartSuggestionsOnWordTouchedByCursor(inputTransaction.mSettingsValues, + false /* forStartInput */, currentKeyboardScriptId); + } return; } if (mEnteredText != null && mConnection.sameAsTextBeforeCursor(mEnteredText)) { diff --git a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java index c7c29772b..9a8a7b9e0 100644 --- a/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/AccountsSettingsFragment.java @@ -22,6 +22,7 @@ import static com.android.inputmethod.latin.settings.LocalSettingsConstants.PREF import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; +import android.content.DialogInterface.OnShowListener; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.AsyncTask; @@ -32,7 +33,9 @@ import android.preference.Preference.OnPreferenceClickListener; import android.preference.SwitchPreference; import android.preference.TwoStatePreference; import android.text.TextUtils; +import android.text.method.LinkMovementMethod; import android.widget.ListView; +import android.widget.TextView; import android.widget.Toast; import com.android.inputmethod.annotations.UsedForTesting; @@ -201,24 +204,19 @@ public final class AccountsSettingsFragment extends SubScreenFragment { * is currently selected. */ private void refreshAccountAndDependentPreferences(@Nullable final String currentAccount) { + // TODO(cvnguyen): Write tests. if (!ProductionFlags.ENABLE_ACCOUNT_SIGN_IN) { return; } - if (currentAccount == null) { - // No account is currently selected; switch enable sync preference off. - mAccountSwitcher.setSummary(getString(R.string.no_accounts_selected)); - mEnableSyncPreference.setChecked(false); - } else { - // Set the currently selected account as the summary text. - mAccountSwitcher.setSummary(getString(R.string.account_selected, currentAccount)); - } + final String[] accountsForLogin = + LoginAccountUtils.getAccountsForLogin(getActivity()); - mAccountSwitcher.setOnPreferenceClickListener(new OnPreferenceClickListener() { + if (accountsForLogin.length > 0) { + enableSyncPreferences(); + mAccountSwitcher.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { - final String[] accountsForLogin = - LoginAccountUtils.getAccountsForLogin(getActivity()); if (accountsForLogin.length > 0) { // TODO: Add addition of account. createAccountPicker(accountsForLogin, currentAccount, @@ -226,7 +224,21 @@ public final class AccountsSettingsFragment extends SubScreenFragment { } return true; } - }); + }); + } else { + mAccountSwitcher.setEnabled(false); + disableSyncPreferences(); + mEnableSyncPreference.setSummary(getString(R.string.add_account_to_enable_sync)); + } + + if (currentAccount == null) { + // No account is currently selected; switch enable sync preference off. + mAccountSwitcher.setSummary(getString(R.string.no_accounts_selected)); + mEnableSyncPreference.setChecked(false); + } else { + // Set the currently selected account as the summary text. + mAccountSwitcher.setSummary(getString(R.string.account_selected, currentAccount)); + } } @Nullable @@ -363,7 +375,8 @@ public final class AccountsSettingsFragment extends SubScreenFragment { /** * Listens to events when user clicks on "Enable sync" feature. */ - class EnableSyncClickListener implements Preference.OnPreferenceClickListener { + class EnableSyncClickListener implements OnShowListener, Preference.OnPreferenceClickListener { + // TODO(cvnguyen): Write tests. @Override public boolean onPreferenceClick(final Preference preference) { final TwoStatePreference syncPreference = (TwoStatePreference) preference; @@ -393,9 +406,19 @@ public final class AccountsSettingsFragment extends SubScreenFragment { }) .setNegativeButton(R.string.cloud_sync_cancel, null) .create(); + optInDialog.setOnShowListener(this); optInDialog.show(); } return true; } + + @Override + public void onShow(DialogInterface dialog) { + TextView messageView = (TextView) ((AlertDialog) dialog).findViewById( + android.R.id.message); + if (messageView != null) { + messageView.setMovementMethod(LinkMovementMethod.getInstance()); + } + } } } diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index f04f093f0..ff0578d13 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -260,7 +260,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo); builder.setKeyboardGeometry( SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT); - builder.setSubtype(new RichInputMethodSubtype(subtype)); + builder.setSubtype(RichInputMethodSubtype.getRichInputMethodSubtype(subtype)); builder.setIsSpellChecker(true /* isSpellChecker */); builder.disableTouchPositionCorrectionData(); return builder.build(); |