Bug 1243354 - Part 1: Correctly handle TextInputLayout in PromptInput r=mcomella draft
authorAndrzej Hunt <ahunt@mozilla.com>
Fri, 29 Jan 2016 15:33:18 -0800
changeset 327257 bad66b396495158cd3ea65f7a02ccb8615be7915
parent 327256 557fb171e6562816f16a317c0d45f688609361c7
child 327258 cdd16f5249e5e2d51737ec3bedbcbd7f5020d229
push id10216
push userahunt@mozilla.com
push dateSat, 30 Jan 2016 00:26:47 +0000
reviewersmcomella
bugs1243354
milestone47.0a1
Bug 1243354 - Part 1: Correctly handle TextInputLayout in PromptInput r=mcomella
mobile/android/base/java/org/mozilla/gecko/prompts/PromptInput.java
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/PromptInput.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/PromptInput.java
@@ -91,56 +91,51 @@ public class PromptInput {
             inputLayout.addView(input);
 
             mView = (View) inputLayout;
             return mView;
         }
 
         @Override
         public Object getValue() {
-            EditText edit = (EditText)mView;
-            return edit.getText();
+            final TextInputLayout inputLayout = (TextInputLayout) mView;
+            return inputLayout.getEditText().getText();
         }
     }
 
     public static class NumberInput extends EditInput {
         public static final String INPUT_TYPE = "number";
         public NumberInput(JSONObject obj) {
             super(obj);
         }
 
         @Override
         public View getView(final Context context) throws UnsupportedOperationException {
-            EditText input = (EditText) super.getView(context);
+            final TextInputLayout inputLayout = (TextInputLayout) super.getView(context);
+            final EditText input = inputLayout.getEditText();
             input.setRawInputType(Configuration.KEYBOARD_12KEY);
             input.setInputType(InputType.TYPE_CLASS_NUMBER |
                                InputType.TYPE_NUMBER_FLAG_SIGNED);
             return input;
         }
     }
 
     public static class PasswordInput extends EditInput {
         public static final String INPUT_TYPE = "password";
         public PasswordInput(JSONObject obj) {
             super(obj);
         }
 
         @Override
         public View getView(Context context) throws UnsupportedOperationException {
-            EditText input = (EditText) super.getView(context);
-            input.setInputType(InputType.TYPE_CLASS_TEXT |
+            final TextInputLayout inputLayout = (TextInputLayout) super.getView(context);
+            inputLayout.getEditText().setInputType(InputType.TYPE_CLASS_TEXT |
                                InputType.TYPE_TEXT_VARIATION_PASSWORD |
                                InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
-            return input;
-        }
-
-        @Override
-        public Object getValue() {
-            EditText edit = (EditText)mView;
-            return edit.getText();
+            return inputLayout;
         }
     }
 
     public static class CheckboxInput extends PromptInput {
         public static final String INPUT_TYPE = "checkbox";
         private final boolean mChecked;
 
         public CheckboxInput(JSONObject obj) {