Remove unused preferences and dead code

Change-Id: Ica8bd735a91417ed44bd547ab7176832745d729e
This commit is contained in:
Tony Mantler 2014-06-10 11:27:55 -07:00
parent 8b38cc1739
commit 51af59fc66
6 changed files with 2 additions and 207 deletions

View File

@ -26,8 +26,6 @@ import android.content.OperationApplicationException;
import android.database.ContentObserver;
import android.database.Cursor;
import android.media.RingtoneManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
@ -594,33 +592,6 @@ public final class Account extends EmailContent implements Parcelable {
}
}
/**
* Given an account id, determine whether the account is currently prohibited from automatic
* sync, due to roaming while the account's policy disables this
* @param context the caller's context
* @param accountId the account id
* @return true if the account can't automatically sync due to roaming; false otherwise
*/
public static boolean isAutomaticSyncDisabledByRoaming(Context context, long accountId) {
Account account = Account.restoreAccountWithId(context, accountId);
// Account being deleted; just return
if (account == null) return false;
long policyKey = account.mPolicyKey;
// If no security policy, we're good
if (policyKey <= 0) return false;
ConnectivityManager cm =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
// If we're not on mobile, we're good
if (info == null || (info.getType() != ConnectivityManager.TYPE_MOBILE)) return false;
// If we're not roaming, we're good
if (!info.isRoaming()) return false;
Policy policy = Policy.restorePolicyWithId(context, policyKey);
// Account being deleted; just return
return policy != null && policy.mRequireManualSyncWhenRoaming;
}
/*
* Override this so that we can store the HostAuth's first and link them to the Account
* (non-Javadoc)

View File

@ -726,51 +726,11 @@
<string name="general_preference_confirm_delete_label">Confirm before deleting</string>
<!-- General preference: Description of the setting for requiring confirmation before
message deletion [CHAR LIMIT=64] -->
<!-- TODO: Delete this string, no longer used -->
<string name="general_preference_confirm_delete_summary">Messages</string>
<!-- General preference: Label of the setting for requiring confirmation before
message sending [CHAR LIMIT=32] -->
<string name="general_preference_confirm_send_label">Confirm before sending</string>
<!-- General preference: Description of the setting for requiring confirmation before
message sending [CHAR LIMIT=32] -->
<!-- TODO: Delete this string, no longer used -->
<string name="general_preference_confirm_send_summary">Messages</string>
<!-- General preference: Label of the setting for the text zoom. [CHAR LIMIT=32] -->
<string name="general_preference_text_zoom_label">Message text size</string>
<!-- General preference: Description of each setting for text zoom. The entries here must
correspond to the strings general_preference_text_zoom_tiny,
general_preference_text_zoom_small, general_preference_text_zoom_normal, etc.
[CHAR LIMIT=64] -->
<string-array name="general_preference_text_zoom_summary_array">
<item>Tiny text</item>
<item>Small text</item>
<item>Normal-sized text</item>
<item>Large text</item>
<item>Huge text</item>
</string-array>
<!-- The message text size values -->
<string-array translatable="false" name="general_preference_text_zoom_size">
<item>0.8</item>
<item>0.9</item>
<item>1.0</item>
<item>1.2</item>
<item>1.5</item>
</string-array>
<!-- General preference: Title of the dialog box with options for text zoom. [CHAR LIMIT=32] -->
<string name="general_preference_text_zoom_dialog_title">Message text size</string>
<!-- General preference: Text zoom. Value is "tiny" (-2) [CHAR LIMIT=32] -->
<string name="general_preference_text_zoom_tiny">Tiny</string>
<!-- General preference: Text zoom. Value is "small" (-1) [CHAR LIMIT=32] -->
<string name="general_preference_text_zoom_small">Small</string>
<!-- General preference: Text zoom. Value is "normal" (0) [CHAR LIMIT=32] -->
<string name="general_preference_text_zoom_normal">Normal</string>
<!-- General preference: Text zoom. Value is "large" (+1) [CHAR LIMIT=32] -->
<string name="general_preference_text_zoom_large">Large</string>
<!-- General preference: Text zoom. Value is "huge" (+2) [CHAR LIMIT=32] -->
<string name="general_preference_text_zoom_huge">Huge</string>
<!-- Generic string shown instead of regular numbers, when a number is larger than 999.
This should not be altered if the original string ("999+") makes sense in the

View File

@ -37,14 +37,6 @@
android:entryValues="@array/prefValues_autoAdvance"
android:dialogTitle="@string/auto_advance_help_title" />
<!-- Note, summary is set dynamically in GeneralPreferences.java -->
<ListPreference
android:key="text_zoom"
android:title="@string/general_preference_text_zoom_label"
android:entries="@array/general_preference_text_zoom_entries"
android:entryValues="@array/general_preference_text_zoom_values"
android:dialogTitle="@string/general_preference_text_zoom_dialog_title" />
<CheckBoxPreference
android:key="conversation_list_icon"
android:persistent="false"

View File

@ -42,14 +42,10 @@ public class Preferences {
private static final String ENABLE_DEBUG_LOGGING = "enableDebugLogging";
private static final String ENABLE_EXCHANGE_LOGGING = "enableExchangeLogging";
private static final String ENABLE_EXCHANGE_FILE_LOGGING = "enableExchangeFileLogging";
private static final String INHIBIT_GRAPHICS_ACCELERATION = "inhibitGraphicsAcceleration";
private static final String FORCE_ONE_MINUTE_REFRESH = "forceOneMinuteRefresh";
private static final String ENABLE_STRICT_MODE = "enableStrictMode";
private static final String DEVICE_UID = "deviceUID";
private static final String ONE_TIME_INITIALIZATION_PROGRESS = "oneTimeInitializationProgress";
private static final String AUTO_ADVANCE_DIRECTION = "autoAdvance";
private static final String TEXT_ZOOM = "textZoom";
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";
@ -69,15 +65,6 @@ public class Preferences {
private static final boolean CONFIRM_DELETE_DEFAULT = false;
private static final boolean CONFIRM_SEND_DEFAULT = false;
// The following constants are used as offsets into R.array.general_preference_text_zoom_size.
public static final int TEXT_ZOOM_TINY = 0;
public static final int TEXT_ZOOM_SMALL = 1;
public static final int TEXT_ZOOM_NORMAL = 2;
public static final int TEXT_ZOOM_LARGE = 3;
public static final int TEXT_ZOOM_HUGE = 4;
// "normal" will be the default
public static final int TEXT_ZOOM_DEFAULT = TEXT_ZOOM_NORMAL;
public static final String CONV_LIST_ICON_SENDER_IMAGE = "senderimage";
public static final String CONV_LIST_ICON_NONE = "none";
public static final String CONV_LIST_ICON_DEFAULT = CONV_LIST_ICON_SENDER_IMAGE;
@ -139,22 +126,6 @@ public class Preferences {
return mSharedPreferences.getBoolean(ENABLE_EXCHANGE_FILE_LOGGING, false);
}
public void setInhibitGraphicsAcceleration(boolean value) {
mSharedPreferences.edit().putBoolean(INHIBIT_GRAPHICS_ACCELERATION, value).apply();
}
public boolean getInhibitGraphicsAcceleration() {
return mSharedPreferences.getBoolean(INHIBIT_GRAPHICS_ACCELERATION, false);
}
public void setForceOneMinuteRefresh(boolean value) {
mSharedPreferences.edit().putBoolean(FORCE_ONE_MINUTE_REFRESH, value).apply();
}
public boolean getForceOneMinuteRefresh() {
return mSharedPreferences.getBoolean(FORCE_ONE_MINUTE_REFRESH, false);
}
public void setEnableStrictMode(boolean value) {
mSharedPreferences.edit().putBoolean(ENABLE_STRICT_MODE, value).apply();
}
@ -239,24 +210,9 @@ public class Preferences {
return mSharedPreferences.getBoolean(REPLY_ALL, false);
}
public int getTextZoom() {
return mSharedPreferences.getInt(TEXT_ZOOM, TEXT_ZOOM_DEFAULT);
}
public void setTextZoom(int zoom) {
mSharedPreferences.edit().putInt(TEXT_ZOOM, zoom).apply();
}
public boolean getBackgroundAttachments() {
return mSharedPreferences.getBoolean(BACKGROUND_ATTACHMENTS, false);
}
public void setBackgroundAttachments(boolean allowed) {
mSharedPreferences.edit().putBoolean(BACKGROUND_ATTACHMENTS, allowed).apply();
}
/**
* @deprecated This has been moved to {@link com.android.mail.preferences.MailPrefs}, and is only here for migration.
* @deprecated This has been moved to {@link com.android.mail.preferences.MailPrefs}, and is
* only here for migration.
*/
@Deprecated
public Set<String> getWhitelistedSenderAddresses() {
@ -278,10 +234,6 @@ public class Preferences {
return result;
}
String packEmailSet(HashSet<String> set) {
return new JSONArray(set).toString();
}
/**
* Returns the last used account ID as set by {@link #setLastUsedAccountId}.
* The system makes no attempt to automatically track what is considered a "use" - clients
@ -321,17 +273,6 @@ public class Preferences {
setBoolean(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(account);
}
public void clear() {
mSharedPreferences.edit().clear().apply();
}

View File

@ -39,7 +39,6 @@ public class GeneralPreferences extends PreferenceFragment implements
OnPreferenceChangeListener {
private static final String PREFERENCE_KEY_AUTO_ADVANCE = "auto_advance";
private static final String PREFERENCE_KEY_TEXT_ZOOM = "text_zoom";
private static final String PREFERENCE_KEY_CONFIRM_DELETE = "confirm_delete";
private static final String PREFERENCE_KEY_CONFIRM_SEND = "confirm_send";
private static final String PREFERENCE_KEY_CONV_LIST_ICON = "conversation_list_icon";
@ -47,12 +46,6 @@ public class GeneralPreferences extends PreferenceFragment implements
private MailPrefs mMailPrefs;
private Preferences mPreferences;
private ListPreference mAutoAdvance;
/**
* TODO: remove this when we've decided for certain that an app setting is unnecessary
* (b/5287963)
*/
@Deprecated
private ListPreference mTextZoom;
private CheckBoxPreference mConfirmDelete;
private CheckBoxPreference mConfirmSend;
//private CheckBoxPreference mConvListAttachmentPreviews;
@ -72,10 +65,6 @@ public class GeneralPreferences extends PreferenceFragment implements
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.general_preferences);
final PreferenceScreen ps = getPreferenceScreen();
// Merely hide app pref for font size until we're sure it's unnecessary (b/5287963)
ps.removePreference(findPreference(PREFERENCE_KEY_TEXT_ZOOM));
}
@Override
@ -103,10 +92,6 @@ public class GeneralPreferences extends PreferenceFragment implements
if (PREFERENCE_KEY_AUTO_ADVANCE.equals(key)) {
mPreferences.setAutoAdvanceDirection(mAutoAdvance.findIndexOfValue((String) newValue));
return true;
} else if (PREFERENCE_KEY_TEXT_ZOOM.equals(key)) {
mPreferences.setTextZoom(mTextZoom.findIndexOfValue((String) newValue));
reloadDynamicSummaries();
return true;
} else if (MailPrefs.PreferenceKeys.DEFAULT_REPLY_ALL.equals(key)) {
mMailPrefs.setDefaultReplyAll((Boolean) newValue);
return true;
@ -144,12 +129,6 @@ public class GeneralPreferences extends PreferenceFragment implements
mAutoAdvance.setValueIndex(mPreferences.getAutoAdvanceDirection());
mAutoAdvance.setOnPreferenceChangeListener(this);
mTextZoom = (ListPreference) findPreference(PREFERENCE_KEY_TEXT_ZOOM);
if (mTextZoom != null) {
mTextZoom.setValueIndex(mPreferences.getTextZoom());
mTextZoom.setOnPreferenceChangeListener(this);
}
final CheckBoxPreference convListIcon =
(CheckBoxPreference) findPreference(PREFERENCE_KEY_CONV_LIST_ICON);
if (convListIcon != null) {
@ -168,27 +147,6 @@ public class GeneralPreferences extends PreferenceFragment implements
(CheckBoxPreference) findPreference(MailPrefs.PreferenceKeys.DEFAULT_REPLY_ALL);
replyAllPreference.setChecked(mMailPrefs.getDefaultReplyAll());
replyAllPreference.setOnPreferenceChangeListener(this);
reloadDynamicSummaries();
}
/**
* Reload any preference summaries that are updated dynamically
*/
private void reloadDynamicSummaries() {
if (mTextZoom != null) {
int textZoomIndex = mPreferences.getTextZoom();
// Update summary - but only load the array once
if (mSizeSummaries == null) {
mSizeSummaries = getActivity().getResources()
.getTextArray(R.array.general_preference_text_zoom_summary_array);
}
CharSequence summary = null;
if (textZoomIndex >= 0 && textZoomIndex < mSizeSummaries.length) {
summary = mSizeSummaries[textZoomIndex];
}
mTextZoom.setSummary(summary);
}
}
@Override

View File

@ -3458,12 +3458,6 @@ public class EmailProvider extends ContentProvider {
values.put(UIProvider.AccountColumns.SettingsColumns.AUTO_ADVANCE,
autoAdvanceToUiValue(autoAdvance));
}
if (projectionColumns.contains(
UIProvider.AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE)) {
int textZoom = prefs.getTextZoom();
values.put(UIProvider.AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE,
textZoomToUiValue(textZoom));
}
// Set default inbox, if we've got an inbox; otherwise, say initial sync needed
final long inboxMailboxId =
Mailbox.findMailboxOfType(context, accountId, Mailbox.TYPE_INBOX);
@ -3569,23 +3563,6 @@ public class EmailProvider extends ContentProvider {
}
}
private static int textZoomToUiValue(int textZoom) {
switch(textZoom) {
case Preferences.TEXT_ZOOM_HUGE:
return UIProvider.MessageTextSize.HUGE;
case Preferences.TEXT_ZOOM_LARGE:
return UIProvider.MessageTextSize.LARGE;
case Preferences.TEXT_ZOOM_NORMAL:
return UIProvider.MessageTextSize.NORMAL;
case Preferences.TEXT_ZOOM_SMALL:
return UIProvider.MessageTextSize.SMALL;
case Preferences.TEXT_ZOOM_TINY:
return UIProvider.MessageTextSize.TINY;
default:
return UIProvider.MessageTextSize.NORMAL;
}
}
/**
* Generate a Uri string for a combined mailbox uri
* @param type the uri command type (e.g. "uimessages")
@ -3698,10 +3675,6 @@ public class EmailProvider extends ContentProvider {
values[colPosMap.get(UIProvider.AccountColumns.SettingsColumns.AUTO_ADVANCE)] =
Integer.toString(UIProvider.AutoAdvance.NEWER);
}
if (colPosMap.containsKey(UIProvider.AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE)) {
values[colPosMap.get(UIProvider.AccountColumns.SettingsColumns.MESSAGE_TEXT_SIZE)] =
Integer.toString(UIProvider.MessageTextSize.NORMAL);
}
if (colPosMap.containsKey(UIProvider.AccountColumns.SettingsColumns.SNAP_HEADERS)) {
values[colPosMap.get(UIProvider.AccountColumns.SettingsColumns.SNAP_HEADERS)] =
Integer.toString(UIProvider.SnapHeaderValue.ALWAYS);