Bug 810278 - Improved background/toolbar visual cohesion. r=wjohnston
authorMorrison Cole <admin@morrisoncole.co.uk>
Fri, 16 Nov 2012 13:43:33 -0800
changeset 113553 eeda949e9f4a3ae44c5ecfc141b29bb538736fe2
parent 113552 c2ea3fb28c45054902ca7d386cfcdcdf3f42cb8b
child 113554 84384977f87b5ae9427848ddaeb3cfe60b8832fd
push id18229
push userwjohnston@mozilla.com
push dateFri, 16 Nov 2012 21:43:52 +0000
treeherdermozilla-inbound@eeda949e9f4a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswjohnston
bugs810278
milestone19.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 810278 - Improved background/toolbar visual cohesion. r=wjohnston
mobile/android/base/BrowserToolbar.java
mobile/android/base/gfx/GeckoLayerClient.java
mobile/android/base/gfx/LayerView.java
mobile/android/base/ui/Axis.java
mobile/android/base/ui/PanZoomController.java
--- a/mobile/android/base/BrowserToolbar.java
+++ b/mobile/android/base/BrowserToolbar.java
@@ -657,17 +657,29 @@ public class BrowserToolbar implements V
                 prevView.setNextFocusRightId(view.getId());
             }
 
             prevView = view;
         }
     }
 
     public void setShadowVisibility(boolean visible) {
-        mShadow.setVisibility(visible ? View.VISIBLE : View.GONE);
+        Tab tab = Tabs.getInstance().getSelectedTab();
+        if (tab == null) {
+            return;
+        }
+
+        String url = tab.getURL();
+
+        // Only set shadow to visible when not on about screens.
+        visible &= !(url == null || url.startsWith("about:"));
+
+        if ((mShadow.getVisibility() == View.VISIBLE) != visible) {
+            mShadow.setVisibility(visible ? View.VISIBLE : View.GONE);
+        }
     }
 
     public void setTitle(CharSequence title) {
         Tab tab = Tabs.getInstance().getSelectedTab();
 
         // Keep the title unchanged if the tab is entering reader mode
         if (tab != null && tab.isEnteringReaderMode())
             return;
@@ -762,17 +774,17 @@ public class BrowserToolbar implements V
         Tab tab = Tabs.getInstance().getSelectedTab();
         if (tab != null) {
             String url = tab.getURL();
             setTitle(tab.getDisplayTitle());
             setFavicon(tab.getFavicon());
             setProgressVisibility(tab.getState() == Tab.STATE_LOADING);
             setSecurityMode(tab.getSecurityMode());
             setReaderMode(tab.getReaderEnabled());
-            setShadowVisibility((url == null) || !url.startsWith("about:"));
+            setShadowVisibility(true);
             updateTabCount(Tabs.getInstance().getCount());
             updateBackButton(tab.canDoBack());
             updateForwardButton(tab.canDoForward());
             updateBackgroundColor(tab.isPrivate() ? 1 : 0);
         }
     }
 
     private void updateBackgroundColor(int level) {
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -1,21 +1,24 @@
 /* -*- 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.gfx;
 
+import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
+import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.ScreenshotHandler;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.ZoomConstraints;
+import org.mozilla.gecko.ui.Axis;
 import org.mozilla.gecko.ui.PanZoomController;
 import org.mozilla.gecko.ui.PanZoomTarget;
 import org.mozilla.gecko.util.EventDispatcher;
 import org.mozilla.gecko.util.FloatUtils;
 import org.mozilla.gecko.util.GeckoEventResponder;
 
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -674,16 +677,33 @@ public class GeckoLayerClient
     }
 
     private void setViewportMetrics(ImmutableViewportMetrics metrics, boolean notifyGecko) {
         mViewportMetrics = metrics;
         mView.requestRender();
         if (notifyGecko && mGeckoIsReady) {
             geometryChanged();
         }
+        setShadowVisibility();
+    }
+
+    private void setShadowVisibility() {
+        GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
+            public void run() {
+                if (BrowserApp.mBrowserToolbar == null) {
+                    return;
+                }
+                Axis.Overscroll overscroll = mPanZoomController.getOverscrollY();
+                if (overscroll == Axis.Overscroll.PLUS || overscroll == Axis.Overscroll.NONE) {
+                    BrowserApp.mBrowserToolbar.setShadowVisibility(true);
+                } else {
+                    BrowserApp.mBrowserToolbar.setShadowVisibility(false);
+                }
+            }
+        });
     }
 
     /** Implementation of PanZoomTarget */
     public void setForceRedraw() {
         mForceRedraw = true;
         if (mGeckoIsReady) {
             geometryChanged();
         }
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -317,17 +317,17 @@ public class LayerView extends FrameLayo
 
     private Bitmap getDrawable(int resId) {
         BitmapFactory.Options options = new BitmapFactory.Options();
         options.inScaled = false;
         return BitmapFactory.decodeResource(getContext().getResources(), resId, options);
     }
 
     Bitmap getBackgroundPattern() {
-        return getDrawable(R.drawable.tabs_tray_selected_bg);
+        return getDrawable(R.drawable.abouthome_bg);
     }
 
     Bitmap getShadowPattern() {
         return getDrawable(R.drawable.shadow);
     }
 
     private void onSizeChanged(int width, int height) {
         mGLController.surfaceChanged(width, height);
--- a/mobile/android/base/ui/Axis.java
+++ b/mobile/android/base/ui/Axis.java
@@ -17,17 +17,17 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
  * This class represents the physics for one axis of movement (i.e. either
  * horizontal or vertical). It tracks the different properties of movement
  * like displacement, velocity, viewport dimensions, etc. pertaining to
  * a particular axis.
  */
-abstract class Axis {
+public abstract class Axis {
     private static final String LOGTAG = "GeckoAxis";
 
     private static final String PREF_SCROLLING_FRICTION_SLOW = "ui.scrolling.friction_slow";
     private static final String PREF_SCROLLING_FRICTION_FAST = "ui.scrolling.friction_fast";
     private static final String PREF_SCROLLING_MAX_EVENT_ACCELERATION = "ui.scrolling.max_event_acceleration";
     private static final String PREF_SCROLLING_OVERSCROLL_DECEL_RATE = "ui.scrolling.overscroll_decel_rate";
     private static final String PREF_SCROLLING_OVERSCROLL_SNAP_LIMIT = "ui.scrolling.overscroll_snap_limit";
     private static final String PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE = "ui.scrolling.min_scrollable_distance";
@@ -112,17 +112,17 @@ abstract class Axis {
     }
 
     private enum FlingStates {
         STOPPED,
         PANNING,
         FLINGING,
     }
 
-    private enum Overscroll {
+    public enum Overscroll {
         NONE,
         MINUS,      // Overscrolled in the negative direction
         PLUS,       // Overscrolled in the positive direction
         BOTH,       // Overscrolled in both directions (page is zoomed to smaller than screen)
     }
 
     private final SubdocumentScrollHelper mSubscroller;
 
@@ -198,17 +198,17 @@ abstract class Axis {
 
         mTouchPos = pos;
     }
 
     boolean overscrolled() {
         return getOverscroll() != Overscroll.NONE;
     }
 
-    private Overscroll getOverscroll() {
+    public Overscroll getOverscroll() {
         boolean minus = (getOrigin() < getPageStart());
         boolean plus = (getViewportEnd() > getPageEnd());
         if (minus && plus) {
             return Overscroll.BOTH;
         } else if (minus) {
             return Overscroll.MINUS;
         } else if (plus) {
             return Overscroll.PLUS;
--- a/mobile/android/base/ui/PanZoomController.java
+++ b/mobile/android/base/ui/PanZoomController.java
@@ -1056,9 +1056,13 @@ public class PanZoomController
     public void setOverScrollMode(int overscrollMode) {
         mX.setOverScrollMode(overscrollMode);
         mY.setOverScrollMode(overscrollMode);
     }
 
     public int getOverScrollMode() {
         return mX.getOverScrollMode();
     }
+
+    public Axis.Overscroll getOverscrollY() {
+        return mY.getOverscroll();
+    }
 }