Bug 878491 - Save about:home top padding in BrowserApp instead of AboutHome fragment. r=lucasr a=bajaj
authorBrian Nicholson <bnicholson@mozilla.com>
Fri, 07 Jun 2013 12:27:21 -0700
changeset 142968 a931d2bb01ccc1af7f415dba4834475f11485804
parent 142967 d5b2aea0d2dbc75cc3a2837a3f20f1a6be81e996
child 142969 e3b14eaaadc3b61734ea9620a04795cd96a66c53
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr, bajaj
bugs878491
milestone23.0a2
Bug 878491 - Save about:home top padding in BrowserApp instead of AboutHome fragment. r=lucasr a=bajaj
mobile/android/base/BrowserApp.java
mobile/android/base/widget/AboutHome.java
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -77,16 +77,17 @@ abstract public class BrowserApp extends
     private static final String PREF_CHROME_DYNAMICTOOLBAR = "browser.chrome.dynamictoolbar";
 
     private static final int TABS_ANIMATION_DURATION = 450;
 
     private static final int READER_ADD_SUCCESS = 0;
     private static final int READER_ADD_FAILED = 1;
     private static final int READER_ADD_DUPLICATE = 2;
 
+    private static final String STATE_ABOUT_HOME_TOP_PADDING = "abouthome_top_padding";
     private static final String STATE_DYNAMIC_TOOLBAR_ENABLED = "dynamic_toolbar";
 
     public static BrowserToolbar mBrowserToolbar;
     private AboutHome mAboutHome;
     protected Telemetry.Timer mAboutHomeStartupTimer = null;
 
     private static final int ADDON_MENU_OFFSET = 1000;
     private class MenuItemInfo {
@@ -423,16 +424,17 @@ abstract public class BrowserApp extends
                         return new NdefMessage(new NdefRecord[] { NdefRecord.createUri(tab.getURL()) });
                     }
                 }, this);
             }
         }
 
         if (savedInstanceState != null) {
             mDynamicToolbarEnabled = savedInstanceState.getBoolean(STATE_DYNAMIC_TOOLBAR_ENABLED);
+            mAboutHome.setTopPadding(savedInstanceState.getInt(STATE_ABOUT_HOME_TOP_PADDING));
         }
 
         // Listen to the dynamic toolbar pref
         mPrefObserverId = PrefsHelper.getPref(PREF_CHROME_DYNAMICTOOLBAR, new PrefsHelper.PrefHandlerBase() {
             @Override
             public void prefValue(String pref, boolean value) {
                 if (value == mDynamicToolbarEnabled) {
                     return;
@@ -980,16 +982,17 @@ abstract public class BrowserApp extends
 
         mMainLayoutAnimator = null;
     }
 
     @Override
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         outState.putBoolean(STATE_DYNAMIC_TOOLBAR_ENABLED, mDynamicToolbarEnabled);
+        outState.putInt(STATE_ABOUT_HOME_TOP_PADDING, mAboutHome.getTopPadding());
     }
 
     /* Favicon methods */
     private void loadFavicon(final Tab tab) {
         maybeCancelFaviconLoad(tab);
 
         long id = Favicons.getInstance().loadFavicon(tab.getURL(), tab.getFaviconURL(), !tab.isPrivate(),
                         new Favicons.OnFaviconLoadedListener() {
--- a/mobile/android/base/widget/AboutHome.java
+++ b/mobile/android/base/widget/AboutHome.java
@@ -39,18 +39,16 @@ public class AboutHome extends Fragment 
     private ContentObserver mTabsContentObserver;
     private int mTopPadding;
     private AboutHomeView mAboutHomeView;
     private AddonsSection mAddonsSection;
     private LastTabsSection mLastTabsSection;
     private RemoteTabsSection mRemoteTabsSection;
     private TopSitesView mTopSitesView;
 
-    private static final String STATE_TOP_PADDING = "top_padding";
-
     public interface UriLoadListener {
         public void onAboutHomeUriLoad(String uriSpec);
     }
 
     public interface LoadCompleteListener {
         public void onAboutHomeLoadComplete();
     }
 
@@ -58,20 +56,16 @@ public class AboutHome extends Fragment 
         return new AboutHome();
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         mLightweightTheme = ((GeckoApplication) getActivity().getApplication()).getLightweightTheme();
-
-        if (savedInstanceState != null) {
-            mTopPadding = savedInstanceState.getInt(STATE_TOP_PADDING, 0);
-        }
     }
 
     @Override
     public void onAttach(Activity activity) {
         super.onAttach(activity);
 
         try {
             mUriLoadListener = (UriLoadListener) activity;
@@ -252,14 +246,12 @@ public class AboutHome extends Fragment 
         }
 
         // If the padding has changed but the view hasn't been created yet,
         // store the padding values here; they will be used later in
         // onViewCreated().
         mTopPadding = topPadding;
     }
 
-    @Override
-    public void onSaveInstanceState(Bundle outState) {
-        super.onSaveInstanceState(outState);
-        outState.putInt(STATE_TOP_PADDING, mTopPadding);
+    public int getTopPadding() {
+        return mTopPadding;
     }
 }