Merge "Browser: change the bookmark UI spec in Browser"
diff --git a/res/drawable-mdpi/icon_up.png b/res/drawable-mdpi/icon_up.png
new file mode 100644
index 0000000..dc598ae
--- /dev/null
+++ b/res/drawable-mdpi/icon_up.png
Binary files differ
diff --git a/src/com/android/browser/AddBookmarkFolder.java b/src/com/android/browser/AddBookmarkFolder.java
index 7fae373..e67d84c 100644
--- a/src/com/android/browser/AddBookmarkFolder.java
+++ b/src/com/android/browser/AddBookmarkFolder.java
@@ -75,7 +75,7 @@
 
     /* package */static final String EXTRA_IS_FOLDER = "is_folder";
 
-    private static final int MAX_CRUMBS_SHOWN = 2;
+    private static final int MAX_CRUMBS_SHOWN = 1;
 
     private long mOriginalFolder = -1;
 
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index 580723c..a7ded1e 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -85,7 +85,7 @@
     /* package */ static final String EXTRA_EDIT_BOOKMARK = "bookmark";
     /* package */ static final String EXTRA_IS_FOLDER = "is_folder";
 
-    private static final int MAX_CRUMBS_SHOWN = 2;
+    private static final int MAX_CRUMBS_SHOWN = 1;
 
     private final String LOGTAG = "Bookmarks";
 
diff --git a/src/com/android/browser/BreadCrumbView.java b/src/com/android/browser/BreadCrumbView.java
index d331b53..c3bff59 100644
--- a/src/com/android/browser/BreadCrumbView.java
+++ b/src/com/android/browser/BreadCrumbView.java
@@ -28,6 +28,7 @@
 import android.widget.ImageButton;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import java.util.ArrayList;
@@ -38,7 +39,7 @@
  * Use setController to receive callbacks from user interactions
  * Use pushView, popView, clear, and getTopData to change/access the view stack
  */
-public class BreadCrumbView extends LinearLayout implements OnClickListener {
+public class BreadCrumbView extends RelativeLayout implements OnClickListener {
     private static final int DIVIDER_PADDING = 12; // dips
     private static final int CRUMB_PADDING = 8; // dips
 
@@ -47,6 +48,8 @@
     }
 
     private ImageButton mBackButton;
+    private LinearLayout mCrumbLayout;
+    private LinearLayout mBackLayout;
     private Controller mController;
     private List<Crumb> mCrumbs;
     private boolean mUseBackButton;
@@ -86,6 +89,7 @@
     private void init(Context ctx) {
         mContext = ctx;
         setFocusable(true);
+        setGravity(Gravity.CENTER_VERTICAL);
         mUseBackButton = false;
         mCrumbs = new ArrayList<Crumb>();
         TypedArray a = mContext.obtainStyledAttributes(com.android.internal.R.styleable.Theme);
@@ -94,7 +98,8 @@
         float density = mContext.getResources().getDisplayMetrics().density;
         mDividerPadding = DIVIDER_PADDING * density;
         mCrumbPadding = (int) (CRUMB_PADDING * density);
-        addBackButton();
+        addCrumbLayout();
+        addBackLayout();
     }
 
     public void setUseBackButton(boolean useflag) {
@@ -169,27 +174,61 @@
 
     private void addBackButton() {
         mBackButton = new ImageButton(mContext);
-        mBackButton.setImageResource(R.drawable.ic_back_hierarchy_holo_dark);
+        mBackButton.setImageResource(R.drawable.icon_up);
         TypedValue outValue = new TypedValue();
         getContext().getTheme().resolveAttribute(
                 android.R.attr.selectableItemBackground, outValue, true);
         int resid = outValue.resourceId;
         mBackButton.setBackgroundResource(resid);
+        mBackButton.setPadding(mCrumbPadding, 0, mCrumbPadding, 0);
         mBackButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                 LayoutParams.MATCH_PARENT));
         mBackButton.setOnClickListener(this);
-        mBackButton.setVisibility(View.GONE);
         mBackButton.setContentDescription(mContext.getText(
                 R.string.accessibility_button_bookmarks_folder_up));
-        addView(mBackButton, 0);
+        mBackLayout.addView(mBackButton);
+    }
+
+    private void addParentLabel() {
+        TextView tv = new TextView(mContext);
+        tv.setTextAppearance(mContext, android.R.style.TextAppearance_Medium);
+        tv.setPadding(mCrumbPadding, 0, 0, 0);
+        tv.setGravity(Gravity.CENTER_VERTICAL);
+        tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
+                LayoutParams.WRAP_CONTENT));
+        tv.setText("/ .../");
+        tv.setSingleLine();
+        tv.setVisibility(View.GONE);
+        mCrumbLayout.addView(tv);
+    }
+
+    private void addCrumbLayout() {
+        mCrumbLayout = new LinearLayout(mContext);
+        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
+                LayoutParams.WRAP_CONTENT);
+        params.addRule(ALIGN_PARENT_LEFT, TRUE);
+        params.setMargins(0, 0, 4 * mCrumbPadding, 0);
+        mCrumbLayout.setLayoutParams(params);
+        mCrumbLayout.setVisibility(View.VISIBLE);
+        addParentLabel();
+        addView(mCrumbLayout);
+    }
+
+    private void addBackLayout() {
+        mBackLayout= new LinearLayout(mContext);
+        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
+                LayoutParams.WRAP_CONTENT);
+        params.addRule(ALIGN_PARENT_RIGHT, TRUE);
+        mBackLayout.setLayoutParams(params);
+        mBackLayout.setVisibility(View.GONE);
+        addSeparator();
+        addBackButton();
+        addView(mBackLayout);
     }
 
     private void pushCrumb(Crumb crumb) {
-        if (mCrumbs.size() > 0) {
-            addSeparator();
-        }
         mCrumbs.add(crumb);
-        addView(crumb.crumbView);
+        mCrumbLayout.addView(crumb.crumbView);
         updateVisible();
         crumb.crumbView.setOnClickListener(this);
     }
@@ -197,7 +236,7 @@
     private void addSeparator() {
         View sep = makeDividerView();
         sep.setLayoutParams(makeDividerLayoutParams());
-        addView(sep);
+        mBackLayout.addView(sep);
     }
 
     private ImageView makeDividerView() {
@@ -207,11 +246,9 @@
         return result;
     }
 
-    private LayoutParams makeDividerLayoutParams() {
-        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
-                LayoutParams.MATCH_PARENT);
-        params.topMargin = (int) mDividerPadding;
-        params.bottomMargin = (int) mDividerPadding;
+    private LinearLayout.LayoutParams makeDividerLayoutParams() {
+        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
+                LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
         return params;
     }
 
@@ -219,17 +256,13 @@
         int n = mCrumbs.size();
         if (n > 0) {
             removeLastView();
-            if (!mUseBackButton || (n > 1)) {
-                // remove separator
-                removeLastView();
-            }
             mCrumbs.remove(n - 1);
             if (mUseBackButton) {
                 Crumb top = getTopCrumb();
                 if (top != null && top.canGoBack) {
-                    mBackButton.setVisibility(View.VISIBLE);
+                    mBackLayout.setVisibility(View.VISIBLE);
                 } else {
-                    mBackButton.setVisibility(View.GONE);
+                    mBackLayout.setVisibility(View.GONE);
                 }
             }
             updateVisible();
@@ -240,7 +273,7 @@
     }
 
     private void updateVisible() {
-        // start at index 1 (0 == back button)
+        // start at index 1 (0 == parent label)
         int childIndex = 1;
         if (mMaxVisible >= 0) {
             int invisibleCrumbs = size() - mMaxVisible;
@@ -248,22 +281,16 @@
                 int crumbIndex = 0;
                 while (crumbIndex < invisibleCrumbs) {
                     // Set the crumb to GONE.
-                    getChildAt(childIndex).setVisibility(View.GONE);
-                    childIndex++;
-                    // Each crumb is followed by a separator (except the last
-                    // one).  Also make it GONE
-                    if (getChildAt(childIndex) != null) {
-                        getChildAt(childIndex).setVisibility(View.GONE);
-                    }
+                    mCrumbLayout.getChildAt(childIndex).setVisibility(View.GONE);
                     childIndex++;
                     // Move to the next crumb.
                     crumbIndex++;
                 }
             }
-            // Make sure the last two are visible.
-            int childCount = getChildCount();
+            // Make sure the last is visible.
+            int childCount = mCrumbLayout.getChildCount();
             while (childIndex < childCount) {
-                getChildAt(childIndex).setVisibility(View.VISIBLE);
+                mCrumbLayout.getChildAt(childIndex).setVisibility(View.VISIBLE);
                 childIndex++;
             }
         } else {
@@ -274,16 +301,21 @@
         }
         if (mUseBackButton) {
             boolean canGoBack = getTopCrumb() != null ? getTopCrumb().canGoBack : false;
-            mBackButton.setVisibility(canGoBack ? View.VISIBLE : View.GONE);
+            mBackLayout.setVisibility(canGoBack ? View.VISIBLE : View.GONE);
+            if (canGoBack) {
+                mCrumbLayout.getChildAt(0).setVisibility(VISIBLE);
+            } else {
+                mCrumbLayout.getChildAt(0).setVisibility(GONE);
+            }
         } else {
-            mBackButton.setVisibility(View.GONE);
+            mBackLayout.setVisibility(View.GONE);
         }
     }
 
     private void removeLastView() {
-        int ix = getChildCount();
+        int ix = mCrumbLayout.getChildCount();
         if (ix > 0) {
-            removeViewAt(ix-1);
+            mCrumbLayout.removeViewAt(ix-1);
         }
     }
 
diff --git a/src/com/android/browser/view/BookmarkExpandableView.java b/src/com/android/browser/view/BookmarkExpandableView.java
index 7badaf5..5c0f030 100644
--- a/src/com/android/browser/view/BookmarkExpandableView.java
+++ b/src/com/android/browser/view/BookmarkExpandableView.java
@@ -417,7 +417,7 @@
                         mInflater.inflate(R.layout.bookmarks_header, null);
                 crumbs.setController(BookmarkExpandableView.this);
                 crumbs.setUseBackButton(true);
-                crumbs.setMaxVisible(2);
+                crumbs.setMaxVisible(1);
                 String bookmarks = mContext.getString(R.string.bookmarks);
                 crumbs.pushView(bookmarks, false,
                         BrowserContract.Bookmarks.CONTENT_URI_DEFAULT_FOLDER);