From 5d2556b93286f5f1d7d829b586b84a8b7ae55743 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Tue, 6 Nov 2012 16:45:44 +0900 Subject: [PATCH 1/5] Reset the IME if requested by the app. Specifically, reset the KeyboardState to the main Alphabet layout in LatinIME.onStartInputViewInternal() if a keyboard layout set doesn't get reloaded in the method. Please note TextView.setText() calls up resetInput(), then the IME should reset with it. bug: 7482086 Note that bug: 6851364 needs to be revisited. Change-Id: I5d448c10963d3dd952dd13cb587085ec7b014e69 --- .../keyboard/KeyboardSwitcher.java | 6 +++++ .../keyboard/internal/KeyboardState.java | 25 +++++++++++++++++++ .../android/inputmethod/latin/LatinIME.java | 4 +++ 3 files changed, 35 insertions(+) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 38025e8e4..de8097b55 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -200,6 +200,12 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mState.onUpdateShiftState(mLatinIME.getCurrentAutoCapsState()); } + // TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout + // when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal(). + public void resetKeyboardStateToAlphabet() { + mState.onResetKeyboardStateToAlphabet(); + } + public void onPressKey(int code) { if (isVibrateAndSoundFeedbackRequired()) { mLatinIME.hapticAndAudioFeedback(code); diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index 58cc8972a..5e111fb9a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -254,6 +254,22 @@ public final class KeyboardState { } } + // TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout + // when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal(). + private void resetKeyboardStateToAlphabet() { + if (DEBUG_ACTION) { + Log.d(TAG, "resetKeyboardStateToAlphabet: " + this); + } + if (mIsAlphabetMode) return; + + mPrevSymbolsKeyboardWasShifted = mIsSymbolShifted; + setAlphabetKeyboard(); + if (mPrevMainKeyboardWasShiftLocked) { + setShiftLocked(true); + } + mPrevMainKeyboardWasShiftLocked = false; + } + private void toggleShiftInSymbols() { if (mIsSymbolShifted) { setSymbolsKeyboard(); @@ -380,6 +396,15 @@ public final class KeyboardState { updateAlphabetShiftState(autoCaps); } + // TODO: Remove this method. Come up with a more comprehensive way to reset the keyboard layout + // when a keyboard layout set doesn't get reloaded in LatinIME.onStartInputViewInternal(). + public void onResetKeyboardStateToAlphabet() { + if (DEBUG_EVENT) { + Log.d(TAG, "onResetKeyboardStateToAlphabet: " + this); + } + resetKeyboardStateToAlphabet(); + } + private void updateAlphabetShiftState(int autoCaps) { if (!mIsAlphabetMode) return; if (!mShiftKeyState.isReleasing()) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 8ac0cd4ca..cf7eea70b 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -732,6 +732,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } switcher.loadKeyboard(editorInfo, mCurrentSettings); + } else if (restarting) { + // TODO: Come up with a more comprehensive way to reset the keyboard layout when + // a keyboard layout set doesn't get reloaded in this method. + switcher.resetKeyboardStateToAlphabet(); } setSuggestionStripShownInternal( isSuggestionsStripVisible(), /* needsInputViewShown */ false); From 8df57deb05647a4265f1bd02f827bbd0bb68bb35 Mon Sep 17 00:00:00 2001 From: Baligh Uddin Date: Tue, 6 Nov 2012 16:54:45 -0800 Subject: [PATCH 2/5] Import translations. DO NOT MERGE Change-Id: I97ceec5680a8ba9f27d5f62a7573555590268376 Auto-generated-cl: translation import --- java/res/values-de/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/res/values-de/strings.xml b/java/res/values-de/strings.xml index 897bfb712..288e37b06 100644 --- a/java/res/values-de/strings.xml +++ b/java/res/values-de/strings.xml @@ -69,7 +69,7 @@ "%s: gespeichert" "Los" "Weiter" - "Vorh." + "Zurück" "Fertig" "Senden" "ABC" @@ -121,7 +121,7 @@ "Nutzer-Feedback aktivieren" "Tragen Sie zur Verbesserung dieses Eingabemethodeneditors bei, indem Sie automatisch Nutzungsstatistiken und Absturzberichte an Google senden." "Tastaturdesign" - "Englisch (Großbritannien)" + "Englisch (UK)" "Englisch (USA)" "Englisch (GB) (%s)" "Englisch (USA) (%s)" From 5b1037fa94a3f4a64fe0f5aed58662d2e40af5d2 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 8 Nov 2012 11:53:49 +0900 Subject: [PATCH 3/5] Fix a bug in the diff tool Fix reporting of removed attributes multiple times instead of just one in some cases. Also, report the frequency of the removed bigram in the same cases. Change-Id: I1455fa7553fcebc3005c222bf5aa9afcf1678c31 --- .../src/com/android/inputmethod/latin/dicttool/Diff.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java index 94db84497..5c3e87e10 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java @@ -181,16 +181,21 @@ public class Diff extends Dicttool.Command { if (!list1.contains(attribute0)) { hasDifferences = true; // Search for a word with the same string but a different frequency + boolean foundString = false; for (final WeightedString attribute1 : list1) { if (attribute0.mWord.equals(attribute1.mWord)) { System.out.println(type + " freq changed: " + word + " " + attribute0.mWord + " " + attribute0.mFrequency + " -> " + attribute1.mFrequency); list1.remove(attribute1); + foundString = true; break; } + } + if (!foundString) { // We come here if we haven't found any matching string. - System.out.println(type + " removed: " + word + " " + attribute0.mWord); + System.out.println(type + " removed: " + word + " " + attribute0.mWord + " " + + attribute0.mFrequency); } } else { list1.remove(attribute0); From c43ff6f66c1a3a36ae46654d57a78ee9bde3ba3e Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 9 Nov 2012 12:44:40 +0900 Subject: [PATCH 4/5] Remove gesture typing settings when disabled by configuration Bug: 7506408 Change-Id: I4de53ace170d5ddc9779f42ac344c4190c80a019 --- .../com/android/inputmethod/latin/Settings.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 238724610..348928df8 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -68,6 +68,7 @@ public final class Settings extends InputMethodSettingsFragment public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY = "pref_key_preview_popup_dismiss_delay"; public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction"; + public static final String PREF_GESTURE_SETTINGS = "gesture_typing_settings"; public static final String PREF_GESTURE_INPUT = "gesture_input"; public static final String PREF_VIBRATION_DURATION_SETTINGS = "pref_vibration_duration_settings"; @@ -136,6 +137,8 @@ public final class Settings extends InputMethodSettingsFragment (PreferenceGroup) findPreference(PREF_GENERAL_SETTINGS); final PreferenceGroup textCorrectionGroup = (PreferenceGroup) findPreference(PREF_CORRECTION_SETTINGS); + final PreferenceGroup gestureTypingSettings = + (PreferenceGroup) findPreference(PREF_GESTURE_SETTINGS); final PreferenceGroup miscSettings = (PreferenceGroup) findPreference(PREF_MISC_SETTINGS); @@ -206,17 +209,8 @@ public final class Settings extends InputMethodSettingsFragment final boolean gestureInputEnabledByBuildConfig = res.getBoolean( R.bool.config_gesture_input_enabled_by_build_config); - final Preference gesturePreviewTrail = findPreference(PREF_GESTURE_PREVIEW_TRAIL); - final Preference gestureFloatingPreviewText = findPreference( - PREF_GESTURE_FLOATING_PREVIEW_TEXT); if (!gestureInputEnabledByBuildConfig) { - miscSettings.removePreference(findPreference(PREF_GESTURE_INPUT)); - miscSettings.removePreference(gesturePreviewTrail); - miscSettings.removePreference(gestureFloatingPreviewText); - } else { - final boolean gestureInputEnabledByUser = prefs.getBoolean(PREF_GESTURE_INPUT, true); - setPreferenceEnabled(gesturePreviewTrail, gestureInputEnabledByUser); - setPreferenceEnabled(gestureFloatingPreviewText, gestureInputEnabledByUser); + getPreferenceScreen().removePreference(gestureTypingSettings); } mKeypressVibrationDurationSettingsPref = From 710d06cea91a8e6bf04a27f0bcd88d76a5cc5acd Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Fri, 9 Nov 2012 12:59:06 +0900 Subject: [PATCH 5/5] Suppress dictionary pack support when IS_EXPERIMENTAL is true Change-Id: If8813cb989c1fa8744a3bf36e8514ced3c8f46a3 --- .../latin/BinaryDictionaryGetter.java | 8 +++-- .../android/inputmethod/latin/LatinIME.java | 30 ++++++++++++------- .../android/inputmethod/latin/Settings.java | 3 +- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java index ecb61b46f..83dabbede 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java @@ -16,6 +16,7 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.makedict.BinaryDictInputOutput; import com.android.inputmethod.latin.makedict.FormatSpec; @@ -422,8 +423,11 @@ final class BinaryDictionaryGetter { // cacheWordListsFromContentProvider returns the list of files it copied to local // storage, but we don't really care about what was copied NOW: what we want is the // list of everything we ever cached, so we ignore the return value. - BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context, - hasDefaultWordList); + // TODO: The experimental version is not supported by the Dictionary Pack Service yet + if (!ProductionFlag.IS_EXPERIMENTAL) { + BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context, + hasDefaultWordList); + } final File[] cachedWordLists = getCachedWordLists(locale.toString(), context); final String mainDictId = getMainDictId(locale); final DictPackSettings dictPackSettings = new DictPackSettings(context); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 5f87c8c91..fa93357a4 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -168,8 +168,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction private int mDisplayOrientation; // Object for reacting to adding/removing a dictionary pack. + // TODO: The experimental version is not supported by the Dictionary Pack Service yet. private BroadcastReceiver mDictionaryPackInstallReceiver = - new DictionaryPackInstallBroadcastReceiver(this); + ProductionFlag.IS_EXPERIMENTAL + ? null : new DictionaryPackInstallBroadcastReceiver(this); // Keeps track of most recently inserted text (multi-character key) for reverting private String mEnteredText; @@ -410,16 +412,19 @@ public final class LatinIME extends InputMethodService implements KeyboardAction filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); registerReceiver(mReceiver, filter); - final IntentFilter packageFilter = new IntentFilter(); - packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); - packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); - packageFilter.addDataScheme(SCHEME_PACKAGE); - registerReceiver(mDictionaryPackInstallReceiver, packageFilter); + // TODO: The experimental version is not supported by the Dictionary Pack Service yet. + if (!ProductionFlag.IS_EXPERIMENTAL) { + final IntentFilter packageFilter = new IntentFilter(); + packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); + packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); + packageFilter.addDataScheme(SCHEME_PACKAGE); + registerReceiver(mDictionaryPackInstallReceiver, packageFilter); - final IntentFilter newDictFilter = new IntentFilter(); - newDictFilter.addAction( - DictionaryPackInstallBroadcastReceiver.NEW_DICTIONARY_INTENT_ACTION); - registerReceiver(mDictionaryPackInstallReceiver, newDictFilter); + final IntentFilter newDictFilter = new IntentFilter(); + newDictFilter.addAction( + DictionaryPackInstallBroadcastReceiver.NEW_DICTIONARY_INTENT_ACTION); + registerReceiver(mDictionaryPackInstallReceiver, newDictFilter); + } } // Has to be package-visible for unit tests @@ -539,7 +544,10 @@ public final class LatinIME extends InputMethodService implements KeyboardAction mSuggest = null; } unregisterReceiver(mReceiver); - unregisterReceiver(mDictionaryPackInstallReceiver); + // TODO: The experimental version is not supported by the Dictionary Pack Service yet. + if (!ProductionFlag.IS_EXPERIMENTAL) { + unregisterReceiver(mDictionaryPackInstallReceiver); + } LatinImeLogger.commit(); LatinImeLogger.onDestroy(); super.onDestroy(); diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 348928df8..fdad5430a 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -203,7 +203,8 @@ public final class Settings extends InputMethodSettingsFragment final Intent intent = dictionaryLink.getIntent(); final int number = context.getPackageManager().queryIntentActivities(intent, 0).size(); - if (0 >= number) { + // TODO: The experimental version is not supported by the Dictionary Pack Service yet + if (ProductionFlag.IS_EXPERIMENTAL || 0 >= number) { textCorrectionGroup.removePreference(dictionaryLink); }