Bug 963036 - Store default and disabled flags as JSON booleans (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Thu, 23 Jan 2014 17:33:25 +0000
changeset 180942 7cc7604607e41b9d4cdba61960db64dd20a569c6
parent 180941 0e7f583a8f1a40adc595c128eaeb1c219d8cc2e5
child 180943 a9913c62d98a74bcf097c6a6780bf75cdeb8187e
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs963036
milestone29.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 963036 - Store default and disabled flags as JSON booleans (r=margaret)
mobile/android/base/home/HomeConfig.java
--- a/mobile/android/base/home/HomeConfig.java
+++ b/mobile/android/base/home/HomeConfig.java
@@ -97,19 +97,16 @@ public final class HomeConfig {
         private static final String JSON_KEY_TYPE = "type";
         private static final String JSON_KEY_TITLE = "title";
         private static final String JSON_KEY_ID = "id";
         private static final String JSON_KEY_LAYOUT = "layout";
         private static final String JSON_KEY_VIEWS = "views";
         private static final String JSON_KEY_DEFAULT = "default";
         private static final String JSON_KEY_DISABLED = "disabled";
 
-        private static final int IS_DEFAULT = 1;
-        private static final int IS_DISABLED = 1;
-
         public enum Flags {
             DEFAULT_PANEL,
             DISABLED_PANEL
         }
 
         public PanelConfig(JSONObject json) throws JSONException, IllegalArgumentException {
             mType = PanelType.fromId(json.getString(JSON_KEY_TYPE));
             mTitle = json.getString(JSON_KEY_TITLE);
@@ -133,23 +130,21 @@ public final class HomeConfig {
                     mViews.add(viewConfig);
                 }
             } else {
                 mViews = null;
             }
 
             mFlags = EnumSet.noneOf(Flags.class);
 
-            final boolean isDefault = (json.optInt(JSON_KEY_DEFAULT, -1) == IS_DEFAULT);
-            if (isDefault) {
+            if (json.optBoolean(JSON_KEY_DEFAULT, false)) {
                 mFlags.add(Flags.DEFAULT_PANEL);
             }
 
-            final boolean isDisabled = (json.optInt(JSON_KEY_DISABLED, -1) == IS_DISABLED);
-            if (isDisabled) {
+            if (json.optBoolean(JSON_KEY_DISABLED, false)) {
                 mFlags.add(Flags.DISABLED_PANEL);
             }
 
             validate();
         }
 
         @SuppressWarnings("unchecked")
         public PanelConfig(Parcel in) {
@@ -295,21 +290,21 @@ public final class HomeConfig {
                     final JSONObject jsonViewConfig = viewConfig.toJSON();
                     jsonViews.put(jsonViewConfig);
                 }
 
                 json.put(JSON_KEY_VIEWS, jsonViews);
             }
 
             if (mFlags.contains(Flags.DEFAULT_PANEL)) {
-                json.put(JSON_KEY_DEFAULT, IS_DEFAULT);
+                json.put(JSON_KEY_DEFAULT, true);
             }
 
             if (mFlags.contains(Flags.DISABLED_PANEL)) {
-                json.put(JSON_KEY_DISABLED, IS_DISABLED);
+                json.put(JSON_KEY_DISABLED, true);
             }
 
             return json;
         }
 
         @Override
         public int describeContents() {
             return 0;