From 5ee018e25ecda8955f865cbf7b0b946bcad2b294 Mon Sep 17 00:00:00 2001 From: Michael Kolb Date: Fri, 18 Feb 2011 15:47:21 -0800 Subject: don't scroll title bar while editing Bug: 3405814 Check if scroll is user initiated and if user is editing url before hiding titlebar when scrolling Change-Id: Icc32ef1cc83018021ebe12402aec016c9555e3a9 --- src/com/android/browser/ScrollWebView.java | 17 +++++++++++++++-- src/com/android/browser/TabBar.java | 7 ++++--- src/com/android/browser/XLargeUi.java | 8 ++++++-- 3 files changed, 25 insertions(+), 7 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/browser/ScrollWebView.java b/src/com/android/browser/ScrollWebView.java index e2ef902..1d7f23a 100644 --- a/src/com/android/browser/ScrollWebView.java +++ b/src/com/android/browser/ScrollWebView.java @@ -18,6 +18,7 @@ package com.android.browser; import android.content.Context; import android.util.AttributeSet; +import android.view.MotionEvent; import android.view.View; import android.webkit.WebView; @@ -31,6 +32,7 @@ public class ScrollWebView extends WebView implements Runnable { private ScrollListener mScrollListener; private boolean mIsCancelled; private boolean mBackgroundRemoved = false; + private boolean mUserInitiated = false; /** * @param context @@ -71,7 +73,7 @@ public class ScrollWebView extends WebView implements Runnable { // scroll runnable implementation public void run() { if (!mIsCancelled && (mScrollListener != null)) { - mScrollListener.onScroll(getVisibleTitleHeight()); + mScrollListener.onScroll(getVisibleTitleHeight(), mUserInitiated); } } @@ -89,6 +91,17 @@ public class ScrollWebView extends WebView implements Runnable { } @Override + public boolean onTouchEvent(MotionEvent evt) { + if (MotionEvent.ACTION_DOWN == evt.getActionMasked()) { + mUserInitiated = true; + } else if (MotionEvent.ACTION_UP == evt.getActionMasked() + || (MotionEvent.ACTION_CANCEL == evt.getActionMasked())) { + mUserInitiated = false; + } + return super.onTouchEvent(evt); + } + + @Override public void stopScroll() { mIsCancelled = true; super.stopScroll(); @@ -111,7 +124,7 @@ public class ScrollWebView extends WebView implements Runnable { // callback for scroll events interface ScrollListener { - public void onScroll(int visibleTitleHeight); + public void onScroll(int visibleTitleHeight, boolean userInitiated); } @Override diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java index 4fb3ad4..9da1927 100644 --- a/src/com/android/browser/TabBar.java +++ b/src/com/android/browser/TabBar.java @@ -262,13 +262,14 @@ public class TabBar extends LinearLayout // webview scroll listener @Override - public void onScroll(int visibleTitleHeight) { + public void onScroll(int visibleTitleHeight, boolean userInitiated) { if (mUseQuickControls) return; // isLoading is using the current tab, which initially might not be set yet if (mTabControl.getCurrentTab() != null && !isLoading()) { if (visibleTitleHeight == 0) { - if (!showsTitleBarIndicator()) { + if (!showsTitleBarIndicator() + && (!mUi.isEditingUrl() || userInitiated)) { mUi.hideTitleBar(); showTitleBarIndicator(true); } @@ -606,7 +607,7 @@ public class TabBar extends LinearLayout WebView webview = tab.getWebView(); if (webview != null) { int h = webview.getVisibleTitleHeight(); - onScroll(h); + onScroll(h, true); } } } diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java index 90e3683..8684042 100644 --- a/src/com/android/browser/XLargeUi.java +++ b/src/com/android/browser/XLargeUi.java @@ -147,8 +147,8 @@ public class XLargeUi extends BaseUi implements ScrollListener { } @Override - public void onScroll(int visibleTitleHeight) { - mTabBar.onScroll(visibleTitleHeight); + public void onScroll(int visibleTitleHeight, boolean userInitiated) { + mTabBar.onScroll(visibleTitleHeight, userInitiated); } void stopWebViewScrolling() { @@ -297,6 +297,10 @@ public class XLargeUi extends BaseUi implements ScrollListener { } } + public boolean isEditingUrl() { + return mTitleBar.isEditingUrl(); + } + @Override protected TitleBarBase getTitleBar() { return mTitleBar; -- cgit v1.1