Bug 5092721: Accounts & sync settings, auto sync in overflow menu.
Was usually "Make auto-sync an on/off switch in the action bar" Changed to a check box in the overflow menu as per the comment in the bug. Change-Id: I5a722ec1c743232c019fe89144a0a9463431747a
This commit is contained in:
@@ -1548,10 +1548,8 @@
|
||||
<!-- Sound settings screen, setting option summary text when check box is clear -->
|
||||
<string name="dock_sounds_enable_summary_off" product="default">Don\'t play sound when inserting or removing phone from dock</string>
|
||||
|
||||
<!-- Acounts & Sync settings screen setting option name to go into the screen for data sync settings-->
|
||||
<!-- Acounts & Sync settings screen setting title. This screen will list the different accounts (mail, gmail...) used on that phone and their sync settings -->
|
||||
<string name="sync_settings">Accounts & sync</string>
|
||||
<!-- Main Settings screen setting option summary text for the itme to go into the screen with data sync settings-->
|
||||
<string name="sync_settings_summary">Add or remove accounts and change account settings</string>
|
||||
|
||||
<!-- Main Settings screen, setting option name to go into search settings -->
|
||||
<string name="search_settings">Search</string>
|
||||
@@ -3296,9 +3294,6 @@ found in the list of installed applications.</string>
|
||||
<string name="sync_is_failing">Sync is currently experiencing problems. It will be back shortly.</string>
|
||||
<!-- Button label to add an account [CHAR LIMIT=20] -->
|
||||
<string name="add_account_label">Add account</string>
|
||||
<!-- Header title for those settings relating to general syncing.
|
||||
[CHAR LIMIT=30] -->
|
||||
<string name="header_general_sync_settings">General sync settings</string>
|
||||
<!-- Data synchronization settings screen, title of setting that controls whether background data should be used [CHAR LIMIT=30] -->
|
||||
<string name="background_data">Background data</string>
|
||||
<!-- Data synchronization settings screen, summary of setting that controls whether background data should be used [CHAR LIMIT=60] -->
|
||||
@@ -3307,13 +3302,8 @@ found in the list of installed applications.</string>
|
||||
<string name="background_data_dialog_title">Attention</string>
|
||||
<!-- Data synchronization settings screen, message of dialog that confirms the user's unchecking of background data [CHAR LIMIT=200] -->
|
||||
<string name="background_data_dialog_message">Disabling background data extends battery life and lowers data use. Some applications may still use the background data connection.</string>
|
||||
<!-- Data synchronization settings screen, setting option name
|
||||
[CHAR LIMIT=30] -->
|
||||
<string name="sync_automatically">Auto-sync</string>
|
||||
<!-- Data synchronization settings screen, setting option summary text when check box is selected [CHAR LIMIT=60] -->
|
||||
<string name="sync_automatically_summary">Applications sync data automatically</string>
|
||||
<!-- Header title for list of accounts on Accounts & Synchronization settings [CHAR LIMIT=30] -->
|
||||
<string name="header_manage_accounts">Manage accounts</string>
|
||||
<!-- Title for a checkbox that enables data synchronization in the account and sync screen [CHAR LIMIT=35] -->
|
||||
<string name="sync_automatically">Auto-sync app data</string>
|
||||
|
||||
<!-- Sync status messages on Accounts & Synchronization settings --><skip />
|
||||
<!-- Sync status shown when sync is enabled [CHAR LIMIT=20] -->
|
||||
|
@@ -16,15 +16,4 @@
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/header_general_sync_settings" />
|
||||
|
||||
<CheckBoxPreference android:key="syncAutomaticallyCheckBox"
|
||||
android:persistent="false"
|
||||
android:title="@string/sync_automatically"
|
||||
android:summary="@string/sync_automatically_summary"/>
|
||||
|
||||
<PreferenceCategory android:key="manageAccountsCategory"
|
||||
android:title="@string/header_manage_accounts" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.accounts;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorDescription;
|
||||
import android.accounts.OnAccountsUpdateListener;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
@@ -28,10 +27,8 @@ import android.content.SyncInfo;
|
||||
import android.content.SyncStatusInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -40,7 +37,6 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.AccountPreference;
|
||||
@@ -48,38 +44,22 @@ import com.android.settings.DialogCreatable;
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
implements OnAccountsUpdateListener, DialogCreatable {
|
||||
|
||||
private static final String TAG = ManageAccountsSettings.class.getSimpleName();
|
||||
|
||||
private static final String AUTHORITIES_FILTER_KEY = "authorities";
|
||||
private static final boolean LDEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
private static final String AUTO_SYNC_CHECKBOX_KEY = "syncAutomaticallyCheckBox";
|
||||
private static final String MANAGE_ACCOUNTS_CATEGORY_KEY = "manageAccountsCategory";
|
||||
|
||||
private static final int MENU_ADD_ACCOUNT = Menu.FIRST;
|
||||
private static final int MENU_SYNC_APP = MENU_ADD_ACCOUNT + 1;
|
||||
|
||||
private static final int REQUEST_SHOW_SYNC_SETTINGS = 1;
|
||||
|
||||
private PreferenceCategory mManageAccountsCategory;
|
||||
private String[] mAuthorities;
|
||||
private TextView mErrorInfoView;
|
||||
private Button mAddAccountButton;
|
||||
private CheckBoxPreference mAutoSyncCheckbox;
|
||||
private MenuItem mSyncAppMenuItem;
|
||||
|
||||
private SettingsDialogFragment mDialogFragment;
|
||||
|
||||
private AuthenticatorDescription[] mAuthDescs;
|
||||
private Map<String, AuthenticatorDescription> mTypeToAuthDescription
|
||||
= new HashMap<String, AuthenticatorDescription>();
|
||||
private HashMap<String, ArrayList<String>> mAccountTypeToAuthorities = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -111,9 +91,6 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
mErrorInfoView = (TextView)view.findViewById(R.id.sync_settings_error_info);
|
||||
mErrorInfoView.setVisibility(View.GONE);
|
||||
|
||||
mAutoSyncCheckbox = (CheckBoxPreference) findPreference(AUTO_SYNC_CHECKBOX_KEY);
|
||||
|
||||
mManageAccountsCategory = (PreferenceCategory)findPreference(MANAGE_ACCOUNTS_CATEGORY_KEY);
|
||||
mAuthorities = activity.getIntent().getStringArrayExtra(AUTHORITIES_FILTER_KEY);
|
||||
|
||||
updateAuthDescriptions();
|
||||
@@ -127,10 +104,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferences, Preference preference) {
|
||||
if (preference == mAutoSyncCheckbox) {
|
||||
ContentResolver.setMasterSyncAutomatically(mAutoSyncCheckbox.isChecked());
|
||||
onSyncStateUpdated();
|
||||
} else if (preference instanceof AccountPreference) {
|
||||
if (preference instanceof AccountPreference) {
|
||||
startAccountSettings((AccountPreference) preference);
|
||||
} else {
|
||||
return false;
|
||||
@@ -158,17 +132,25 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
MenuItem actionItem =
|
||||
menu.add(0, MENU_ADD_ACCOUNT, 0, R.string.add_account_label);
|
||||
actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||
MenuItem addAccountItem = menu.add(0, MENU_ADD_ACCOUNT, 0, R.string.add_account_label);
|
||||
addAccountItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
mSyncAppMenuItem = menu.add(0, MENU_SYNC_APP, 0, R.string.sync_automatically).
|
||||
setCheckable(true).setChecked(ContentResolver.getMasterSyncAutomatically());
|
||||
mSyncAppMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == MENU_ADD_ACCOUNT) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == MENU_ADD_ACCOUNT) {
|
||||
onAddAccountClicked();
|
||||
return true;
|
||||
} else if (itemId == MENU_SYNC_APP) {
|
||||
// Use the opposite, the checked state has not yet been changed
|
||||
ContentResolver.setMasterSyncAutomatically(!item.isChecked());
|
||||
onSyncStateUpdated();
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@@ -179,8 +161,9 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
// Catch any delayed delivery of update messages
|
||||
if (getActivity() == null) return;
|
||||
// Set background connection state
|
||||
boolean masterSyncAutomatically = ContentResolver.getMasterSyncAutomatically();
|
||||
mAutoSyncCheckbox.setChecked(masterSyncAutomatically);
|
||||
if (mSyncAppMenuItem != null) {
|
||||
mSyncAppMenuItem.setChecked(ContentResolver.getMasterSyncAutomatically());
|
||||
}
|
||||
|
||||
// iterate over all the preferences, setting the state properly for each
|
||||
SyncInfo currentSync = ContentResolver.getCurrentSync();
|
||||
@@ -196,8 +179,8 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
userFacing.add(sa.authority);
|
||||
}
|
||||
}
|
||||
for (int i = 0, count = mManageAccountsCategory.getPreferenceCount(); i < count; i++) {
|
||||
Preference pref = mManageAccountsCategory.getPreference(i);
|
||||
for (int i = 0, count = getPreferenceScreen().getPreferenceCount(); i < count; i++) {
|
||||
Preference pref = getPreferenceScreen().getPreference(i);
|
||||
if (! (pref instanceof AccountPreference)) {
|
||||
continue;
|
||||
}
|
||||
@@ -211,7 +194,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
for (String authority : authorities) {
|
||||
SyncStatusInfo status = ContentResolver.getSyncStatus(account, authority);
|
||||
boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority)
|
||||
&& masterSyncAutomatically
|
||||
&& ContentResolver.getMasterSyncAutomatically()
|
||||
&& (ContentResolver.getIsSyncable(account, authority) > 0);
|
||||
boolean authorityIsPending = ContentResolver.isSyncPending(account, authority);
|
||||
boolean activelySyncing = currentSync != null
|
||||
@@ -251,7 +234,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
@Override
|
||||
public void onAccountsUpdated(Account[] accounts) {
|
||||
if (getActivity() == null) return;
|
||||
mManageAccountsCategory.removeAll();
|
||||
getPreferenceScreen().removeAll();
|
||||
for (int i = 0, n = accounts.length; i < n; i++) {
|
||||
final Account account = accounts[i];
|
||||
final ArrayList<String> auths = getAuthoritiesForAccountType(account.type);
|
||||
@@ -271,7 +254,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
final Drawable icon = getDrawableForType(account.type);
|
||||
final AccountPreference preference =
|
||||
new AccountPreference(getActivity(), account, icon, auths);
|
||||
mManageAccountsCategory.addPreference(preference);
|
||||
getPreferenceScreen().addPreference(preference);
|
||||
}
|
||||
}
|
||||
onSyncStateUpdated();
|
||||
@@ -280,8 +263,8 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
@Override
|
||||
protected void onAuthDescriptionsUpdated() {
|
||||
// Update account icons for all account preference items
|
||||
for (int i = 0; i < mManageAccountsCategory.getPreferenceCount(); i++) {
|
||||
AccountPreference pref = (AccountPreference) mManageAccountsCategory.getPreference(i);
|
||||
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
|
||||
AccountPreference pref = (AccountPreference) getPreferenceScreen().getPreference(i);
|
||||
pref.setProviderIcon(getDrawableForType(pref.getAccount().type));
|
||||
pref.setSummary(getLabelForType(pref.getAccount().type));
|
||||
}
|
||||
|
Reference in New Issue
Block a user