Cache account prefs so we don't lose a11y focus
Fixes: 28767151 Change-Id: I876712c42b02bb2efaaa492ad951ad42935ecb32
This commit is contained in:
committed by
Daniel Sandler
parent
aa56eef3fd
commit
cd66b4a99f
@@ -154,6 +154,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
setPreferenceScreen(null);
|
setPreferenceScreen(null);
|
||||||
addPreferencesFromResource(R.xml.account_sync_settings);
|
addPreferencesFromResource(R.xml.account_sync_settings);
|
||||||
|
getPreferenceScreen().setOrderingAsAdded(false);
|
||||||
setAccessibilityTitle();
|
setAccessibilityTitle();
|
||||||
|
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
@@ -234,8 +235,13 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addSyncStateSwitch(Account account, String authority) {
|
private void addSyncStateSwitch(Account account, String authority) {
|
||||||
SyncStateSwitchPreference item =
|
SyncStateSwitchPreference item = (SyncStateSwitchPreference) getCachedPreference(authority);
|
||||||
new SyncStateSwitchPreference(getPrefContext(), account, authority);
|
if (item == null) {
|
||||||
|
item = new SyncStateSwitchPreference(getPrefContext(), account, authority);
|
||||||
|
getPreferenceScreen().addPreference(item);
|
||||||
|
} else {
|
||||||
|
item.setup(account, authority);
|
||||||
|
}
|
||||||
item.setPersistent(false);
|
item.setPersistent(false);
|
||||||
final ProviderInfo providerInfo = getPackageManager().resolveContentProviderAsUser(
|
final ProviderInfo providerInfo = getPackageManager().resolveContentProviderAsUser(
|
||||||
authority, 0, mUserHandle.getIdentifier());
|
authority, 0, mUserHandle.getIdentifier());
|
||||||
@@ -250,7 +256,6 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
String title = getString(R.string.sync_item_title, providerLabel);
|
String title = getString(R.string.sync_item_title, providerLabel);
|
||||||
item.setTitle(title);
|
item.setTitle(title);
|
||||||
item.setKey(authority);
|
item.setKey(authority);
|
||||||
mSwitches.add(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -529,14 +534,10 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = mSwitches.size(); i < n; i++) {
|
|
||||||
getPreferenceScreen().removePreference(mSwitches.get(i));
|
|
||||||
}
|
|
||||||
mSwitches.clear();
|
|
||||||
|
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||||
Log.d(TAG, "looking for sync adapters that match account " + mAccount);
|
Log.d(TAG, "looking for sync adapters that match account " + mAccount);
|
||||||
}
|
}
|
||||||
|
cacheRemoveAllPrefs(getPreferenceScreen());
|
||||||
for (int j = 0, m = authorities.size(); j < m; j++) {
|
for (int j = 0, m = authorities.size(); j < m; j++) {
|
||||||
final String authority = authorities.get(j);
|
final String authority = authorities.get(j);
|
||||||
// We could check services here....
|
// We could check services here....
|
||||||
@@ -549,11 +550,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
addSyncStateSwitch(mAccount, authority);
|
addSyncStateSwitch(mAccount, authority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
removeCachedPrefs(getPreferenceScreen());
|
||||||
Collections.sort(mSwitches);
|
|
||||||
for (int i = 0, n = mSwitches.size(); i < n; i++) {
|
|
||||||
getPreferenceScreen().addPreference(mSwitches.get(i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -562,7 +559,6 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
|||||||
@Override
|
@Override
|
||||||
protected void onAuthDescriptionsUpdated() {
|
protected void onAuthDescriptionsUpdated() {
|
||||||
super.onAuthDescriptionsUpdated();
|
super.onAuthDescriptionsUpdated();
|
||||||
getPreferenceScreen().removeAll();
|
|
||||||
if (mAccount != null) {
|
if (mAccount != null) {
|
||||||
mProviderIcon.setImageDrawable(getDrawableForType(mAccount.type));
|
mProviderIcon.setImageDrawable(getDrawableForType(mAccount.type));
|
||||||
mProviderId.setText(getLabelForType(mAccount.type));
|
mProviderId.setText(getLabelForType(mAccount.type));
|
||||||
|
@@ -51,8 +51,13 @@ public class SyncStateSwitchPreference extends SwitchPreference {
|
|||||||
|
|
||||||
public SyncStateSwitchPreference(Context context, Account account, String authority) {
|
public SyncStateSwitchPreference(Context context, Account account, String authority) {
|
||||||
super(context, null, 0, R.style.SyncSwitchPreference);
|
super(context, null, 0, R.style.SyncSwitchPreference);
|
||||||
|
setup(account, authority);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setup(Account account, String authority) {
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
mAuthority = authority;
|
mAuthority = authority;
|
||||||
|
notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user