resolved conflicts for merge of 565e94cd to master

Change-Id: I424541a5c8d1d74b78e19170e40edb071fa68c0e
This commit is contained in:
Mindy Pereira 2011-11-02 10:47:25 -07:00
commit d0e7f538cb
3 changed files with 1 additions and 107 deletions

View File

@ -50,7 +50,6 @@ public class Preferences {
private static final String BACKGROUND_ATTACHMENTS = "backgroundAttachments";
private static final String TRUSTED_SENDERS = "trustedSenders";
private static final String LAST_ACCOUNT_USED = "lastAccountUsed";
private static final String REQUIRE_MANUAL_SYNC_DIALOG_SHOWN = "requireManualSyncDialogShown";
public static final int AUTO_ADVANCE_NEWER = 0;
public static final int AUTO_ADVANCE_OLDER = 1;
@ -288,34 +287,6 @@ public class Preferences {
.apply();
}
/**
* Gets whether the require manual sync dialog has been shown for the specified account.
* It should only be shown once per account.
*/
public boolean getHasShownRequireManualSync(Context context, Account account) {
return getBoolean(context, account.getEmailAddress(), REQUIRE_MANUAL_SYNC_DIALOG_SHOWN,
false);
}
/**
* Sets whether the require manual sync dialog has been shown for the specified account.
* It should only be shown once per account.
*/
public void setHasShownRequireManualSync(Context context, Account account, boolean value) {
setBoolean(context, account.getEmailAddress(), REQUIRE_MANUAL_SYNC_DIALOG_SHOWN, value);
}
/**
* Get whether to show the manual sync dialog. This dialog is shown when the user is roaming,
* connected to a mobile network, the administrator has set the RequireManualSyncWhenRoaming
* flag to true, and the dialog has not been shown before for the supplied account.
*/
public boolean shouldShowRequireManualSync(Context context, Account account) {
return Account.isAutomaticSyncDisabledByRoaming(context, account.mId)
&& !getHasShownRequireManualSync(context, account);
}
public void clear() {
mSharedPreferences.edit().clear().apply();
}
@ -327,25 +298,4 @@ public class Preferences {
}
}
}
/**
* Utility method for setting a boolean value on a per-account preference.
*/
private void setBoolean(Context context, String account, String key, Boolean value) {
mSharedPreferences.edit().putBoolean(makeKey(account, key), value).apply();
}
/**
* Utility method for getting a boolean value from a per-account preference.
*/
private boolean getBoolean(Context context, String account, String key, boolean def) {
return mSharedPreferences.getBoolean(makeKey(account, key), def);
}
/**
* Utility method for creating a per account preference key.
*/
private String makeKey(String account, String key) {
return account != null ? account + "-" + key : key;
}
}

View File

@ -1,40 +0,0 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.email;
import com.android.emailcommon.provider.Account;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Resources;
public class RequireManualSyncDialog extends AlertDialog implements OnClickListener {
public RequireManualSyncDialog(Context context, Account account) {
super(context);
setMessage(context.getResources().getString(R.string.require_manual_sync_message));
setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok), this);
Preferences.getPreferences(context).setHasShownRequireManualSync(context, account, true);
}
/** {@inheritDoc} */
public void onClick(DialogInterface dialog, int which) {
// No-op.
}
}

View File

@ -32,7 +32,6 @@ import com.android.email.MessageListContext;
import com.android.email.Preferences;
import com.android.email.R;
import com.android.email.RefreshManager;
import com.android.email.RequireManualSyncDialog;
import com.android.email.activity.setup.AccountSettings;
import com.android.email.activity.setup.MailboxSettings;
import com.android.emailcommon.Logging;
@ -207,9 +206,7 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
if (mNfcHandler != null) {
mNfcHandler.onAccountChanged(); // workaround for email not set on initial load
}
long accountId = getUIAccountId();
Preferences.getPreferences(mActivity).setLastUsedAccountId(accountId);
showAccountSpecificWarning(accountId);
Preferences.getPreferences(mActivity).setLastUsedAccountId(getUIAccountId());
}
/**
@ -561,7 +558,6 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
mNfcHandler.onAccountChanged();
}
Preferences.getPreferences(mActivity).setLastUsedAccountId(accountId);
showAccountSpecificWarning(accountId);
}
/**
@ -1021,18 +1017,6 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
}
}
private void showAccountSpecificWarning(long accountId) {
if (accountId != Account.NO_ACCOUNT && accountId != Account.NO_ACCOUNT) {
Account account = Account.restoreAccountWithId(mActivity, accountId);
if (account != null &&
Preferences.getPreferences(mActivity)
.shouldShowRequireManualSync(mActivity, account)) {
new RequireManualSyncDialog(mActivity, account).show();
}
}
}
@Override
public String toString() {
return getClass().getSimpleName(); // Shown on logcat