diff options
author | Leon Scroggins <scroggo@google.com> | 2010-10-18 17:22:35 -0400 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2010-10-19 13:04:09 -0400 |
commit | 6573f9edd734c8dc42251840d6f693058ca4dfd8 (patch) | |
tree | cbf99df79f66589a8cf1ded24cbdf109b27f47da /src | |
parent | 52f7daafdd225359cca972e766f0ebaba6ae9bee (diff) | |
download | packages_apps_Browser-6573f9edd734c8dc42251840d6f693058ca4dfd8.zip packages_apps_Browser-6573f9edd734c8dc42251840d6f693058ca4dfd8.tar.gz packages_apps_Browser-6573f9edd734c8dc42251840d6f693058ca4dfd8.tar.bz2 |
Updates to add bookmark.
Bug:2953515
Create an empty view for the list showing sub folders.
Update the text in the new folder button.
When the user changes bread crumbs, cancel folder naming.
Change-Id: I8c3f33b5b3bb6e07cd0fd421199eb905f40e45f4
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/AddBookmarkPage.java | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java index d0679e1..9e5b349 100644 --- a/src/com/android/browser/AddBookmarkPage.java +++ b/src/com/android/browser/AddBookmarkPage.java @@ -97,6 +97,7 @@ public class AddBookmarkPage extends Activity private BreadCrumbView mCrumbs; private TextView mFakeTitle; private View mCrumbHolder; + private ListView mListView; private static class Folder { String Name; @@ -128,6 +129,9 @@ public class AddBookmarkPage extends Activity loader.setUri(uri); loader.forceLoad(); updateVisible(); + if (mFolderNamer.getVisibility() == View.VISIBLE) { + completeOrCancelFolderNaming(true); + } } /** @@ -169,7 +173,7 @@ public class AddBookmarkPage extends Activity if (actionId == EditorInfo.IME_NULL) { // Only want to do this once. if (event.getAction() == KeyEvent.ACTION_UP) { - completeFolderNaming(); + completeOrCancelFolderNaming(false); } } } @@ -200,7 +204,7 @@ public class AddBookmarkPage extends Activity if (mFolderSelector.getVisibility() == View.VISIBLE) { // We are showing the folder selector. if (mFolderNamer.getVisibility() == View.VISIBLE) { - completeFolderNaming(); + completeOrCancelFolderNaming(false); } else { // User has selected a folder. Go back to the opening page switchToDefaultView(true); @@ -210,9 +214,7 @@ public class AddBookmarkPage extends Activity } } else if (v == mCancelButton) { if (mFolderNamer.getVisibility() == View.VISIBLE) { - mFolderNamer.setVisibility(View.GONE); - mAddNewFolder.setVisibility(View.VISIBLE); - mAddSeparator.setVisibility(View.VISIBLE); + completeOrCancelFolderNaming(true); } else if (mFolderSelector.getVisibility() == View.VISIBLE) { switchToDefaultView(false); } else { @@ -224,6 +226,7 @@ public class AddBookmarkPage extends Activity mFolderNamer.setVisibility(View.VISIBLE); mFolderNamer.setText(R.string.new_folder); mFolderNamer.requestFocus(); + updateList(); mAddNewFolder.setVisibility(View.GONE); mAddSeparator.setVisibility(View.GONE); getInputMethodManager().showSoftInput(mFolderNamer, @@ -231,17 +234,27 @@ public class AddBookmarkPage extends Activity } } - private void completeFolderNaming() { - if (!TextUtils.isEmpty(mFolderNamer.getText())) { + // Refresh the ListView to hide or show the empty view, as necessary. + // Should be called after mFolderNamer is shown or hidden. + private void updateList() { + if (mAdapter.getCount() == 0) { + // XXX: Is there a better way to refresh the ListView? + mListView.setAdapter(mAdapter); + } + } + + private void completeOrCancelFolderNaming(boolean cancel) { + if (!cancel && !TextUtils.isEmpty(mFolderNamer.getText())) { String name = mFolderNamer.getText().toString(); long id = addFolderToCurrent(mFolderNamer.getText().toString()); descendInto(name, id); - mFolderNamer.setVisibility(View.GONE); - mAddNewFolder.setVisibility(View.VISIBLE); - mAddSeparator.setVisibility(View.VISIBLE); - getInputMethodManager().hideSoftInputFromWindow( - mFolderNamer.getWindowToken(), 0); } + mFolderNamer.setVisibility(View.GONE); + mAddNewFolder.setVisibility(View.VISIBLE); + mAddSeparator.setVisibility(View.VISIBLE); + getInputMethodManager().hideSoftInputFromWindow( + mFolderNamer.getWindowToken(), 0); + updateList(); } private long addFolderToCurrent(String name) { @@ -398,6 +411,12 @@ public class AddBookmarkPage extends Activity getDrawable(android.R.drawable.list_selector_background)); return view; } + + @Override + public boolean isEmpty() { + // Do not show the empty view if the user is creating a new folder. + return super.isEmpty() && mFolderNamer.getVisibility() == View.GONE; + } } protected void onCreate(Bundle icicle) { @@ -484,9 +503,11 @@ public class AddBookmarkPage extends Activity mCrumbHolder = findViewById(R.id.crumb_holder); mAdapter = new FolderAdapter(this); - ListView list = (ListView) findViewById(R.id.list); - list.setAdapter(mAdapter); - list.setOnItemClickListener(this); + mListView = (ListView) findViewById(R.id.list); + View empty = findViewById(R.id.empty); + mListView.setEmptyView(empty); + mListView.setAdapter(mAdapter); + mListView.setOnItemClickListener(this); LoaderManager manager = getLoaderManager(); if (mCurrentFolder != BrowserProvider2.FIXED_ID_ROOT) { // Find all the folders |