diff options
author | John Reck <jreck@google.com> | 2011-08-12 11:08:30 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-08-12 11:08:59 -0700 |
commit | 718a24d6c9671fe2da4112a3b5f30fd3939b38e8 (patch) | |
tree | 41a6e829625f0e47dda2b65a455adf15c1e36339 /src/com/android/browser/BaseUi.java | |
parent | 58891907e3cf77b72f1107ef5d9f4c984cb176ed (diff) | |
download | packages_apps_Browser-718a24d6c9671fe2da4112a3b5f30fd3939b38e8.zip packages_apps_Browser-718a24d6c9671fe2da4112a3b5f30fd3939b38e8.tar.gz packages_apps_Browser-718a24d6c9671fe2da4112a3b5f30fd3939b38e8.tar.bz2 |
URL Bar auto show tweaks
Bug: 5144824
Bug: 5142398
Change-Id: I235828d52bc8d8c35e2b625d767caeffb2d9b654
Diffstat (limited to 'src/com/android/browser/BaseUi.java')
-rw-r--r-- | src/com/android/browser/BaseUi.java | 58 |
1 files changed, 14 insertions, 44 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java index 368021a..a52bc56 100644 --- a/src/com/android/browser/BaseUi.java +++ b/src/com/android/browser/BaseUi.java @@ -36,11 +36,8 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; -import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; -import android.view.View.OnTouchListener; -import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.WindowManager; @@ -60,7 +57,7 @@ import java.util.List; /** * UI interface definitions */ -public abstract class BaseUi implements UI, OnTouchListener { +public abstract class BaseUi implements UI { private static final String LOGTAG = "BaseUi"; @@ -97,10 +94,9 @@ public abstract class BaseUi implements UI, OnTouchListener { private LinearLayout mErrorConsoleContainer = null; - private Toast mStopToast; + private UrlBarAutoShowManager mUrlBarAutoShowManager; - private float mInitialY; - private int mTitlebarScrollTriggerSlop; + private Toast mStopToast; // the default <video> poster private Bitmap mDefaultVideoPoster; @@ -135,16 +131,11 @@ public abstract class BaseUi implements UI, OnTouchListener { setFullscreen(BrowserSettings.getInstance().useFullscreen()); mGenericFavicon = res.getDrawable( R.drawable.app_web_browser_sm); - ViewConfiguration config = ViewConfiguration.get(browser); - mTitlebarScrollTriggerSlop = Math.max( - config.getScaledOverflingDistance(), - config.getScaledOverscrollDistance()); - mTitlebarScrollTriggerSlop = Math.max(mTitlebarScrollTriggerSlop, - config.getScaledTouchSlop()); mTitleBar = new TitleBar(mActivity, mUiController, this, mContentView); mTitleBar.setProgress(100); mNavigationBar = mTitleBar.getNavigationBar(); + mUrlBarAutoShowManager = new UrlBarAutoShowManager(this); } private void cancelStopToast() { @@ -244,9 +235,7 @@ public abstract class BaseUi implements UI, OnTouchListener { } mActiveTab = tab; WebView web = mActiveTab.getWebView(); - if (web != null && !mUseQuickControls) { - web.setOnTouchListener(this); - } + updateUrlBarAutoShowManagerTarget(); attachTabToContentView(tab); setShouldShowErrorConsole(tab, mUiController.shouldShowErrorConsole()); onTabDataChanged(tab); @@ -261,6 +250,15 @@ public abstract class BaseUi implements UI, OnTouchListener { } } + protected void updateUrlBarAutoShowManagerTarget() { + WebView web = mActiveTab != null ? mActiveTab.getWebView() : null; + if (!mUseQuickControls && web instanceof BrowserWebView) { + mUrlBarAutoShowManager.setTarget((BrowserWebView) web); + } else { + mUrlBarAutoShowManager.setTarget(null); + } + } + Tab getActiveTab() { return mActiveTab; } @@ -805,34 +803,6 @@ public abstract class BaseUi implements UI, OnTouchListener { mHandler.sendMessageDelayed(msg, HIDE_TITLEBAR_DELAY); } - @Override - public boolean onTouch(View v, MotionEvent event) { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - mInitialY = event.getY(); - break; - case MotionEvent.ACTION_MOVE: - WebView web = (WebView) v; - if (event.getPointerCount() == 1 - && !isTitleBarShowing() - && web.getVisibleTitleHeight() == 0 - && event.getY() > (mInitialY + mTitlebarScrollTriggerSlop)) { - showTitleBar(); - } else if (event.getY() < mInitialY) { - mInitialY = event.getY(); - } - break; - case MotionEvent.ACTION_CANCEL: - case MotionEvent.ACTION_UP: - if (isTitleBarShowing()) { - Message msg = Message.obtain(mHandler, MSG_HIDE_TITLEBAR); - mHandler.sendMessageDelayed(msg, HIDE_TITLEBAR_DELAY); - } - break; - } - return false; - } - private Handler mHandler = new Handler() { @Override |