Bookmarks page UI updates
Bug: 3248628
Updates the bookmark page UI based off of the newest UI design
document.
Change-Id: I26447b7e1c38798b3c229c9d8c10af2565458a7b
diff --git a/src/com/android/browser/BreadCrumbView.java b/src/com/android/browser/BreadCrumbView.java
index d0ba8ad..e4940e9 100644
--- a/src/com/android/browser/BreadCrumbView.java
+++ b/src/com/android/browser/BreadCrumbView.java
@@ -47,6 +47,7 @@
private List<Crumb> mCrumbs;
private boolean mUseBackButton;
private Drawable mSeparatorDrawable;
+ private int mMaxVisible = -1;
/**
* @param context
@@ -80,22 +81,31 @@
mCrumbs = new ArrayList<Crumb>();
mSeparatorDrawable = ctx.getResources().getDrawable(
R.drawable.crumb_divider);
+ addBackButton();
}
public void setUseBackButton(boolean useflag) {
mUseBackButton = useflag;
- if (mUseBackButton && (mBackButton == null)) {
- addBackButton();
- } else if (!mUseBackButton && (mBackButton != null)) {
- removeView(mBackButton);
- mBackButton = null;
- }
+ updateVisible();
}
public void setController(Controller ctl) {
mController = ctl;
}
+ public int getMaxVisible() {
+ return mMaxVisible;
+ }
+
+ public void setMaxVisible(int max) {
+ mMaxVisible = max;
+ updateVisible();
+ }
+
+ public int getTopLevel() {
+ return mCrumbs.size();
+ }
+
public Object getTopData() {
Crumb c = getTopCrumb();
if (c != null) {
@@ -155,14 +165,12 @@
}
private void pushCrumb(Crumb crumb) {
- if (!mUseBackButton || (mCrumbs.size() > 0)) {
+ if (mCrumbs.size() > 0) {
addSeparator();
}
mCrumbs.add(crumb);
addView(crumb.crumbView);
- if (mUseBackButton) {
- mBackButton.setVisibility(crumb.canGoBack ? View.VISIBLE : View.INVISIBLE);
- }
+ updateVisible();
crumb.crumbView.setOnClickListener(this);
}
@@ -191,12 +199,54 @@
mBackButton.setVisibility(View.INVISIBLE);
}
}
+ updateVisible();
if (notify) {
notifyController();
}
}
}
+ private void updateVisible() {
+ // start at index 1 (0 == back button)
+ int childIndex = 1;
+ if (mMaxVisible >= 0) {
+ int invisibleCrumbs = size() - mMaxVisible;
+ if (invisibleCrumbs > 0) {
+ 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);
+ }
+ childIndex++;
+ // Move to the next crumb.
+ crumbIndex++;
+ }
+ }
+ // Make sure the last two are visible.
+ int childCount = getChildCount();
+ while (childIndex < childCount) {
+ getChildAt(childIndex).setVisibility(View.VISIBLE);
+ childIndex++;
+ }
+ } else {
+ int count = getChildCount();
+ for (int i = childIndex; i < count ; i++) {
+ getChildAt(i).setVisibility(View.VISIBLE);
+ }
+ }
+ if (mUseBackButton) {
+ boolean canGoBack = getTopCrumb() != null ? getTopCrumb().canGoBack : false;
+ mBackButton.setVisibility(canGoBack ? View.VISIBLE : View.INVISIBLE);
+ } else {
+ mBackButton.setVisibility(View.GONE);
+ }
+ }
+
private void removeLastView() {
int ix = getChildCount();
if (ix > 0) {