Bug 793056 - Part 0: cleanup. r=bnicholson
authorRichard Newman <rnewman@mozilla.com>
Thu, 04 Oct 2012 12:05:05 -0700
changeset 115569 0fb72381f95c62128b861714765b9141587d23fd
parent 115568 9089551ace1d14f9331abda5eadfad0ee4c405ec
child 115570 dea201a3c919ee1f93b25837a39e1333be9bde0c
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersbnicholson
bugs793056
milestone18.0a1
Bug 793056 - Part 0: cleanup. r=bnicholson
mobile/android/base/GeckoPreferences.java
--- a/mobile/android/base/GeckoPreferences.java
+++ b/mobile/android/base/GeckoPreferences.java
@@ -42,16 +42,20 @@ public class GeckoPreferences
 {
     private static final String LOGTAG = "GeckoPreferences";
 
     private ArrayList<String> mPreferencesList;
     private PreferenceScreen mPreferenceScreen;
     private static boolean sIsCharEncodingEnabled = false;
     private static final String NON_PREF_PREFIX = "android.not_a_preference.";
 
+    // These match keys in resources/xml/preferences.xml.in.
+    public static String PREFS_MP_ENABLED         = "privacy.masterpassword.enabled";
+    public static String PREFS_MENU_CHAR_ENCODING = "browser.menu.showCharacterEncoding";
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         addPreferencesFromResource(R.xml.preferences);
         registerEventListener("Sanitize:Finished");
     }
 
     @Override
@@ -131,20 +135,20 @@ public class GeckoPreferences
 
     public static boolean getCharEncodingState() {
         return sIsCharEncodingEnabled;
     }
 
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         String prefName = preference.getKey();
-        if (prefName != null && prefName.equals("privacy.masterpassword.enabled")) {
-            showDialog((Boolean)newValue ? DIALOG_CREATE_MASTER_PASSWORD : DIALOG_REMOVE_MASTER_PASSWORD);
+        if (prefName != null && prefName.equals(PREFS_MP_ENABLED)) {
+            showDialog((Boolean) newValue ? DIALOG_CREATE_MASTER_PASSWORD : DIALOG_REMOVE_MASTER_PASSWORD);
             return false;
-        } else if (prefName != null && prefName.equals("browser.menu.showCharacterEncoding")) {
+        } else if (prefName != null && prefName.equals(PREFS_MENU_CHAR_ENCODING)) {
             setCharEncodingState(((String) newValue).equals("true"));
         }
 
         if (!TextUtils.isEmpty(prefName)) {
             PrefsHelper.setPref(prefName, newValue);
         }
         if (preference instanceof ListPreference) {
             // We need to find the entry for the new value
@@ -209,24 +213,24 @@ public class GeckoPreferences
                 linearLayout.addView(input2);
 
                 builder.setTitle(R.string.masterpassword_create_title)
                        .setView((View)linearLayout)
                        .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {  
                             public void onClick(DialogInterface dialog, int which) {
                                 JSONObject jsonPref = new JSONObject();
                                 try {
-                                    jsonPref.put("name", "privacy.masterpassword.enabled");
+                                    jsonPref.put("name", PREFS_MP_ENABLED);
                                     jsonPref.put("type", "string");
                                     jsonPref.put("value", input1.getText().toString());
                     
                                     GeckoEvent event = GeckoEvent.createBroadcastEvent("Preferences:Set", jsonPref.toString());
                                     GeckoAppShell.sendEventToGecko(event);
                                 } catch(Exception ex) {
-                                    Log.e(LOGTAG, "Error setting masterpassword", ex);
+                                    Log.e(LOGTAG, "Error setting master password", ex);
                                 }
                                 return;
                             }
                         })
                         .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {  
                             public void onClick(DialogInterface dialog, int which) {
                                 return;
                             }
@@ -248,17 +252,17 @@ public class GeckoPreferences
             case DIALOG_REMOVE_MASTER_PASSWORD:
                 final EditText input = getTextBox(R.string.masterpassword_password);
                 linearLayout.addView(input);
 
                 builder.setTitle(R.string.masterpassword_remove_title)
                        .setView((View)linearLayout)
                        .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {  
                             public void onClick(DialogInterface dialog, int which) {
-                                PrefsHelper.setPref("privacy.masterpassword.enabled", input.getText().toString());
+                                PrefsHelper.setPref(PREFS_MP_ENABLED, input.getText().toString());
                             }
                         })
                         .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {  
                             public void onClick(DialogInterface dialog, int which) {
                                 return;
                             }
                         });
                         dialog = builder.create();