Fix for bug #3325868 (add accounts should not use the settings activity as part of its flow)
- suppress non needed AccountSyncSettingsInAddAccount class Change-Id: I27ba9ea2d45a5e2c9ec1d2ed6033f6d68e100a3f
This commit is contained in:
@@ -1050,20 +1050,6 @@
|
||||
android:resource="@id/sync_settings" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="Settings$AccountSyncSettingsInAddAccountActivity"
|
||||
android:label="@string/account_sync_settings_title"
|
||||
android:theme="@android:style/Theme.Holo">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.settings.ACCOUNT_SYNC_SETTINGS_ADD_ACCOUNT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.accounts.AccountSyncSettingsInAddAccount" />
|
||||
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
|
||||
android:resource="@id/sync_settings" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="com.android.settings.accounts.AddAccountSettings"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:label="@string/header_add_an_account">
|
||||
|
@@ -81,8 +81,6 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
||||
private ArrayList<SyncStateCheckBoxPreference> mCheckBoxes =
|
||||
new ArrayList<SyncStateCheckBoxPreference>();
|
||||
private ArrayList<String> mInvisibleAdapters = Lists.newArrayList();
|
||||
// Tell if we will use the current SyncManager data or just the User input
|
||||
protected boolean mUseSyncManagerFeedsState = true;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(final int id) {
|
||||
@@ -264,7 +262,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(PreferenceScreen preferences, Preference preference) {
|
||||
if (preference instanceof SyncStateCheckBoxPreference && mUseSyncManagerFeedsState) {
|
||||
if (preference instanceof SyncStateCheckBoxPreference) {
|
||||
SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) preference;
|
||||
String authority = syncPref.getAuthority();
|
||||
Account account = syncPref.getAccount();
|
||||
@@ -345,10 +343,10 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
||||
@Override
|
||||
protected void onSyncStateUpdated() {
|
||||
if (!isResumed()) return;
|
||||
setFeedsState(mUseSyncManagerFeedsState);
|
||||
setFeedsState();
|
||||
}
|
||||
|
||||
private void setFeedsState(boolean useSyncManager) {
|
||||
private void setFeedsState() {
|
||||
// iterate over all the preferences, setting the state properly for each
|
||||
Date date = new Date();
|
||||
List<SyncInfo> currentSyncs = ContentResolver.getCurrentSyncs();
|
||||
@@ -367,7 +365,6 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
||||
String authority = syncPref.getAuthority();
|
||||
Account account = syncPref.getAccount();
|
||||
|
||||
if (useSyncManager) {
|
||||
SyncStatusInfo status = ContentResolver.getSyncStatus(account, authority);
|
||||
boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority);
|
||||
boolean authorityIsPending = status == null ? false : status.pending;
|
||||
@@ -411,9 +408,6 @@ public class AccountSyncSettings extends AccountPreferenceBase {
|
||||
final boolean oneTimeSyncMode = !masterSyncAutomatically || !backgroundDataEnabled;
|
||||
syncPref.setOneTimeSyncMode(oneTimeSyncMode);
|
||||
syncPref.setChecked(oneTimeSyncMode || syncEnabled);
|
||||
} else {
|
||||
syncPref.setChecked(true);
|
||||
}
|
||||
}
|
||||
mErrorInfoView.setVisibility(syncIsFailing ? View.VISIBLE : View.GONE);
|
||||
getActivity().invalidateOptionsMenu();
|
||||
|
@@ -1,60 +0,0 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.ContentResolver;
|
||||
import android.preference.Preference;
|
||||
import com.android.settings.R;
|
||||
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
/**
|
||||
* This is AccountSyncSettings with 'remove account' button always gone and
|
||||
* a wizard-like button bar to complete the activity.
|
||||
*/
|
||||
public class AccountSyncSettingsInAddAccount extends AccountSyncSettings
|
||||
implements OnClickListener {
|
||||
private View mFinishArea;
|
||||
private View mFinishButton;
|
||||
|
||||
@Override
|
||||
protected void initializeUi(final View rootView) {
|
||||
super.initializeUi(rootView);
|
||||
|
||||
mFinishArea = (View) rootView.findViewById(R.id.finish_button_area);
|
||||
mFinishArea.setVisibility(View.VISIBLE);
|
||||
mFinishButton = (View) rootView.findViewById(R.id.finish_button);
|
||||
mFinishButton.setOnClickListener(this);
|
||||
|
||||
mUseSyncManagerFeedsState = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
// Remove the "remove account" menu item
|
||||
menu.findItem(MENU_REMOVE_ACCOUNT_ID).setVisible(false);
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
applySyncSettingsToSyncManager();
|
||||
finish();
|
||||
}
|
||||
|
||||
private void applySyncSettingsToSyncManager() {
|
||||
for (int i = 0, count = getPreferenceScreen().getPreferenceCount(); i < count; i++) {
|
||||
Preference pref = getPreferenceScreen().getPreference(i);
|
||||
if (! (pref instanceof SyncStateCheckBoxPreference)) {
|
||||
continue;
|
||||
}
|
||||
SyncStateCheckBoxPreference syncPref = (SyncStateCheckBoxPreference) pref;
|
||||
|
||||
String authority = syncPref.getAuthority();
|
||||
Account account = syncPref.getAccount();
|
||||
|
||||
ContentResolver.setSyncAutomatically(account, authority, syncPref.isChecked());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user