Bug 1288256 - Part 3: update BrowserApp to use HomeScreen interface instead of
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 21 Jul 2016 08:48:11 -0700
changeset 306237 35add519e9f4ae0c4f03befb6483d1fc255a5ad7
parent 306236 e68f8bf2096ea5986e1d17facdc06b3da7258a3d
child 306238 bd6655e7b879214b7d983ca85c8160a77a653178
push id79800
push usercbook@mozilla.com
push dateFri, 22 Jul 2016 10:17:37 +0000
treeherdermozilla-inbound@30745bed2567 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1288256
milestone50.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 1288256 - Part 3: update BrowserApp to use HomeScreen interface instead of HomePager r=sebastian MozReview-Commit-ID: 7h6s6ewfSOu
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -45,16 +45,17 @@ import org.mozilla.gecko.home.HomeBanner
 import org.mozilla.gecko.home.HomeConfig;
 import org.mozilla.gecko.home.HomeConfig.PanelType;
 import org.mozilla.gecko.home.HomeConfigPrefsBackend;
 import org.mozilla.gecko.home.HomeFragment;
 import org.mozilla.gecko.home.HomePager;
 import org.mozilla.gecko.home.HomePager.OnUrlOpenInBackgroundListener;
 import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
 import org.mozilla.gecko.home.HomePanelsManager;
+import org.mozilla.gecko.home.HomeScreen;
 import org.mozilla.gecko.home.SearchEngine;
 import org.mozilla.gecko.javaaddons.JavaAddonManager;
 import org.mozilla.gecko.media.AudioFocusAgent;
 import org.mozilla.gecko.menu.GeckoMenu;
 import org.mozilla.gecko.menu.GeckoMenuItem;
 import org.mozilla.gecko.mozglue.SafeIntent;
 import org.mozilla.gecko.overlays.ui.ShareDialog;
 import org.mozilla.gecko.permissions.Permissions;
@@ -232,17 +233,17 @@ public class BrowserApp extends GeckoApp
     public ViewFlipper mActionBarFlipper;
     public ActionModeCompatView mActionBar;
     private BrowserToolbar mBrowserToolbar;
     private View mDoorhangerOverlay;
     // We can't name the TabStrip class because it's not included on API 9.
     private TabStripInterface mTabStrip;
     private ToolbarProgressView mProgressView;
     private FirstrunAnimationContainer mFirstrunAnimationContainer;
-    private HomePager mHomePager;
+    private HomeScreen mHomeScreen;
     private TabsPanel mTabsPanel;
     /**
      * Container for the home screen implementation. This will be populated with any valid
      * home screen implementation (currently that is just the HomePager, but that will be extended
      * to permit further experimental replacement panels such as the activity-stream panel).
      */
     private ViewGroup mHomeScreenContainer;
     private ActionModeCompat mActionMode;
@@ -634,24 +635,24 @@ public class BrowserApp extends GeckoApp
 
         ((GeckoApp.MainLayout) mMainLayout).setTouchEventInterceptor(new HideOnTouchListener());
         ((GeckoApp.MainLayout) mMainLayout).setMotionEventInterceptor(new MotionEventInterceptor() {
             @Override
             public boolean onInterceptMotionEvent(View view, MotionEvent event) {
                 // If we get a gamepad panning MotionEvent while the focus is not on the layerview,
                 // put the focus on the layerview and carry on
                 if (mLayerView != null && !mLayerView.hasFocus() && GamepadUtils.isPanningControl(event)) {
-                    if (mHomePager == null) {
+                    if (mHomeScreen == null) {
                         return false;
                     }
 
                     if (isHomePagerVisible()) {
                         mLayerView.requestFocus();
                     } else {
-                        mHomePager.requestFocus();
+                        mHomeScreen.requestFocus();
                     }
                 }
                 return false;
             }
         });
 
         mHomeScreenContainer = (ViewGroup) findViewById(R.id.home_screen_container);
 
@@ -1152,17 +1153,17 @@ public class BrowserApp extends GeckoApp
                 filterEditingMode(searchText, handler);
             }
         });
 
         mBrowserToolbar.setOnFocusChangeListener(new View.OnFocusChangeListener() {
             @Override
             public void onFocusChange(View v, boolean hasFocus) {
                 if (isHomePagerVisible()) {
-                    mHomePager.onToolbarFocusChange(hasFocus);
+                    mHomeScreen.onToolbarFocusChange(hasFocus);
                 }
             }
         });
 
         mBrowserToolbar.setOnStartEditingListener(new BrowserToolbar.OnStartEditingListener() {
             @Override
             public void onStartEditing() {
                 final Tab selectedTab = Tabs.getInstance().getSelectedTab();
@@ -2291,17 +2292,17 @@ public class BrowserApp extends GeckoApp
         }
 
         Tabs.getInstance().loadUrl(url, searchEngine, -1, flags);
 
         mBrowserToolbar.cancelEdit();
     }
 
     private boolean isHomePagerVisible() {
-        return (mHomePager != null && mHomePager.isVisible()
+        return (mHomeScreen != null && mHomeScreen.isVisible()
                 && mHomeScreenContainer != null && mHomeScreenContainer.getVisibility() == View.VISIBLE);
     }
 
     private boolean isFirstrunVisible() {
         return (mFirstrunAnimationContainer != null && mFirstrunAnimationContainer.isVisible()
                 && mHomeScreenContainer != null && mHomeScreenContainer.getVisibility() == View.VISIBLE);
     }
 
@@ -2661,17 +2662,17 @@ public class BrowserApp extends GeckoApp
 
     private void showHomePager(String panelId, Bundle panelRestoreData) {
         showHomePagerWithAnimator(panelId, panelRestoreData, null);
     }
 
     private void showHomePagerWithAnimator(String panelId, Bundle panelRestoreData, PropertyAnimator animator) {
         if (isHomePagerVisible()) {
             // Home pager already visible, make sure it shows the correct panel.
-            mHomePager.showPanel(panelId, panelRestoreData);
+            mHomeScreen.showPanel(panelId, panelRestoreData);
             return;
         }
 
         // This must be called before the dynamic toolbar is set visible because it calls
         // FormAssistPopup.onMetricsChanged, which queues a runnable that undoes the effect of hide.
         // With hide first, onMetricsChanged will return early instead.
         mFormAssistPopup.hide();
         mFindInPageBar.hide();
@@ -2680,60 +2681,60 @@ public class BrowserApp extends GeckoApp
         refreshToolbarHeight();
 
         // Show the toolbar before hiding about:home so the
         // onMetricsChanged callback still works.
         if (mDynamicToolbar.isEnabled()) {
             mDynamicToolbar.setVisible(true, VisibilityTransition.IMMEDIATE);
         }
 
-        if (mHomePager == null) {
+        if (mHomeScreen == null) {
             final ViewStub homePagerStub = (ViewStub) findViewById(R.id.home_pager_stub);
-            mHomePager = (HomePager) homePagerStub.inflate();
-
-            mHomePager.setOnPanelChangeListener(new HomePager.OnPanelChangeListener() {
+            mHomeScreen = (HomePager) homePagerStub.inflate();
+
+            mHomeScreen.setOnPanelChangeListener(new HomeScreen.OnPanelChangeListener() {
                 @Override
                 public void onPanelSelected(String panelId) {
                     final Tab currentTab = Tabs.getInstance().getSelectedTab();
                     if (currentTab != null) {
                         currentTab.setMostRecentHomePanel(panelId);
                     }
                 }
             });
 
             // Set this listener to persist restore data (via the Tab) every time panel state changes.
-            mHomePager.setPanelStateChangeListener(new HomeFragment.PanelStateChangeListener() {
+            mHomeScreen.setPanelStateChangeListener(new HomeFragment.PanelStateChangeListener() {
                 @Override
                 public void onStateChanged(Bundle bundle) {
                     final Tab currentTab = Tabs.getInstance().getSelectedTab();
                     if (currentTab != null) {
                         currentTab.setMostRecentHomePanelData(bundle);
                     }
                 }
             });
 
             // Don't show the banner in guest mode.
             if (!Restrictions.isUserRestricted()) {
                 final ViewStub homeBannerStub = (ViewStub) findViewById(R.id.home_banner_stub);
                 final HomeBanner homeBanner = (HomeBanner) homeBannerStub.inflate();
-                mHomePager.setBanner(homeBanner);
+                mHomeScreen.setBanner(homeBanner);
 
                 // Remove the banner from the view hierarchy if it is dismissed.
                 homeBanner.setOnDismissListener(new HomeBanner.OnDismissListener() {
                     @Override
                     public void onDismiss() {
-                        mHomePager.setBanner(null);
+                        mHomeScreen.setBanner(null);
                         mHomeScreenContainer.removeView(homeBanner);
                     }
                 });
             }
         }
 
         mHomeScreenContainer.setVisibility(View.VISIBLE);
-        mHomePager.load(getSupportLoaderManager(),
+        mHomeScreen.load(getSupportLoaderManager(),
                         getSupportFragmentManager(),
                         panelId,
                         panelRestoreData,
                         animator);
 
         // Hide the web content so it cannot be focused by screen readers.
         hideWebContentOnPropertyAnimationEnd(animator);
     }
@@ -2805,18 +2806,18 @@ public class BrowserApp extends GeckoApp
 
         // Prevent race in hiding web content - see declaration for more info.
         mHideWebContentOnAnimationEnd = false;
 
         // Display the previously hidden web content (which prevented screen reader access).
         mLayerView.setVisibility(View.VISIBLE);
         mHomeScreenContainer.setVisibility(View.GONE);
 
-        if (mHomePager != null) {
-            mHomePager.unload();
+        if (mHomeScreen != null) {
+            mHomeScreen.unload();
         }
 
         mBrowserToolbar.setNextFocusDownId(R.id.layer_view);
 
         // Refresh toolbar height to possibly restore the toolbar padding
         refreshToolbarHeight();
     }