Bug fix: Chinese keyboard not setting to english alphabet by default.
Return BrowserInputConnection only in case of AOSP keyboard. In case
of other Keyboards (for ex Chinese etc) we return the base class
input connection.
Change-Id: I9d3d3e5a086e8edddbcbb4f1626e9e433e509c11
diff --git a/src/com/android/browser/UrlInputView.java b/src/com/android/browser/UrlInputView.java
index 9cdc423..c8f2d40 100644
--- a/src/com/android/browser/UrlInputView.java
+++ b/src/com/android/browser/UrlInputView.java
@@ -16,10 +16,14 @@
package com.android.browser;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.inputmethodservice.InputMethodService;
+import android.provider.Settings.Secure;
+import android.os.Build;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
@@ -34,7 +38,9 @@
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
+import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodSubtype;
import android.text.InputType;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -50,6 +56,7 @@
import com.android.browser.search.SearchEngineInfo;
import com.android.browser.search.SearchEngines;
+import java.util.List;
/**
* url/search input view
* handling suggestions
@@ -60,6 +67,7 @@
static final String TYPED = "browser-type";
static final String SUGGESTED = "browser-suggest";
+ static final String LATIN_INPUTMETHOD_PACKAGE_NAME = "com.android.inputmethod.latin";
static final int POST_DELAY = 100;
static final int URL_MAX_LENGTH = 2048;
@@ -107,14 +115,32 @@
this(context, attrs, 0);
}
+ private String getCurrentImeInfo(){
+ InputMethodManager imm =
+ (InputMethodManager) mContext.getSystemService(mContext.INPUT_METHOD_SERVICE);
+ List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList();
+
+ final int n = mInputMethodProperties.size();
+ for (int i = 0; i < n; i++) {
+ InputMethodInfo imeInfo = mInputMethodProperties.get(i);
+ if (imeInfo.getId().equals(Secure.getString(mContext.getContentResolver(),
+ Secure.DEFAULT_INPUT_METHOD))) {
+ return imeInfo.getPackageName();
+ }
+ }
+ return null;
+ }
+
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
- BrowserInputConnection browserInputConnection =
- new BrowserInputConnection(this, false);
- outAttrs.actionLabel = null;
- outAttrs.inputType = InputType.TYPE_NULL;
- outAttrs.imeOptions = EditorInfo.IME_ACTION_GO;
- return browserInputConnection;
+ String imeInfo = getCurrentImeInfo();
+ if(imeInfo != null && imeInfo.equals(LATIN_INPUTMETHOD_PACKAGE_NAME)
+ && (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2)) {
+ outAttrs.imeOptions = EditorInfo.IME_ACTION_GO;
+ return new BrowserInputConnection(this, false);
+ }
+ else
+ return super.onCreateInputConnection(outAttrs);
}
public UrlInputView(Context context) {