You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2018/07/05 08:55:39 UTC

[4/4] incubator-weex git commit: [WEEX-490][android] fix the bug of input component when setting property "type=tel" and "type=number" in input component,users can also input text Bug: 490

[WEEX-490][android] fix the bug of input component when setting property "type=tel" and "type=number" in input component,users can also input text
Bug: 490


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e5b66888
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e5b66888
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e5b66888

Branch: refs/heads/master
Commit: e5b6688876c4cec5edbc2e6a9770e0202d724b05
Parents: 6d4da70
Author: chenfeng <ch...@alibaba-inc.com>
Authored: Wed Jul 4 17:11:58 2018 +0800
Committer: YorkShen <sh...@gmail.com>
Committed: Thu Jul 5 16:53:09 2018 +0800

----------------------------------------------------------------------
 .../com/taobao/weex/ui/component/AbstractEditComponent.java     | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e5b66888/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java
index 139b1b5..3281d56 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java
@@ -27,6 +27,7 @@ import android.text.InputType;
 import android.text.TextPaint;
 import android.text.TextUtils;
 import android.text.TextWatcher;
+import android.text.method.DigitsKeyListener;
 import android.text.method.PasswordTransformationMethod;
 import android.util.Log;
 import android.util.TypedValue;
@@ -655,6 +656,8 @@ public abstract class AbstractEditComponent extends WXComponent<WXEditText> {
   }
 
   private int getInputType(String type) {
+    String digits = "1234567890";
+    String digitsWithDot = "12234567890.";
     int inputType;
     switch (type) {
       case Constants.Value.TEXT:
@@ -676,6 +679,7 @@ public abstract class AbstractEditComponent extends WXComponent<WXEditText> {
         break;
       case Constants.Value.TEL:
         inputType = InputType.TYPE_CLASS_PHONE;
+        getHostView().setKeyListener(DigitsKeyListener.getInstance(digits));
         break;
       case Constants.Value.TIME:
         inputType = InputType.TYPE_NULL;
@@ -686,6 +690,7 @@ public abstract class AbstractEditComponent extends WXComponent<WXEditText> {
         break;
       case Constants.Value.NUMBER:
         inputType = InputType.TYPE_CLASS_NUMBER;
+        getHostView().setKeyListener(DigitsKeyListener.getInstance(digitsWithDot));
         break;
       default:
         inputType = InputType.TYPE_CLASS_TEXT;