diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r-- | java/src/com/android/inputmethod/latin/SubtypeSwitcher.java | 7 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Utils.java | 18 |
2 files changed, 23 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 10a3369ac..053e2abe4 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -210,7 +210,7 @@ public class SubtypeSwitcher { final String newLocale; final String newMode; final String oldMode = getCurrentSubtypeMode(); - if (newSubtype == null || !newSubtype.hasOriginalObject()) { + if (newSubtype == null) { // Normally, newSubtype shouldn't be null. But just in case newSubtype was null, // fallback to the default locale. Log.w(TAG, "Couldn't get the current subtype."); @@ -539,6 +539,11 @@ public class SubtypeSwitcher { return null == mCurrentSubtype ? false : VOICE_MODE.equals(getCurrentSubtypeMode()); } + public boolean isDummyVoiceMode() { + return mCurrentSubtype != null && mCurrentSubtype.getOriginalObject() == null + && VOICE_MODE.equals(getCurrentSubtypeMode()); + } + private void triggerVoiceIME() { if (!mService.isInputViewShown()) return; VoiceProxy.getInstance().startListening(false, diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 35b2b123c..3e092d938 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -21,6 +21,7 @@ import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputTypeCompatUtils; import com.android.inputmethod.keyboard.KeyboardId; +import android.content.Context; import android.content.res.Resources; import android.inputmethodservice.InputMethodService; import android.os.AsyncTask; @@ -110,9 +111,14 @@ public class Utils { } public static String getInputMethodId(InputMethodManagerCompatWrapper imm, String packageName) { + return getInputMethodInfo(imm, packageName).getId(); + } + + public static InputMethodInfoCompatWrapper getInputMethodInfo( + InputMethodManagerCompatWrapper imm, String packageName) { for (final InputMethodInfoCompatWrapper imi : imm.getEnabledInputMethodList()) { if (imi.getPackageName().equals(packageName)) - return imi.getId(); + return imi; } throw new RuntimeException("Can not find input method id for " + packageName); } @@ -601,4 +607,14 @@ public class Utils { } return true; } + + public static float getDipScale(Context context) { + final float scale = context.getResources().getDisplayMetrics().density; + return scale; + } + + /** Convert pixel to DIP */ + public static int dipToPixel(float scale, int dip) { + return (int) ((float) dip * scale + 0.5); + } } |