From f5d9649680ae5ee3fe11e839d3111f3351d15285 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 26 May 2011 19:19:13 +0900 Subject: [PATCH] Introduce web and email mode (DO NOT MERGE) This change introduces new keyboard mode "webEmail" to honor InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS. In this mode, both '@' key and TAB key appear on the keyboard. The keyboard layouts will be modified with other change. Bug: 4490948 Change-Id: I66f9bda4907da448db097e9c900199dfa700b16a --- java/res/values/attrs.xml | 2 ++ .../inputmethod/keyboard/KeyboardId.java | 4 +++ .../android/inputmethod/latin/LatinIME.java | 26 ++++++++++--------- .../com/android/inputmethod/latin/Utils.java | 9 +++++-- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index f0da2744b..fb4d97b8b 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -167,6 +167,8 @@ + + diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 97ef687bd..91dbf25cf 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -36,6 +36,8 @@ public class KeyboardId { public static final int MODE_WEB = 4; public static final int MODE_PHONE = 5; public static final int MODE_NUMBER = 6; + // Should come up with implementing web & email mode clearer way. + public static final int MODE_WEB_EMAIL = 7; public final Locale mLocale; public final int mOrientation; @@ -159,6 +161,7 @@ public class KeyboardId { case MODE_WEB: return "web"; case MODE_PHONE: return "phone"; case MODE_NUMBER: return "number"; + case MODE_WEB_EMAIL: return "webEmail"; } return null; } @@ -182,6 +185,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_NEXT: action = "actionNext"; break; case EditorInfo.IME_ACTION_PREVIOUS: action = "actionPrevious"; break; default: action = "actionUnknown(" + actionNo + ")"; break; } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 6e76cadf2..bf831bfbc 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -16,15 +16,6 @@ package com.android.inputmethod.latin; -import com.android.inputmethod.keyboard.Keyboard; -import com.android.inputmethod.keyboard.KeyboardActionListener; -import com.android.inputmethod.keyboard.KeyboardSwitcher; -import com.android.inputmethod.keyboard.KeyboardView; -import com.android.inputmethod.keyboard.LatinKeyboard; -import com.android.inputmethod.keyboard.LatinKeyboardView; -import com.android.inputmethod.latin.Utils.RingCharBuffer; -import com.android.inputmethod.voice.VoiceIMEConnector; - import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -72,6 +63,15 @@ import android.widget.FrameLayout; import android.widget.HorizontalScrollView; import android.widget.LinearLayout; +import com.android.inputmethod.keyboard.Keyboard; +import com.android.inputmethod.keyboard.KeyboardActionListener; +import com.android.inputmethod.keyboard.KeyboardSwitcher; +import com.android.inputmethod.keyboard.KeyboardView; +import com.android.inputmethod.keyboard.LatinKeyboard; +import com.android.inputmethod.keyboard.LatinKeyboardView; +import com.android.inputmethod.latin.Utils.RingCharBuffer; +import com.android.inputmethod.voice.VoiceIMEConnector; + import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -85,7 +85,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private static final String TAG = LatinIME.class.getSimpleName(); private static final boolean PERF_DEBUG = false; private static final boolean TRACE = false; - private static boolean DEBUG = LatinImeLogger.sDBG; + private static boolean DEBUG; /** * The private IME option used to indicate that no microphone should be @@ -390,6 +390,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mKeyboardSwitcher = KeyboardSwitcher.getInstance(); mAccessibilityUtils = AccessibilityUtils.getInstance(); + DEBUG = LatinImeLogger.sDBG; final Resources res = getResources(); mResources = res; @@ -532,8 +533,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final KeyboardSwitcher switcher = mKeyboardSwitcher; LatinKeyboardView inputView = switcher.getInputView(); - if(DEBUG) { - Log.d(TAG, "onStartInputView: " + inputView); + if (DEBUG) { + Log.d(TAG, "onStartInputView: inputType=" + ((attribute == null) ? "none" + : String.format("0x%08x", attribute.inputType))); } // In landscape mode, this method gets called without the input view being created. if (inputView == null) { diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 727e3f16d..a895ba281 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -25,6 +25,7 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Process; import android.text.InputType; +import android.text.TextUtils; import android.text.format.DateUtils; import android.util.Log; import android.view.inputmethod.EditorInfo; @@ -38,6 +39,7 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; +import java.lang.reflect.Field; import java.text.SimpleDateFormat; import java.util.Date; @@ -485,7 +487,9 @@ public class Utils { case InputType.TYPE_CLASS_PHONE: return KeyboardId.MODE_PHONE; case InputType.TYPE_CLASS_TEXT: - if (Utils.isEmailVariation(variation)) { + if (variation == InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS) { + return KeyboardId.MODE_WEB_EMAIL; + } else if (Utils.isEmailVariation(variation)) { return KeyboardId.MODE_EMAIL; } else if (variation == InputType.TYPE_TEXT_VARIATION_URI) { return KeyboardId.MODE_URL; @@ -493,7 +497,8 @@ public class Utils { return KeyboardId.MODE_IM; } else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) { return KeyboardId.MODE_TEXT; - } else if (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT) { + } else if (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT + || variation == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD) { return KeyboardId.MODE_WEB; } else { return KeyboardId.MODE_TEXT;