Bug 713922 - Don't allow empty password for master password. r=mfinkle
authorWes Johnston <wjohnston@mozilla.com>
Wed, 18 Jan 2012 08:50:11 -0800
changeset 86014 19af1aac33aca78cdd832bb8090a588b2e2335ec
parent 86013 e29329299573b697d3fcbe973d1ddb00bfc4dada
child 86015 c461f057fcff66b2ba7d20665aa02acc1500854d
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs713922
milestone12.0a1
Bug 713922 - Don't allow empty password for master password. r=mfinkle
mobile/android/base/GeckoPreferences.java
--- a/mobile/android/base/GeckoPreferences.java
+++ b/mobile/android/base/GeckoPreferences.java
@@ -53,16 +53,17 @@ import android.preference.Preference.*;
 import android.text.InputType;
 import android.util.Log;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.EditText;
 import android.widget.LinearLayout;
 import android.text.TextWatcher;
+import android.text.TextUtils;
 import android.content.DialogInterface;
 
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 public class GeckoPreferences
     extends PreferenceActivity
@@ -182,17 +183,18 @@ public class GeckoPreferences
         }
 
         public void afterTextChanged(Editable s) {
             if (dialog == null)
                 return;
 
             String text1 = input1.getText().toString();
             String text2 = input2.getText().toString();
-            dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(text1.equals(text2));
+            boolean disabled = TextUtils.isEmpty(text1) || TextUtils.isEmpty(text2) || !text1.equals(text2);
+            dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(!disabled);
         }
 
         public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
         public void onTextChanged(CharSequence s, int start, int before, int count) { }
     }
 
     protected Dialog onCreateDialog(int id) {
         AlertDialog.Builder builder = new AlertDialog.Builder(this);
@@ -225,18 +227,18 @@ public class GeckoPreferences
                             }
                         })
                         .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {  
                             public void onClick(DialogInterface dialog, int which) {
                                 return;
                             }
                         });
                         dialog = builder.create();
-                        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
-                            public void onDismiss(DialogInterface dialog) {
+                        dialog.setOnShowListener(new DialogInterface.OnShowListener() {
+                            public void onShow(DialogInterface dialog) {
                                 input1.setText("");
                                 input2.setText("");
                                 input1.requestFocus();
                             }
                         });
 
                         PasswordTextWatcher watcher = new PasswordTextWatcher(input1, input2, dialog);
                         input1.addTextChangedListener((TextWatcher)watcher);