diff options
author | John Reck <jreck@google.com> | 2011-09-02 10:14:16 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-02 10:14:16 -0700 |
commit | f09d7efeac20221f610aedaa706e1781cf04e03e (patch) | |
tree | c64e6257b390d11e7ee67d40958249317fe6d820 | |
parent | 9a50dc0a30f054c9637d2d022abef0b45bda6c7f (diff) | |
parent | bc6adb4501853dbaba1c3bb592a159ee901b70e7 (diff) | |
download | packages_apps_Browser-f09d7efeac20221f610aedaa706e1781cf04e03e.zip packages_apps_Browser-f09d7efeac20221f610aedaa706e1781cf04e03e.tar.gz packages_apps_Browser-f09d7efeac20221f610aedaa706e1781cf04e03e.tar.bz2 |
Merge "URL bar pull down tweaks"
-rw-r--r-- | src/com/android/browser/BaseUi.java | 8 | ||||
-rw-r--r-- | src/com/android/browser/UrlBarAutoShowManager.java | 18 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java index 7d7fda1..17ba4d7 100644 --- a/src/com/android/browser/BaseUi.java +++ b/src/com/android/browser/BaseUi.java @@ -804,10 +804,14 @@ public abstract class BaseUi implements UI { } } - protected void showTitleBarForDuration() { + protected final void showTitleBarForDuration() { + showTitleBarForDuration(HIDE_TITLEBAR_DELAY); + } + + protected final void showTitleBarForDuration(long duration) { showTitleBar(); Message msg = Message.obtain(mHandler, MSG_HIDE_TITLEBAR); - mHandler.sendMessageDelayed(msg, HIDE_TITLEBAR_DELAY); + mHandler.sendMessageDelayed(msg, duration); } private Handler mHandler = new Handler() { diff --git a/src/com/android/browser/UrlBarAutoShowManager.java b/src/com/android/browser/UrlBarAutoShowManager.java index 25192ca..0db31ff 100644 --- a/src/com/android/browser/UrlBarAutoShowManager.java +++ b/src/com/android/browser/UrlBarAutoShowManager.java @@ -31,6 +31,8 @@ public class UrlBarAutoShowManager implements OnTouchListener, OnScrollChangedListener { private static float V_TRIGGER_ANGLE = .9f; + private static long SCROLL_TIMEOUT_DURATION = 150; + private static long IGNORE_INTERVAL = 250; private BrowserWebView mTarget; private BaseUi mUi; @@ -39,10 +41,10 @@ public class UrlBarAutoShowManager implements OnTouchListener, private float mStartTouchX; private float mStartTouchY; - private float mLastTouchX; - private float mLastTouchY; private boolean mIsTracking; private boolean mHasTriggered; + private long mLastScrollTime; + private long mTriggeredTime; public UrlBarAutoShowManager(BaseUi ui) { mUi = ui; @@ -66,11 +68,15 @@ public class UrlBarAutoShowManager implements OnTouchListener, @Override public void onScrollChanged(int l, int t, int oldl, int oldt) { + mLastScrollTime = System.currentTimeMillis(); if (t != oldt) { if (t != 0) { // If it is showing, extend it if (mUi.isTitleBarShowing()) { - mUi.showTitleBarForDuration(); + long remaining = mLastScrollTime - mTriggeredTime; + remaining = Math.max(BaseUi.HIDE_TITLEBAR_DELAY - remaining, + SCROLL_TIMEOUT_DURATION); + mUi.showTitleBarForDuration(remaining); } } else { mUi.suggestHideTitleBar(); @@ -95,6 +101,11 @@ public class UrlBarAutoShowManager implements OnTouchListener, switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (!mIsTracking && event.getPointerCount() == 1) { + long sinceLastScroll = + System.currentTimeMillis() - mLastScrollTime; + if (sinceLastScroll < IGNORE_INTERVAL) { + break; + } mStartTouchY = event.getY(); mStartTouchX = event.getX(); mIsTracking = true; @@ -113,6 +124,7 @@ public class UrlBarAutoShowManager implements OnTouchListener, if (dy > mSlop && angle > V_TRIGGER_ANGLE && !mUi.isTitleBarShowing() && web.getVisibleTitleHeight() == 0) { + mTriggeredTime = System.currentTimeMillis(); mUi.showTitleBar(); } } |