Bug 1288124 - Add basic/blank Activity Stream panel and show if flag is enabled r=jonalmeida,sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 21 Jul 2016 11:31:57 -0700
changeset 331603 34d992753650814d9dc84b152e0b72c1e64d178f
parent 331602 268d2ffd7a0541073df31abd121e0e6002cb73c4
child 331604 d5403a0e1c779912d79e14f7cd5d22e978653f89
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonalmeida, sebastian
bugs1288124
milestone50.0a1
Bug 1288124 - Add basic/blank Activity Stream panel and show if flag is enabled r=jonalmeida,sebastian MozReview-Commit-ID: JqbOywOFsoF
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/home/activitystream/ActivityStream.java
mobile/android/base/moz.build
mobile/android/base/resources/layout/activity_stream.xml
mobile/android/base/resources/layout/gecko_app.xml
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -2686,39 +2686,47 @@ public class BrowserApp extends GeckoApp
 
         // Show the toolbar before hiding about:home so the
         // onMetricsChanged callback still works.
         if (mDynamicToolbar.isEnabled()) {
             mDynamicToolbar.setVisible(true, VisibilityTransition.IMMEDIATE);
         }
 
         if (mHomeScreen == null) {
-            final ViewStub homePagerStub = (ViewStub) findViewById(R.id.home_pager_stub);
-            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);
+            if (AppConstants.MOZ_ANDROID_ACTIVITY_STREAM) {
+                final ViewStub asStub = (ViewStub) findViewById(R.id.activity_stream_stub);
+                mHomeScreen = (HomeScreen) asStub.inflate();
+            } else {
+                final ViewStub homePagerStub = (ViewStub) findViewById(R.id.home_pager_stub);
+                mHomeScreen = (HomeScreen) homePagerStub.inflate();
+
+                // For now these listeners are HomePager specific. In future we might want
+                // to have a more abstracted data storage, with one Bundle containing all
+                // relevant restore data.
+                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.
-            mHomeScreen.setPanelStateChangeListener(new HomeFragment.PanelStateChangeListener() {
-                @Override
-                public void onStateChanged(Bundle bundle) {
-                    final Tab currentTab = Tabs.getInstance().getSelectedTab();
-                    if (currentTab != null) {
-                        currentTab.setMostRecentHomePanelData(bundle);
+                });
+
+                // Set this listener to persist restore data (via the Tab) every time panel state changes.
+                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();
                 mHomeScreen.setBanner(homeBanner);
 
                 // Remove the banner from the view hierarchy if it is dismissed.
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/ActivityStream.java
@@ -0,0 +1,69 @@
+/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ package org.mozilla.gecko.home.activitystream;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.LoaderManager;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+import org.mozilla.gecko.animation.PropertyAnimator;
+import org.mozilla.gecko.home.HomeBanner;
+import org.mozilla.gecko.home.HomeFragment;
+import org.mozilla.gecko.home.HomeScreen;
+
+public class ActivityStream extends FrameLayout implements HomeScreen {
+
+    public ActivityStream(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    public boolean isVisible() {
+        // This is dependent on the loading state - currently we're a dumb panel so we're always
+        // "visible"
+        return true;
+    }
+
+    @Override
+    public void onToolbarFocusChange(boolean hasFocus) {
+        // We don't care: this is HomePager specific
+    }
+
+    @Override
+    public void showPanel(String panelId, Bundle restoreData) {
+        // We could use this to restore Panel data. In practice this isn't likely to be relevant for
+        // AS and can be ignore for now.
+    }
+
+    @Override
+    public void setOnPanelChangeListener(OnPanelChangeListener listener) {
+        // As with showPanel: not relevant yet, could be used for persistence (scroll position?)
+    }
+
+    @Override
+    public void setPanelStateChangeListener(HomeFragment.PanelStateChangeListener listener) {
+        // See setOnPanelChangeListener
+    }
+
+    @Override
+    public void setBanner(HomeBanner banner) {
+        // TODO: we should probably implement this to show snippets.
+    }
+
+    @Override
+    public void load(LoaderManager lm, FragmentManager fm, String panelId, Bundle restoreData,
+                     PropertyAnimator animator) {
+        // Signal to load data from storage as needed, compare with HomePager
+    }
+
+    @Override
+    public void unload() {
+        // Signal to clear data that has been loaded, compare with HomePager
+    }
+}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -396,16 +396,17 @@ gbjar.sources += ['java/org/mozilla/geck
     'gfx/TouchEventHandler.java',
     'gfx/ViewTransform.java',
     'gfx/VirtualLayer.java',
     'GlobalHistory.java',
     'GuestSession.java',
     'health/HealthRecorder.java',
     'health/SessionInformation.java',
     'health/StubbedHealthRecorder.java',
+    'home/activitystream/ActivityStream.java',
     'home/BookmarkFolderView.java',
     'home/BookmarkScreenshotRow.java',
     'home/BookmarksListAdapter.java',
     'home/BookmarksListView.java',
     'home/BookmarksPanel.java',
     'home/BrowserSearch.java',
     'home/ClientsAdapter.java',
     'home/CombinedHistoryAdapter.java',
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/resources/layout/activity_stream.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<org.mozilla.gecko.home.activitystream.ActivityStream xmlns:android="http://schemas.android.com/apk/res/android"
+                                                      xmlns:tools="http://schemas.android.com/tools"
+                                                      android:orientation="vertical"
+                                                      android:layout_width="match_parent"
+                                                      android:layout_height="match_parent"
+                                                      android:background="@android:color/white">
+
+    <TextView
+        tools:ignore="HardcodedText"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Activity Stream \\o/"
+        android:id="@+id/textView"
+        android:layout_gravity="center_horizontal"/>
+</org.mozilla.gecko.home.activitystream.ActivityStream>
\ No newline at end of file
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -61,16 +61,21 @@
                          android:layout_height="match_parent"
                          android:visibility="gone">
 
                 <ViewStub android:id="@+id/home_pager_stub"
                           android:layout="@layout/home_pager"
                           android:layout_width="match_parent"
                           android:layout_height="match_parent"/>
 
+                <ViewStub android:id="@+id/activity_stream_stub"
+                          android:layout="@layout/activity_stream"
+                          android:layout_width="match_parent"
+                          android:layout_height="match_parent"/>
+
                 <ViewStub android:id="@+id/home_banner_stub"
                           android:layout="@layout/home_banner"
                           android:layout_width="match_parent"
                           android:layout_height="@dimen/home_banner_height"
                           android:layout_gravity="bottom"/>
 
                 <ViewStub android:id="@+id/firstrun_pager_stub"
                           android:layout="@layout/firstrun_animation_container"