diff options
author | John Reck <jreck@google.com> | 2011-08-22 16:31:14 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-08-22 16:41:13 -0700 |
commit | 4f61ee45c1a2794d4254998c735a320fa6718edd (patch) | |
tree | 403bfc8e709a824db0ef5c5b1555ba7052648bd2 /src/com/android/browser/view | |
parent | 1a51fecec2292d1c3389b9635968b1acda5785dd (diff) | |
download | packages_apps_Browser-4f61ee45c1a2794d4254998c735a320fa6718edd.zip packages_apps_Browser-4f61ee45c1a2794d4254998c735a320fa6718edd.tar.gz packages_apps_Browser-4f61ee45c1a2794d4254998c735a320fa6718edd.tar.bz2 |
Save bookmark group state
Bug: 5135795
Change-Id: Id5069cc3f2afb16bcadac5b83d523200898a7d73
Diffstat (limited to 'src/com/android/browser/view')
-rw-r--r-- | src/com/android/browser/view/BookmarkExpandableView.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/com/android/browser/view/BookmarkExpandableView.java b/src/com/android/browser/view/BookmarkExpandableView.java index baa9172..edc497b 100644 --- a/src/com/android/browser/view/BookmarkExpandableView.java +++ b/src/com/android/browser/view/BookmarkExpandableView.java @@ -43,12 +43,17 @@ import com.android.browser.BrowserBookmarksPage.ExtraDragState; import com.android.browser.R; import com.android.internal.view.menu.MenuBuilder; +import org.json.JSONException; +import org.json.JSONObject; + import java.util.ArrayList; import java.util.HashMap; public class BookmarkExpandableView extends ExpandableListView implements BreadCrumbView.Controller { + public static final String LOCAL_ACCOUNT_NAME = "local"; + // Experimental drag & drop private static final boolean ENABLE_DRAG_DROP = false; @@ -123,7 +128,8 @@ public class BookmarkExpandableView extends ExpandableListView mAdapter.clear(); } - public void addAccount(String accountName, BrowserBookmarksAdapter adapter) { + public void addAccount(String accountName, BrowserBookmarksAdapter adapter, + boolean expandGroup) { // First, check if it already exists int indexOf = mAdapter.mGroups.indexOf(accountName); if (indexOf >= 0) { @@ -144,7 +150,9 @@ public class BookmarkExpandableView extends ExpandableListView adapter.registerDataSetObserver(mAdapter.mObserver); } mAdapter.notifyDataSetChanged(); - expandGroup(mAdapter.getGroupCount() - 1); + if (expandGroup) { + expandGroup(mAdapter.getGroupCount() - 1); + } } @Override @@ -308,6 +316,18 @@ public class BookmarkExpandableView extends ExpandableListView mAdapter.notifyDataSetChanged(); } + public JSONObject saveGroupState() throws JSONException { + JSONObject obj = new JSONObject(); + int count = mAdapter.getGroupCount(); + for (int i = 0; i < count; i++) { + String acctName = mAdapter.mGroups.get(i); + if (!isGroupExpanded(i)) { + obj.put(acctName != null ? acctName : LOCAL_ACCOUNT_NAME, false); + } + } + return obj; + } + class BookmarkAccountAdapter extends BaseExpandableListAdapter { ArrayList<BrowserBookmarksAdapter> mChildren; ArrayList<String> mGroups; |