summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2010-10-18 16:57:46 -0400
committerLeon Scroggins <scroggo@google.com>2010-10-18 17:05:25 -0400
commit52f7daafdd225359cca972e766f0ebaba6ae9bee (patch)
tree2ca681fa6b4f49d8f1d3a9607164ae5ae749b108 /src
parent3f429a7b5a96c1ac6d40325e3a231aa52b04e9c7 (diff)
downloadpackages_apps_Browser-52f7daafdd225359cca972e766f0ebaba6ae9bee.zip
packages_apps_Browser-52f7daafdd225359cca972e766f0ebaba6ae9bee.tar.gz
packages_apps_Browser-52f7daafdd225359cca972e766f0ebaba6ae9bee.tar.bz2
Update the "Add to" field of the add bookmarks page.
Bug:2953515 Only change mCurrentFolder when(if) the user presses OK on a folder. Allow a cancel press to go back to the default view without changing mCurrentFolder. In completeFolderNaming, use the id found in the top bread crumb to determine the containing folder. When changing mCurrentFolder, update the "Add to" field. Also fix a null pointer exception when editing a bookmark. Change-Id: I6f33b918a88d15e045007f213fa6f39d567ce10b
Diffstat (limited to 'src')
-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);