Account types at toplevel of Settings

Reorganized Account settings to show account types at the top-level
of Settings. Only account types that have accounts added are visible
here. There is an Add account button to add a new account.

Master sync toggle has moved to Data Usage screen in the overflow menu.
It shows additional detail of the function of the auto-sync toggle when
it is toggled by the user.

Account type screen (ManageAccountsSettings) shows list of accounts of
that type and any available authenticator settings. It additionally
verifies any Intents can be resolved before showing the corresponding
entry. This screen now shows last synced time for each account.

You can now sync all accounts of a type by selecting Sync now in the
Account type screen.

Account Sync screen that shows the list of syncable items has minor
tweaks:
 - "Last synced...", "Sync is OFF"
 - Doesn't show the authenticator settings here anymore.

Bug: 6579937

Change-Id: I8139a4c992b525a3e1efc24d2d223c3f5caddc76
This commit is contained in:
Amith Yamasani
2012-05-18 09:50:08 -07:00
parent 13b2f06d2e
commit d1ab82807a
15 changed files with 520 additions and 238 deletions

View File

@@ -20,7 +20,6 @@ import java.util.ArrayList;
import android.accounts.Account;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
import android.util.Log;
@@ -36,25 +35,20 @@ public class AccountPreference extends Preference {
public static final int SYNC_ENABLED = 0; // all know sync adapters are enabled and OK
public static final int SYNC_DISABLED = 1; // no sync adapters are enabled
public static final int SYNC_ERROR = 2; // one or more sync adapters have a problem
public static final int SYNC_IN_PROGRESS = 3; // currently syncing
private int mStatus;
private Account mAccount;
private ArrayList<String> mAuthorities;
private Drawable mProviderIcon;
private ImageView mSyncStatusIcon;
private ImageView mProviderIconView;
public AccountPreference(Context context, Account account, Drawable icon,
ArrayList<String> authorities) {
super(context);
mAccount = account;
mAuthorities = authorities;
mProviderIcon = icon;
setWidgetLayoutResource(R.layout.account_preference);
setTitle(mAccount.name);
setSummary("");
setPersistent(false);
setSyncStatus(SYNC_DISABLED);
setIcon(mProviderIcon);
}
public Account getAccount() {
@@ -69,23 +63,14 @@ public class AccountPreference extends Preference {
protected void onBindView(View view) {
super.onBindView(view);
setSummary(getSyncStatusMessage(mStatus));
mSyncStatusIcon = (ImageView) view.findViewById(R.id.syncStatusIcon);
mSyncStatusIcon.setImageResource(getSyncStatusIcon(mStatus));
mSyncStatusIcon.setContentDescription(getSyncContentDescription(mStatus));
}
public void setProviderIcon(Drawable icon) {
mProviderIcon = icon;
if (mProviderIconView != null) {
mProviderIconView.setImageDrawable(icon);
}
ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
iconView.setImageResource(getSyncStatusIcon(mStatus));
iconView.setContentDescription(getSyncContentDescription(mStatus));
}
public void setSyncStatus(int status) {
mStatus = status;
if (mSyncStatusIcon != null) {
mSyncStatusIcon.setImageResource(getSyncStatusIcon(status));
}
setIcon(getSyncStatusIcon(status));
setSummary(getSyncStatusMessage(status));
}
@@ -101,6 +86,9 @@ public class AccountPreference extends Preference {
case SYNC_ERROR:
res = R.string.sync_error;
break;
case SYNC_IN_PROGRESS:
res = R.string.sync_in_progress;
break;
default:
res = R.string.sync_error;
Log.e(TAG, "Unknown sync status: " + status);
@@ -120,6 +108,9 @@ public class AccountPreference extends Preference {
case SYNC_ERROR:
res = R.drawable.ic_sync_red_holo;
break;
case SYNC_IN_PROGRESS:
res = R.drawable.ic_sync_grey_holo;
break;
default:
res = R.drawable.ic_sync_red_holo;
Log.e(TAG, "Unknown sync status: " + status);
@@ -140,13 +131,4 @@ public class AccountPreference extends Preference {
return getContext().getString(R.string.accessibility_sync_error);
}
}
@Override
public int compareTo(Preference other) {
if (!(other instanceof AccountPreference)) {
// Put other preference types above us
return 1;
}
return mAccount.name.compareTo(((AccountPreference) other).mAccount.name);
}
}