More updates to the add bookmark page.
Bug:2953515
Bug:3183399
Use icons for menu and "Add to"
Use a TableLayout
Remove the duplicate title
Change-Id: I06e9b3010215ceae4d0212bccb61bc446e2c4e39
diff --git a/res/layout/browser_add_bookmark.xml b/res/layout/browser_add_bookmark.xml
index 7e518dd..58b7a6b 100644
--- a/res/layout/browser_add_bookmark.xml
+++ b/res/layout/browser_add_bookmark.xml
@@ -30,8 +30,6 @@
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/add_divider"
/>
- <!-- FIXME: The drawable does not line up properly. We may also want a
- different asset in the final version. -->
<TextView
android:id="@+id/add_new_folder"
android:layout_width="wrap_content"
@@ -39,6 +37,7 @@
android:layout_alignParentRight="true"
android:layout_alignBaseline="@+id/crumbs"
android:drawableLeft="@drawable/ic_add_string"
+ android:gravity="center_vertical"
android:text="@string/new_folder"
android:visibility="gone"
android:textAppearance="?android:attr/textAppearanceMedium" />
@@ -49,14 +48,13 @@
android:src="@drawable/crumb_divider"
/>
</RelativeLayout>
- <!-- FIXME: The drawable does not line up properly. We may also want a
- different asset in the final version. -->
<TextView android:id="@+id/fake_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_list_bookmark"
android:text="@string/bookmark_this_page"
android:layout_gravity="left"
+ android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium" />
<View android:id="@+id/titleDivider"
@@ -66,89 +64,80 @@
android:background="?android:attr/colorForeground"
/>
- <!-- XXX Use a TableLayout instead -->
- <RelativeLayout android:id="@+id/default_view"
+ <TableLayout android:id="@+id/default_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:paddingTop="5dip"
- android:paddingBottom="13dip"
+ android:stretchColumns="1"
+ android:paddingTop="20dip"
android:paddingLeft="20dip"
android:paddingRight="20dip" >
-
+ <TableRow>
<TextView
android:id="@+id/titleText"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_marginRight="50dip"
android:layout_marginBottom="40dip"
- android:layout_marginTop="40dip"
android:text="@string/name"
- android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/title"
android:layout_height="wrap_content"
- android:layout_width="325dip"
+ android:layout_width="wrap_content"
+ android:layout_marginRight="20dip"
+ android:layout_marginLeft="20dip"
android:gravity="fill_horizontal"
- android:layout_alignBaseline="@+id/titleText"
- android:layout_toRightOf="@+id/titleText"
android:inputType="textCapSentences"
- android:selectAllOnFocus="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" />
-
+ </TableRow>
-
+ <TableRow>
<TextView
android:id="@+id/addressText"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/location"
android:gravity="left"
- android:layout_below="@+id/titleText"
- android:layout_alignLeft="@+id/titleText"
android:layout_marginBottom="40dip"
- android:layout_marginRight="20dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/address"
android:layout_height="wrap_content"
- android:layout_width="325dip"
+ android:layout_width="wrap_content"
+ android:layout_marginRight="20dip"
+ android:layout_marginLeft="20dip"
android:hint="@string/http"
- android:layout_alignBaseline="@+id/addressText"
- android:layout_alignLeft="@+id/title"
android:gravity="fill_horizontal"
android:inputType="textUri"
- android:selectAllOnFocus="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" />
-
+ </TableRow>
+ <TableRow>
<TextView
android:id="@+id/add_to"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/containing_folder"
- android:layout_below="@+id/addressText"
- android:layout_alignLeft="@+id/titleText"
- android:layout_marginRight="20dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/folder"
android:layout_height="wrap_content"
android:layout_width="250dip"
- android:layout_alignLeft="@+id/title"
- android:layout_alignBaseline="@+id/add_to"
+ android:layout_marginRight="20dip"
+ android:layout_marginLeft="20dip"
+ android:gravity="center_vertical"
android:singleLine="true"
android:ellipsize="start"
android:text="@string/bookmarks"
+ android:drawableLeft="@drawable/ic_menu_bookmarks"
+ android:layout_marginBottom="40dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
-
- </RelativeLayout>
+ </TableRow>
+ </TableLayout>
<LinearLayout android:id="@+id/folder_selector"
android:layout_width="match_parent"
diff --git a/res/menu/folder_choice.xml b/res/menu/folder_choice.xml
index 068b170..c62e2f8 100644
--- a/res/menu/folder_choice.xml
+++ b/res/menu/folder_choice.xml
@@ -16,9 +16,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/home_screen"
+ android:icon="@*android:drawable/ic_menu_home"
android:title="@string/add_to_homescreen_menu_option"/>
<item android:id="@+id/bookmarks"
+ android:icon="@drawable/ic_menu_bookmarks"
android:title="@string/add_to_bookmarks_menu_option"/>
<item android:id="@+id/other"
+ android:icon="@*android:drawable/ic_menu_archive"
android:title="@string/add_to_other_folder_menu_option"/>
</menu>
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index 5670881..25c9217 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -31,6 +31,7 @@
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
import android.net.ParseException;
import android.net.Uri;
import android.net.WebAddress;
@@ -104,6 +105,7 @@
private View mCrumbHolder;
private ListView mListView;
private boolean mSaveToHomeScreen;
+ private long mRootFolder;
private static class Folder {
String Name;
@@ -200,7 +202,11 @@
if (data != null) {
Folder folder = (Folder) data;
mCurrentFolder = folder.Id;
- mFolder.setText(folder.Name);
+ int resource = mCurrentFolder == mRootFolder ?
+ R.drawable.ic_menu_bookmarks :
+ com.android.internal.R.drawable.ic_menu_archive;
+ Drawable drawable = getResources().getDrawable(resource);
+ updateFolderLabel(folder.Name, drawable);
}
}
}
@@ -250,14 +256,14 @@
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.bookmarks:
- mCurrentFolder = getBookmarksBarId(this);
- mFolder.setText(item.getTitle());
+ mCurrentFolder = mRootFolder;
+ updateFolderLabel(item.getTitle(), item.getIcon());
mSaveToHomeScreen = false;
break;
case R.id.home_screen:
// Create a short cut to the home screen
mSaveToHomeScreen = true;
- mFolder.setText(item.getTitle());
+ updateFolderLabel(item.getTitle(), item.getIcon());
break;
case R.id.other:
switchToFolderSelector();
@@ -309,7 +315,7 @@
if (data != null) {
currentFolder = ((Folder) data).Id;
} else {
- currentFolder = getBookmarksBarId(this);
+ currentFolder = mRootFolder;
}
values.put(BrowserContract.Bookmarks.PARENT, currentFolder);
Uri uri = getContentResolver().insert(
@@ -404,7 +410,9 @@
}
String name = cursor.getString(titleIndex);
if (parent == mCurrentFolder) {
- mFolder.setText(name);
+ Drawable draw = getResources().getDrawable(
+ com.android.internal.R.drawable.ic_menu_archive);
+ updateFolderLabel(name, draw);
}
folderStack.push(new Folder(name, parent));
parent = cursor.getLong(parentIndex);
@@ -421,6 +429,18 @@
}
}
+ /**
+ * Update the name and image to show where the bookmark will be added
+ * @param name Name of the location to save (folder name, bookmarks, or home
+ * screen.
+ * @param drawable Image to show corresponding to the save location.
+ */
+ void updateFolderLabel(CharSequence name, Drawable drawable) {
+ mFolder.setText(name);
+ mFolder.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null,
+ null);
+ }
+
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
@@ -464,8 +484,6 @@
super.onCreate(icicle);
if (DEBUG_CRASH) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
- } else {
- requestWindowFeature(Window.FEATURE_LEFT_ICON);
}
mMap = getIntent().getExtras();
@@ -474,8 +492,7 @@
Window window = getWindow();
if (!DEBUG_CRASH) {
- setTitle(R.string.bookmark_this_page);
- window.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.ic_list_bookmark);
+ setTitle("");
}
String title = null;
@@ -489,9 +506,6 @@
mMap = b;
mEditingExisting = true;
mFakeTitle.setText(R.string.edit_bookmark);
- if (!DEBUG_CRASH) {
- setTitle(R.string.bookmark_this_page);
- }
} else {
int gravity = mMap.getInt("gravity", -1);
if (gravity != -1) {
@@ -505,8 +519,9 @@
mTouchIconUrl = mMap.getString(TOUCH_ICON_URL);
mCurrentFolder = mMap.getLong(BrowserContract.Bookmarks.PARENT, DEFAULT_FOLDER_ID);
}
+ mRootFolder = getBookmarksBarId(this);
if (mCurrentFolder == DEFAULT_FOLDER_ID) {
- mCurrentFolder = getBookmarksBarId(this);
+ mCurrentFolder = mRootFolder;
}
mTitle = (EditText) findViewById(R.id.title);