Allow user to create a new bookmark in the new UI.
Not the final visual design, but allows dogfooders to create new
bookmarks.
diff --git a/src/com/android/browser/BookmarkGridPage.java b/src/com/android/browser/BookmarkGridPage.java
index a9db7ac..ed51464 100644
--- a/src/com/android/browser/BookmarkGridPage.java
+++ b/src/com/android/browser/BookmarkGridPage.java
@@ -40,6 +40,7 @@
public class BookmarkGridPage extends Activity {
private final static int SPACING = 10;
+ private static final int BOOKMARKS_SAVE = 1;
private BookmarkGrid mGridView;
private BookmarkGridAdapter mAdapter;
@@ -60,6 +61,20 @@
mGridView.requestFocus();
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode,
+ Intent data) {
+ switch(requestCode) {
+ case BOOKMARKS_SAVE:
+ if (resultCode == RESULT_OK) {
+ mAdapter.refreshData();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
private class BookmarkGrid extends GridView {
public BookmarkGrid(Context context) {
super(context);
@@ -91,6 +106,15 @@
new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView parent, View v,
int position, long id) {
+ if (0 == position) {
+ // Launch the add bookmark activity
+ Intent i = new Intent(BookmarkGridPage.this,
+ AddBookmarkPage.class);
+ i.putExtras(getIntent());
+ startActivityForResult(i, BOOKMARKS_SAVE);
+ return;
+ }
+ position--;
mCursor.moveToPosition(position);
String url = mCursor.getString(
Browser.HISTORY_PROJECTION_URL_INDEX);
@@ -179,6 +203,20 @@
ImageView thumb = (ImageView) v.findViewById(R.id.thumb);
TextView tv = (TextView) v.findViewById(R.id.label);
+ ViewGroup.LayoutParams lp = thumb.getLayoutParams();
+ if (lp.height != mThumbHeight) {
+ lp.height = mThumbHeight;
+ thumb.requestLayout();
+ }
+
+ if (0 == position) {
+ // This is to create a bookmark for the current page.
+ tv.setText(R.string.add_new_bookmark);
+ thumb.setImageResource(
+ R.drawable.ic_tab_browser_bookmark_selected);
+ return v;
+ }
+ position--;
mCursor.moveToPosition(position);
tv.setText(mCursor.getString(
Browser.HISTORY_PROJECTION_TITLE_INDEX));
@@ -199,11 +237,6 @@
thumb.setImageResource(R.drawable.app_web_browser_sm);
thumb.setScaleType(ImageView.ScaleType.CENTER);
}
- ViewGroup.LayoutParams lp = thumb.getLayoutParams();
- if (lp.height != mThumbHeight) {
- lp.height = mThumbHeight;
- thumb.requestLayout();
- }
return v;
}