Bug 810278 - Improved background/toolbar visual cohesion. r=wjohnston

This commit is contained in:
Morrison Cole 2012-11-16 13:43:33 -08:00
parent 852a9b7915
commit 2e18e44df6
5 changed files with 42 additions and 6 deletions

View File

@ -662,7 +662,19 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
}
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) {
@ -767,7 +779,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
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());

View File

@ -5,12 +5,15 @@
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;
@ -679,6 +682,23 @@ public class GeckoLayerClient
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 */

View File

@ -322,7 +322,7 @@ public class LayerView extends FrameLayout {
}
Bitmap getBackgroundPattern() {
return getDrawable(R.drawable.tabs_tray_selected_bg);
return getDrawable(R.drawable.abouthome_bg);
}
Bitmap getShadowPattern() {

View File

@ -22,7 +22,7 @@ import java.util.Map;
* 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";
@ -117,7 +117,7 @@ abstract class Axis {
FLINGING,
}
private enum Overscroll {
public enum Overscroll {
NONE,
MINUS, // Overscrolled in the negative direction
PLUS, // Overscrolled in the positive direction
@ -203,7 +203,7 @@ abstract class Axis {
return getOverscroll() != Overscroll.NONE;
}
private Overscroll getOverscroll() {
public Overscroll getOverscroll() {
boolean minus = (getOrigin() < getPageStart());
boolean plus = (getViewportEnd() > getPageEnd());
if (minus && plus) {

View File

@ -1061,4 +1061,8 @@ public class PanZoomController
public int getOverScrollMode() {
return mX.getOverScrollMode();
}
public Axis.Overscroll getOverscrollY() {
return mY.getOverscroll();
}
}