Phone UI title bar work

 Updated progress bar to holo and below URL bar
 Removed spinner
 Swapped stop/bookmark with new assets
 Wired up bookmark listener to change star state

Change-Id: Ie91ae446cc1c429ce4a1662cc337202aaf7877c3
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 9bce3cd..6e8f603 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -193,7 +193,10 @@
 
     @Override
     public void bookmarkedStatusHasChanged(Tab tab) {
-        // no op in base case
+        if (tab.inForeground()) {
+            boolean isBookmark = tab.isBookmarkedSite();
+            getTitleBar().setCurrentUrlIsBookmark(isBookmark);
+        }
     }
 
     @Override
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index 56db187..686416c 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -21,15 +21,12 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.content.res.Resources;
-import android.graphics.drawable.Animatable;
 import android.graphics.drawable.Drawable;
 import android.speech.RecognizerIntent;
 import android.text.SpannableString;
 import android.text.Spanned;
 import android.text.TextUtils;
 import android.text.style.ImageSpan;
-import android.util.DisplayMetrics;
-import android.util.TypedValue;
 import android.view.ContextMenu;
 import android.view.LayoutInflater;
 import android.view.MenuInflater;
@@ -38,7 +35,6 @@
 import android.view.View.OnFocusChangeListener;
 import android.widget.ImageButton;
 import android.widget.ImageView;
-import android.widget.ProgressBar;
 
 /**
  * This class represents a title bar for a particular "tab" or "window" in the
@@ -49,19 +45,13 @@
 
     private Activity mActivity;
     private ImageButton mBookmarkButton;
-    private Drawable mCircularProgress;
-    private ProgressBar mHorizontalProgress;
+    private PageProgressView mHorizontalProgress;
     private ImageButton mStopButton;
     private Drawable mBookmarkDrawable;
     private Drawable mVoiceDrawable;
     private boolean mInLoad;
-    private View mTitleBg;
     private Intent mVoiceSearchIntent;
-    private Drawable mVoiceModeBackground;
-    private Drawable mNormalBackground;
     private ImageSpan mArcsSpan;
-    private int mLeftMargin;
-    private int mRightMargin;
 
     public TitleBar(Activity activity, UiController controller, PhoneUi ui) {
         super(activity, controller, ui);
@@ -77,7 +67,6 @@
         mUrlInput.setUrlInputListener(this);
         mUrlInput.setOnFocusChangeListener(this);
 
-        mTitleBg = findViewById(R.id.title_bg);
         mLockIcon = (ImageView) findViewById(R.id.lock);
         mFavicon = (ImageView) findViewById(R.id.favicon);
         mStopButton = (ImageButton) findViewById(R.id.stop);
@@ -85,18 +74,7 @@
         mStopButton.setOnClickListener(this);
         mBookmarkButton.setOnClickListener(this);
 
-        Resources resources = activity.getResources();
-        mCircularProgress = resources.getDrawable(
-                com.android.internal.R.drawable.search_spinner);
-        DisplayMetrics metrics = resources.getDisplayMetrics();
-        mLeftMargin = (int) TypedValue.applyDimension(
-                TypedValue.COMPLEX_UNIT_DIP, 8f, metrics);
-        mRightMargin = (int) TypedValue.applyDimension(
-                TypedValue.COMPLEX_UNIT_DIP, 6f, metrics);
-        int iconDimension = (int) TypedValue.applyDimension(
-                TypedValue.COMPLEX_UNIT_DIP, 20f, metrics);
-        mCircularProgress.setBounds(0, 0, iconDimension, iconDimension);
-        mHorizontalProgress = (ProgressBar) findViewById(
+        mHorizontalProgress = (PageProgressView) findViewById(
                 R.id.progress_horizontal);
         mVoiceSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
         mVoiceSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
@@ -110,6 +88,7 @@
         PackageManager pm = activity.getPackageManager();
         ResolveInfo ri = pm.resolveActivity(mVoiceSearchIntent,
                 PackageManager.MATCH_DEFAULT_ONLY);
+        Resources resources = getResources();
         if (ri == null) {
             mVoiceSearchIntent = null;
         } else {
@@ -117,9 +96,6 @@
                     android.R.drawable.ic_btn_speak_now);
         }
         mBookmarkDrawable = mBookmarkButton.getDrawable();
-        mVoiceModeBackground = resources.getDrawable(
-                R.drawable.title_voice);
-        mNormalBackground = mTitleBg.getBackground();
         mArcsSpan = new ImageSpan(activity, R.drawable.arcs,
                 ImageSpan.ALIGN_BASELINE);
     }
@@ -142,13 +118,9 @@
         Drawable titleDrawable;
         if (mInVoiceMode) {
             mBookmarkButton.setImageDrawable(mVoiceDrawable);
-            titleDrawable = mVoiceModeBackground;
             mUrlInput.setEllipsize(null);
             mBookmarkButton.setVisibility(View.VISIBLE);
             mStopButton.setVisibility(View.GONE);
-            mTitleBg.setBackgroundDrawable(titleDrawable);
-            mTitleBg.setPadding(mLeftMargin, mTitleBg.getPaddingTop(),
-                    mRightMargin, mTitleBg.getPaddingBottom());
         } else {
             if (mInLoad) {
                 mBookmarkButton.setVisibility(View.GONE);
@@ -159,7 +131,6 @@
                 mBookmarkButton.setImageDrawable(mBookmarkDrawable);
             }
             mUrlInput.setEllipsize(TextUtils.TruncateAt.END);
-            mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
         }
         mUrlInput.setSingleLine(!mInVoiceMode);
     }
@@ -169,31 +140,20 @@
      */
     @Override
     void setProgress(int newProgress) {
-        if (newProgress >= mHorizontalProgress.getMax()) {
-            mUrlInput.setCompoundDrawables(null, null, null, null);
-            ((Animatable) mCircularProgress).stop();
-            mHorizontalProgress.setVisibility(View.INVISIBLE);
+        if (newProgress >= PROGRESS_MAX) {
+            mHorizontalProgress.setVisibility(View.GONE);
             if (!mInVoiceMode) {
                 mBookmarkButton.setImageDrawable(mBookmarkDrawable);
                 mBookmarkButton.setVisibility(View.VISIBLE);
                 mStopButton.setVisibility(View.GONE);
-                mTitleBg.setBackgroundDrawable(mNormalBackground);
-                mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
             }
             mInLoad = false;
         } else {
-            mHorizontalProgress.setProgress(newProgress);
-            if (!mInLoad && getWindowToken() != null) {
-                // checking the window token lets us be sure that we
-                // are attached to a window before starting the animation,
-                // preventing a potential race condition
-                // (fix for bug http://b/2115736)
-                mUrlInput.setCompoundDrawables(null, null, mCircularProgress,
-                        null);
-                ((Animatable) mCircularProgress).start();
+            mHorizontalProgress.setProgress(newProgress * PageProgressView.MAX_PROGRESS
+                    / PROGRESS_MAX);
+            if (!mInLoad) {
                 mHorizontalProgress.setVisibility(View.VISIBLE);
                 if (!mInVoiceMode) {
-                    mTitleBg.setPadding(mLeftMargin, 0, mRightMargin, 0);
                     mBookmarkButton.setVisibility(View.GONE);
                     mStopButton.setVisibility(View.VISIBLE);
                 }
@@ -243,4 +203,9 @@
                     true);
         }
     }
+
+    @Override
+    public void setCurrentUrlIsBookmark(boolean isBookmark) {
+        mBookmarkButton.setActivated(isBookmark);
+    }
 }
diff --git a/src/com/android/browser/TitleBarBase.java b/src/com/android/browser/TitleBarBase.java
index f62e0e4..2b64aa3 100644
--- a/src/com/android/browser/TitleBarBase.java
+++ b/src/com/android/browser/TitleBarBase.java
@@ -39,6 +39,9 @@
  * Base class for a title bar used by the browser.
  */
 public class TitleBarBase extends LinearLayout implements UrlInputListener {
+
+    protected static final int PROGRESS_MAX = 100;
+
     // These need to be set by the subclass.
     protected ImageView mFavicon;
     protected ImageView mLockIcon;
@@ -168,4 +171,7 @@
         }
     }
 
+    public void setCurrentUrlIsBookmark(boolean isBookmark) {
+    }
+
 }
diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java
index 3931526..c732da8 100644
--- a/src/com/android/browser/TitleBarXLarge.java
+++ b/src/com/android/browser/TitleBarXLarge.java
@@ -48,8 +48,6 @@
         implements OnClickListener, OnFocusChangeListener,
     TextWatcher {
 
-    private static final int PROGRESS_MAX = 100;
-
     private XLargeUi mUi;
 
     private Drawable mStopDrawable;
@@ -210,6 +208,7 @@
         mUrlInput.clearNeedsUpdate();
     }
 
+    @Override
     public void setCurrentUrlIsBookmark(boolean isBookmark) {
         mStar.setActivated(isBookmark);
     }
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java
index f361e57..90e3683 100644
--- a/src/com/android/browser/XLargeUi.java
+++ b/src/com/android/browser/XLargeUi.java
@@ -161,14 +161,6 @@
     // WebView callbacks
 
     @Override
-    public void bookmarkedStatusHasChanged(Tab tab) {
-        if (tab.inForeground()) {
-            boolean isBookmark = tab.isBookmarkedSite();
-            mTitleBar.setCurrentUrlIsBookmark(isBookmark);
-        }
-    }
-
-    @Override
     public void onProgressChanged(Tab tab) {
         int progress = tab.getLoadProgress();
         mTabBar.onProgress(tab, progress);