summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/TitleBar.java
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2009-09-15 15:31:54 -0400
committerLeon Scroggins <scroggo@google.com>2009-09-15 15:31:54 -0400
commit68579393973f745fc65a2781061af9bb8f2d7020 (patch)
treedf0c79454bd8963dd4b843cccafbf6c95e0f70d0 /src/com/android/browser/TitleBar.java
parent25d3547e0df084f963e38c6a93c99b02bd619de3 (diff)
downloadpackages_apps_Browser-68579393973f745fc65a2781061af9bb8f2d7020.tar.gz
packages_apps_Browser-68579393973f745fc65a2781061af9bb8f2d7020.tar.bz2
packages_apps_Browser-68579393973f745fc65a2781061af9bb8f2d7020.zip
Remove the tab slider, and go back to simply using a touchable title bar.
Remove the tab slider (TitleBarSet) from eclair. In TitleBar, override onTouchEvent to handle touches as either presses of the right button or the textfield. Fix the press states on the title bar to correctly reflect what will happen if you release your finger. Change-Id: I025b55e5ba546e8be4e9360e6f7db80fb6d9d3f9
Diffstat (limited to 'src/com/android/browser/TitleBar.java')
-rw-r--r--src/com/android/browser/TitleBar.java67
1 files changed, 58 insertions, 9 deletions
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index 857aa38be..9c3e55aea 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -28,8 +28,9 @@ import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.PaintDrawable;
import android.util.TypedValue;
import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
-import android.webkit.WebView;
+import android.view.ViewConfiguration;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@@ -50,12 +51,12 @@ public class TitleBar extends LinearLayout {
private Drawable mStopDrawable;
private Drawable mBookmarkDrawable;
private boolean mInLoad;
- private WebView mWebView;
private BrowserActivity mBrowserActivity;
private Drawable mGenericFavicon;
private int mIconDimension;
+ private View mTitleBg;
- public TitleBar(BrowserActivity context, WebView webview) {
+ public TitleBar(BrowserActivity context) {
super(context, null);
LayoutInflater factory = LayoutInflater.from(context);
factory.inflate(R.layout.title_bar, this);
@@ -64,6 +65,7 @@ public class TitleBar extends LinearLayout {
mTitle = (TextView) findViewById(R.id.title);
mTitle.setCompoundDrawablePadding(5);
+ mTitleBg = findViewById(R.id.title_bg);
mLockIcon = (ImageView) findViewById(R.id.lock);
mFavicon = (ImageView) findViewById(R.id.favicon);
@@ -77,16 +79,63 @@ public class TitleBar extends LinearLayout {
mCircularProgress.setBounds(0, 0, mIconDimension, mIconDimension);
mHorizontalProgress = (ProgressBar) findViewById(
R.id.progress_horizontal);
- mWebView = webview;
mGenericFavicon = context.getResources().getDrawable(
R.drawable.app_web_browser_sm);
}
- /**
- * Return the WebView associated with this TitleBar.
- */
- /* package */ WebView getWebView() {
- return mWebView;
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ // Make all touches hit either the textfield or the button,
+ // depending on which side of the right edge of the textfield
+ // they hit.
+ if ((int) event.getX() > mTitleBg.getRight()) {
+ mRtButton.setPressed(true);
+ } else {
+ mTitleBg.setPressed(true);
+ }
+ break;
+ case MotionEvent.ACTION_MOVE:
+ int slop = ViewConfiguration.get(mBrowserActivity)
+ .getScaledTouchSlop();
+ if ((int) event.getY() > getHeight() + slop) {
+ // We only trigger the actions in ACTION_UP if one or the
+ // other is pressed. Since the user moved off the title
+ // bar, mark both as not pressed.
+ mTitleBg.setPressed(false);
+ mRtButton.setPressed(false);
+ break;
+ }
+ int x = (int) event.getX();
+ int titleRight = mTitleBg.getRight();
+ if (mTitleBg.isPressed() && x > titleRight + slop) {
+ mTitleBg.setPressed(false);
+ } else if (mRtButton.isPressed() && x < titleRight - slop) {
+ mRtButton.setPressed(false);
+ }
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ mRtButton.setPressed(false);
+ mTitleBg.setPressed(false);
+ break;
+ case MotionEvent.ACTION_UP:
+ if (mRtButton.isPressed()) {
+ if (mInLoad) {
+ mBrowserActivity.stopLoading();
+ } else {
+ mBrowserActivity.bookmarksOrHistoryPicker(false);
+ }
+ mRtButton.setPressed(false);
+ } else if (mTitleBg.isPressed()) {
+ mBrowserActivity.onSearchRequested();
+ mTitleBg.setPressed(false);
+ }
+ break;
+ default:
+ break;
+ }
+ return true;
}
/**