From 4aad61bd3677b744f641dcb408e753eec3494cc6 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 27 Dec 2010 20:41:52 +0900 Subject: [PATCH] Fix build breakage by removing HC APIs calls Change-Id: I0cd4a52da00680f8d51a1417898fa283974726c4 --- .../compat/InputMethodSubtype.java | 157 ++++++++++++++++++ .../inputmethod/keyboard/KeyboardId.java | 2 +- .../android/inputmethod/latin/LatinIME.java | 27 +-- .../android/inputmethod/latin/Settings.java | 4 +- .../inputmethod/latin/SubtypeSwitcher.java | 25 +-- .../com/android/inputmethod/latin/Utils.java | 5 +- .../inputmethod/voice/VoiceIMEConnector.java | 2 + .../inputmethod/voice/VoiceInputLogger.java | 2 +- 8 files changed, 198 insertions(+), 26 deletions(-) create mode 100644 java/src/com/android/inputmethod/compat/InputMethodSubtype.java diff --git a/java/src/com/android/inputmethod/compat/InputMethodSubtype.java b/java/src/com/android/inputmethod/compat/InputMethodSubtype.java new file mode 100644 index 000000000..6630dbe75 --- /dev/null +++ b/java/src/com/android/inputmethod/compat/InputMethodSubtype.java @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2010 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. + */ + +// Note: This class has been copied from Honeycomb framework. +// Original class in Honeycomb framework is {@link android.view.inputmethod.InputMethodSubtype}. + +package com.android.inputmethod.compat; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Arrays; + +/** + * Information given to an {@link InputMethod} about a client connecting + * to it. + */ +/** + * InputMethodSubtype is a subtype contained in the input method. Subtype can describe + * locales (e.g. en_US, fr_FR...) and modes (e.g. voice, keyboard...), and is used for + * IME switch. The subtype allows the system to call the specified subtype of IME directly. + */ +public final class InputMethodSubtype implements Parcelable { + private final int mSubtypeNameResId; + private final int mSubtypeIconResId; + private final String mSubtypeLocale; + private final String mSubtypeMode; + private final String mSubtypeExtraValue; + private final int mSubtypeHashCode; + + /** + * Constructor + * @param nameId The name of the subtype + * @param iconId The icon of the subtype + * @param locale The locale supported by the subtype + * @param modeId The mode supported by the subtype + * @param extraValue The extra value of the subtype + */ + InputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue) { + mSubtypeNameResId = nameId; + mSubtypeIconResId = iconId; + mSubtypeLocale = locale != null ? locale : ""; + mSubtypeMode = mode != null ? mode : ""; + mSubtypeExtraValue = extraValue != null ? extraValue : ""; + mSubtypeHashCode = hashCodeInternal(mSubtypeNameResId, mSubtypeIconResId, mSubtypeLocale, + mSubtypeMode, mSubtypeExtraValue); + } + + InputMethodSubtype(Parcel source) { + String s; + mSubtypeNameResId = source.readInt(); + mSubtypeIconResId = source.readInt(); + s = source.readString(); + mSubtypeLocale = s != null ? s : ""; + s = source.readString(); + mSubtypeMode = s != null ? s : ""; + s = source.readString(); + mSubtypeExtraValue = s != null ? s : ""; + mSubtypeHashCode = hashCodeInternal(mSubtypeNameResId, mSubtypeIconResId, mSubtypeLocale, + mSubtypeMode, mSubtypeExtraValue); + } + + /** + * @return the name of the subtype + */ + public int getNameResId() { + return mSubtypeNameResId; + } + + /** + * @return the icon of the subtype + */ + public int getIconResId() { + return mSubtypeIconResId; + } + + /** + * @return the locale of the subtype + */ + public String getLocale() { + return mSubtypeLocale; + } + + /** + * @return the mode of the subtype + */ + public String getMode() { + return mSubtypeMode; + } + + /** + * @return the extra value of the subtype + */ + public String getExtraValue() { + return mSubtypeExtraValue; + } + + @Override + public int hashCode() { + return mSubtypeHashCode; + } + + @Override + public boolean equals(Object o) { + if (o instanceof InputMethodSubtype) { + InputMethodSubtype subtype = (InputMethodSubtype) o; + return (subtype.hashCode() == hashCode()) + && (subtype.getNameResId() == getNameResId()) + && (subtype.getMode().equals(getMode())) + && (subtype.getIconResId() == getIconResId()) + && (subtype.getLocale().equals(getLocale())) + && (subtype.getExtraValue().equals(getExtraValue())); + } + return false; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int parcelableFlags) { + dest.writeInt(mSubtypeNameResId); + dest.writeInt(mSubtypeIconResId); + dest.writeString(mSubtypeLocale); + dest.writeString(mSubtypeMode); + dest.writeString(mSubtypeExtraValue); + } + + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator() { + public InputMethodSubtype createFromParcel(Parcel source) { + return new InputMethodSubtype(source); + } + + public InputMethodSubtype[] newArray(int size) { + return new InputMethodSubtype[size]; + } + }; + + private static int hashCodeInternal(int nameResId, int iconResId, String locale, + String mode, String extraValue) { + return Arrays.hashCode(new Object[] {nameResId, iconResId, locale, mode, extraValue}); + } +} diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index db86740c3..8c70d8ffe 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -171,7 +171,7 @@ public class KeyboardId { case EditorInfo.IME_ACTION_SEARCH: action = "actionSearch"; break; case EditorInfo.IME_ACTION_SEND: action = "actionSend"; break; case EditorInfo.IME_ACTION_DONE: action = "actionDone"; break; - case EditorInfo.IME_ACTION_PREVIOUS: action = "actionPrevious"; break; + // @@@ case EditorInfo.IME_ACTION_PREVIOUS: action = "actionPrevious"; break; default: action = "actionUnknown(" + actionNo + ")"; break; } if ((imeOptions & EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 51b56ec14..c44410449 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -16,6 +16,7 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.compat.InputMethodSubtype; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; import com.android.inputmethod.keyboard.KeyboardId; @@ -63,13 +64,12 @@ import android.view.ViewParent; import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.CompletionInfo; -import android.view.inputmethod.CorrectionInfo; +// @@@ import android.view.inputmethod.CorrectionInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; -import android.view.inputmethod.InputMethodSubtype; import android.widget.HorizontalScrollView; import android.widget.LinearLayout; @@ -479,7 +479,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (container.getPaddingRight() != 0) { HorizontalScrollView scrollView = (HorizontalScrollView) container.findViewById(R.id.candidates_scroll_view); - scrollView.setOverScrollMode(View.OVER_SCROLL_NEVER); + // @@@ scrollView.setOverScrollMode(View.OVER_SCROLL_NEVER); container.setGravity(Gravity.CENTER_HORIZONTAL); } mCandidateView = (CandidateView) container.findViewById(R.id.candidates); @@ -490,13 +490,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private static boolean isPasswordVariation(int variation) { return variation == InputType.TYPE_TEXT_VARIATION_PASSWORD - || variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD - || variation == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD; + || variation == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD; + // @@@ || variation == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD; } private static boolean isEmailVariation(int variation) { - return variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS - || variation == InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS; + return variation == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; + // @@@ || variation == InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS; } @Override @@ -1200,8 +1200,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void handleTab() { final int imeOptions = getCurrentInputEditorInfo().imeOptions; - final int navigationFlags = - EditorInfo.IME_FLAG_NAVIGATE_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS; + final int navigationFlags = 0; + // @@@ final int navigationFlags = + // @@@ EditorInfo.IME_FLAG_NAVIGATE_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS; if ((imeOptions & navigationFlags) == 0) { sendDownUpKeyEvents(KeyEvent.KEYCODE_TAB); return; @@ -1211,6 +1212,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (ic == null) return; + /* @@@ // True if keyboard is in either chording shift or manual temporary upper case mode. final boolean isManualTemporaryUpperCase = mKeyboardSwitcher.isManualTemporaryUpperCase(); if ((imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0 @@ -1220,6 +1222,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen && isManualTemporaryUpperCase) { ic.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); } + */ } private void abortCorrection(boolean force) { @@ -1346,9 +1349,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen TextEntryState.backToAcceptedDefault(typedWord); if (!TextUtils.isEmpty(typedWord) && !typedWord.equals(mBestWord)) { if (ic != null) { + /* @@@ CorrectionInfo correctionInfo = new CorrectionInfo( mLastSelectionEnd - typedWord.length(), typedWord, mBestWord); ic.commitCorrection(correctionInfo); + */ } if (mCandidateView != null) mCandidateView.onAutoCorrectionInverted(mBestWord); @@ -2037,7 +2042,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Get the settings preferences final SharedPreferences prefs = mPrefs; Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); - mVibrateOn = vibrator != null && vibrator.hasVibrator() + // @@@ mVibrateOn = vibrator != null && vibrator.hasVibrator() + mVibrateOn = vibrator != null && prefs.getBoolean(Settings.PREF_VIBRATE_ON, false); mSoundOn = prefs.getBoolean(Settings.PREF_SOUND_ON, false); mPopupOn = prefs.getBoolean(Settings.PREF_POPUP_ON, @@ -2197,7 +2203,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen System.out.println("CPS = " + ((CPS_BUFFER_SIZE * 1000f) / total)); } - @Override public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { SubtypeSwitcher.getInstance().updateSubtype(subtype); } diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 3f604a381..ea1faf512 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -116,7 +116,9 @@ public class Settings extends PreferenceActivity } Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); - if (vibrator == null || !vibrator.hasVibrator()) { + if (vibrator == null + // @@@ || !vibrator.hasVibrator() + ) { getPreferenceScreen().removePreference( getPreferenceScreen().findPreference(PREF_VIBRATE_ON)); } diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index a5bfdeb94..3539f9fa6 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -16,6 +16,7 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.compat.InputMethodSubtype; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.voice.SettingsUtil; @@ -33,7 +34,6 @@ import android.text.TextUtils; import android.util.Log; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; -import android.view.inputmethod.InputMethodSubtype; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +44,8 @@ import java.util.Map; public class SubtypeSwitcher { // This flag indicates if we support language switching by swipe on space bar. // We may or may not draw the current language on space bar regardless of this flag. - public static final boolean USE_SPACEBAR_LANGUAGE_SWITCHER = false; + // @@@ + public static final boolean USE_SPACEBAR_LANGUAGE_SWITCHER = true; private static final boolean DBG = false; private static final String TAG = "SubtypeSwitcher"; @@ -104,7 +105,7 @@ public class SubtypeSwitcher { mSystemLocale = null; mInputLocale = null; mInputLocaleStr = null; - mMode = null; + mMode = KEYBOARD_MODE; mAllEnabledSubtypesOfCurrentInputMethod = null; // TODO: Voice input should be created here mVoiceInput = null; @@ -114,7 +115,7 @@ public class SubtypeSwitcher { // Only configuration changed event is allowed to call this because this is heavy. private void updateAllParameters() { mSystemLocale = mResources.getConfiguration().locale; - updateSubtype(mImm.getCurrentInputMethodSubtype()); + // @@@ updateSubtype(mImm.getCurrentInputMethodSubtype()); updateParametersOnStartInputView(); } @@ -132,8 +133,8 @@ public class SubtypeSwitcher { // Reload enabledSubtypes from the framework. private void updateEnabledSubtypes() { boolean foundCurrentSubtypeBecameDisabled = true; - mAllEnabledSubtypesOfCurrentInputMethod = mImm.getEnabledInputMethodSubtypeList( - null, false); + // @@@ mAllEnabledSubtypesOfCurrentInputMethod = mImm.getEnabledInputMethodSubtypeList( + //null, false); mEnabledLanguagesOfCurrentInputMethod.clear(); mEnabledKeyboardSubtypesOfCurrentInputMethod.clear(); for (InputMethodSubtype ims: mAllEnabledSubtypesOfCurrentInputMethod) { @@ -156,12 +157,13 @@ public class SubtypeSwitcher { if (DBG) { Log.w(TAG, "Last subtype was disabled. Update to the current one."); } - updateSubtype(mImm.getCurrentInputMethodSubtype()); + // @@@ updateSubtype(mImm.getCurrentInputMethodSubtype()); } } private void updateShortcutIME() { // TODO: Update an icon for shortcut IME + /* Map> shortcuts = mImm.getShortcutInputMethodsAndSubtypes(); for (InputMethodInfo imi: shortcuts.keySet()) { @@ -173,7 +175,8 @@ public class SubtypeSwitcher { // as appropriate. mShortcutSubtype = subtypes.size() > 0 ? subtypes.get(0) : null; break; - } + } + */ } // Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function. @@ -268,7 +271,7 @@ public class SubtypeSwitcher { if (token == null || mShortcutInfo == null) { return; } - mImm.setInputMethodAndSubtype(token, mShortcutInfo.getId(), mShortcutSubtype); + // @@@ mImm.setInputMethodAndSubtype(token, mShortcutInfo.getId(), mShortcutSubtype); } public Drawable getShortcutIcon() { @@ -276,6 +279,7 @@ public class SubtypeSwitcher { } private Drawable getSubtypeIcon(InputMethodInfo imi, InputMethodSubtype subtype) { + /* final PackageManager pm = mService.getPackageManager(); if (imi != null) { final String imiPackageName = imi.getPackageName(); @@ -297,7 +301,8 @@ public class SubtypeSwitcher { Log.w(TAG, "IME can't be found: " + imiPackageName); } } - } + } + */ return null; } diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 92b990482..0e0cba9b3 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -89,10 +89,11 @@ public class Utils { } public static boolean hasMultipleEnabledIMEsOrSubtypes(InputMethodManager imm) { - return imm.getEnabledInputMethodList().size() > 1 + return imm.getEnabledInputMethodList().size() > 1; + // @@@ return imm.getEnabledInputMethodList().size() > 1 // imm.getEnabledInputMethodSubtypeList(null, false) will return the current IME's enabled // input method subtype (The current IME should be LatinIME.) - || imm.getEnabledInputMethodSubtypeList(null, false).size() > 1; + // || imm.getEnabledInputMethodSubtypeList(null, false).size() > 1; } /* package */ static class RingCharBuffer { diff --git a/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java b/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java index d9528eb40..1ff918315 100644 --- a/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java +++ b/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java @@ -541,8 +541,10 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { } private void switchToLastInputMethod() { + /* @@@ IBinder token = mContext.getWindow().getWindow().getAttributes().token; mImm.switchToLastInputMethod(token); + */ } private void reallyStartListening(boolean swipe, final boolean configurationChanging) { diff --git a/java/src/com/android/inputmethod/voice/VoiceInputLogger.java b/java/src/com/android/inputmethod/voice/VoiceInputLogger.java index 107ec78e4..1cea681f8 100644 --- a/java/src/com/android/inputmethod/voice/VoiceInputLogger.java +++ b/java/src/com/android/inputmethod/voice/VoiceInputLogger.java @@ -257,7 +257,7 @@ public class VoiceInputLogger { // 2. type subject in subject field // 3. speak message in message field // 4. press send - UserHappinessSignals.setHasVoiceLoggingInfo(hasLoggingInfo); + // @@@ UserHappinessSignals.setHasVoiceLoggingInfo(hasLoggingInfo); } private boolean hasLoggingInfo(){