зеркало из https://github.com/mozilla/pjs.git
Bug 722752 - Show/hide sync banner when sync accounts are added/removed (r=mfinkle)
This commit is contained in:
Родитель
3d67588f95
Коммит
56b4577fc0
|
@ -59,6 +59,7 @@ import org.mozilla.gecko.sync.setup.activities.SetupSyncActivity;
|
|||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.OnAccountsUpdateListener;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
|
@ -110,6 +111,8 @@ public class AboutHomeContent extends ScrollView {
|
|||
UriLoadCallback mUriLoadCallback = null;
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
private AccountManager mAccountManager;
|
||||
|
||||
protected SimpleCursorAdapter mTopSitesAdapter;
|
||||
protected GridView mTopSitesGrid;
|
||||
|
||||
|
@ -125,6 +128,26 @@ public class AboutHomeContent extends ScrollView {
|
|||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mInflater.inflate(R.layout.abouthome_content, this);
|
||||
|
||||
mAccountManager = AccountManager.get(context);
|
||||
|
||||
// The listener will run on the background thread (see 2nd argument)
|
||||
mAccountManager.addOnAccountsUpdatedListener(new OnAccountsUpdateListener() {
|
||||
public void onAccountsUpdated(Account[] accounts) {
|
||||
final GeckoApp.StartupMode startupMode = GeckoApp.mAppContext.getStartupMode();
|
||||
final boolean syncIsSetup = isSyncSetup();
|
||||
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
// The listener might run before the UI is initially updated.
|
||||
// In this case, we should simply wait for the initial setup
|
||||
// to happen.
|
||||
if (mTopSitesAdapter != null)
|
||||
updateLayout(startupMode, syncIsSetup);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, GeckoAppShell.getHandler(), true);
|
||||
|
||||
setScrollContainer(true);
|
||||
setBackgroundResource(R.drawable.abouthome_bg_repeat);
|
||||
|
||||
|
@ -226,8 +249,7 @@ public class AboutHomeContent extends ScrollView {
|
|||
}
|
||||
|
||||
private boolean isSyncSetup() {
|
||||
AccountManager accountManager = AccountManager.get(getContext());
|
||||
Account[] accounts = accountManager.getAccountsByType("org.mozilla.firefox_sync");
|
||||
Account[] accounts = mAccountManager.getAccountsByType("org.mozilla.firefox_sync");
|
||||
return accounts.length > 0;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче