diff options
author | John Reck <jreck@google.com> | 2011-10-18 08:44:16 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-18 08:44:16 -0700 |
commit | 4e61ad777a698ad7c67be6e4dcf7410b30b08e6f (patch) | |
tree | a3b51ce8962ad0ce0e4fb43e53c198414e7d2410 | |
parent | 5818811e40d0e5805fcf68ce3117b258b2b4591d (diff) | |
parent | 3bf3cfbf2938774d2f2ba3d2d6d5928ad95d52bb (diff) | |
download | packages_apps_browser-4e61ad777a698ad7c67be6e4dcf7410b30b08e6f.zip packages_apps_browser-4e61ad777a698ad7c67be6e4dcf7410b30b08e6f.tar.gz packages_apps_browser-4e61ad777a698ad7c67be6e4dcf7410b30b08e6f.tar.bz2 |
Merge "Cleanup widget config activity" into ics-mr0
-rw-r--r-- | src/com/android/browser/AddBookmarkPage.java | 2 | ||||
-rw-r--r-- | src/com/android/browser/widget/BookmarkWidgetConfigure.java | 33 |
2 files changed, 30 insertions, 5 deletions
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java index 71af567..ae5ae69 100644 --- a/src/com/android/browser/AddBookmarkPage.java +++ b/src/com/android/browser/AddBookmarkPage.java @@ -999,7 +999,7 @@ public class AddBookmarkPage extends Activity } } - public static class AccountsLoader extends CursorLoader { + static class AccountsLoader extends CursorLoader { static final String[] PROJECTION = new String[] { Accounts.ACCOUNT_NAME, diff --git a/src/com/android/browser/widget/BookmarkWidgetConfigure.java b/src/com/android/browser/widget/BookmarkWidgetConfigure.java index 4231f37..a74bed9 100644 --- a/src/com/android/browser/widget/BookmarkWidgetConfigure.java +++ b/src/com/android/browser/widget/BookmarkWidgetConfigure.java @@ -19,16 +19,18 @@ package com.android.browser.widget; import android.app.ListActivity; import android.app.LoaderManager.LoaderCallbacks; import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.content.CursorLoader; import android.content.Intent; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; +import android.provider.BrowserContract.Accounts; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; -import com.android.browser.AddBookmarkPage.AccountsLoader; import com.android.browser.AddBookmarkPage.BookmarkAccount; import com.android.browser.R; import com.android.browser.provider.BrowserProvider2; @@ -91,10 +93,12 @@ public class BookmarkWidgetConfigure extends ListActivity @Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { - if (cursor == null || cursor.getCount() <= 1) { - // We always have the local account, so if count == 1 it must - // be the local account + if (cursor == null || cursor.getCount() < 1) { + // We always have the local account, so fall back to that pickAccount(BrowserProvider2.FIXED_ID_ROOT); + } else if (cursor.getCount() == 1) { + cursor.moveToFirst(); + pickAccount(cursor.getLong(AccountsLoader.COLUMN_INDEX_ROOT_ID)); } else { mAccountAdapter.clear(); while (cursor.moveToNext()) { @@ -110,4 +114,25 @@ public class BookmarkWidgetConfigure extends ListActivity // Don't care } + static class AccountsLoader extends CursorLoader { + + static final String[] PROJECTION = new String[] { + Accounts.ACCOUNT_NAME, + Accounts.ACCOUNT_TYPE, + Accounts.ROOT_ID, + }; + + static final int COLUMN_INDEX_ACCOUNT_NAME = 0; + static final int COLUMN_INDEX_ACCOUNT_TYPE = 1; + static final int COLUMN_INDEX_ROOT_ID = 2; + + public AccountsLoader(Context context) { + super(context, Accounts.CONTENT_URI + .buildUpon() + .appendQueryParameter(BrowserProvider2.PARAM_ALLOW_EMPTY_ACCOUNTS, "false") + .build(), PROJECTION, null, null, null); + } + + } + } |