Bug 713922 - Don't allow empty password for master password. r=mfinkle a=akeybl
authorWes Johnston <wjohnston@mozilla.com>
Wed, 18 Jan 2012 08:50:11 -0800
changeset 85019 8508d6cc7e46e6bf83a3698d378c145f4d42af30
parent 85018 ab94103a2cdd7e6c325fc84f0994beabdef91d84
child 85020 b6ad62e6f63777c8fd16e697eac6125545613119
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, akeybl
bugs713922
milestone11.0a2
Bug 713922 - Don't allow empty password for master password. r=mfinkle a=akeybl
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);