More edits to the add bookmark page.
Bug:2953515
BreadCrumbView:
Make sure the height is at least as tall as the separator,
so the height will not change when a separator is added or
removed.
Override getBaseline() to return the baseline of the
crumbs.
AddBookmarkPage:
Move the Add new folder button to the top.
Update the divider between the title and the rest of the
dialog.
Change-Id: I60d329626bd4ec2975cbf6ef00081338beeb7553
diff --git a/src/com/android/browser/BreadCrumbView.java b/src/com/android/browser/BreadCrumbView.java
index e501703..4939b48 100644
--- a/src/com/android/browser/BreadCrumbView.java
+++ b/src/com/android/browser/BreadCrumbView.java
@@ -17,6 +17,7 @@
package com.android.browser;
import android.content.Context;
+import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -45,6 +46,7 @@
private Controller mController;
private List<Crumb> mCrumbs;
private boolean mUseBackButton;
+ private Drawable mSeparatorDrawable;
/**
* @param context
@@ -76,6 +78,8 @@
private void init(Context ctx) {
mUseBackButton = false;
mCrumbs = new ArrayList<Crumb>();
+ mSeparatorDrawable = ctx.getResources().getDrawable(
+ R.drawable.crumb_divider);
}
public void setUseBackButton(boolean useflag) {
@@ -164,7 +168,7 @@
private void addSeparator() {
ImageView sep = new ImageView(mContext);
- sep.setImageResource(R.drawable.crumb_divider);
+ sep.setImageDrawable(mSeparatorDrawable);
sep.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT));
addView(sep);
@@ -221,6 +225,39 @@
notifyController();
}
}
+ @Override
+ public int getBaseline() {
+ int ix = getChildCount();
+ if (ix > 0) {
+ // If there is at least one crumb, the baseline will be its
+ // baseline.
+ return getChildAt(ix-1).getBaseline();
+ }
+ return super.getBaseline();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int height = mSeparatorDrawable.getIntrinsicHeight();
+ if (mMeasuredHeight < height) {
+ // This should only be an issue if there are currently no separators
+ // showing; i.e. if there is one crumb and no back button.
+ int mode = View.MeasureSpec.getMode(heightMeasureSpec);
+ switch(mode) {
+ case View.MeasureSpec.AT_MOST:
+ if (View.MeasureSpec.getSize(heightMeasureSpec) < height) {
+ return;
+ }
+ break;
+ case View.MeasureSpec.EXACTLY:
+ return;
+ default:
+ break;
+ }
+ setMeasuredDimension(mMeasuredWidth, height);
+ }
+ }
class Crumb {