From be324535f63420a283d5eb4ed889052b2c941c31 Mon Sep 17 00:00:00 2001 From: satok Date: Thu, 20 Jan 2011 01:08:13 +0900 Subject: Add subtype languages Change-Id: Ib251bd63f79281a4dc1739b213b16e8a936ea319 --- java/src/com/android/inputmethod/latin/SubtypeSwitcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index a9bd114f3..99d31d4d2 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -41,7 +41,7 @@ import java.util.Locale; import java.util.Map; public class SubtypeSwitcher { - private static final boolean DBG = false; + private static final boolean DBG = LatinImeLogger.sDBG; private static final String TAG = "SubtypeSwitcher"; private static final char LOCALE_SEPARATER = '_'; -- cgit v1.2.3-83-g751a From 6845da8d7b940018c4ef77646f0028d131ed2753 Mon Sep 17 00:00:00 2001 From: satok Date: Thu, 20 Jan 2011 17:33:10 +0900 Subject: Add touchable region Bug: 3238092 Change-Id: I3cda3106a61c40c3b66741dc38c9ff4cc55f487b --- java/src/com/android/inputmethod/latin/LatinIME.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 4e1c56cba..bc42dff84 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -27,6 +27,7 @@ import com.android.inputmethod.latin.Utils.RingCharBuffer; import com.android.inputmethod.voice.VoiceIMEConnector; import android.app.AlertDialog; +import android.app.Dialog; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; @@ -35,6 +36,7 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Region; import android.inputmethodservice.InputMethodService; import android.media.AudioManager; import android.os.Debug; @@ -862,6 +864,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (!isFullscreenMode()) { outInsets.contentTopInsets = outInsets.visibleTopInsets; } + KeyboardView inputView = mKeyboardSwitcher.getInputView(); + if (inputView != null) { + // Screen's heightPixels may be too big, but want to make + // it large enough to cover status bar in any cases. + outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION; + outInsets.touchableRegion.set( + 0, 0, inputView.getWidth(), getResources().getDisplayMetrics().heightPixels); + } } @Override -- cgit v1.2.3-83-g751a From fefda4e6df5c2f8e2b2730dfe5b88644a1caaa6b Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Thu, 20 Jan 2011 23:29:53 +0900 Subject: Refine InputMethodInfo API bug: 3370297 Change-Id: I16073e6b8b90a06a20e506dac66e3ca25b4712d0 --- .../android/inputmethod/latin/SubtypeSwitcher.java | 4 ++-- .../inputmethod/latin/SubtypeLocaleTests.java | 27 ++++++---------------- 2 files changed, 9 insertions(+), 22 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 99d31d4d2..da46d26bf 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -288,9 +288,9 @@ public class SubtypeSwitcher { if (subtype != null) { return pm.getDrawable(imiPackageName, subtype.getIconResId(), imi.getServiceInfo().applicationInfo); - } else if (imi.getSubtypes().size() > 0 && imi.getSubtypes().get(0) != null) { + } else if (imi.getSubtypeCount() > 0 && imi.getSubtypeAt(0) != null) { return pm.getDrawable(imiPackageName, - imi.getSubtypes().get(0).getIconResId(), + imi.getSubtypeAt(0).getIconResId(), imi.getServiceInfo().applicationInfo); } else { try { diff --git a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java index 004ddb61a..e1c3678fd 100644 --- a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java +++ b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java @@ -33,19 +33,6 @@ public class SubtypeLocaleTests extends AndroidTestCase { private Resources mRes; private List mKeyboardSubtypes; - public interface Predicator { - public boolean evaluate(T object); - } - - private static List filter(List source, Predicator predicator) { - final ArrayList filtered = new ArrayList(); - for (final T element : source) { - if (predicator.evaluate(element)) - filtered.add(element); - } - return filtered; - } - @Override protected void setUp() throws Exception { super.setUp(); @@ -59,13 +46,13 @@ public class SubtypeLocaleTests extends AndroidTestCase { Context.INPUT_METHOD_SERVICE); for (final InputMethodInfo imi : imm.getInputMethodList()) { if (imi.getPackageName().equals(PACKAGE)) { - mKeyboardSubtypes = filter(imi.getSubtypes(), - new Predicator() { - @Override - public boolean evaluate(InputMethodSubtype ims) { - return ims.getMode().equals("keyboard"); - } - }); + final int subtypeCount = imi.getSubtypeCount(); + for (int i = 0; i < subtypeCount; ++i) { + InputMethodSubtype subtype = imi.getSubtypeAt(i); + if (subtype.getMode().equals("keyboard")) { + mKeyboardSubtypes.add(subtype); + } + } break; } } -- cgit v1.2.3-83-g751a From 2fa21f5854e1565deb139e0bf22719fecc5340bc Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 20 Jan 2011 22:52:02 +0900 Subject: Add input method subtype selector and IME settings dialog Bug: 3351762 Change-Id: Ic1767faac6d4470a89cacb851d449ac53b2f8205 --- .../com/android/inputmethod/latin/LatinIME.java | 74 ++++++++++++++++------ java/src/com/android/inputmethod/latin/Utils.java | 8 +++ 2 files changed, 62 insertions(+), 20 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index bc42dff84..fb8c9b3a8 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -123,6 +123,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private AlertDialog mOptionsDialog; private InputMethodManager mImm; + private Resources mResources; + private SharedPreferences mPrefs; + private String mInputMethodId; private KeyboardSwitcher mKeyboardSwitcher; private SubtypeSwitcher mSubtypeSwitcher; private VoiceIMEConnector mVoiceConnector; @@ -132,9 +135,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private ContactsDictionary mContactsDictionary; private AutoDictionary mAutoDictionary; - private Resources mResources; - private SharedPreferences mPrefs; - // These variables are initialized according to the {@link EditorInfo#inputType}. private boolean mAutoSpace; private boolean mInputTypeNoAutoCorrect; @@ -156,6 +156,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private boolean mPopupOn; private boolean mAutoCap; private boolean mQuickFixes; + private boolean mConfigEnableShowSubtypeSettings; private boolean mConfigSwipeDownDismissKeyboardEnabled; private int mConfigDelayBeforeFadeoutLanguageOnSpacebar; private int mConfigDurationOfFadeoutLanguageOnSpacebar; @@ -350,6 +351,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen super.onCreate(); mImm = ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)); + mInputMethodId = Utils.getInputMethodId(mImm, getApplicationInfo().packageName); mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mKeyboardSwitcher = KeyboardSwitcher.getInstance(); @@ -365,6 +367,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mReCorrectionEnabled = res.getBoolean(R.bool.default_recorrection_enabled); } + mConfigEnableShowSubtypeSettings = res.getBoolean( + R.bool.config_enable_show_subtype_settings); mConfigSwipeDownDismissKeyboardEnabled = res.getBoolean( R.bool.config_swipe_down_dismiss_keyboard_enabled); mConfigDelayBeforeFadeoutLanguageOnSpacebar = res.getInteger( @@ -462,6 +466,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen commitTyped(ic); if (ic != null) ic.finishComposingText(); // For voice input mOrientation = conf.orientation; + if (isShowingOptionDialog()) + mOptionsDialog.dismiss(); } mConfigurationChanging = true; @@ -1044,7 +1050,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void onSettingsKeyPressed() { if (!isShowingOptionDialog()) { - if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm)) { + if (!mConfigEnableShowSubtypeSettings) { + showSubtypeSelectorAndSettings(); + } else if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm)) { showOptionsMenu(); } else { launchSettings(); @@ -2183,30 +2191,56 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return mSuggestPuncs.contains(String.valueOf((char)code)); } - private void showOptionsMenu() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setCancelable(true); - builder.setIcon(R.drawable.ic_dialog_keyboard); - builder.setNegativeButton(android.R.string.cancel, null); - CharSequence itemSettings = getString(R.string.english_ime_settings); - CharSequence itemInputMethod = getString(R.string.selectInputMethod); - builder.setItems(new CharSequence[] { - itemInputMethod, itemSettings}, - new DialogInterface.OnClickListener() { + private void showSubtypeSelectorAndSettings() { + showOptionsMenuInternal(new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface di, int position) { + di.dismiss(); + switch (position) { + case POS_SETTINGS: + launchSettings(); + break; + case POS_METHOD: + Intent intent = new Intent( + android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED + | Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.putExtra(android.provider.Settings.EXTRA_INPUT_METHOD_ID, + mInputMethodId); + startActivity(intent); + break; + } + } + }); + } + private void showOptionsMenu() { + showOptionsMenuInternal(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int position) { di.dismiss(); switch (position) { - case POS_SETTINGS: - launchSettings(); - break; - case POS_METHOD: - mImm.showInputMethodPicker(); - break; + case POS_SETTINGS: + launchSettings(); + break; + case POS_METHOD: + mImm.showInputMethodPicker(); + break; } } }); + } + + private void showOptionsMenuInternal(DialogInterface.OnClickListener listener) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setCancelable(true); + builder.setIcon(R.drawable.ic_dialog_keyboard); + builder.setNegativeButton(android.R.string.cancel, null); + CharSequence itemSettings = getString(R.string.english_ime_settings); + CharSequence itemInputMethod = getString(R.string.selectInputMethod); + builder.setItems(new CharSequence[] { + itemInputMethod, itemSettings}, listener); builder.setTitle(mResources.getString(R.string.english_ime_input_options)); mOptionsDialog = builder.create(); Window window = mOptionsDialog.getWindow(); diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index d2582b115..5059860d7 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -23,6 +23,7 @@ import android.os.HandlerThread; import android.os.Process; import android.text.format.DateUtils; import android.util.Log; +import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import java.io.BufferedReader; @@ -97,6 +98,13 @@ public class Utils { || imm.getEnabledInputMethodSubtypeList(null, false).size() > 1; } + public static String getInputMethodId(InputMethodManager imm, String packageName) { + for (final InputMethodInfo imi : imm.getEnabledInputMethodList()) { + if (imi.getPackageName().equals(packageName)) + return imi.getId(); + } + throw new RuntimeException("Can not find input method id for " + packageName); + } public static boolean shouldBlockedBySafetyNetForAutoCorrection(SuggestedWords suggestions) { // Safety net for auto correction. -- cgit v1.2.3-83-g751a From a2ad96d95986eb61c3d2d5abce154fb4c3803cac Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 21 Jan 2011 14:07:05 +0900 Subject: Make settings dialog cancel-able by touching outside Bug: 3374426 Change-Id: I6ba9b82d4481c43c78b59e78dcf22cd9875a8240 --- java/src/com/android/inputmethod/latin/LatinIME.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index fb8c9b3a8..7089874eb 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -27,7 +27,6 @@ import com.android.inputmethod.latin.Utils.RingCharBuffer; import com.android.inputmethod.voice.VoiceIMEConnector; import android.app.AlertDialog; -import android.app.Dialog; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; @@ -36,7 +35,6 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; -import android.graphics.Region; import android.inputmethodservice.InputMethodService; import android.media.AudioManager; import android.os.Debug; @@ -2243,6 +2241,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen itemInputMethod, itemSettings}, listener); builder.setTitle(mResources.getString(R.string.english_ime_input_options)); mOptionsDialog = builder.create(); + mOptionsDialog.setCanceledOnTouchOutside(true); Window window = mOptionsDialog.getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); lp.token = mKeyboardSwitcher.getInputView().getWindowToken(); -- cgit v1.2.3-83-g751a From 58d6d0615d62c45c390bb4c5c0e3d2efabac814d Mon Sep 17 00:00:00 2001 From: satok Date: Fri, 21 Jan 2011 14:37:35 +0900 Subject: Disable touchable region until we come up with correct implementation bug: 3373640 Change-Id: I22448b779b0adc60f590aaef916075c7847dcdc9 --- java/src/com/android/inputmethod/latin/LatinIME.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7089874eb..9a939bea8 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -868,14 +868,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (!isFullscreenMode()) { outInsets.contentTopInsets = outInsets.visibleTopInsets; } - KeyboardView inputView = mKeyboardSwitcher.getInputView(); + /*KeyboardView inputView = mKeyboardSwitcher.getInputView(); if (inputView != null) { // Screen's heightPixels may be too big, but want to make // it large enough to cover status bar in any cases. outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION; outInsets.touchableRegion.set( 0, 0, inputView.getWidth(), getResources().getDisplayMetrics().heightPixels); - } + }*/ } @Override -- cgit v1.2.3-83-g751a From 6f7218627eda110a8454053f8ecb7b80edfdc8ce Mon Sep 17 00:00:00 2001 From: satok Date: Wed, 19 Jan 2011 17:29:27 +0900 Subject: Dim previously suggested words Change-Id: Id673c03bfa22ea9ce1bedb5174d8309a37a2a460 --- .../android/inputmethod/latin/CandidateView.java | 28 +++++-- .../com/android/inputmethod/latin/LatinIME.java | 2 +- .../src/com/android/inputmethod/latin/Suggest.java | 16 ++-- .../android/inputmethod/latin/SuggestedWords.java | 85 ++++++++++++++++------ .../inputmethod/voice/VoiceIMEConnector.java | 2 +- 5 files changed, 94 insertions(+), 39 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index d2d1f22dd..fc45c7c75 100644 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -16,8 +16,11 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; + import android.content.Context; import android.content.res.Resources; +import android.graphics.Color; import android.graphics.Typeface; import android.os.Handler; import android.os.Message; @@ -43,6 +46,7 @@ import android.widget.PopupWindow; import android.widget.TextView; import java.util.ArrayList; +import java.util.List; public class CandidateView extends LinearLayout implements OnClickListener, OnLongClickListener { @@ -50,6 +54,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan(); private static final int MAX_SUGGESTIONS = 16; + private static boolean DBG = LatinImeLogger.sDBG; + private final ArrayList mWords = new ArrayList(); private final boolean mConfigCandidateHighlightFontColorEnabled; private final CharacterStyle mInvertedForegroundColorSpan; @@ -175,11 +181,12 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo final SuggestedWords suggestions = mSuggestions; clear(); final int count = suggestions.size(); - final Object[] debugInfo = suggestions.mDebugInfo; for (int i = 0; i < count; i++) { CharSequence word = suggestions.getWord(i); if (word == null) continue; final int wordLength = word.length(); + final List suggestedWordInfoList = + suggestions.mSuggestedWordInfoList; final View v = mWords.get(i); final TextView tv = (TextView)v.findViewById(R.id.candidate_word); @@ -209,10 +216,21 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo } tv.setText(word); tv.setClickable(true); - if (debugInfo != null && i < debugInfo.length && debugInfo[i] != null - && !TextUtils.isEmpty(debugInfo[i].toString())) { - dv.setText(debugInfo[i].toString()); - dv.setVisibility(VISIBLE); + + if (suggestedWordInfoList != null && suggestedWordInfoList.get(i) != null) { + final SuggestedWordInfo info = suggestedWordInfoList.get(i); + if (info.isPreviousSuggestedWord()) { + int color = tv.getCurrentTextColor(); + tv.setTextColor(Color.argb((int)(Color.alpha(color) * 0.5f), Color.red(color), + Color.green(color), Color.blue(color))); + } + final String debugString = info.getDebugString(); + if (DBG) { + if (!TextUtils.isEmpty(debugString)) { + dv.setText(debugString); + dv.setVisibility(VISIBLE); + } + } } else { dv.setVisibility(GONE); } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 7089874eb..02a696088 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1519,7 +1519,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mKeyboardSwitcher.setPreferredLetters(nextLettersFrequencies); boolean correctionAvailable = !mInputTypeNoAutoCorrect && !mJustReverted - && mSuggest.hasMinimalCorrection(); + && mSuggest.hasAutoCorrection(); final CharSequence typedWord = word.getTypedWord(); // If we're in basic correct final boolean typedWordValid = mSuggest.isValidWord(typedWord) || diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 24c73e8ea..1772b2669 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -95,7 +95,7 @@ public class Suggest implements Dictionary.WordCallback { private ArrayList mSuggestions = new ArrayList(); ArrayList mBigramSuggestions = new ArrayList(); private ArrayList mStringPool = new ArrayList(); - private boolean mHaveAutoCorrection; + private boolean mHasAutoCorrection; private String mLowerOriginalWord; // TODO: Remove these member variables by passing more context to addWord() callback method @@ -200,7 +200,7 @@ public class Suggest implements Dictionary.WordCallback { public SuggestedWords.Builder getSuggestedWordBuilder(View view, WordComposer wordComposer, CharSequence prevWordForBigram) { LatinImeLogger.onStartSuggestion(prevWordForBigram); - mHaveAutoCorrection = false; + mHasAutoCorrection = false; mIsFirstCharCapitalized = wordComposer.isFirstCharCapitalized(); mIsAllUpperCase = wordComposer.isAllUpperCase(); collectGarbage(mSuggestions, mPrefMaxSuggestions); @@ -278,7 +278,7 @@ public class Suggest implements Dictionary.WordCallback { if (DBG) { Log.d(TAG, "Auto corrected by CORRECTION_FULL."); } - mHaveAutoCorrection = true; + mHasAutoCorrection = true; } } if (mMainDict != null) mMainDict.getWords(wordComposer, this, mNextLettersFrequencies); @@ -297,7 +297,7 @@ public class Suggest implements Dictionary.WordCallback { if (DBG) { Log.d(TAG, "Auto corrected by S-threthhold."); } - mHaveAutoCorrection = true; + mHasAutoCorrection = true; } } } @@ -342,7 +342,7 @@ public class Suggest implements Dictionary.WordCallback { if (DBG) { Log.d(TAG, "Auto corrected by AUTOTEXT."); } - mHaveAutoCorrection = true; + mHasAutoCorrection = true; mSuggestions.add(i + 1, autoText); i++; } @@ -350,7 +350,7 @@ public class Suggest implements Dictionary.WordCallback { } } removeDupes(); - return new SuggestedWords.Builder().addWords(mSuggestions); + return new SuggestedWords.Builder().addWords(mSuggestions, null); } public int[] getNextLettersFrequencies() { @@ -384,8 +384,8 @@ public class Suggest implements Dictionary.WordCallback { } } - public boolean hasMinimalCorrection() { - return mHaveAutoCorrection; + public boolean hasAutoCorrection() { + return mHasAutoCorrection; } private boolean compareCaseInsensitive(final String mLowerOriginalWord, diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 0fbbcdd91..4407e5b31 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -29,10 +29,11 @@ public class SuggestedWords { public final boolean mIsApplicationSpecifiedCompletions; public final boolean mTypedWordValid; public final boolean mHasMinimalSuggestion; - public final Object[] mDebugInfo; + public final List mSuggestedWordInfoList; private SuggestedWords(List words, boolean isApplicationSpecifiedCompletions, - boolean typedWordValid, boolean hasMinamlSuggestion, Object[] debugInfo) { + boolean typedWordValid, boolean hasMinamlSuggestion, + List suggestedWordInfoList) { if (words != null) { mWords = words; } else { @@ -41,7 +42,7 @@ public class SuggestedWords { mIsApplicationSpecifiedCompletions = isApplicationSpecifiedCompletions; mTypedWordValid = typedWordValid; mHasMinimalSuggestion = hasMinamlSuggestion; - mDebugInfo = debugInfo; + mSuggestedWordInfoList = suggestedWordInfoList; } public int size() { @@ -61,38 +62,46 @@ public class SuggestedWords { } public static class Builder { - private List mWords; + private List mWords = new ArrayList(); private boolean mIsCompletions; private boolean mTypedWordValid; private boolean mHasMinimalSuggestion; - private Object[] mDebugInfo; + private List mSuggestedWordInfoList = + new ArrayList(); public Builder() { // Nothing to do here. } - public Builder addWords(List words) { - for (final CharSequence word : words) - addWord(word); + public Builder addWords(List words, + List suggestedWordInfoList) { + final int N = words.size(); + for (int i = 0; i < N; ++i) { + SuggestedWordInfo suggestedWordInfo = null; + if (suggestedWordInfoList != null) { + suggestedWordInfo = suggestedWordInfoList.get(i); + } + if (suggestedWordInfo == null) { + suggestedWordInfo = new SuggestedWordInfo(); + } + addWord(words.get(i), suggestedWordInfo); + } return this; } - public Builder setDebugInfo(Object[] debuginfo) { - mDebugInfo = debuginfo; - return this; + public Builder addWord(CharSequence word) { + return addWord(word, null, false); } - public Builder addWord(int pos, CharSequence word) { - if (mWords == null) - mWords = new ArrayList(); - mWords.add(pos, word); - return this; + public Builder addWord(CharSequence word, CharSequence debugString, + boolean isPreviousSuggestedWord) { + SuggestedWordInfo info = new SuggestedWordInfo(debugString, isPreviousSuggestedWord); + return addWord(word, info); } - public Builder addWord(CharSequence word) { - if (mWords == null) - mWords = new ArrayList(); + private Builder addWord(CharSequence word, SuggestedWordInfo suggestedWordInfo) { mWords.add(word); + mSuggestedWordInfoList.add(suggestedWordInfo); return this; } @@ -117,11 +126,12 @@ public class SuggestedWords { // and replace it with what the user currently typed. public Builder addTypedWordAndPreviousSuggestions(CharSequence typedWord, SuggestedWords previousSuggestions) { - if (mWords != null) mWords.clear(); - addWord(typedWord); + mWords.clear(); + mSuggestedWordInfoList.clear(); + addWord(typedWord, null, false); final int previousSize = previousSuggestions.size(); for (int pos = 1; pos < previousSize; pos++) - addWord(previousSuggestions.getWord(pos)); + addWord(previousSuggestions.getWord(pos), null, true); mIsCompletions = false; mTypedWordValid = false; mHasMinimalSuggestion = false; @@ -130,15 +140,42 @@ public class SuggestedWords { public SuggestedWords build() { return new SuggestedWords(mWords, mIsCompletions, mTypedWordValid, - mHasMinimalSuggestion, mDebugInfo); + mHasMinimalSuggestion, mSuggestedWordInfoList); } public int size() { - return mWords == null ? 0 : mWords.size(); + return mWords.size(); } public CharSequence getWord(int pos) { return mWords.get(pos); } } + + public static class SuggestedWordInfo { + private final CharSequence mDebugString; + private final boolean mPreviousSuggestedWord; + + public SuggestedWordInfo() { + mDebugString = ""; + mPreviousSuggestedWord = false; + } + + public SuggestedWordInfo(CharSequence debugString, boolean previousSuggestedWord) { + mDebugString = debugString; + mPreviousSuggestedWord = previousSuggestedWord; + } + + public String getDebugString() { + if (mDebugString == null) { + return ""; + } else { + return mDebugString.toString(); + } + } + + public boolean isPreviousSuggestedWord () { + return mPreviousSuggestedWord; + } + } } diff --git a/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java b/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java index a02dbcb55..6c9b7d527 100644 --- a/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java +++ b/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java @@ -437,7 +437,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { builder.addWord(word); } } else { - builder.addWords(suggestions); + builder.addWords(suggestions, null); } builder.setTypedWordValid(true).setHasMinimalSuggestion(true); mService.setSuggestions(builder.build()); -- cgit v1.2.3-83-g751a From f3df63a93a8f623e2aca5895ee749bd297b58d12 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 21 Jan 2011 15:03:09 +0900 Subject: Update suggestions if user typed word is found in dictionary This change aslo eliminates duplicate suggestion from past suggestions. And call setTypedWordVaild to past suggestions. Bug: 3367722 Change-Id: I7ffaa2f7e4e30b3951b6c2df002d269671c9d654 --- java/src/com/android/inputmethod/latin/LatinIME.java | 9 +++++---- java/src/com/android/inputmethod/latin/SuggestedWords.java | 13 +++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 053bf6c1a..04cb89177 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1535,10 +1535,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Basically, we update the suggestion strip only when suggestion count > 1. However, // there is an exception: We update the suggestion strip whenever typed word's length - // is 1, regardless of suggestion count. Actually, in most cases, suggestion count is 1 - // when typed word's length is 1, but we do always need to clear the previous state when - // the user starts typing a word (i.e. typed word's length == 1). - if (typedWord.length() == 1 || builder.size() > 1 + // is 1 or typed word is found in dictionary, regardless of suggestion count. Actually, + // in most cases, suggestion count is 1 when typed word's length is 1, but we do always + // need to clear the previous state when the user starts typing a word (i.e. typed word's + // length == 1). + if (builder.size() > 1 || typedWord.length() == 1 || typedWordValid || mCandidateView.isShowingAddToDictionaryHint()) { builder.setTypedWordValid(typedWordValid).setHasMinimalSuggestion(correctionAvailable); } else { diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 4407e5b31..f774ce3a5 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -20,6 +20,7 @@ import android.view.inputmethod.CompletionInfo; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; public class SuggestedWords { @@ -128,10 +129,18 @@ public class SuggestedWords { SuggestedWords previousSuggestions) { mWords.clear(); mSuggestedWordInfoList.clear(); + final HashSet alreadySeen = new HashSet(); addWord(typedWord, null, false); + alreadySeen.add(typedWord.toString()); final int previousSize = previousSuggestions.size(); - for (int pos = 1; pos < previousSize; pos++) - addWord(previousSuggestions.getWord(pos), null, true); + for (int pos = 1; pos < previousSize; pos++) { + final String prevWord = previousSuggestions.getWord(pos).toString(); + // Filter out duplicate suggestion. + if (!alreadySeen.contains(prevWord)) { + addWord(prevWord, null, true); + alreadySeen.add(prevWord); + } + } mIsCompletions = false; mTypedWordValid = false; mHasMinimalSuggestion = false; -- cgit v1.2.3-83-g751a From 9e347d3d448e48229c46aad394ec9bd60cd5807b Mon Sep 17 00:00:00 2001 From: satok Date: Fri, 21 Jan 2011 19:04:00 +0900 Subject: Fix touchable region Bug: 3238092 Change-Id: Ie2087086af90ba51e0e310f9e46964e450561cbe --- .../com/android/inputmethod/latin/LatinIME.java | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 053bf6c1a..41646ff21 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -67,6 +67,7 @@ import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; +import android.widget.FrameLayout; import android.widget.HorizontalScrollView; import android.widget.LinearLayout; @@ -83,12 +84,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = "LatinIME"; private static final boolean PERF_DEBUG = false; - private static final boolean DEBUG = false; + private static final boolean DEBUG = LatinImeLogger.sDBG; private static final boolean TRACE = false; private static final int DELAY_UPDATE_SUGGESTIONS = 180; private static final int DELAY_UPDATE_OLD_SUGGESTIONS = 300; private static final int DELAY_UPDATE_SHIFT_STATE = 300; + private static final int EXTENDED_TOUCHABLE_REGION_HEIGHT = 100; // How many continuous deletes at which to start deleting at a higher speed. private static final int DELETE_ACCELERATE_AT = 20; @@ -868,14 +870,34 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (!isFullscreenMode()) { outInsets.contentTopInsets = outInsets.visibleTopInsets; } - /*KeyboardView inputView = mKeyboardSwitcher.getInputView(); - if (inputView != null) { - // Screen's heightPixels may be too big, but want to make - // it large enough to cover status bar in any cases. + KeyboardView inputView = mKeyboardSwitcher.getInputView(); + // Need to set touchable region only if input view is being shown + if (inputView != null && mKeyboardSwitcher.isInputViewShown()) { + final int x = 0; + int y = 0; + final int width = inputView.getWidth(); + int height = inputView.getHeight() + EXTENDED_TOUCHABLE_REGION_HEIGHT; + if (mCandidateViewContainer != null) { + ViewParent candidateParent = mCandidateViewContainer.getParent(); + if (candidateParent instanceof FrameLayout) { + FrameLayout fl = (FrameLayout) candidateParent; + if (fl != null) { + // Check frame layout's visibility + if (fl.getVisibility() == View.INVISIBLE) { + y = fl.getHeight(); + height += y; + } else if (fl.getVisibility() == View.VISIBLE) { + height += fl.getHeight(); + } + } + } + } + if (DEBUG) { + Log.d(TAG, "Touchable region " + x + ", " + y + ", " + width + ", " + height); + } outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION; - outInsets.touchableRegion.set( - 0, 0, inputView.getWidth(), getResources().getDisplayMetrics().heightPixels); - }*/ + outInsets.touchableRegion.set(x, y, width, height); + } } @Override -- cgit v1.2.3-83-g751a From 910b73127fa207dd26ec8124000262523b0aac0c Mon Sep 17 00:00:00 2001 From: satok Date: Sun, 23 Jan 2011 05:46:30 +0900 Subject: Add log for voice IME Change-Id: I7d0a458b3cf41fc9dc679f654347e8870c75185d --- java/src/com/android/inputmethod/latin/LatinIME.java | 5 ++++- .../src/com/android/inputmethod/latin/SubtypeSwitcher.java | 14 +++++++++++++- java/src/com/android/inputmethod/voice/VoiceInput.java | 7 ++++++- 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'java/src') diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 847038fee..bbe3f78f2 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -84,8 +84,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen SharedPreferences.OnSharedPreferenceChangeListener { private static final String TAG = "LatinIME"; private static final boolean PERF_DEBUG = false; - private static final boolean DEBUG = LatinImeLogger.sDBG; private static final boolean TRACE = false; + private static boolean DEBUG = LatinImeLogger.sDBG; private static final int DELAY_UPDATE_SUGGESTIONS = 180; private static final int DELAY_UPDATE_OLD_SUGGESTIONS = 300; @@ -514,6 +514,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final KeyboardSwitcher switcher = mKeyboardSwitcher; LatinKeyboardView inputView = switcher.getInputView(); + if(DEBUG) { + Log.d(TAG, "onStartInputView: " + inputView); + } // In landscape mode, this method gets called without the input view being created. if (inputView == null) { return; diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index da46d26bf..ffce66e9b 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -41,7 +41,7 @@ import java.util.Locale; import java.util.Map; public class SubtypeSwitcher { - private static final boolean DBG = LatinImeLogger.sDBG; + private static boolean DBG = LatinImeLogger.sDBG; private static final String TAG = "SubtypeSwitcher"; private static final char LOCALE_SEPARATER = '_'; @@ -163,6 +163,12 @@ public class SubtypeSwitcher { } private void updateShortcutIME() { + if (DBG) { + Log.d(TAG, "Update shortcut IME from : " + + (mShortcutInfo == null ? "" : mShortcutInfo.getId()) + ", " + + (mShortcutSubtype == null ? "" : (mShortcutSubtype.getLocale() + + ", " + mShortcutSubtype.getMode()))); + } // TODO: Update an icon for shortcut IME Map> shortcuts = mImm.getShortcutInputMethodsAndSubtypes(); @@ -176,6 +182,12 @@ public class SubtypeSwitcher { mShortcutSubtype = subtypes.size() > 0 ? subtypes.get(0) : null; break; } + if (DBG) { + Log.d(TAG, "Update shortcut IME to : " + + (mShortcutInfo == null ? "" : mShortcutInfo.getId()) + ", " + + (mShortcutSubtype == null ? "" : (mShortcutSubtype.getLocale() + + ", " + mShortcutSubtype.getMode()))); + } } // Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function. diff --git a/java/src/com/android/inputmethod/voice/VoiceInput.java b/java/src/com/android/inputmethod/voice/VoiceInput.java index ffa349fde..20211d46c 100644 --- a/java/src/com/android/inputmethod/voice/VoiceInput.java +++ b/java/src/com/android/inputmethod/voice/VoiceInput.java @@ -17,6 +17,7 @@ package com.android.inputmethod.voice; import com.android.inputmethod.latin.EditingUtils; +import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import android.content.ContentResolver; @@ -58,6 +59,7 @@ public class VoiceInput implements OnClickListener { private static final String EXTRA_CALLING_PACKAGE = "calling_package"; private static final String EXTRA_ALTERNATES = "android.speech.extra.ALTERNATES"; private static final int MAX_ALT_LIST_LENGTH = 6; + private static boolean DBG = LatinImeLogger.sDBG; private static final String DEFAULT_RECOMMENDED_PACKAGES = "com.android.mms " + @@ -313,8 +315,11 @@ public class VoiceInput implements OnClickListener { * @param swipe whether this voice input was started by swipe, for logging purposes */ public void startListening(FieldContext context, boolean swipe) { + if (DBG) { + Log.d(TAG, "startListening: " + context); + } mState = DEFAULT; - + Locale locale = Locale.getDefault(); String localeString = locale.getLanguage() + "-" + locale.getCountry(); -- cgit v1.2.3-83-g751a From de59a84029d3d3ec114b5b0f2eca0b3752982fef Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 21 Jan 2011 18:46:19 +0900 Subject: Implement callback to handle touch event outside SoftInputWindow Bug: 3238092 Change-Id: Ie8d4469bc2c6880bdf2a0c4e4eec68bb136b837c --- java/res/values-xlarge/dimens.xml | 1 + java/res/values/dimens.xml | 1 + .../latin/ClipTouchEventWindowCallback.java | 75 +++++++++ .../com/android/inputmethod/latin/LatinIME.java | 28 ++-- .../inputmethod/latin/WindowCallbackAdapter.java | 168 +++++++++++++++++++++ 5 files changed, 264 insertions(+), 9 deletions(-) create mode 100644 java/src/com/android/inputmethod/latin/ClipTouchEventWindowCallback.java create mode 100644 java/src/com/android/inputmethod/latin/WindowCallbackAdapter.java (limited to 'java/src') diff --git a/java/res/values-xlarge/dimens.xml b/java/res/values-xlarge/dimens.xml index 69283202e..11ad6b184 100644 --- a/java/res/values-xlarge/dimens.xml +++ b/java/res/values-xlarge/dimens.xml @@ -42,6 +42,7 @@ 24dip 6dip + 10.0mm 46dip 15.0mm diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 7f00cdba3..90bf1bfad 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -46,6 +46,7 @@ -0.05in + 0.0mm 42dip 63dip diff --git a/java/src/com/android/inputmethod/latin/ClipTouchEventWindowCallback.java b/java/src/com/android/inputmethod/latin/ClipTouchEventWindowCallback.java new file mode 100644 index 000000000..d12c70075 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/ClipTouchEventWindowCallback.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.android.inputmethod.latin; + +import android.view.MotionEvent; +import android.view.View; +import android.view.Window; + +public class ClipTouchEventWindowCallback extends WindowCallbackAdapter { + private final View mDecorView; + private final int mKeyboardBottomRowVerticalCorrection; + + public ClipTouchEventWindowCallback(Window window, int keyboardBottomRowVerticalCorrection) { + super(window.getCallback()); + mDecorView = window.getDecorView(); + mKeyboardBottomRowVerticalCorrection = keyboardBottomRowVerticalCorrection; + } + + @Override + public boolean dispatchTouchEvent(MotionEvent me) { + final int height = mDecorView.getHeight(); + final MotionEvent event = clipMotionEvent(me, height, + height + mKeyboardBottomRowVerticalCorrection); + return super.dispatchTouchEvent(event); + } + + private static MotionEvent clipMotionEvent(MotionEvent me, int minHeight, int maxHeight) { + final int pointerCount = me.getPointerCount(); + boolean shouldClip = false; + for (int pointerIndex = 0; pointerIndex < pointerCount; pointerIndex++) { + final float y = me.getY(pointerIndex); + if (y >= minHeight && y < maxHeight) { + shouldClip = true; + break; + } + } + if (!shouldClip) + return me; + + if (pointerCount == 1) { + me.setLocation(me.getX(), minHeight - 1); + return me; + } + + final int[] pointerIds = new int[pointerCount]; + final MotionEvent.PointerCoords[] pointerCoords = + new MotionEvent.PointerCoords[pointerCount]; + for (int pointerIndex = 0; pointerIndex < pointerCount; pointerIndex++) { + pointerIds[pointerIndex] = me.getPointerId(pointerIndex); + final MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords(); + me.getPointerCoords(pointerIndex, coords); + pointerCoords[pointerIndex] = coords; + if (coords.y >= minHeight && coords.y < maxHeight) + coords.y = minHeight - 1; + } + return MotionEvent.obtain( + me.getDownTime(), me.getEventTime(), me.getAction(), pointerCount, pointerIds, + pointerCoords, me.getMetaState(), me.getXPrecision(), me.getYPrecision(), + me.getDeviceId(), me.getEdgeFlags(), me.getSource(), me.getFlags()); + } +} diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 847038fee..f0c9a5cd4 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -161,6 +161,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private int mConfigDelayBeforeFadeoutLanguageOnSpacebar; private int mConfigDurationOfFadeoutLanguageOnSpacebar; private float mConfigFinalFadeoutFactorOfLanguageOnSpacebar; + // For example, to deal with status bar on tablet. + private int mKeyboardBottomRowVerticalCorrection; private int mCorrectionMode; private int mCommittedLength; @@ -377,6 +379,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen R.integer.config_duration_of_fadeout_language_on_spacebar); mConfigFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger( R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f; + mKeyboardBottomRowVerticalCorrection = (int)res.getDimension( + R.dimen.keyboard_bottom_row_vertical_correction); Utils.GCUtils.getInstance().reset(); boolean tryGC = true; @@ -566,6 +570,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mVoiceConnector.onStartInputView(inputView.getWindowToken()); + if (mKeyboardBottomRowVerticalCorrection > 0) { + final Window window = getWindow().getWindow(); + if (!(window.getCallback() instanceof ClipTouchEventWindowCallback)) { + window.setCallback(new ClipTouchEventWindowCallback( + window, mKeyboardBottomRowVerticalCorrection)); + } + } + if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); } @@ -880,15 +892,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (mCandidateViewContainer != null) { ViewParent candidateParent = mCandidateViewContainer.getParent(); if (candidateParent instanceof FrameLayout) { - FrameLayout fl = (FrameLayout) candidateParent; - if (fl != null) { - // Check frame layout's visibility - if (fl.getVisibility() == View.INVISIBLE) { - y = fl.getHeight(); - height += y; - } else if (fl.getVisibility() == View.VISIBLE) { - height += fl.getHeight(); - } + final FrameLayout fl = (FrameLayout) candidateParent; + // Check frame layout's visibility + if (fl.getVisibility() == View.INVISIBLE) { + y = fl.getHeight(); + height += y; + } else if (fl.getVisibility() == View.VISIBLE) { + height += fl.getHeight(); } } } diff --git a/java/src/com/android/inputmethod/latin/WindowCallbackAdapter.java b/java/src/com/android/inputmethod/latin/WindowCallbackAdapter.java new file mode 100644 index 000000000..be9bb2bd8 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/WindowCallbackAdapter.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.android.inputmethod.latin; + +import android.view.ActionMode; +import android.view.ActionMode.Callback; +import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.Window; +import android.view.WindowManager.LayoutParams; +import android.view.accessibility.AccessibilityEvent; + +public class WindowCallbackAdapter implements Window.Callback { + private final Window.Callback mPreviousCallback; + + public WindowCallbackAdapter(Window.Callback previousCallback) { + mPreviousCallback = previousCallback; + } + + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (mPreviousCallback != null) + return mPreviousCallback.dispatchKeyEvent(event); + return false; + } + + @Override + public boolean dispatchKeyShortcutEvent(KeyEvent event) { + if (mPreviousCallback != null) + return mPreviousCallback.dispatchKeyShortcutEvent(event); + return false; + } + + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + if (mPreviousCallback != null) + return mPreviousCallback.dispatchPopulateAccessibilityEvent(event); + return false; + } + + @Override + public boolean dispatchTouchEvent(MotionEvent event) { + if (mPreviousCallback != null) + return mPreviousCallback.dispatchTouchEvent(event); + return false; + } + + @Override + public boolean dispatchTrackballEvent(MotionEvent event) { + if (mPreviousCallback != null) + return mPreviousCallback.dispatchTrackballEvent(event); + return false; + } + + @Override + public void onActionModeFinished(ActionMode mode) { + if (mPreviousCallback != null) + mPreviousCallback.onActionModeFinished(mode); + } + + @Override + public void onActionModeStarted(ActionMode mode) { + if (mPreviousCallback != null) + mPreviousCallback.onActionModeStarted(mode); + } + + @Override + public void onAttachedToWindow() { + if (mPreviousCallback != null) + mPreviousCallback.onAttachedToWindow(); + } + + @Override + public void onContentChanged() { + if (mPreviousCallback != null) + mPreviousCallback.onContentChanged(); + } + + @Override + public boolean onCreatePanelMenu(int featureId, Menu menu) { + if (mPreviousCallback != null) + return mPreviousCallback.onCreatePanelMenu(featureId, menu); + return false; + } + + @Override + public View onCreatePanelView(int featureId) { + if (mPreviousCallback != null) + return mPreviousCallback.onCreatePanelView(featureId); + return null; + } + + @Override + public void onDetachedFromWindow() { + if (mPreviousCallback != null) + mPreviousCallback.onDetachedFromWindow(); + } + + @Override + public boolean onMenuItemSelected(int featureId, MenuItem item) { + if (mPreviousCallback != null) + return mPreviousCallback.onMenuItemSelected(featureId, item); + return false; + } + + @Override + public boolean onMenuOpened(int featureId, Menu menu) { + if (mPreviousCallback != null) + return mPreviousCallback.onMenuOpened(featureId, menu); + return false; + } + + @Override + public void onPanelClosed(int featureId, Menu menu) { + if (mPreviousCallback != null) + mPreviousCallback.onPanelClosed(featureId, menu); + } + + @Override + public boolean onPreparePanel(int featureId, View view, Menu menu) { + if (mPreviousCallback != null) + return mPreviousCallback.onPreparePanel(featureId, view, menu); + return false; + } + + @Override + public boolean onSearchRequested() { + if (mPreviousCallback != null) + return mPreviousCallback.onSearchRequested(); + return false; + } + + @Override + public void onWindowAttributesChanged(LayoutParams attrs) { + if (mPreviousCallback != null) + mPreviousCallback.onWindowAttributesChanged(attrs); + } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + if (mPreviousCallback != null) + mPreviousCallback.onWindowFocusChanged(hasFocus); + } + + @Override + public ActionMode onWindowStartingActionMode(Callback callback) { + if (mPreviousCallback != null) + return mPreviousCallback.onWindowStartingActionMode(callback); + return null; + } +} -- cgit v1.2.3-83-g751a From 8cacb024cf400241f9885cccee782c286cbf1330 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 24 Jan 2011 17:38:49 +0900 Subject: Set minimum height for RecognitionView in the case that there is no keyboard view loaded. Bug: 3352322 Change-Id: I9a7b2a745b47bdc62a96a5cd2c0d8ad717e1b406 --- java/res/layout/recognition_status.xml | 2 +- java/src/com/android/inputmethod/latin/SubtypeSwitcher.java | 2 +- .../com/android/inputmethod/voice/VoiceIMEConnector.java | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'java/src') diff --git a/java/res/layout/recognition_status.xml b/java/res/layout/recognition_status.xml index b2c9f4a51..b00432f0c 100644 --- a/java/res/layout/recognition_status.xml +++ b/java/res/layout/recognition_status.xml @@ -26,7 +26,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/popup_layout" android:orientation="vertical" - android:layout_height="0dip" + android:layout_height="371dip" android:layout_width="500dip" android:layout_centerInParent="true" android:background="@drawable/vs_dialog_red"> diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index ffce66e9b..d3aa70c28 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -435,7 +435,7 @@ public class SubtypeSwitcher { mVoiceInput = vi; if (isVoiceMode()) { if (DBG) { - Log.d(TAG, "Set and call voice input."); + Log.d(TAG, "Set and call voice input.: " + getInputLocaleStr()); } triggerVoiceIME(); return true; diff --git a/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java b/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java index 6c9b7d527..a3a3ea88e 100644 --- a/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java +++ b/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java @@ -78,6 +78,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { // given text field. For instance this is specified by the search dialog when the // dialog is already showing a voice search button. private static final String IME_OPTION_NO_MICROPHONE = "nm"; + private static final int RECOGNITIONVIEW_HEIGHT_THRESHOLD_RATIO = 6; @SuppressWarnings("unused") private static final String TAG = "VoiceIMEConnector"; @@ -543,10 +544,14 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { // As we add mm, we don't know how the rounding is going to work // thus we may end up with few pixels extra (or less). if (keyboardView != null) { - int h = keyboardView.getHeight(); - if (h > 0) { - View popupLayout = v.findViewById(R.id.popup_layout); - popupLayout.getLayoutParams().height = h; + View popupLayout = v.findViewById(R.id.popup_layout); + final int displayHeight = + mService.getResources().getDisplayMetrics().heightPixels; + final int currentHeight = popupLayout.getLayoutParams().height; + final int keyboardHeight = keyboardView.getHeight(); + if (keyboardHeight > currentHeight || keyboardHeight + > (displayHeight / RECOGNITIONVIEW_HEIGHT_THRESHOLD_RATIO)) { + popupLayout.getLayoutParams().height = keyboardHeight; } } mService.setInputView(v); -- cgit v1.2.3-83-g751a From 2c5ec3a50dc9c20cb89fd6219f84600e65dddc6e Mon Sep 17 00:00:00 2001 From: Luca Zanolin Date: Mon, 24 Jan 2011 10:36:15 +0000 Subject: Always display the VoiceIME language in the Speak Now pop-up Change-Id: I1b01458aff98447b7b3d5459b765968bed5515cb --- java/res/layout/recognition_status.xml | 16 +++++++++++++ .../android/inputmethod/voice/RecognitionView.java | 27 ++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) (limited to 'java/src') diff --git a/java/res/layout/recognition_status.xml b/java/res/layout/recognition_status.xml index b2c9f4a51..81fae2ada 100644 --- a/java/res/layout/recognition_status.xml +++ b/java/res/layout/recognition_status.xml @@ -70,6 +70,22 @@ android:layout_centerInParent="true" android:visibility="gone"/> + +