Use a custom title bar that is touchable.

The new title bar is thicker and has areas that can be touched
to open the search bar, zoom in, zoom out, and stop a load. Also
inserted a flag to use the old title bar.
diff --git a/res/drawable/background_titlebar.png b/res/drawable/background_titlebar.png
new file mode 100644
index 0000000..0d7c562
--- /dev/null
+++ b/res/drawable/background_titlebar.png
Binary files differ
diff --git a/res/drawable/button_line.xml b/res/drawable/button_line.xml
new file mode 100644
index 0000000..03b5d35
--- /dev/null
+++ b/res/drawable/button_line.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+    <item>
+        <shape android:width="2dip">
+            <!-- Want it to have 90% alpha -->
+            <solid android:color="#ffdfdfdf"/>
+        </shape>
+    </item>
+    <item android:left="1dip" android:width="1dip">
+        <shape>
+            <solid android:color="#ffb6b6b6"/>
+        </shape>
+    </item>
+</layer-list>
diff --git a/res/drawable/ic_titlebar_zoom.png b/res/drawable/ic_titlebar_zoom.png
new file mode 100644
index 0000000..b497dab
--- /dev/null
+++ b/res/drawable/ic_titlebar_zoom.png
Binary files differ
diff --git a/res/drawable/ic_titlebar_zoom_out.png b/res/drawable/ic_titlebar_zoom_out.png
new file mode 100644
index 0000000..4b5a3dd
--- /dev/null
+++ b/res/drawable/ic_titlebar_zoom_out.png
Binary files differ
diff --git a/res/layout/title_bar.xml b/res/layout/title_bar.xml
new file mode 100644
index 0000000..fed4c6c
--- /dev/null
+++ b/res/layout/title_bar.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:fitsSystemWindows="true"
+    android:orientation="horizontal"
+    android:layout_width="fill_parent"
+    android:background="@drawable/background_titlebar"
+    android:layout_height="45dip">
+    <ImageView android:id="@+id/favicon"
+        android:layout_height="20dip"
+        android:layout_width="20dip"
+        android:layout_marginLeft="6dip"
+        android:layout_marginRight="6dip"
+        android:layout_gravity="center_vertical"
+        />
+    <!-- layout which contains the title, progress bar, and url -->
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="0dip"
+        android:layout_weight="1"
+        android:layout_height="wrap_content">
+        <!-- This part contains the favicon and the progress bar -->
+        <RelativeLayout
+            android:layout_marginTop="3dip"
+            android:layout_height="wrap_content"
+            android:layout_width="fill_parent"
+            >
+            <LinearLayout
+                android:orientation="horizontal"
+                android:layout_marginTop="3dip"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content">
+                <ProgressBar android:id="@+id/progress_horizontal"
+                    style="?android:attr/progressBarStyleHorizontal"
+                    android:layout_width="0dip"
+                    android:layout_weight="1"
+                    android:layout_height="wrap_content"
+                    android:max="100" />
+                <ProgressBar android:id="@+id/progress_circular"
+                    style="?android:attr/progressBarStyleSmallTitle"
+                    android:layout_marginLeft="3dip"
+                    android:layout_gravity="center_vertical"
+                    android:max="100"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content" />
+            </LinearLayout>
+            <!-- need to make this no wider than the horizontal progress bar -->
+            <TextView android:id="@+id/url"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="4dip"
+                android:layout_marginLeft="6dip"
+                android:textSize="12dip"
+                android:textColor="#ff333333"
+                android:singleLine="true"
+                />
+            <TextView android:id="@+id/title"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:layout_marginLeft="6dip"
+                android:layout_below="@id/url"
+                android:textSize="14dip"
+                android:textColor="#ff333333"
+                android:textStyle="bold"
+                android:singleLine="true"
+                />
+            <ImageView android:id="@+id/lock_icon"
+                android:layout_height="wrap_content"
+                android:layout_width="wrap_content"
+                android:layout_alignBottom="@id/title"
+                android:layout_alignParentRight="true"
+                android:visibility="gone"/>
+        </RelativeLayout>
+    </LinearLayout>
+    <!-- divider -->
+    <View
+        android:layout_height="fill_parent"
+        android:layout_width="2dip"
+        android:background="@drawable/button_line"/>
+    <!-- These buttons will change look/functionality -->
+    <ImageView android:id="@+id/zoom_in"
+        android:layout_width="52dip"
+        android:layout_height="wrap_content"
+        android:src="@drawable/ic_titlebar_zoom"/>
+    <!-- divider -->
+    <View android:id="@+id/divider"
+        android:layout_height="fill_parent"
+        android:layout_width="2dip"
+        android:background="@drawable/button_line"/>
+    <ImageView android:id="@+id/zoom_out"
+        android:layout_width="52dip"
+        android:layout_height="wrap_content"
+        android:src="@drawable/ic_titlebar_zoom_out"/>
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bb2f8e2..8440314 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -58,7 +58,10 @@
         <!-- Case of several matches -->
         <item quantity="other"><xliff:g id="number" example="137">%d</xliff:g> matches</item>
     </plurals>
-    
+
+    <!-- Displayed on the title bar while the page is loading -->
+    <string name="title_bar_loading">Loading\u2026</string>
+
     <!-- Menu item -->
     <string name="page_info">Page info</string>
     <!-- Label for a button on an SSL error dialog that allows the user to see
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index f63fea2..fd74b2d 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -640,16 +640,23 @@
         }
     }
 
+    // Flag to enable the touchable browser bar with buttons
+    private final boolean CUSTOM_BROWSER_BAR = true;
+
     @Override public void onCreate(Bundle icicle) {
         if (LOGV_ENABLED) {
             Log.v(LOGTAG, this + " onStart");
         }
         super.onCreate(icicle);
-        this.requestWindowFeature(Window.FEATURE_LEFT_ICON);
-        this.requestWindowFeature(Window.FEATURE_RIGHT_ICON);
-        this.requestWindowFeature(Window.FEATURE_PROGRESS);
-        this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
-
+        if (CUSTOM_BROWSER_BAR) {
+            this.requestWindowFeature(Window.FEATURE_NO_TITLE);
+            mTitleBar = new TitleBar(this);
+        } else {
+            this.requestWindowFeature(Window.FEATURE_LEFT_ICON);
+            this.requestWindowFeature(Window.FEATURE_RIGHT_ICON);
+            this.requestWindowFeature(Window.FEATURE_PROGRESS);
+            this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+        }
         // test the browser in OpenGL
         // requestWindowFeature(Window.FEATURE_OPENGL);
 
@@ -677,8 +684,25 @@
         mGenericFavicon = getResources().getDrawable(
                 R.drawable.app_web_browser_sm);
 
-        mContentView = (FrameLayout) getWindow().getDecorView().findViewById(
-                com.android.internal.R.id.content);
+        FrameLayout frameLayout = (FrameLayout) getWindow().getDecorView()
+                .findViewById(com.android.internal.R.id.content);
+        if (CUSTOM_BROWSER_BAR) {
+            mContentView = new FrameLayout(this);
+            // This LinearLayout will hold the title bar and a FrameLayout, which
+            // holds everything else.
+            LinearLayout linearLayout = new LinearLayout(this);
+            linearLayout.setOrientation(LinearLayout.VERTICAL);
+            linearLayout.addView(mTitleBar, new LinearLayout.LayoutParams(
+                    ViewGroup.LayoutParams.FILL_PARENT,
+                    ViewGroup.LayoutParams.WRAP_CONTENT));
+            linearLayout.addView(mContentView, new LinearLayout.LayoutParams(
+                    ViewGroup.LayoutParams.FILL_PARENT,
+                    ViewGroup.LayoutParams.FILL_PARENT));
+
+            frameLayout.addView(linearLayout, COVER_SCREEN_PARAMS);
+        } else {
+            mContentView = frameLayout;
+        }
 
         // Create the tab control and our initial tab
         mTabControl = new TabControl(this);
@@ -2430,7 +2454,11 @@
         // While the tab overview is animating or being shown, block changes
         // to the title.
         if (mAnimationCount == 0 && mTabOverview == null) {
-            setTitle(buildUrlTitle(url, title));
+            if (CUSTOM_BROWSER_BAR) {
+                mTitleBar.setTitleAndUrl(title, url);
+            } else {
+                setTitle(buildUrlTitle(url, title));
+            }
         }
     }
 
@@ -2507,18 +2535,34 @@
         if (mAnimationCount > 0 || mTabOverview != null) {
             return;
         }
-        Drawable[] array = new Drawable[2];
-        PaintDrawable p = new PaintDrawable(Color.WHITE);
-        p.setCornerRadius(3f);
-        array[0] = p;
-        if (icon == null) {
-            array[1] = mGenericFavicon;
+        if (CUSTOM_BROWSER_BAR) {
+            Drawable[] array = new Drawable[3];
+            array[0] = new PaintDrawable(Color.BLACK);
+            PaintDrawable p = new PaintDrawable(Color.WHITE);
+            array[1] = p;
+            if (icon == null) {
+                array[2] = mGenericFavicon;
+            } else {
+                array[2] = new BitmapDrawable(icon);
+            }
+            LayerDrawable d = new LayerDrawable(array);
+            d.setLayerInset(1, 1, 1, 1, 1);
+            d.setLayerInset(2, 2, 2, 2, 2);
+            mTitleBar.setFavicon(d);
         } else {
-            array[1] = new BitmapDrawable(icon);
+            Drawable[] array = new Drawable[2];
+            PaintDrawable p = new PaintDrawable(Color.WHITE);
+            p.setCornerRadius(3f);
+            array[0] = p;
+            if (icon == null) {
+                array[1] = mGenericFavicon;
+            } else {
+                array[1] = new BitmapDrawable(icon);
+            }
+            LayerDrawable d = new LayerDrawable(array);
+            d.setLayerInset(1, 2, 2, 2, 2);
+            getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON, d);
         }
-        LayerDrawable d = new LayerDrawable(array);
-        d.setLayerInset(1, 2, 2, 2, 2);
-        getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON, d);
     }
 
     /**
@@ -3540,8 +3584,13 @@
             // Block progress updates to the title bar while the tab overview
             // is animating or being displayed.
             if (mAnimationCount == 0 && mTabOverview == null) {
-                getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
-                        newProgress * 100);
+                if (CUSTOM_BROWSER_BAR) {
+                    mTitleBar.setProgress(newProgress);
+                } else {
+                    getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
+                            newProgress * 100);
+
+                }
             }
 
             if (newProgress == 100) {
@@ -3836,7 +3885,11 @@
         // If the tab overview is animating or being shown, do not update the
         // lock icon.
         if (mAnimationCount == 0 && mTabOverview == null) {
-            getWindow().setFeatureDrawable(Window.FEATURE_RIGHT_ICON, d);
+            if (CUSTOM_BROWSER_BAR) {
+                mTitleBar.setLock(d);
+            } else {
+                getWindow().setFeatureDrawable(Window.FEATURE_RIGHT_ICON, d);
+            }
         }
     }
 
@@ -4543,11 +4596,15 @@
         mAnimationCount++;
         // Always change the title bar to the window overview title while
         // animating.
-        getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON, null);
-        getWindow().setFeatureDrawable(Window.FEATURE_RIGHT_ICON, null);
-        getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
-                Window.PROGRESS_VISIBILITY_OFF);
-        setTitle(R.string.tab_picker_title);
+        if (CUSTOM_BROWSER_BAR) {
+            mTitleBar.setToTabPicker();
+        } else {
+            getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON, null);
+            getWindow().setFeatureDrawable(Window.FEATURE_RIGHT_ICON, null);
+            getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
+                    Window.PROGRESS_VISIBILITY_OFF);
+            setTitle(R.string.tab_picker_title);
+        }
         // Make the menu empty until the animation completes.
         mMenuState = EMPTY_MENU;
     }
@@ -4885,6 +4942,8 @@
 
     private Toast mStopToast;
 
+    private TitleBar mTitleBar;
+
     // Used during animations to prevent other animations from being triggered.
     // A count is used since the animation to and from the Window overview can
     // overlap. A count of 0 means no animation where a count of > 0 means
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
new file mode 100644
index 0000000..b512c78
--- /dev/null
+++ b/src/com/android/browser/TitleBar.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.browser;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.webkit.WebView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import android.view.LayoutInflater;
+import android.view.View;
+
+/* package */ class TitleBar extends LinearLayout {
+    private TextView        mTitle;
+    private TextView        mUrl;
+    private ImageView       mZoomIn;
+    private View            mZoomOut;
+    private View            mDivider;
+    private ProgressBar     mCircularProgress;
+    private ProgressBar     mHorizontalProgress;
+    private ImageView       mFavicon;
+    private ImageView       mLockIcon;
+    private boolean         mInLoad;
+    private CharSequence    mTitleOnceLoaded;
+    private BrowserActivity mActivity;
+
+
+    /* package */ TitleBar(BrowserActivity context) {
+        super(context);
+        mActivity = context;
+        LayoutInflater factory = LayoutInflater.from(context);
+        factory.inflate(R.layout.title_bar, this);
+
+        mTitle = (TextView) findViewById(R.id.title);
+        mUrl = (TextView) findViewById(R.id.url);
+
+        mZoomIn = (ImageView) findViewById(R.id.zoom_in);
+        mZoomIn.setOnClickListener(new View.OnClickListener() {
+                    public void onClick(View v) {
+                        if (mInLoad) {
+                            mActivity.getTopWindow().stopLoading();
+                        } else {
+                            mActivity.getTopWindow().zoomIn();
+                        }
+                    }
+                });
+        mZoomOut = findViewById(R.id.zoom_out);
+        // Make zoom out disappear while loading
+        mZoomOut.setOnClickListener(new View.OnClickListener() {
+                    public void onClick(View v) {
+                        mActivity.getTopWindow().zoomOut();
+                    }
+                });
+
+        mCircularProgress = (ProgressBar) findViewById(R.id.progress_circular);
+        mHorizontalProgress = (ProgressBar) findViewById(
+                R.id.progress_horizontal);
+        mFavicon = (ImageView) findViewById(R.id.favicon);
+        mLockIcon = (ImageView) findViewById(R.id.lock_icon);
+        mDivider = findViewById(R.id.divider);
+        setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                mActivity.onSearchRequested();
+            }
+        });
+    }
+
+    /* package */ void setFavicon(Drawable d) {
+        mFavicon.setImageDrawable(d);
+    }
+
+    /* package */ void setLock(Drawable d) {
+        if (d == null) {
+            mLockIcon.setVisibility(View.GONE);
+        } else {
+            mLockIcon.setImageDrawable(d);
+            mLockIcon.setVisibility(View.VISIBLE);
+        }
+    }
+
+    /* package */ void setProgress(int newProgress) {
+        if (newProgress == mCircularProgress.getMax()) {
+            mCircularProgress.setVisibility(View.GONE);
+            mHorizontalProgress.setVisibility(View.GONE);
+            mTitle.setText(mTitleOnceLoaded);
+            mDivider.setVisibility(View.VISIBLE);
+            mZoomOut.setVisibility(View.VISIBLE);
+            mZoomIn.setImageResource(R.drawable.ic_titlebar_zoom);
+            mInLoad = false;
+        } else {
+            mCircularProgress.setProgress(newProgress);
+            mHorizontalProgress.setProgress(newProgress);
+            mCircularProgress.setVisibility(View.VISIBLE);
+            mHorizontalProgress.setVisibility(View.VISIBLE);
+            mDivider.setVisibility(View.GONE);
+            mZoomOut.setVisibility(View.GONE);
+            mZoomIn.setImageResource(com.android.internal.R.drawable.ic_menu_stop);
+            mInLoad = true;
+        }
+    }
+
+    /* package */ void setTitleAndUrl(CharSequence title, CharSequence url) {
+        mTitleOnceLoaded = title;
+        if (null == title || mHorizontalProgress.getProgress() <
+                mHorizontalProgress.getMax()) {
+            mTitle.setText(R.string.title_bar_loading);
+        } else {
+            mTitle.setText(title);
+        }
+        mUrl.setText(url);
+    }
+
+    /* package */ void setToTabPicker() {
+        mTitle.setText(R.string.tab_picker_title);
+        setFavicon(null);
+        setLock(null);
+        mCircularProgress.setVisibility(View.GONE);
+        mHorizontalProgress.setVisibility(View.GONE);
+    }
+}