summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable/ic_action_bookmark.xml3
-rw-r--r--res/layout/bookmark_group_view.xml13
-rw-r--r--res/layout/browser_add_bookmark_content.xml20
-rw-r--r--res/values-v17/styles.xml8
-rw-r--r--res/values/strings.xml7
-rw-r--r--src/com/android/browser/AddBookmarkFolder.java2
-rw-r--r--src/com/android/browser/AddBookmarkPage.java75
-rw-r--r--src/com/android/browser/BookmarkUtils.java9
-rw-r--r--src/com/android/browser/BreadCrumbView.java34
-rw-r--r--src/com/android/browser/BrowserBookmarksPage.java3
-rw-r--r--src/com/android/browser/Controller.java7
-rw-r--r--src/com/android/browser/view/BookmarkExpandableView.java20
12 files changed, 162 insertions, 39 deletions
diff --git a/res/drawable/ic_action_bookmark.xml b/res/drawable/ic_action_bookmark.xml
index bdce2c74..2d022541 100644
--- a/res/drawable/ic_action_bookmark.xml
+++ b/res/drawable/ic_action_bookmark.xml
@@ -36,6 +36,9 @@
<item android:state_enabled="true" android:state_checked="true"
android:drawable="@drawable/ic_action_bookmark_checked" />
+ <item android:state_enabled="true" android:state_activated="true"
+ android:drawable="@drawable/ic_action_bookmark_checked" />
+
<item android:state_enabled="true" android:state_selected="true"
android:drawable="@drawable/ic_action_bookmark_checked" />
diff --git a/res/layout/bookmark_group_view.xml b/res/layout/bookmark_group_view.xml
index 8eede042..5bf70fd3 100644
--- a/res/layout/bookmark_group_view.xml
+++ b/res/layout/bookmark_group_view.xml
@@ -21,18 +21,27 @@
android:orientation="horizontal"
android:background="?android:attr/listChoiceBackgroundIndicator">
+<!--
<TextView
android:id="@+id/group_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingStart="50dp"
android:textAppearance="@style/BookmarkText"
- android:textColor="@color/accent"
android:gravity="center_vertical" />
+-->
+
+ <TextView
+ android:id="@+id/crumb_overflow"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:textAppearance="@style/BookmarkPathText"
+ android:visibility="gone"
+ />
<FrameLayout
android:id="@+id/crumb_holder"
- android:paddingStart="16dp"
+ android:textAppearance="@style/BookmarkPathText"
android:layout_width="match_parent"
android:layout_height="match_parent" />
diff --git a/res/layout/browser_add_bookmark_content.xml b/res/layout/browser_add_bookmark_content.xml
index f97753dc..186bbc09 100644
--- a/res/layout/browser_add_bookmark_content.xml
+++ b/res/layout/browser_add_bookmark_content.xml
@@ -135,7 +135,8 @@
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
- <TableRow android:layout_marginBottom="10dip">
+ <TableRow android:layout_marginBottom="10dip"
+ android:id="@+id/row_account">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@@ -203,21 +204,22 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
+ android:gravity="end"
style="?android:attr/buttonBarStyle">
+ <Button android:id="@+id/delete"
+ android:visibility="gone"
+ android:text="@string/remove_bookmark"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="?android:attr/buttonBarButtonStyle" />
<Button android:id="@+id/cancel"
android:text="@string/do_not_save"
- android:layout_width="0dip"
- android:layout_gravity="end"
- android:layout_weight="1"
- android:maxLines="2"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle" />
<Button android:id="@+id/OK"
android:text="@string/save"
- android:layout_width="0dip"
- android:layout_gravity="start"
- android:layout_weight="1"
- android:maxLines="2"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>
diff --git a/res/values-v17/styles.xml b/res/values-v17/styles.xml
index f251c030..63ff2146 100644
--- a/res/values-v17/styles.xml
+++ b/res/values-v17/styles.xml
@@ -69,6 +69,14 @@
<item name="android:fontFamily">roboto</item>
</style>
+ <style name="BookmarkPathText">
+ <item name="android:textSize">18sp</item>
+ <item name="android:textColor">@color/bookmarkLabelColor</item>
+ <item name="android:textStyle">normal</item>
+ <item name="android:textAlignment">center</item>
+ <item name="android:fontFamily">roboto</item>
+ </style>
+
<style name="ShortcutTheme" parent="@style/BrowserBase">
</style>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d6d27132..a4cce68e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -153,7 +153,7 @@
<!-- Menu item to save the newly created bookmark to the home screen. [CHAR-LIMIT=30]-->
<string name="add_to_homescreen_menu_option">Home screen</string>
<!-- Menu item to open a picker to determine which folder to save a bookmark in. [CHAR-LIMIT=30]-->
- <string name="add_to_other_folder_menu_option">Other folder</string>
+ <string name="add_to_other_folder_menu_option">Select folder...</string>
<!-- Field label in Bookmark dialog box: title that the user wishes to use for the bookmark -->
<string name="name">Label</string>
<!-- Initial value in Location field in Bookmark dialog box -->
@@ -179,7 +179,7 @@
<!-- Context menu item for setting the bookmark/history item as the homepage -->
<string name="set_as_homepage">Set as homepage</string>
<!-- Toast informing the user that their action to save a bookmark has succeeded -->
- <string name="bookmark_saved">Saved to bookmarks.</string>
+ <string name="bookmark_saved">Bookmarked</string>
<!-- Toast informing the user that their action to save a bookmark did not succeed -->
<string name="bookmark_not_saved">Couldn\'t save bookmark.</string>
<!-- Toast confirming that the homepage has been set -->
@@ -212,6 +212,9 @@
<!-- Confirmation dialog message confirming that the user wishes to delete
the bookmark they selected for deletion -->
<string name="delete_bookmark_warning">Delete bookmark \"<xliff:g id="bookmark">%s</xliff:g>\"?</string>
+ <!-- Confirmation dialog message confirming that the user wishes to delete
+ the folder they selected for deletion -->
+ <string name="delete_folder_warning">Delete folder \"<xliff:g id="bookmark">%s</xliff:g>\"?</string>
<!-- Context menu item to open every bookmark in a folder in new tabs [CHAR LIMIT=50] -->
<string name="open_all_in_new_window">Open all in new tabs</string>
<!-- Menu item to open a dialog which allows the user to enter a url or do search-->
diff --git a/src/com/android/browser/AddBookmarkFolder.java b/src/com/android/browser/AddBookmarkFolder.java
index b468da26..faff0274 100644
--- a/src/com/android/browser/AddBookmarkFolder.java
+++ b/src/com/android/browser/AddBookmarkFolder.java
@@ -638,7 +638,7 @@ public class AddBookmarkFolder extends Activity implements View.OnClickListener,
mAddSeparator.setVisibility(View.GONE);
mCrumbs = (BreadCrumbView) findViewById(R.id.crumbs);
- mCrumbs.setUseBackButton(true);
+ //mCrumbs.setUseBackButton(true);
mCrumbs.setController(this);
mHeaderIcon = getResources().getDrawable(R.drawable.ic_deco_folder_normal);
mCrumbHolder = findViewById(R.id.crumb_holder);
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index a50a7d64..ef462bc3 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -103,6 +103,7 @@ public class AddBookmarkPage extends Activity
private EditText mAddress;
private TextView mButton;
private View mCancelButton;
+ private View mDeleteButton;
private boolean mEditingExisting;
private boolean mEditingFolder;
private Bundle mMap;
@@ -314,6 +315,8 @@ public class AddBookmarkPage extends Activity
} else {
finish();
}
+ } else if (v == mDeleteButton || v == mRemoveLink) {
+ onDeleteWithConfirm();
} else if (v == mFolderCancel) {
completeOrCancelFolderNaming(true);
} else if (v == mAddNewFolder) {
@@ -330,16 +333,6 @@ public class AddBookmarkPage extends Activity
Class[] type = new Class[] {View.class};
ReflectHelper.invokeMethod(imm, "focusIn", type, params);
imm.showSoftInput(mFolderNamer, InputMethodManager.SHOW_IMPLICIT);
- } else if (v == mRemoveLink) {
- if (!mEditingExisting) {
- throw new AssertionError("Remove button should not be shown for"
- + " new bookmarks");
- }
- long id = mMap.getLong(BrowserContract.Bookmarks._ID);
- createHandler();
- Message msg = Message.obtain(mHandler, BOOKMARK_DELETED);
- BookmarkUtils.displayRemoveBookmarkDialog(id,
- mTitle.getText().toString(), this, msg);
}
}
@@ -546,6 +539,14 @@ public class AddBookmarkPage extends Activity
while (cursor.moveToNext()) {
mAccountAdapter.add(new BookmarkAccount(this, cursor));
}
+
+ if (cursor.getCount() < 2) {
+ View accountView = findViewById(R.id.row_account);
+ if (accountView != null) {
+ accountView.setVisibility(View.GONE);
+ }
+ }
+
getLoaderManager().destroyLoader(LOADER_ID_ACCOUNTS);
getLoaderManager().restartLoader(LOADER_ID_EDIT_INFO, null,
mEditInfoLoaderCallbacks);
@@ -660,6 +661,10 @@ public class AddBookmarkPage extends Activity
mTouchIconUrl = null;
mFakeTitle = (TextView) findViewById(R.id.fake_title);
+
+ mDeleteButton = findViewById(R.id.delete);
+ mDeleteButton.setOnClickListener(this);
+
if (mMap != null) {
Bundle b = mMap.getBundle(EXTRA_EDIT_BOOKMARK);
if (b != null) {
@@ -691,6 +696,7 @@ public class AddBookmarkPage extends Activity
title = title.substring(0, MAX_TITLE_LENGTH);
}
}
+
}
mTitle = (EditText) findViewById(R.id.title);
@@ -731,7 +737,7 @@ public class AddBookmarkPage extends Activity
mAddSeparator = findViewById(R.id.add_divider);
mCrumbs = (BreadCrumbView) findViewById(R.id.crumbs);
- mCrumbs.setUseBackButton(true);
+ //mCrumbs.setUseBackButton(true);
mCrumbs.setController(this);
mHeaderIcon = getResources().getDrawable(R.drawable.ic_deco_folder_normal);
mCrumbHolder = findViewById(R.id.crumb_holder);
@@ -769,6 +775,7 @@ public class AddBookmarkPage extends Activity
}
private void showRemoveButton() {
+ mDeleteButton.setVisibility(View.VISIBLE);
findViewById(R.id.remove_divider).setVisibility(View.VISIBLE);
mRemoveLink = findViewById(R.id.remove);
mRemoveLink.setVisibility(View.VISIBLE);
@@ -909,6 +916,52 @@ public class AddBookmarkPage extends Activity
context.getContentResolver().delete(uri, null, null);
}
+ private void onDeleteWithConfirm() {
+ final String title = mTitle.getText().toString().trim();
+ final String unfilteredUrl = UrlUtils.fixUrl(mAddress.getText().toString());
+ final String url = unfilteredUrl.trim();
+ new AlertDialog.Builder(this)
+ .setIconAttribute(android.R.attr.alertDialogIcon)
+ .setMessage(getString(R.string.delete_bookmark_warning, title))
+ .setNegativeButton(android.R.string.cancel, null)
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ ContentResolver cr = getContentResolver();
+ Cursor cursor = cr.query(BrowserContract.Bookmarks.CONTENT_URI,
+ BookmarksLoader.PROJECTION,
+ "title = ? OR url = ?",
+ new String[] {
+ title, url
+ },
+ null);
+
+ if (cursor == null) {
+ finish();
+ return;
+ }
+
+ try {
+ if (cursor.moveToFirst()) {
+ do {
+ long index = cursor.getLong(
+ cursor.getColumnIndex(BrowserContract.Bookmarks._ID));
+ cr.delete(ContentUris.withAppendedId(
+ BrowserContract.Bookmarks.CONTENT_URI, index),
+ null, null);
+ } while (cursor.moveToNext());
+ }
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ } finally {
+ if (cursor != null)
+ cursor.close();
+ }
+ finish();
+ }
+ })
+ .show();
+ }
+
private void onSaveWithConfirm() {
String title = mTitle.getText().toString().trim();
String unfilteredUrl = UrlUtils.fixUrl(mAddress.getText().toString());
diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java
index 0bce3c25..335a352d 100644
--- a/src/com/android/browser/BookmarkUtils.java
+++ b/src/com/android/browser/BookmarkUtils.java
@@ -235,12 +235,13 @@ public class BookmarkUtils {
* @param msg Message to send if the bookmark is deleted.
*/
static void displayRemoveBookmarkDialog( final long id, final String title,
- final Context context, final Message msg) {
+ final Context context, final Message msg, boolean is_folder) {
new AlertDialog.Builder(context)
.setIconAttribute(android.R.attr.alertDialogIcon)
- .setMessage(context.getString(R.string.delete_bookmark_warning,
- title))
+ .setMessage(is_folder ?
+ context.getString(R.string.delete_folder_warning, title) :
+ context.getString(R.string.delete_bookmark_warning, title))
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener() {
@Override
@@ -248,7 +249,7 @@ public class BookmarkUtils {
if (msg != null) {
msg.sendToTarget();
}
- Runnable runnable = new Runnable(){
+ Runnable runnable = new Runnable() {
@Override
public void run() {
removeBookmarkOrFolder(context, id);
diff --git a/src/com/android/browser/BreadCrumbView.java b/src/com/android/browser/BreadCrumbView.java
index 0cd82263..1501d211 100644
--- a/src/com/android/browser/BreadCrumbView.java
+++ b/src/com/android/browser/BreadCrumbView.java
@@ -60,6 +60,7 @@ public class BreadCrumbView extends RelativeLayout implements OnClickListener {
private int mMaxVisible = -1;
private Context mContext;
private int mCrumbPadding;
+ private TextView mOverflowView;
/**
* @param context
@@ -164,6 +165,16 @@ public class BreadCrumbView extends RelativeLayout implements OnClickListener {
return crumb.crumbView;
}
+ public void addOverflowLabel(TextView view) {
+ mOverflowView = view;
+ if (view != null) {
+ view.setTextAppearance(mContext, R.style.BookmarkPathText);
+ view.setPadding(mCrumbPadding, 0, mCrumbPadding, 0);
+ view.setGravity(Gravity.CENTER_VERTICAL);
+ view.setText("... >");
+ }
+ }
+
public void pushView(View view, Object data) {
Crumb crumb = new Crumb(view, true, data);
pushCrumb(crumb);
@@ -211,7 +222,7 @@ public class BreadCrumbView extends RelativeLayout implements OnClickListener {
params.setMargins(0, 0, 4 * mCrumbPadding, 0);
mCrumbLayout.setLayoutParams(params);
mCrumbLayout.setVisibility(View.VISIBLE);
- addParentLabel();
+ //addParentLabel();
addView(mCrumbLayout);
}
@@ -275,11 +286,15 @@ public class BreadCrumbView extends RelativeLayout implements OnClickListener {
private void updateVisible() {
// start at index 1 (0 == parent label)
- int childIndex = 1;
+ int childIndex = 0;
if (mMaxVisible >= 0) {
int invisibleCrumbs = size() - mMaxVisible;
if (invisibleCrumbs > 0) {
int crumbIndex = 0;
+ if (mOverflowView != null) {
+ mOverflowView.setVisibility(VISIBLE);
+ mOverflowView.setOnClickListener(this);
+ }
while (crumbIndex < invisibleCrumbs) {
// Set the crumb to GONE.
mCrumbLayout.getChildAt(childIndex).setVisibility(View.GONE);
@@ -287,6 +302,10 @@ public class BreadCrumbView extends RelativeLayout implements OnClickListener {
// Move to the next crumb.
crumbIndex++;
}
+ } else {
+ if (mOverflowView != null) {
+ mOverflowView.setVisibility(GONE);
+ }
}
// Make sure the last is visible.
int childCount = mCrumbLayout.getChildCount();
@@ -333,6 +352,13 @@ public class BreadCrumbView extends RelativeLayout implements OnClickListener {
if (mBackButton == v) {
popView();
notifyController();
+ } else if (mOverflowView == v) {
+ int maxVisible = getMaxVisible();
+ while (maxVisible > 0) {
+ pop(false);
+ maxVisible--;
+ }
+ notifyController();
} else {
// pop until view matches crumb view
while (v != getTopCrumb().crumbView) {
@@ -397,10 +423,10 @@ public class BreadCrumbView extends RelativeLayout implements OnClickListener {
private TextView makeCrumbView(String name) {
TextView tv = new TextView(mContext);
- tv.setTextAppearance(mContext, R.style.BookmarkText);
+ tv.setTextAppearance(mContext, R.style.BookmarkPathText);
tv.setPadding(mCrumbPadding, 0, mCrumbPadding, 0);
tv.setGravity(Gravity.CENTER_VERTICAL);
- tv.setText(name);
+ tv.setText(name + " >");
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT));
tv.setSingleLine();
diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java
index 59d4a68a..935bdc60 100644
--- a/src/com/android/browser/BrowserBookmarksPage.java
+++ b/src/com/android/browser/BrowserBookmarksPage.java
@@ -723,7 +723,8 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
long id = cursor.getLong(BookmarksLoader.COLUMN_INDEX_ID);
String title = cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE);
Context context = getActivity();
- BookmarkUtils.displayRemoveBookmarkDialog(id, title, context, null);
+ BookmarkUtils.displayRemoveBookmarkDialog(id, title, context, null,
+ (cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) == 1));
}
private String getUrl(BrowserBookmarksAdapter adapter, int position) {
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 5c6a9b8d..63372370 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -261,6 +261,8 @@ public class Controller
private PowerConnectionReceiver mLowPowerReceiver;
private PowerConnectionReceiver mPowerChangeReceiver;
+ private boolean mCurrentPageBookmarked;
+
public Controller(Activity browser) {
mActivity = browser;
mSettings = BrowserSettings.getInstance();
@@ -1947,7 +1949,8 @@ public class Controller
String title = w.getTitle();
String url = w.getUrl();
- if (title != null && url != null && lookupBookmark(title, url) > 0) {
+ mCurrentPageBookmarked = (lookupBookmark(title, url) > 0);
+ if (title != null && url != null && mCurrentPageBookmarked) {
bookmark_icon.setChecked(true);
} else {
bookmark_icon.setChecked(false);
@@ -2348,7 +2351,7 @@ public class Controller
WebView w = getCurrentTopWebView();
if (w == null)
return;
- final Intent i = createBookmarkCurrentPageIntent(false);
+ final Intent i = createBookmarkCurrentPageIntent(mCurrentPageBookmarked);
mActivity.startActivity(i);
}
}
diff --git a/src/com/android/browser/view/BookmarkExpandableView.java b/src/com/android/browser/view/BookmarkExpandableView.java
index 5e685656..3ed000c3 100644
--- a/src/com/android/browser/view/BookmarkExpandableView.java
+++ b/src/com/android/browser/view/BookmarkExpandableView.java
@@ -82,6 +82,9 @@ public class BookmarkExpandableView extends ExpandableListView
.getInteger(R.integer.max_bookmark_columns);
setScrollBarStyle(SCROLLBARS_OUTSIDE_OVERLAY);
mAdapter = new BookmarkAccountAdapter(mContext);
+ if (mAdapter.getGroupCount() < 2) {
+ setGroupIndicator(null);
+ }
super.setAdapter(mAdapter);
}
@@ -251,6 +254,10 @@ public class BookmarkExpandableView extends ExpandableListView
@Override
public void onClick(View v) {
+ if (mAdapter.getGroupCount() < 2) {
+ return;
+ }
+
int groupPosition = (Integer) v.getTag(R.id.group_position);
if (isGroupExpanded(groupPosition)) {
collapseGroup(groupPosition);
@@ -402,6 +409,7 @@ public class BookmarkExpandableView extends ExpandableListView
View view, ViewGroup parent) {
if (view == null) {
view = mInflater.inflate(R.layout.bookmark_group_view, parent, false);
+ view.setEnabled(false);
view.setOnClickListener(mGroupOnClickListener);
}
view.setTag(R.id.group_position, groupPosition);
@@ -411,13 +419,19 @@ public class BookmarkExpandableView extends ExpandableListView
if (crumbs.getParent() != null) {
((ViewGroup)crumbs.getParent()).removeView(crumbs);
}
+ crumbs.setVisibility(VISIBLE);
crumbHolder.addView(crumbs);
+
+ TextView overflowView = (TextView) view.findViewById(R.id.crumb_overflow);
+ crumbs.addOverflowLabel(overflowView);
+/*
TextView name = (TextView) view.findViewById(R.id.group_name);
String groupName = mGroups.get(groupPosition);
if (groupName == null) {
- groupName = mContext.getString(R.string.local_bookmarks);
+ groupName = mContext.getString(R.string.bookmarks);
}
name.setText(groupName);
+*/
return view;
}
@@ -427,8 +441,8 @@ public class BookmarkExpandableView extends ExpandableListView
crumbs = (BreadCrumbView)
mInflater.inflate(R.layout.bookmarks_header, null);
crumbs.setController(BookmarkExpandableView.this);
- crumbs.setUseBackButton(true);
- crumbs.setMaxVisible(1);
+ //crumbs.setUseBackButton(true);
+ crumbs.setMaxVisible(2);
String bookmarks = mContext.getString(R.string.bookmarks);
crumbs.pushView(bookmarks, false,
BrowserContract.Bookmarks.CONTENT_URI_DEFAULT_FOLDER);