mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 07:05:24 +00:00
Bug 1227325 - Part 3: Upgrade GeckoPreferences to use TextInputLayout r=mcomella
--HG-- extra : commitid : CSdCsd2YLVG extra : rebase_source : 4a8ca2558940ad2828695ef07ee2447c83dae6d1 extra : source : d50bbdbc596b327ca18c8edabd4f59a2947ec7ea
This commit is contained in:
parent
57bb0866d3
commit
653fa590e8
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
package org.mozilla.gecko.preferences;
|
package org.mozilla.gecko.preferences;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import org.mozilla.gecko.AboutPages;
|
import org.mozilla.gecko.AboutPages;
|
||||||
import org.mozilla.gecko.AdjustConstants;
|
import org.mozilla.gecko.AdjustConstants;
|
||||||
import org.mozilla.gecko.AppConstants;
|
import org.mozilla.gecko.AppConstants;
|
||||||
@ -45,8 +43,8 @@ import org.mozilla.gecko.util.InputOptionsUtils;
|
|||||||
import org.mozilla.gecko.util.NativeEventListener;
|
import org.mozilla.gecko.util.NativeEventListener;
|
||||||
import org.mozilla.gecko.util.NativeJSObject;
|
import org.mozilla.gecko.util.NativeJSObject;
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
import org.mozilla.gecko.widget.FloatingHintEditText;
|
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
@ -60,6 +58,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.Manifest;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
@ -73,6 +72,7 @@ import android.preference.PreferenceGroup;
|
|||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.preference.TwoStatePreference;
|
import android.preference.TwoStatePreference;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -87,6 +87,7 @@ import android.widget.ListAdapter;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -1289,14 +1290,18 @@ OnSharedPreferenceChangeListener
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private EditText getTextBox(int aHintText) {
|
private TextInputLayout getTextBox(int aHintText) {
|
||||||
EditText input = new FloatingHintEditText(this);
|
final EditText input = new EditText(this);
|
||||||
int inputtype = InputType.TYPE_CLASS_TEXT;
|
int inputtype = InputType.TYPE_CLASS_TEXT;
|
||||||
inputtype |= InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
inputtype |= InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
||||||
input.setInputType(inputtype);
|
input.setInputType(inputtype);
|
||||||
|
|
||||||
input.setHint(aHintText);
|
input.setHint(aHintText);
|
||||||
return input;
|
|
||||||
|
final TextInputLayout layout = new TextInputLayout(this);
|
||||||
|
layout.addView(input);
|
||||||
|
|
||||||
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PasswordTextWatcher implements TextWatcher {
|
private class PasswordTextWatcher implements TextWatcher {
|
||||||
@ -1360,10 +1365,13 @@ OnSharedPreferenceChangeListener
|
|||||||
AlertDialog dialog;
|
AlertDialog dialog;
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case DIALOG_CREATE_MASTER_PASSWORD:
|
case DIALOG_CREATE_MASTER_PASSWORD:
|
||||||
final EditText input1 = getTextBox(R.string.masterpassword_password);
|
final TextInputLayout inputLayout1 = getTextBox(R.string.masterpassword_password);
|
||||||
final EditText input2 = getTextBox(R.string.masterpassword_confirm);
|
final TextInputLayout inputLayout2 = getTextBox(R.string.masterpassword_confirm);
|
||||||
linearLayout.addView(input1);
|
linearLayout.addView(inputLayout1);
|
||||||
linearLayout.addView(input2);
|
linearLayout.addView(inputLayout2);
|
||||||
|
|
||||||
|
final EditText input1 = inputLayout1.getEditText();
|
||||||
|
final EditText input2 = inputLayout2.getEditText();
|
||||||
|
|
||||||
builder.setTitle(R.string.masterpassword_create_title)
|
builder.setTitle(R.string.masterpassword_create_title)
|
||||||
.setView((View) linearLayout)
|
.setView((View) linearLayout)
|
||||||
@ -1407,8 +1415,9 @@ OnSharedPreferenceChangeListener
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case DIALOG_REMOVE_MASTER_PASSWORD:
|
case DIALOG_REMOVE_MASTER_PASSWORD:
|
||||||
final EditText input = getTextBox(R.string.masterpassword_password);
|
final TextInputLayout inputLayout = getTextBox(R.string.masterpassword_password);
|
||||||
linearLayout.addView(input);
|
linearLayout.addView(inputLayout);
|
||||||
|
final EditText input = inputLayout.getEditText();
|
||||||
|
|
||||||
builder.setTitle(R.string.masterpassword_remove_title)
|
builder.setTitle(R.string.masterpassword_remove_title)
|
||||||
.setView((View) linearLayout)
|
.setView((View) linearLayout)
|
||||||
|
Loading…
Reference in New Issue
Block a user