Merge "Do not reuse preference for AccountPreferenceController" into main

This commit is contained in:
Jacky Wang
2023-11-13 04:25:08 +00:00
committed by Android (Google) Code Review

View File

@@ -100,7 +100,6 @@ public class AccountPreferenceController extends AbstractPreferenceController
private SparseArray<ProfileData> mProfiles = new SparseArray<ProfileData>(); private SparseArray<ProfileData> mProfiles = new SparseArray<ProfileData>();
private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver = private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver =
new ManagedProfileBroadcastReceiver(); new ManagedProfileBroadcastReceiver();
private Preference mProfileNotAvailablePreference;
private String[] mAuthorities; private String[] mAuthorities;
private int mAuthoritiesCount = 0; private int mAuthoritiesCount = 0;
private DashboardFragment mFragment; private DashboardFragment mFragment;
@@ -531,18 +530,19 @@ public class AccountPreferenceController extends AbstractPreferenceController
} else { } else {
profileData.preferenceGroup.removeAll(); profileData.preferenceGroup.removeAll();
// Put a label instead of the accounts list // Put a label instead of the accounts list
if (mProfileNotAvailablePreference == null) { final Preference profileNotAvailablePreference =
mProfileNotAvailablePreference = new Preference(mFragment.getPreferenceManager().getContext());
new Preference(mFragment.getPreferenceManager().getContext()); profileNotAvailablePreference.setEnabled(false);
} profileNotAvailablePreference.setIcon(R.drawable.empty_icon);
mProfileNotAvailablePreference.setEnabled(false); profileNotAvailablePreference.setTitle(null);
mProfileNotAvailablePreference.setIcon(R.drawable.empty_icon); profileNotAvailablePreference.setSummary(
mProfileNotAvailablePreference.setTitle(null); mDpm.getResources()
mProfileNotAvailablePreference.setSummary( .getString(
mDpm.getResources().getString( WORK_PROFILE_NOT_AVAILABLE,
WORK_PROFILE_NOT_AVAILABLE, () -> mContext.getString( () ->
R.string.managed_profile_not_available_label))); mContext.getString(
profileData.preferenceGroup.addPreference(mProfileNotAvailablePreference); R.string.managed_profile_not_available_label)));
profileData.preferenceGroup.addPreference(profileNotAvailablePreference);
} }
if (profileData.removeWorkProfilePreference != null) { if (profileData.removeWorkProfilePreference != null) {
profileData.preferenceGroup.addPreference(profileData.removeWorkProfilePreference); profileData.preferenceGroup.addPreference(profileData.removeWorkProfilePreference);