summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/browser/AddBookmarkPage.java57
1 files changed, 41 insertions, 16 deletions
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index c230858..d0679e1 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -119,8 +119,9 @@ public class AddBookmarkPage extends Activity
@Override
public void onTop(int level, Object data) {
if (null == data) return;
- mCurrentFolder = (Long) data;
- Uri uri = BrowserContract.Bookmarks.buildFolderUri(mCurrentFolder);
+ Folder folderData = (Folder) data;
+ long folder = folderData.Id;
+ Uri uri = BrowserContract.Bookmarks.buildFolderUri(folder);
LoaderManager manager = getLoaderManager();
CursorLoader loader = (CursorLoader) ((Loader) manager.getLoader(
LOADER_ID_FOLDER_CONTENTS));
@@ -178,19 +179,31 @@ public class AddBookmarkPage extends Activity
return false;
}
+ private void switchToDefaultView(boolean changedFolder) {
+ mFolderSelector.setVisibility(View.GONE);
+ mDefaultView.setVisibility(View.VISIBLE);
+ mCrumbHolder.setVisibility(View.GONE);
+ mFakeTitle.setVisibility(View.VISIBLE);
+ if (changedFolder) {
+ Object data = mCrumbs.getTopData();
+ if (data != null) {
+ Folder folder = (Folder) data;
+ mCurrentFolder = folder.Id;
+ mFolder.setText(folder.Name);
+ }
+ }
+ }
+
@Override
public void onClick(View v) {
if (v == mButton) {
if (mFolderSelector.getVisibility() == View.VISIBLE) {
- // We are showing the folder selector.
+ // We are showing the folder selector.
if (mFolderNamer.getVisibility() == View.VISIBLE) {
completeFolderNaming();
} else {
// User has selected a folder. Go back to the opening page
- mFolderSelector.setVisibility(View.GONE);
- mDefaultView.setVisibility(View.VISIBLE);
- mCrumbHolder.setVisibility(View.GONE);
- mFakeTitle.setVisibility(View.VISIBLE);
+ switchToDefaultView(true);
}
} else if (save()) {
finish();
@@ -200,6 +213,8 @@ public class AddBookmarkPage extends Activity
mFolderNamer.setVisibility(View.GONE);
mAddNewFolder.setVisibility(View.VISIBLE);
mAddSeparator.setVisibility(View.VISIBLE);
+ } else if (mFolderSelector.getVisibility() == View.VISIBLE) {
+ switchToDefaultView(false);
} else {
finish();
}
@@ -235,8 +250,14 @@ public class AddBookmarkPage extends Activity
values.put(BrowserContract.Bookmarks.TITLE,
name);
values.put(BrowserContract.Bookmarks.IS_FOLDER, 1);
- values.put(BrowserContract.Bookmarks.PARENT,
- mCurrentFolder);
+ long currentFolder;
+ Object data = mCrumbs.getTopData();
+ if (data != null) {
+ currentFolder = ((Folder) data).Id;
+ } else {
+ currentFolder = getBookmarksBarId(this);
+ }
+ values.put(BrowserContract.Bookmarks.PARENT, currentFolder);
Uri uri = getContentResolver().insert(
BrowserContract.Bookmarks.CONTENT_URI, values);
if (uri != null) {
@@ -257,8 +278,7 @@ public class AddBookmarkPage extends Activity
private void descendInto(String foldername, long id) {
if (id != DEFAULT_FOLDER_ID) {
- mCurrentFolder = id;
- mCrumbs.pushView(foldername, id);
+ mCrumbs.pushView(foldername, new Folder(foldername, id));
mCrumbs.notifyController();
}
}
@@ -329,12 +349,15 @@ public class AddBookmarkPage extends Activity
+ ") holding this bookmark does not exist!");
}
String name = cursor.getString(titleIndex);
+ if (parent == mCurrentFolder) {
+ mFolder.setText(name);
+ }
folderStack.push(new Folder(name, parent));
parent = cursor.getLong(parentIndex);
}
while (!folderStack.isEmpty()) {
Folder thisFolder = (Folder) folderStack.pop();
- mCrumbs.pushView(thisFolder.Name, thisFolder.Id);
+ mCrumbs.pushView(thisFolder.Name, thisFolder);
}
getLoaderManager().stopLoader(LOADER_ID_ALL_FOLDERS);
updateVisible();
@@ -398,6 +421,8 @@ public class AddBookmarkPage extends Activity
String title = null;
String url = null;
+ mFakeTitle = (TextView) findViewById(R.id.fake_title);
+
if (mMap != null) {
Bundle b = mMap.getBundle("bookmark");
if (b != null) {
@@ -453,12 +478,11 @@ public class AddBookmarkPage extends Activity
mCrumbs = (BreadCrumbView) findViewById(R.id.crumbs);
mCrumbs.setUseBackButton(true);
mCrumbs.setController(this);
- mCrumbs.pushView(getString(R.string.bookmarks), false,
- BrowserProvider2.FIXED_ID_ROOT);
+ String name = getString(R.string.bookmarks);
+ mCrumbs.pushView(name, false,
+ new Folder(name, BrowserProvider2.FIXED_ID_ROOT));
mCrumbHolder = findViewById(R.id.crumb_holder);
- mFakeTitle = (TextView) findViewById(R.id.fake_title);
-
mAdapter = new FolderAdapter(this);
ListView list = (ListView) findViewById(R.id.list);
list.setAdapter(mAdapter);
@@ -468,6 +492,7 @@ public class AddBookmarkPage extends Activity
// Find all the folders
manager.initLoader(LOADER_ID_ALL_FOLDERS, null, this);
}
+ // Find the contents of the current folder
manager.initLoader(LOADER_ID_FOLDER_CONTENTS, null, this);