diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/AddBookmarkPage.java | 24 | ||||
-rw-r--r-- | src/com/android/browser/BreadCrumbView.java | 39 |
2 files changed, 54 insertions, 9 deletions
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java index 1f14629..c230858 100644 --- a/src/com/android/browser/AddBookmarkPage.java +++ b/src/com/android/browser/AddBookmarkPage.java @@ -91,10 +91,12 @@ public class AddBookmarkPage extends Activity private View mFolderSelector; private EditText mFolderNamer; private View mAddNewFolder; + private View mAddSeparator; private long mCurrentFolder = 0; private FolderAdapter mAdapter; private BreadCrumbView mCrumbs; - private View mFakeTitleBar; + private TextView mFakeTitle; + private View mCrumbHolder; private static class Folder { String Name; @@ -187,8 +189,8 @@ public class AddBookmarkPage extends Activity // User has selected a folder. Go back to the opening page mFolderSelector.setVisibility(View.GONE); mDefaultView.setVisibility(View.VISIBLE); - mCrumbs.setVisibility(View.GONE); - mFakeTitleBar.setVisibility(View.VISIBLE); + mCrumbHolder.setVisibility(View.GONE); + mFakeTitle.setVisibility(View.VISIBLE); } } else if (save()) { finish(); @@ -197,6 +199,7 @@ public class AddBookmarkPage extends Activity if (mFolderNamer.getVisibility() == View.VISIBLE) { mFolderNamer.setVisibility(View.GONE); mAddNewFolder.setVisibility(View.VISIBLE); + mAddSeparator.setVisibility(View.VISIBLE); } else { finish(); } @@ -207,6 +210,7 @@ public class AddBookmarkPage extends Activity mFolderNamer.setText(R.string.new_folder); mFolderNamer.requestFocus(); mAddNewFolder.setVisibility(View.GONE); + mAddSeparator.setVisibility(View.GONE); getInputMethodManager().showSoftInput(mFolderNamer, InputMethodManager.SHOW_IMPLICIT); } @@ -219,6 +223,7 @@ public class AddBookmarkPage extends Activity descendInto(name, id); mFolderNamer.setVisibility(View.GONE); mAddNewFolder.setVisibility(View.VISIBLE); + mAddSeparator.setVisibility(View.VISIBLE); getInputMethodManager().hideSoftInputFromWindow( mFolderNamer.getWindowToken(), 0); } @@ -244,8 +249,10 @@ public class AddBookmarkPage extends Activity private void switchToFolderSelector() { mDefaultView.setVisibility(View.GONE); mFolderSelector.setVisibility(View.VISIBLE); - mCrumbs.setVisibility(View.VISIBLE); - mFakeTitleBar.setVisibility(View.GONE); + mCrumbHolder.setVisibility(View.VISIBLE); + mFakeTitle.setVisibility(View.GONE); + mAddNewFolder.setVisibility(View.VISIBLE); + mAddSeparator.setVisibility(View.VISIBLE); } private void descendInto(String foldername, long id) { @@ -396,8 +403,7 @@ public class AddBookmarkPage extends Activity if (b != null) { mMap = b; mEditingExisting = true; - TextView fakeTitle = (TextView) findViewById(R.id.fake_title); - fakeTitle.setText(R.string.edit_bookmark); + mFakeTitle.setText(R.string.edit_bookmark); if (!DEBUG_CRASH) { setTitle(R.string.bookmark_this_page); } @@ -442,14 +448,16 @@ public class AddBookmarkPage extends Activity mAddNewFolder = findViewById(R.id.add_new_folder); mAddNewFolder.setOnClickListener(this); + mAddSeparator = findViewById(R.id.add_divider); mCrumbs = (BreadCrumbView) findViewById(R.id.crumbs); mCrumbs.setUseBackButton(true); mCrumbs.setController(this); mCrumbs.pushView(getString(R.string.bookmarks), false, BrowserProvider2.FIXED_ID_ROOT); + mCrumbHolder = findViewById(R.id.crumb_holder); - mFakeTitleBar = findViewById(R.id.fake_title_bar); + mFakeTitle = (TextView) findViewById(R.id.fake_title); mAdapter = new FolderAdapter(this); ListView list = (ListView) findViewById(R.id.list); 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 @@ public class BreadCrumbView extends LinearLayout implements OnClickListener { private Controller mController; private List<Crumb> mCrumbs; private boolean mUseBackButton; + private Drawable mSeparatorDrawable; /** * @param context @@ -76,6 +78,8 @@ public class BreadCrumbView extends LinearLayout implements OnClickListener { 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 @@ public class BreadCrumbView extends LinearLayout implements OnClickListener { 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 @@ public class BreadCrumbView extends LinearLayout implements OnClickListener { 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 { |