Remove old accounts tile, replaced by a separate screen
Bug: 15815948 Bug: 15819268 Change-Id: I3b6978cff346c73cca1d6a2c209ffe4c71808244
This commit is contained in:
@@ -188,20 +188,6 @@
|
|||||||
|
|
||||||
</dashboard-category>
|
</dashboard-category>
|
||||||
|
|
||||||
<!-- ACCOUNTS section -->
|
|
||||||
<dashboard-category
|
|
||||||
android:id="@+id/account_settings"
|
|
||||||
android:title="@string/account_settings" >
|
|
||||||
|
|
||||||
<dashboard-tile
|
|
||||||
android:id="@+id/account_add"
|
|
||||||
android:title="@string/add_account_label"
|
|
||||||
android:icon="@drawable/ic_menu_add_dark">
|
|
||||||
<intent android:action="android.settings.ADD_ACCOUNT_SETTINGS"/>
|
|
||||||
</dashboard-tile>
|
|
||||||
|
|
||||||
</dashboard-category>
|
|
||||||
|
|
||||||
<!-- SYSTEM -->
|
<!-- SYSTEM -->
|
||||||
<dashboard-category
|
<dashboard-category
|
||||||
android:id="@+id/system_section"
|
android:id="@+id/system_section"
|
||||||
|
@@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.accounts.Account;
|
|
||||||
import android.accounts.AccountManager;
|
|
||||||
import android.accounts.OnAccountsUpdateListener;
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
@@ -70,8 +67,6 @@ import com.android.internal.util.XmlUtils;
|
|||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
import com.android.settings.accessibility.CaptionPropertiesFragment;
|
import com.android.settings.accessibility.CaptionPropertiesFragment;
|
||||||
import com.android.settings.accounts.AccountSyncSettings;
|
import com.android.settings.accounts.AccountSyncSettings;
|
||||||
import com.android.settings.accounts.AuthenticatorHelper;
|
|
||||||
import com.android.settings.accounts.ManageAccountsSettings;
|
|
||||||
import com.android.settings.applications.InstalledAppDetails;
|
import com.android.settings.applications.InstalledAppDetails;
|
||||||
import com.android.settings.applications.ManageApplications;
|
import com.android.settings.applications.ManageApplications;
|
||||||
import com.android.settings.applications.ProcessStatsUi;
|
import com.android.settings.applications.ProcessStatsUi;
|
||||||
@@ -117,8 +112,6 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -127,10 +120,9 @@ import static com.android.settings.dashboard.DashboardTile.TILE_ID_UNDEFINED;
|
|||||||
public class SettingsActivity extends Activity
|
public class SettingsActivity extends Activity
|
||||||
implements PreferenceManager.OnPreferenceTreeClickListener,
|
implements PreferenceManager.OnPreferenceTreeClickListener,
|
||||||
PreferenceFragment.OnPreferenceStartFragmentCallback,
|
PreferenceFragment.OnPreferenceStartFragmentCallback,
|
||||||
ButtonBarHandler, OnAccountsUpdateListener, FragmentManager.OnBackStackChangedListener,
|
ButtonBarHandler, FragmentManager.OnBackStackChangedListener,
|
||||||
SearchView.OnQueryTextListener, SearchView.OnCloseListener,
|
SearchView.OnQueryTextListener, SearchView.OnCloseListener,
|
||||||
MenuItem.OnActionExpandListener,
|
MenuItem.OnActionExpandListener {
|
||||||
AuthenticatorHelper.OnAccountsUpdateListener {
|
|
||||||
|
|
||||||
private static final String LOG_TAG = "Settings";
|
private static final String LOG_TAG = "Settings";
|
||||||
|
|
||||||
@@ -221,7 +213,6 @@ public class SettingsActivity extends Activity
|
|||||||
R.id.language_settings,
|
R.id.language_settings,
|
||||||
R.id.user_settings,
|
R.id.user_settings,
|
||||||
R.id.account_settings,
|
R.id.account_settings,
|
||||||
R.id.account_add,
|
|
||||||
R.id.system_section,
|
R.id.system_section,
|
||||||
R.id.date_time_settings,
|
R.id.date_time_settings,
|
||||||
R.id.about_settings,
|
R.id.about_settings,
|
||||||
@@ -275,7 +266,6 @@ public class SettingsActivity extends Activity
|
|||||||
UserSettings.class.getName(),
|
UserSettings.class.getName(),
|
||||||
NotificationAccessSettings.class.getName(),
|
NotificationAccessSettings.class.getName(),
|
||||||
ConditionProviderSettings.class.getName(),
|
ConditionProviderSettings.class.getName(),
|
||||||
ManageAccountsSettings.class.getName(),
|
|
||||||
PrintSettingsFragment.class.getName(),
|
PrintSettingsFragment.class.getName(),
|
||||||
PrintJobSettingsFragment.class.getName(),
|
PrintJobSettingsFragment.class.getName(),
|
||||||
TrustedCredentialsSettings.class.getName(),
|
TrustedCredentialsSettings.class.getName(),
|
||||||
@@ -297,9 +287,6 @@ public class SettingsActivity extends Activity
|
|||||||
private SharedPreferences mDevelopmentPreferences;
|
private SharedPreferences mDevelopmentPreferences;
|
||||||
private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener;
|
private SharedPreferences.OnSharedPreferenceChangeListener mDevelopmentPreferencesListener;
|
||||||
|
|
||||||
private AuthenticatorHelper mAuthenticatorHelper;
|
|
||||||
private boolean mListeningToAccountUpdates;
|
|
||||||
|
|
||||||
private boolean mBatteryPresent = true;
|
private boolean mBatteryPresent = true;
|
||||||
private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
|
||||||
|
|
||||||
@@ -363,10 +350,6 @@ public class SettingsActivity extends Activity
|
|||||||
return mSwitchBar;
|
return mSwitchBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticatorHelper getAuthenticatorHelper() {
|
|
||||||
return mAuthenticatorHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DashboardCategory> getDashboardCategories() {
|
public List<DashboardCategory> getDashboardCategories() {
|
||||||
if (mNeedToRebuildCategories || mCategories.size() == 0) {
|
if (mNeedToRebuildCategories || mCategories.size() == 0) {
|
||||||
buildDashboardCategories(mCategories);
|
buildDashboardCategories(mCategories);
|
||||||
@@ -482,13 +465,6 @@ public class SettingsActivity extends Activity
|
|||||||
if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
|
if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
|
||||||
getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
|
getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
|
||||||
}
|
}
|
||||||
// TODO: Delete accounts tile once we have the new screen working
|
|
||||||
// See: http://b/15815948
|
|
||||||
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
|
|
||||||
mAuthenticatorHelper = new AuthenticatorHelper(
|
|
||||||
this, UserHandle.getCallingUserHandle(), um, this);
|
|
||||||
mAuthenticatorHelper.updateAuthDescriptions(this);
|
|
||||||
mAuthenticatorHelper.onAccountsUpdated(null);
|
|
||||||
|
|
||||||
mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE,
|
mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE,
|
||||||
Context.MODE_PRIVATE);
|
Context.MODE_PRIVATE);
|
||||||
@@ -743,10 +719,6 @@ public class SettingsActivity extends Activity
|
|||||||
mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
|
mDevelopmentPreferences.unregisterOnSharedPreferenceChangeListener(
|
||||||
mDevelopmentPreferencesListener);
|
mDevelopmentPreferencesListener);
|
||||||
mDevelopmentPreferencesListener = null;
|
mDevelopmentPreferencesListener = null;
|
||||||
|
|
||||||
if (mListeningToAccountUpdates) {
|
|
||||||
AccountManager.get(this).removeOnAccountsUpdatedListener(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isValidFragment(String fragmentName) {
|
protected boolean isValidFragment(String fragmentName) {
|
||||||
@@ -1071,10 +1043,6 @@ public class SettingsActivity extends Activity
|
|||||||
|
|
||||||
// Ids are integers, so downcasting is ok
|
// Ids are integers, so downcasting is ok
|
||||||
int id = (int) category.id;
|
int id = (int) category.id;
|
||||||
if (id == R.id.account_settings) {
|
|
||||||
insertAccountsTiles(category);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int n = category.getTilesCount() - 1;
|
int n = category.getTilesCount() - 1;
|
||||||
while (n >= 0) {
|
while (n >= 0) {
|
||||||
|
|
||||||
@@ -1146,10 +1114,6 @@ public class SettingsActivity extends Activity
|
|||||||
UserManager.DISALLOW_DEBUGGING_FEATURES)) {
|
UserManager.DISALLOW_DEBUGGING_FEATURES)) {
|
||||||
category.removeTile(n);
|
category.removeTile(n);
|
||||||
}
|
}
|
||||||
} else if (id == R.id.account_add) {
|
|
||||||
if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
|
|
||||||
category.removeTile(n);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
|
if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
|
||||||
@@ -1201,62 +1165,6 @@ public class SettingsActivity extends Activity
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertAccountsTiles(DashboardCategory target) {
|
|
||||||
String[] accountTypes = mAuthenticatorHelper.getEnabledAccountTypes();
|
|
||||||
List<DashboardTile> dashboardTiles = new ArrayList<DashboardTile>(accountTypes.length);
|
|
||||||
for (String accountType : accountTypes) {
|
|
||||||
CharSequence label = mAuthenticatorHelper.getLabelForType(this, accountType);
|
|
||||||
if (label == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Account[] accounts = AccountManager.get(this).getAccountsByType(accountType);
|
|
||||||
boolean skipToAccount = accounts.length == 1
|
|
||||||
&& !mAuthenticatorHelper.hasAccountPreferences(accountType);
|
|
||||||
DashboardTile accountTile = new DashboardTile();
|
|
||||||
accountTile.title = label;
|
|
||||||
if (accountTile.extras == null) {
|
|
||||||
accountTile.extras = new Bundle();
|
|
||||||
}
|
|
||||||
if (skipToAccount) {
|
|
||||||
accountTile.fragment = AccountSyncSettings.class.getName();
|
|
||||||
accountTile.fragmentArguments = new Bundle();
|
|
||||||
// Need this for the icon
|
|
||||||
accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
|
|
||||||
accountTile.extras.putParcelable(AccountSyncSettings.ACCOUNT_KEY, accounts[0]);
|
|
||||||
accountTile.fragmentArguments.putParcelable(AccountSyncSettings.ACCOUNT_KEY,
|
|
||||||
accounts[0]);
|
|
||||||
} else {
|
|
||||||
accountTile.fragment = ManageAccountsSettings.class.getName();
|
|
||||||
accountTile.fragmentArguments = new Bundle();
|
|
||||||
accountTile.extras.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE, accountType);
|
|
||||||
accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_TYPE,
|
|
||||||
accountType);
|
|
||||||
accountTile.fragmentArguments.putString(ManageAccountsSettings.KEY_ACCOUNT_LABEL,
|
|
||||||
label.toString());
|
|
||||||
}
|
|
||||||
dashboardTiles.add(accountTile);
|
|
||||||
mAuthenticatorHelper.preloadDrawableForType(this, accountType);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort by label
|
|
||||||
Collections.sort(dashboardTiles, new Comparator<DashboardTile>() {
|
|
||||||
@Override
|
|
||||||
public int compare(DashboardTile t1, DashboardTile t2) {
|
|
||||||
return t1.title.toString().compareTo(t2.title.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
int index = 0;
|
|
||||||
for (DashboardTile tile : dashboardTiles) {
|
|
||||||
target.addTile(index, tile);
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
if (!mListeningToAccountUpdates) {
|
|
||||||
AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true);
|
|
||||||
mListeningToAccountUpdates = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getMetaData() {
|
private void getMetaData() {
|
||||||
try {
|
try {
|
||||||
ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(),
|
ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(),
|
||||||
@@ -1283,18 +1191,6 @@ public class SettingsActivity extends Activity
|
|||||||
return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class));
|
return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccountsUpdated(Account[] accounts) {
|
|
||||||
// TODO: watch for package upgrades to invalidate cache; see 7206643
|
|
||||||
mAuthenticatorHelper.updateAuthDescriptions(this);
|
|
||||||
invalidateCategories();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccountsUpdate(UserHandle userHandle) {
|
|
||||||
invalidateCategories();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void requestHomeNotice() {
|
public static void requestHomeNotice() {
|
||||||
sShowNoHomeNotice = true;
|
sShowNoHomeNotice = true;
|
||||||
}
|
}
|
||||||
|
@@ -171,9 +171,7 @@ final public class AuthenticatorHelper extends BroadcastReceiver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAccountsUpdated(Account[] accounts) {
|
void onAccountsUpdated(Account[] accounts) {
|
||||||
// TODO: Revert to non-public once no longer needed in SettingsActivity
|
|
||||||
// See http://b/15819268
|
|
||||||
updateAuthDescriptions(mContext);
|
updateAuthDescriptions(mContext);
|
||||||
if (accounts == null) {
|
if (accounts == null) {
|
||||||
accounts = AccountManager.get(mContext).getAccountsAsUser(mUserHandle.getIdentifier());
|
accounts = AccountManager.get(mContext).getAccountsAsUser(mUserHandle.getIdentifier());
|
||||||
@@ -193,6 +191,7 @@ final public class AuthenticatorHelper extends BroadcastReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(final Context context, final Intent intent) {
|
public void onReceive(final Context context, final Intent intent) {
|
||||||
|
// TODO: watch for package upgrades to invalidate cache; see http://b/7206643
|
||||||
final Account[] accounts = AccountManager.get(mContext)
|
final Account[] accounts = AccountManager.get(mContext)
|
||||||
.getAccountsAsUser(mUserHandle.getIdentifier());
|
.getAccountsAsUser(mUserHandle.getIdentifier());
|
||||||
onAccountsUpdated(accounts);
|
onAccountsUpdated(accounts);
|
||||||
|
@@ -16,13 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settings.dashboard;
|
package com.android.settings.dashboard;
|
||||||
|
|
||||||
import android.accounts.Account;
|
|
||||||
import android.accounts.AccountManager;
|
|
||||||
import android.accounts.OnAccountsUpdateListener;
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@@ -35,18 +31,14 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.accounts.AuthenticatorHelper;
|
|
||||||
import com.android.settings.accounts.ManageAccountsSettings;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DashboardSummary extends Fragment implements OnAccountsUpdateListener {
|
public class DashboardSummary extends Fragment {
|
||||||
private static final String LOG_TAG = "DashboardSummary";
|
private static final String LOG_TAG = "DashboardSummary";
|
||||||
|
|
||||||
private LayoutInflater mLayoutInflater;
|
private LayoutInflater mLayoutInflater;
|
||||||
private ViewGroup mDashboard;
|
private ViewGroup mDashboard;
|
||||||
private AuthenticatorHelper mAuthHelper;
|
|
||||||
private boolean mAccountListenerAdded;
|
|
||||||
|
|
||||||
private static final int MSG_REBUILD_UI = 1;
|
private static final int MSG_REBUILD_UI = 1;
|
||||||
private Handler mHandler = new Handler() {
|
private Handler mHandler = new Handler() {
|
||||||
@@ -72,8 +64,6 @@ public class DashboardSummary extends Fragment implements OnAccountsUpdateListen
|
|||||||
final View rootView = inflater.inflate(R.layout.dashboard, container, false);
|
final View rootView = inflater.inflate(R.layout.dashboard, container, false);
|
||||||
mDashboard = (ViewGroup) rootView.findViewById(R.id.dashboard_container);
|
mDashboard = (ViewGroup) rootView.findViewById(R.id.dashboard_container);
|
||||||
|
|
||||||
mAuthHelper = ((SettingsActivity) context).getAuthenticatorHelper();
|
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,45 +119,19 @@ public class DashboardSummary extends Fragment implements OnAccountsUpdateListen
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (!mAccountListenerAdded) {
|
|
||||||
AccountManager.get(getActivity()).addOnAccountsUpdatedListener(this, null, false);
|
|
||||||
mAccountListenerAdded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendRebuildUI();
|
sendRebuildUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
if (mAccountListenerAdded) {
|
|
||||||
AccountManager.get(getActivity()).removeOnAccountsUpdatedListener(this);
|
|
||||||
mAccountListenerAdded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTileView(Context context, Resources res, DashboardTile tile,
|
private void updateTileView(Context context, Resources res, DashboardTile tile,
|
||||||
ImageView tileIcon, TextView tileTextView, TextView statusTextView) {
|
ImageView tileIcon, TextView tileTextView, TextView statusTextView) {
|
||||||
|
|
||||||
if (tile.extras != null
|
if (tile.iconRes > 0) {
|
||||||
&& tile.extras.containsKey(ManageAccountsSettings.KEY_ACCOUNT_TYPE)) {
|
tileIcon.setImageResource(tile.iconRes);
|
||||||
String accType = tile.extras.getString(ManageAccountsSettings.KEY_ACCOUNT_TYPE);
|
|
||||||
Drawable drawable = mAuthHelper.getDrawableForType(context, accType);
|
|
||||||
tileIcon.setImageDrawable(drawable);
|
|
||||||
} else {
|
} else {
|
||||||
if (tile.iconRes > 0) {
|
tileIcon.setImageDrawable(null);
|
||||||
tileIcon.setImageResource(tile.iconRes);
|
tileIcon.setBackground(null);
|
||||||
} else {
|
|
||||||
tileIcon.setImageDrawable(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tileIcon != null) {
|
|
||||||
if (tile.iconRes > 0) {
|
|
||||||
} else {
|
|
||||||
tileIcon.setBackground(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tileTextView.setText(tile.getTitle(res));
|
tileTextView.setText(tile.getTitle(res));
|
||||||
|
|
||||||
CharSequence summary = tile.getSummary(res);
|
CharSequence summary = tile.getSummary(res);
|
||||||
@@ -184,11 +148,4 @@ public class DashboardSummary extends Fragment implements OnAccountsUpdateListen
|
|||||||
mHandler.sendEmptyMessage(MSG_REBUILD_UI);
|
mHandler.sendEmptyMessage(MSG_REBUILD_UI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccountsUpdated(Account[] accounts) {
|
|
||||||
final SettingsActivity sa = (SettingsActivity) getActivity();
|
|
||||||
sa.setNeedToRebuildCategories(true);
|
|
||||||
sendRebuildUI();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user