From 418668c815aa65b4eb022c515cf4b581b3d42b7a Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Fri, 6 Jul 2012 18:35:29 -0700 Subject: [PATCH] Bug 735842 - replace hard-coded isSyncSetup() with SyncAccounts.syncAccountsExist in AboutHomeContent. r=rnewman --- mobile/android/base/AboutHomeContent.java | 16 ++++++---------- mobile/android/base/SyncPreference.java | 3 +-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index 987eef7859e..05d88f77ed9 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -23,6 +23,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.mozilla.gecko.db.BrowserDB; import org.mozilla.gecko.db.BrowserDB.URLColumns; +import org.mozilla.gecko.sync.setup.SyncAccounts; import org.mozilla.gecko.sync.setup.activities.SetupSyncActivity; import android.accounts.Account; @@ -108,7 +109,7 @@ public class AboutHomeContent extends ScrollView } public void init() { - Context context = getContext(); + final Context context = getContext(); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater.inflate(R.layout.abouthome_content, this); @@ -118,7 +119,7 @@ public class AboutHomeContent extends ScrollView mAccountManager.addOnAccountsUpdatedListener(mAccountListener = new OnAccountsUpdateListener() { public void onAccountsUpdated(Account[] accounts) { final GeckoApp.StartupMode startupMode = GeckoApp.mAppContext.getStartupMode(); - final boolean syncIsSetup = isSyncSetup(); + final boolean syncIsSetup = SyncAccounts.syncAccountsExist(context); GeckoApp.mAppContext.mMainHandler.post(new Runnable() { public void run() { @@ -263,11 +264,6 @@ public class AboutHomeContent extends ScrollView syncContainer.setBackgroundResource(background); } - private boolean isSyncSetup() { - Account[] accounts = mAccountManager.getAccountsByType("org.mozilla.firefox_sync"); - return accounts.length > 0; - } - private void updateLayout(GeckoApp.StartupMode startupMode, boolean syncIsSetup) { // The idea here is that we only show the sync invitation // on the very first run. Show sync banner below the top @@ -295,9 +291,9 @@ public class AboutHomeContent extends ScrollView // the top sites section layout in main thread. final GeckoApp.StartupMode startupMode = GeckoApp.mAppContext.getStartupMode(); - // The isSyncSetup method should not be called on + // The SyncAccounts.syncAccountsExist method should not be called on // UI thread as it touches disk to access a sqlite DB. - final boolean syncIsSetup = isSyncSetup(); + final boolean syncIsSetup = SyncAccounts.syncAccountsExist(activity); final ContentResolver resolver = GeckoApp.mAppContext.getContentResolver(); final Cursor oldCursor = mCursor; @@ -589,7 +585,7 @@ public class AboutHomeContent extends ScrollView } private void loadRemoteTabs(final Activity activity) { - if (!isSyncSetup()) { + if (!SyncAccounts.syncAccountsExist(activity)) { GeckoApp.mAppContext.mMainHandler.post(new Runnable() { public void run() { mRemoteTabs.hide(); diff --git a/mobile/android/base/SyncPreference.java b/mobile/android/base/SyncPreference.java index 38d98971f5c..cd7ac757f6e 100644 --- a/mobile/android/base/SyncPreference.java +++ b/mobile/android/base/SyncPreference.java @@ -31,8 +31,7 @@ class SyncPreference extends Preference { final String accountType = org.mozilla.gecko.sync.setup.Constants.ACCOUNTTYPE_SYNC; // Show Sync setup if no accounts exist; otherwise, show account settings. - Account[] accounts = AccountManager.get(mContext).getAccountsByType(accountType); - if (accounts.length > 0) { + if (SyncAccounts.syncAccountsExist(mContext)) { SyncAccounts.openSyncSettings(mContext); } else { Intent intent = new Intent(mContext, SetupSyncActivity.class);