Bug 1227325 - Part 3: Upgrade GeckoPreferences to use TextInputLayout r=mcomella
authorAndrzej Hunt <ahunt@mozilla.com>
Fri, 22 Jan 2016 16:46:26 -0800
changeset 281382 d50bbdbc596b327ca18c8edabd4f59a2947ec7ea
parent 281381 d868de0c4779f073934b728ca8ddf7f2d661ac43
child 281383 5a6812d11eeca1e13d73b063f96f18a49796c512
push id29935
push userphilringnalda@gmail.com
push dateSun, 24 Jan 2016 02:12:02 +0000
treeherdermozilla-central@a2e81822194a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1227325
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1227325 - Part 3: Upgrade GeckoPreferences to use TextInputLayout r=mcomella
mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -1,17 +1,15 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.preferences;
 
-import android.Manifest;
-import android.annotation.TargetApi;
 import org.mozilla.gecko.AboutPages;
 import org.mozilla.gecko.AdjustConstants;
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.AppConstants.Versions;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.BrowserLocaleManager;
 import org.mozilla.gecko.DataReportingNotification;
 import org.mozilla.gecko.EventDispatcher;
@@ -40,58 +38,61 @@ import org.mozilla.gecko.updater.UpdateS
 import org.mozilla.gecko.updater.UpdateServiceHelper;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoEventListener;
 import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.InputOptionsUtils;
 import org.mozilla.gecko.util.NativeEventListener;
 import org.mozilla.gecko.util.NativeJSObject;
 import org.mozilla.gecko.util.ThreadUtils;
-import org.mozilla.gecko.widget.FloatingHintEditText;
 
+import android.annotation.TargetApi;
 import android.app.ActionBar;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.NotificationManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
 import android.content.res.Configuration;
+import android.Manifest;
 import android.os.Build;
 import android.os.Bundle;
 import android.preference.CheckBoxPreference;
 import android.preference.EditTextPreference;
 import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.Preference.OnPreferenceChangeListener;
 import android.preference.Preference.OnPreferenceClickListener;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceGroup;
 import android.preference.PreferenceScreen;
 import android.preference.TwoStatePreference;
 import android.support.design.widget.Snackbar;
+import android.support.design.widget.TextInputLayout;
 import android.text.Editable;
 import android.text.InputType;
 import android.text.TextUtils;
 import android.text.TextWatcher;
 import android.util.Log;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.EditText;
 import android.widget.LinearLayout;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 
 import org.json.JSONObject;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
 public class GeckoPreferences
@@ -1284,24 +1285,28 @@ OnSharedPreferenceChangeListener
                     @Override
                     public void run() {
                         preference.setChecked(true);
                         broadcastStumblerPref(GeckoPreferences.this, true);
                     }
                 });
     }
 
-    private EditText getTextBox(int aHintText) {
-        EditText input = new FloatingHintEditText(this);
+    private TextInputLayout getTextBox(int aHintText) {
+        final EditText input = new EditText(this);
         int inputtype = InputType.TYPE_CLASS_TEXT;
         inputtype |= InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
         input.setInputType(inputtype);
 
         input.setHint(aHintText);
-        return input;
+
+        final TextInputLayout layout = new TextInputLayout(this);
+        layout.addView(input);
+
+        return layout;
     }
 
     private class PasswordTextWatcher implements TextWatcher {
         EditText input1;
         EditText input2;
         AlertDialog dialog;
 
         PasswordTextWatcher(EditText aInput1, EditText aInput2, AlertDialog aDialog) {
@@ -1355,20 +1360,23 @@ OnSharedPreferenceChangeListener
     @Override
     protected Dialog onCreateDialog(int id) {
         AlertDialog.Builder builder = new AlertDialog.Builder(this);
         LinearLayout linearLayout = new LinearLayout(this);
         linearLayout.setOrientation(LinearLayout.VERTICAL);
         AlertDialog dialog;
         switch(id) {
             case DIALOG_CREATE_MASTER_PASSWORD:
-                final EditText input1 = getTextBox(R.string.masterpassword_password);
-                final EditText input2 = getTextBox(R.string.masterpassword_confirm);
-                linearLayout.addView(input1);
-                linearLayout.addView(input2);
+                final TextInputLayout inputLayout1 = getTextBox(R.string.masterpassword_password);
+                final TextInputLayout inputLayout2 = getTextBox(R.string.masterpassword_confirm);
+                linearLayout.addView(inputLayout1);
+                linearLayout.addView(inputLayout2);
+
+                final EditText input1 = inputLayout1.getEditText();
+                final EditText input2 = inputLayout2.getEditText();
 
                 builder.setTitle(R.string.masterpassword_create_title)
                        .setView((View) linearLayout)
                        .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
                             @Override
                             public void onClick(DialogInterface dialog, int which) {
                                 JSONObject jsonPref = new JSONObject();
                                 try {
@@ -1402,18 +1410,19 @@ OnSharedPreferenceChangeListener
                         });
 
                         PasswordTextWatcher watcher = new PasswordTextWatcher(input1, input2, dialog);
                         input1.addTextChangedListener((TextWatcher) watcher);
                         input2.addTextChangedListener((TextWatcher) watcher);
 
                 break;
             case DIALOG_REMOVE_MASTER_PASSWORD:
-                final EditText input = getTextBox(R.string.masterpassword_password);
-                linearLayout.addView(input);
+                final TextInputLayout inputLayout = getTextBox(R.string.masterpassword_password);
+                linearLayout.addView(inputLayout);
+                final EditText input = inputLayout.getEditText();
 
                 builder.setTitle(R.string.masterpassword_remove_title)
                        .setView((View) linearLayout)
                        .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
                             @Override
                             public void onClick(DialogInterface dialog, int which) {
                                 PrefsHelper.setPref(PREFS_MP_ENABLED, input.getText().toString());
                             }