Bug 1251362 - Part 13 - Redirect direct loads of the old recent tabs panel to the new combined history panel and directly open the recent tabs subview there draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 21 May 2016 15:25:50 +0200
changeset 369307 e96b080896057fdb11523292d1d8464d6772af14
parent 369306 569f39526669fef0aace554cc782c2d45b8f4545
child 369308 7d302341a3860d6c6520f0d07998554fbf4f94a9
push id18831
push usermozilla@buttercookie.de
push dateSat, 21 May 2016 18:52:21 +0000
bugs1251362
milestone49.0a1
Bug 1251362 - Part 13 - Redirect direct loads of the old recent tabs panel to the new combined history panel and directly open the recent tabs subview there MozReview-Commit-ID: 7dQ7tW2dD1M
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -2531,16 +2531,22 @@ public class BrowserApp extends GeckoApp
                 // to panel BAR, the history URL still contains FOO, and we restore to FOO. In most
                 // cases however we aren't supplying a panel ID in the URL so this code still works
                 // for most cases.
                 // We can't fix this directly since we can't ignore the panelId if we're explicitly
                 // loading a specific panel, and we currently can't distinguish between loading
                 // history, and loading new pages, see Bug 1268887
                 panelId = tab.getMostRecentHomePanel();
                 panelRestoreData = tab.getMostRecentHomePanelData();
+            } else if (panelId.equals(HomeConfig.getIdForBuiltinPanelType(PanelType.RECENT_TABS))) {
+                // Redirect to the Combined History panel.
+                panelId = HomeConfig.getIdForBuiltinPanelType(PanelType.COMBINED_HISTORY);
+                panelRestoreData = new Bundle();
+                // Jump directly to the Recent Tabs subview of the Combined History panel.
+                panelRestoreData.putBoolean("goToRecentTabs", true);
             }
             showHomePager(panelId, panelRestoreData);
 
             if (mDynamicToolbar.isEnabled()) {
                 mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
             }
         } else {
             hideHomePager();
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1415,23 +1415,26 @@ public abstract class GeckoApp
         mDoorHangerPopup = new DoorHangerPopup(this);
         mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);
         mFormAssistPopup = (FormAssistPopup) findViewById(R.id.form_assist_popup);
     }
 
     /**
      * Loads the initial tab at Fennec startup. If we don't restore tabs, this
      * tab will be about:home, or the homepage if the user has set one.
-     * If we've temporarily disabled restoring to break out of a crash loop, we'll
-     * show the recent tabs panel so the user can manually restore tabs as needed.
+     * If we've temporarily disabled restoring to break out of a crash loop, we'll show
+     * the Recent Tabs section of the Combined History panel, so the user can manually
+     * restore tabs as needed.
      * If we restore tabs, we don't need to create a new tab.
      */
     protected void loadStartupTab(final int flags) {
         if (!mShouldRestore) {
             if (mLastSessionCrashed) {
+                // The Recent Tabs panel no longer exists, but BrowserApp will redirect us
+                // to the Recent Tabs section of the Combined History panel.
                 Tabs.getInstance().loadUrl(AboutPages.getURLForBuiltinPanelType(PanelType.RECENT_TABS), flags);
             } else {
                 final String homepage = getHomepage();
                 Tabs.getInstance().loadUrl(!TextUtils.isEmpty(homepage) ? homepage : AboutPages.HOME, flags);
             }
         }
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
@@ -219,16 +219,27 @@ public class CombinedHistoryPanel extend
         final ImageView recentTabsIcon = (ImageView) mRecentTabsEmptyView.findViewById(R.id.home_empty_image);
         recentTabsIcon.setImageResource(R.drawable.icon_remote_tabs_empty);
 
         final TextView recentTabsText = (TextView) mRecentTabsEmptyView.findViewById(R.id.home_empty_text);
         recentTabsText.setText(R.string.home_last_tabs_empty);
     }
 
     @Override
+    public void restoreData(Bundle data) {
+        if (data != null && data.getBoolean("goToRecentTabs", false) && mPanelLevel != PanelLevel.CHILD_RECENT_TABS) {
+            mPanelLevel = PanelLevel.CHILD_RECENT_TABS;
+
+            mRecyclerView.swapAdapter(mRecentTabsAdapter, true);
+            updateEmptyView();
+            updateButtonFromLevel();
+        }
+    }
+
+    @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         mCursorLoaderCallbacks = new CursorLoaderCallbacks();
     }
 
     @Override
     protected void load() {
         getLoaderManager().initLoader(LOADER_ID_HISTORY, null, mCursorLoaderCallbacks);