Merge branch 'master' into pgp_mime_preparations

This commit is contained in:
cketti 2015-02-17 00:56:42 +01:00
commit 9659bee8c5
24 changed files with 224 additions and 216 deletions

View file

@ -53,6 +53,7 @@ android {
}
debug {
applicationIdSuffix ".debug"
testCoverageEnabled rootProject.testCoverage
}
}

View file

@ -29,36 +29,36 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<permission
android:name="com.fsck.k9.permission.READ_ATTACHMENT"
android:name="${applicationId}.permission.READ_ATTACHMENT"
android:description="@string/read_attachment_desc"
android:label="@string/read_attachment_label"
android:permissionGroup="android.permission-group.MESSAGES"
android:protectionLevel="dangerous"/>
<uses-permission android:name="com.fsck.k9.permission.READ_ATTACHMENT"/>
<uses-permission android:name="${applicationId}.permission.READ_ATTACHMENT"/>
<permission
android:name="com.fsck.k9.permission.REMOTE_CONTROL"
android:name="${applicationId}.permission.REMOTE_CONTROL"
android:description="@string/remote_control_desc"
android:label="@string/remote_control_label"
android:permissionGroup="android.permission-group.MESSAGES"
android:protectionLevel="dangerous"/>
<uses-permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"/>
<uses-permission android:name="${applicationId}.permission.REMOTE_CONTROL"/>
<permission
android:name="com.fsck.k9.permission.READ_MESSAGES"
android:name="${applicationId}.permission.READ_MESSAGES"
android:description="@string/read_messages_desc"
android:label="@string/read_messages_label"
android:permissionGroup="android.permission-group.MESSAGES"
android:protectionLevel="dangerous"/>
<uses-permission android:name="com.fsck.k9.permission.READ_MESSAGES"/>
<uses-permission android:name="${applicationId}.permission.READ_MESSAGES"/>
<permission
android:name="com.fsck.k9.permission.DELETE_MESSAGES"
android:name="${applicationId}.permission.DELETE_MESSAGES"
android:description="@string/delete_messages_desc"
android:label="@string/delete_messages_label"
android:permissionGroup="android.permission-group.MESSAGES"
android:protectionLevel="dangerous"/>
<uses-permission android:name="com.fsck.k9.permission.DELETE_MESSAGES"/>
<uses-permission android:name="${applicationId}.permission.DELETE_MESSAGES"/>
<application
@ -70,7 +70,7 @@
<meta-data
android:name="android.app.default_searchable"
android:value=".activity.Search"/>
android:value="com.fsck.k9.activity.Search"/>
<activity
android:name=".activity.Accounts"
@ -98,7 +98,7 @@
android:configChanges="locale"
android:excludeFromRecents="true"
android:label="@string/prefs_title"
android:taskAffinity="com.fsck.k9.activity.setup.Prefs"/>
android:taskAffinity="${applicationId}.activity.setup.Prefs"/>
<activity
android:name=".activity.setup.WelcomeMessage"
@ -315,12 +315,12 @@
<receiver
android:name=".service.RemoteControlReceiver"
android:enabled="true"
android:permission="com.fsck.k9.permission.REMOTE_CONTROL">
android:permission="${applicationId}.permission.REMOTE_CONTROL">
<intent-filter>
<action android:name="com.fsck.k9.K9RemoteControl.set"/>
<action android:name="${applicationId}.K9RemoteControl.set"/>
</intent-filter>
<intent-filter>
<action android:name="com.fsck.k9.K9RemoteControl.requestAccounts"/>
<action android:name="${applicationId}.K9RemoteControl.requestAccounts"/>
</intent-filter>
</receiver>
@ -383,7 +383,7 @@
<service
android:name=".service.RemoteControlService"
android:enabled="true"
android:permission="com.fsck.k9.permission.REMOTE_CONTROL"/>
android:permission="${applicationId}.permission.REMOTE_CONTROL"/>
<service
android:name=".service.SleepService"
@ -395,24 +395,24 @@
<provider
android:name=".provider.AttachmentProvider"
android:authorities="com.fsck.k9.attachmentprovider"
android:authorities="${applicationId}.attachmentprovider"
android:exported="true"
android:grantUriPermissions="true"
android:multiprocess="true"
android:readPermission="com.fsck.k9.permission.READ_ATTACHMENT"/>
android:readPermission="${applicationId}.permission.READ_ATTACHMENT"/>
<provider
android:name=".provider.MessageProvider"
android:authorities="com.fsck.k9.messageprovider"
android:authorities="${applicationId}.messageprovider"
android:exported="true"
android:grantUriPermissions="true"
android:multiprocess="true"
android:readPermission="com.fsck.k9.permission.READ_MESSAGES"
android:writePermission="com.fsck.k9.permission.DELETE_MESSAGES"/>
android:readPermission="${applicationId}.permission.READ_MESSAGES"
android:writePermission="${applicationId}.permission.DELETE_MESSAGES"/>
<provider
android:name=".provider.EmailProvider"
android:authorities="com.fsck.k9.provider.email"
android:authorities="${applicationId}.provider.email"
android:exported="false"/>
<provider

View file

@ -47,6 +47,8 @@ import com.fsck.k9.mail.ssl.LocalKeyStore;
import com.fsck.k9.view.ColorChip;
import com.larswerkman.colorpicker.ColorPicker;
import static com.fsck.k9.Preferences.getEnumStringPref;
/**
* Account stores all of the settings for a single account defined by the user. It is able to save
* and delete itself given a Preferences to work with. Each account is defined by a UUID.
@ -62,19 +64,43 @@ public class Account implements BaseAccount, StoreConfig {
*/
public static final String OUTBOX = "K9MAIL_INTERNAL_OUTBOX";
public static final String EXPUNGE_IMMEDIATELY = "EXPUNGE_IMMEDIATELY";
public static final String EXPUNGE_MANUALLY = "EXPUNGE_MANUALLY";
public static final String EXPUNGE_ON_POLL = "EXPUNGE_ON_POLL";
public enum Expunge {
EXPUNGE_IMMEDIATELY,
EXPUNGE_MANUALLY,
EXPUNGE_ON_POLL
}
public static final int DELETE_POLICY_NEVER = 0;
public static final int DELETE_POLICY_7DAYS = 1;
public static final int DELETE_POLICY_ON_DELETE = 2;
public static final int DELETE_POLICY_MARK_AS_READ = 3;
public enum DeletePolicy {
NEVER(0),
SEVEN_DAYS(1),
ON_DELETE(2),
MARK_AS_READ(3);
public static final String TYPE_WIFI = "WIFI";
public static final String TYPE_MOBILE = "MOBILE";
public static final String TYPE_OTHER = "OTHER";
private static final String[] networkTypes = { TYPE_WIFI, TYPE_MOBILE, TYPE_OTHER };
public final int setting;
DeletePolicy(int setting) {
this.setting = setting;
}
public String preferenceString() {
return Integer.toString(setting);
}
public static DeletePolicy fromInt(int initialSetting) {
for (DeletePolicy policy: values()) {
if (policy.setting == initialSetting) {
return policy;
}
}
throw new IllegalArgumentException("DeletePolicy " + initialSetting + " unknown");
}
}
public enum NetworkType {
WIFI,
MOBILE,
OTHER
}
public static final MessageFormat DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML;
public static final boolean DEFAULT_MESSAGE_FORMAT_AUTO = false;
@ -138,16 +164,7 @@ public class Account implements BaseAccount, StoreConfig {
public static final boolean DEFAULT_SORT_ASCENDING = false;
public static final String NO_OPENPGP_PROVIDER = "";
/**
* <pre>
* 0 - Never (DELETE_POLICY_NEVER)
* 1 - After 7 days (DELETE_POLICY_7DAYS)
* 2 - When I delete from inbox (DELETE_POLICY_ON_DELETE)
* 3 - Mark as read (DELETE_POLICY_MARK_AS_READ)
* </pre>
*/
private int mDeletePolicy;
private DeletePolicy mDeletePolicy = DeletePolicy.NEVER;
private final String mUuid;
private String mStoreUri;
@ -186,11 +203,11 @@ public class Account implements BaseAccount, StoreConfig {
private Map<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>();
private ShowPictures mShowPictures;
private boolean mIsSignatureBeforeQuotedText;
private String mExpungePolicy = EXPUNGE_IMMEDIATELY;
private Expunge mExpungePolicy = Expunge.EXPUNGE_IMMEDIATELY;
private int mMaxPushFolders;
private int mIdleRefreshMinutes;
private boolean goToUnreadMessageSearch;
private final Map<String, Boolean> compressionMap = new ConcurrentHashMap<String, Boolean>();
private final Map<NetworkType, Boolean> compressionMap = new ConcurrentHashMap<NetworkType, Boolean>();
private Searchable searchableFolders;
private boolean subscribedFoldersOnly;
private int maximumPolledMessageAge;
@ -283,7 +300,7 @@ public class Account implements BaseAccount, StoreConfig {
mSortAscending.put(DEFAULT_SORT_TYPE, DEFAULT_SORT_ASCENDING);
mShowPictures = ShowPictures.NEVER;
mIsSignatureBeforeQuotedText = false;
mExpungePolicy = EXPUNGE_IMMEDIATELY;
mExpungePolicy = Expunge.EXPUNGE_IMMEDIATELY;
mAutoExpandFolderName = INBOX;
mInboxFolderName = INBOX;
mMaxPushFolders = 10;
@ -379,22 +396,18 @@ public class Account implements BaseAccount, StoreConfig {
mLastAutomaticCheckTime = prefs.getLong(mUuid + ".lastAutomaticCheckTime", 0);
mLatestOldMessageSeenTime = prefs.getLong(mUuid + ".latestOldMessageSeenTime", 0);
mNotifyNewMail = prefs.getBoolean(mUuid + ".notifyNewMail", false);
try {
mFolderNotifyNewMailMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderNotifyNewMailMode",
FolderMode.ALL.name()));
} catch (Exception e) {
mFolderNotifyNewMailMode = FolderMode.ALL;
}
mFolderNotifyNewMailMode = getEnumStringPref(prefs, mUuid + ".folderNotifyNewMailMode", FolderMode.ALL);
mNotifySelfNewMail = prefs.getBoolean(mUuid + ".notifySelfNewMail", true);
mNotifySync = prefs.getBoolean(mUuid + ".notifyMailCheck", false);
mDeletePolicy = prefs.getInt(mUuid + ".deletePolicy", 0);
mDeletePolicy = DeletePolicy.fromInt(prefs.getInt(mUuid + ".deletePolicy", DeletePolicy.NEVER.setting));
mInboxFolderName = prefs.getString(mUuid + ".inboxFolderName", INBOX);
mDraftsFolderName = prefs.getString(mUuid + ".draftsFolderName", "Drafts");
mSentFolderName = prefs.getString(mUuid + ".sentFolderName", "Sent");
mTrashFolderName = prefs.getString(mUuid + ".trashFolderName", "Trash");
mArchiveFolderName = prefs.getString(mUuid + ".archiveFolderName", "Archive");
mSpamFolderName = prefs.getString(mUuid + ".spamFolderName", "Spam");
mExpungePolicy = prefs.getString(mUuid + ".expungePolicy", EXPUNGE_IMMEDIATELY);
mExpungePolicy = getEnumStringPref(prefs, mUuid + ".expungePolicy", Expunge.EXPUNGE_IMMEDIATELY);
mSyncRemoteDeletions = prefs.getBoolean(mUuid + ".syncRemoteDeletions", true);
mMaxPushFolders = prefs.getInt(mUuid + ".maxPushFolders", 10);
@ -402,18 +415,18 @@ public class Account implements BaseAccount, StoreConfig {
subscribedFoldersOnly = prefs.getBoolean(mUuid + ".subscribedFoldersOnly", false);
maximumPolledMessageAge = prefs.getInt(mUuid + ".maximumPolledMessageAge", -1);
maximumAutoDownloadMessageSize = prefs.getInt(mUuid + ".maximumAutoDownloadMessageSize", 32768);
mMessageFormat = MessageFormat.valueOf(prefs.getString(mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT.name()));
mMessageFormat = getEnumStringPref(prefs, mUuid + ".messageFormat", DEFAULT_MESSAGE_FORMAT);
mMessageFormatAuto = prefs.getBoolean(mUuid + ".messageFormatAuto", DEFAULT_MESSAGE_FORMAT_AUTO);
if (mMessageFormatAuto && mMessageFormat == MessageFormat.TEXT) {
mMessageFormat = MessageFormat.AUTO;
}
mMessageReadReceipt = prefs.getBoolean(mUuid + ".messageReadReceipt", DEFAULT_MESSAGE_READ_RECEIPT);
mQuoteStyle = QuoteStyle.valueOf(prefs.getString(mUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE.name()));
mQuoteStyle = getEnumStringPref(prefs, mUuid + ".quoteStyle", DEFAULT_QUOTE_STYLE);
mQuotePrefix = prefs.getString(mUuid + ".quotePrefix", DEFAULT_QUOTE_PREFIX);
mDefaultQuotedTextShown = prefs.getBoolean(mUuid + ".defaultQuotedTextShown", DEFAULT_QUOTED_TEXT_SHOWN);
mReplyAfterQuote = prefs.getBoolean(mUuid + ".replyAfterQuote", DEFAULT_REPLY_AFTER_QUOTE);
mStripSignature = prefs.getBoolean(mUuid + ".stripSignature", DEFAULT_STRIP_SIGNATURE);
for (String type : networkTypes) {
for (NetworkType type : NetworkType.values()) {
Boolean useCompression = prefs.getBoolean(mUuid + ".useCompression." + type,
true);
compressionMap.put(type, useCompression);
@ -425,21 +438,11 @@ public class Account implements BaseAccount, StoreConfig {
mChipColor = prefs.getInt(mUuid + ".chipColor", ColorPicker.getRandomColor());
try {
mSortType = SortType.valueOf(prefs.getString(mUuid + ".sortTypeEnum",
SortType.SORT_DATE.name()));
} catch (Exception e) {
mSortType = SortType.SORT_DATE;
}
mSortType = getEnumStringPref(prefs, mUuid + ".sortTypeEnum", SortType.SORT_DATE);
mSortAscending.put(mSortType, prefs.getBoolean(mUuid + ".sortAscending", false));
try {
mShowPictures = ShowPictures.valueOf(prefs.getString(mUuid + ".showPicturesEnum",
ShowPictures.NEVER.name()));
} catch (Exception e) {
mShowPictures = ShowPictures.NEVER;
}
mShowPictures = getEnumStringPref(prefs, mUuid + ".showPicturesEnum", ShowPictures.NEVER);
mNotificationSetting.setVibrate(prefs.getBoolean(mUuid + ".vibrate", false));
mNotificationSetting.setVibratePattern(prefs.getInt(mUuid + ".vibratePattern", 0));
@ -450,40 +453,15 @@ public class Account implements BaseAccount, StoreConfig {
mNotificationSetting.setLed(prefs.getBoolean(mUuid + ".led", true));
mNotificationSetting.setLedColor(prefs.getInt(mUuid + ".ledColor", mChipColor));
try {
mFolderDisplayMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderDisplayMode",
FolderMode.NOT_SECOND_CLASS.name()));
} catch (Exception e) {
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
}
mFolderDisplayMode = getEnumStringPref(prefs, mUuid + ".folderDisplayMode", FolderMode.NOT_SECOND_CLASS);
try {
mFolderSyncMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderSyncMode",
FolderMode.FIRST_CLASS.name()));
} catch (Exception e) {
mFolderSyncMode = FolderMode.FIRST_CLASS;
}
mFolderSyncMode = getEnumStringPref(prefs, mUuid + ".folderSyncMode", FolderMode.FIRST_CLASS);
try {
mFolderPushMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderPushMode",
FolderMode.FIRST_CLASS.name()));
} catch (Exception e) {
mFolderPushMode = FolderMode.FIRST_CLASS;
}
mFolderPushMode = getEnumStringPref(prefs, mUuid + ".folderPushMode", FolderMode.FIRST_CLASS);
try {
mFolderTargetMode = FolderMode.valueOf(prefs.getString(mUuid + ".folderTargetMode",
FolderMode.NOT_SECOND_CLASS.name()));
} catch (Exception e) {
mFolderTargetMode = FolderMode.NOT_SECOND_CLASS;
}
mFolderTargetMode = getEnumStringPref(prefs, mUuid + ".folderTargetMode", FolderMode.NOT_SECOND_CLASS);
try {
searchableFolders = Searchable.valueOf(prefs.getString(mUuid + ".searchableFolders",
Searchable.ALL.name()));
} catch (Exception e) {
searchableFolders = Searchable.ALL;
}
searchableFolders = getEnumStringPref(prefs, mUuid + ".searchableFolders", Searchable.ALL);
mIsSignatureBeforeQuotedText = prefs.getBoolean(mUuid + ".signatureBeforeQuotedText", false);
identities = loadIdentities(prefs);
@ -591,8 +569,8 @@ public class Account implements BaseAccount, StoreConfig {
editor.remove(mUuid + ".messageFormat");
editor.remove(mUuid + ".messageReadReceipt");
editor.remove(mUuid + ".notifyMailCheck");
for (String type : networkTypes) {
editor.remove(mUuid + ".useCompression." + type);
for (NetworkType type : NetworkType.values()) {
editor.remove(mUuid + ".useCompression." + type.name());
}
deleteIdentities(preferences.getPreferences(), editor);
// TODO: Remove preference settings that may exist for individual
@ -707,7 +685,7 @@ public class Account implements BaseAccount, StoreConfig {
editor.putString(mUuid + ".folderNotifyNewMailMode", mFolderNotifyNewMailMode.name());
editor.putBoolean(mUuid + ".notifySelfNewMail", mNotifySelfNewMail);
editor.putBoolean(mUuid + ".notifyMailCheck", mNotifySync);
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy);
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy.setting);
editor.putString(mUuid + ".inboxFolderName", mInboxFolderName);
editor.putString(mUuid + ".draftsFolderName", mDraftsFolderName);
editor.putString(mUuid + ".sentFolderName", mSentFolderName);
@ -724,7 +702,7 @@ public class Account implements BaseAccount, StoreConfig {
editor.putString(mUuid + ".folderPushMode", mFolderPushMode.name());
editor.putString(mUuid + ".folderTargetMode", mFolderTargetMode.name());
editor.putBoolean(mUuid + ".signatureBeforeQuotedText", this.mIsSignatureBeforeQuotedText);
editor.putString(mUuid + ".expungePolicy", mExpungePolicy);
editor.putString(mUuid + ".expungePolicy", mExpungePolicy.name());
editor.putBoolean(mUuid + ".syncRemoteDeletions", mSyncRemoteDeletions);
editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders);
editor.putString(mUuid + ".searchableFolders", searchableFolders.name());
@ -765,7 +743,7 @@ public class Account implements BaseAccount, StoreConfig {
editor.putBoolean(mUuid + ".led", mNotificationSetting.isLed());
editor.putInt(mUuid + ".ledColor", mNotificationSetting.getLedColor());
for (String type : networkTypes) {
for (NetworkType type : NetworkType.values()) {
Boolean useCompression = compressionMap.get(type);
if (useCompression != null) {
editor.putBoolean(mUuid + ".useCompression." + type, useCompression);
@ -1056,11 +1034,11 @@ public class Account implements BaseAccount, StoreConfig {
this.mFolderNotifyNewMailMode = folderNotifyNewMailMode;
}
public synchronized int getDeletePolicy() {
public synchronized DeletePolicy getDeletePolicy() {
return mDeletePolicy;
}
public synchronized void setDeletePolicy(int deletePolicy) {
public synchronized void setDeletePolicy(DeletePolicy deletePolicy) {
this.mDeletePolicy = deletePolicy;
}
@ -1273,11 +1251,11 @@ public class Account implements BaseAccount, StoreConfig {
mNotifySelfNewMail = notifySelfNewMail;
}
public synchronized String getExpungePolicy() {
public synchronized Expunge getExpungePolicy() {
return mExpungePolicy;
}
public synchronized void setExpungePolicy(String expungePolicy) {
public synchronized void setExpungePolicy(Expunge expungePolicy) {
mExpungePolicy = expungePolicy;
}
@ -1312,11 +1290,11 @@ public class Account implements BaseAccount, StoreConfig {
return mDescription;
}
public synchronized void setCompression(String networkType, boolean useCompression) {
public synchronized void setCompression(NetworkType networkType, boolean useCompression) {
compressionMap.put(networkType, useCompression);
}
public synchronized boolean useCompression(String networkType) {
public synchronized boolean useCompression(NetworkType networkType) {
Boolean useCompression = compressionMap.get(networkType);
if (useCompression == null) {
return true;
@ -1326,13 +1304,13 @@ public class Account implements BaseAccount, StoreConfig {
}
public boolean useCompression(int type) {
String networkType = TYPE_OTHER;
NetworkType networkType = NetworkType.OTHER;
switch (type) {
case ConnectivityManager.TYPE_MOBILE:
networkType = TYPE_MOBILE;
networkType = NetworkType.MOBILE;
break;
case ConnectivityManager.TYPE_WIFI:
networkType = TYPE_WIFI;
networkType = NetworkType.WIFI;
break;
}
return useCompression(networkType);

View file

@ -339,18 +339,18 @@ public class K9 extends Application {
public static class Intents {
public static class EmailReceived {
public static final String ACTION_EMAIL_RECEIVED = "com.fsck.k9.intent.action.EMAIL_RECEIVED";
public static final String ACTION_EMAIL_DELETED = "com.fsck.k9.intent.action.EMAIL_DELETED";
public static final String ACTION_REFRESH_OBSERVER = "com.fsck.k9.intent.action.REFRESH_OBSERVER";
public static final String EXTRA_ACCOUNT = "com.fsck.k9.intent.extra.ACCOUNT";
public static final String EXTRA_FOLDER = "com.fsck.k9.intent.extra.FOLDER";
public static final String EXTRA_SENT_DATE = "com.fsck.k9.intent.extra.SENT_DATE";
public static final String EXTRA_FROM = "com.fsck.k9.intent.extra.FROM";
public static final String EXTRA_TO = "com.fsck.k9.intent.extra.TO";
public static final String EXTRA_CC = "com.fsck.k9.intent.extra.CC";
public static final String EXTRA_BCC = "com.fsck.k9.intent.extra.BCC";
public static final String EXTRA_SUBJECT = "com.fsck.k9.intent.extra.SUBJECT";
public static final String EXTRA_FROM_SELF = "com.fsck.k9.intent.extra.FROM_SELF";
public static final String ACTION_EMAIL_RECEIVED = BuildConfig.APPLICATION_ID + ".intent.action.EMAIL_RECEIVED";
public static final String ACTION_EMAIL_DELETED = BuildConfig.APPLICATION_ID + ".intent.action.EMAIL_DELETED";
public static final String ACTION_REFRESH_OBSERVER = BuildConfig.APPLICATION_ID + ".intent.action.REFRESH_OBSERVER";
public static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".intent.extra.ACCOUNT";
public static final String EXTRA_FOLDER = BuildConfig.APPLICATION_ID + ".intent.extra.FOLDER";
public static final String EXTRA_SENT_DATE = BuildConfig.APPLICATION_ID + ".intent.extra.SENT_DATE";
public static final String EXTRA_FROM = BuildConfig.APPLICATION_ID + ".intent.extra.FROM";
public static final String EXTRA_TO = BuildConfig.APPLICATION_ID + ".intent.extra.TO";
public static final String EXTRA_CC = BuildConfig.APPLICATION_ID + ".intent.extra.CC";
public static final String EXTRA_BCC = BuildConfig.APPLICATION_ID + ".intent.extra.BCC";
public static final String EXTRA_SUBJECT = BuildConfig.APPLICATION_ID + ".intent.extra.SUBJECT";
public static final String EXTRA_FROM_SELF = BuildConfig.APPLICATION_ID + ".intent.extra.FROM_SELF";
}
public static class Share {
@ -359,7 +359,7 @@ public class K9 extends Application {
* because of different semantics (String array vs. string with comma separated
* email addresses)
*/
public static final String EXTRA_FROM = "com.fsck.k9.intent.extra.SENDER";
public static final String EXTRA_FROM = BuildConfig.APPLICATION_ID + ".intent.extra.SENDER";
}
}

View file

@ -70,6 +70,7 @@ public class Preferences {
/**
* Returns an array of the accounts on the system. If no accounts are
* registered the method returns an empty array.
*
* @return all accounts
*/
public synchronized List<Account> getAccounts() {
@ -83,6 +84,7 @@ public class Preferences {
/**
* Returns an array of the accounts on the system. If no accounts are
* registered the method returns an empty array.
*
* @return all accounts with {@link Account#isAvailable(Context)}
*/
public synchronized Collection<Account> getAvailableAccounts() {
@ -164,4 +166,21 @@ public class Preferences {
public SharedPreferences getPreferences() {
return mStorage;
}
public static <T extends Enum<T>> T getEnumStringPref(SharedPreferences prefs, String key, T defaultEnum) {
String stringPref = prefs.getString(key, null);
if (stringPref == null) {
return defaultEnum;
} else {
try {
return Enum.valueOf(defaultEnum.getDeclaringClass(), stringPref);
} catch (IllegalArgumentException ex) {
Log.w(K9.LOG_TAG, "Unable to convert preference key [" + key +
"] value [" + stringPref + "] to enum of type " + defaultEnum.getDeclaringClass(), ex);
return defaultEnum;
}
}
}
}

View file

@ -1,7 +1,6 @@
package com.fsck.k9.activity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.os.AsyncTask;

View file

@ -17,7 +17,6 @@ import com.fsck.k9.R;
public class ManageIdentities extends ChooseIdentity {
private boolean mIdentitiesChanged = false;
public static final String EXTRA_IDENTITIES = "com.fsck.k9.EditIdentity_identities";
private static final int ACTIVITY_EDIT_IDENTITY = 1;

View file

@ -23,8 +23,13 @@ import android.preference.RingtonePreference;
import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.Account.DeletePolicy;
import com.fsck.k9.Account.Expunge;
import com.fsck.k9.Account.FolderMode;
import com.fsck.k9.Account.MessageFormat;
import com.fsck.k9.Account.QuoteStyle;
import com.fsck.k9.Account.Searchable;
import com.fsck.k9.Account.ShowPictures;
import com.fsck.k9.K9;
import com.fsck.k9.NotificationSetting;
import com.fsck.k9.Preferences;
@ -353,9 +358,9 @@ public class AccountSettings extends K9PreferenceActivity {
mDeletePolicy = (ListPreference) findPreference(PREFERENCE_DELETE_POLICY);
if (!mIsSeenFlagSupported) {
removeListEntry(mDeletePolicy, Integer.toString(Account.DELETE_POLICY_MARK_AS_READ));
removeListEntry(mDeletePolicy, DeletePolicy.MARK_AS_READ.preferenceString());
}
mDeletePolicy.setValue(Integer.toString(mAccount.getDeletePolicy()));
mDeletePolicy.setValue(mAccount.getDeletePolicy().preferenceString());
mDeletePolicy.setSummary(mDeletePolicy.getEntry());
mDeletePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
@ -370,7 +375,7 @@ public class AccountSettings extends K9PreferenceActivity {
mExpungePolicy = (ListPreference) findPreference(PREFERENCE_EXPUNGE_POLICY);
if (mIsExpungeCapable) {
mExpungePolicy.setValue(mAccount.getExpungePolicy());
mExpungePolicy.setValue(mAccount.getExpungePolicy().name());
mExpungePolicy.setSummary(mExpungePolicy.getEntry());
mExpungePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
@ -729,7 +734,7 @@ public class AccountSettings extends K9PreferenceActivity {
mAccount.setDescription(mAccountDescription.getText());
mAccount.setMarkMessageAsReadOnView(mMarkMessageAsReadOnView.isChecked());
mAccount.setNotifyNewMail(mAccountNotify.isChecked());
mAccount.setFolderNotifyNewMailMode(Account.FolderMode.valueOf(mAccountNotifyNewMailMode.getValue()));
mAccount.setFolderNotifyNewMailMode(FolderMode.valueOf(mAccountNotifyNewMailMode.getValue()));
mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked());
mAccount.setShowOngoing(mAccountNotifySync.isChecked());
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
@ -742,14 +747,14 @@ public class AccountSettings extends K9PreferenceActivity {
mAccount.getNotificationSetting().setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getValue()));
mAccount.getNotificationSetting().setLed(mAccountLed.isChecked());
mAccount.setGoToUnreadMessageSearch(mNotificationOpensUnread.isChecked());
mAccount.setFolderTargetMode(Account.FolderMode.valueOf(mTargetMode.getValue()));
mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue()));
mAccount.setFolderTargetMode(FolderMode.valueOf(mTargetMode.getValue()));
mAccount.setDeletePolicy(DeletePolicy.fromInt(Integer.parseInt(mDeletePolicy.getValue())));
if (mIsExpungeCapable) {
mAccount.setExpungePolicy(mExpungePolicy.getValue());
mAccount.setExpungePolicy(Expunge.valueOf(mExpungePolicy.getValue()));
}
mAccount.setSyncRemoteDeletions(mSyncRemoteDeletions.isChecked());
mAccount.setSearchableFolders(Account.Searchable.valueOf(mSearchableFolders.getValue()));
mAccount.setMessageFormat(Account.MessageFormat.valueOf(mMessageFormat.getValue()));
mAccount.setSearchableFolders(Searchable.valueOf(mSearchableFolders.getValue()));
mAccount.setMessageFormat(MessageFormat.valueOf(mMessageFormat.getValue()));
mAccount.setAlwaysShowCcBcc(mAlwaysShowCcBcc.isChecked());
mAccount.setMessageReadReceipt(mMessageReadReceipt.isChecked());
mAccount.setQuoteStyle(QuoteStyle.valueOf(mQuoteStyle.getValue()));
@ -788,9 +793,9 @@ public class AccountSettings extends K9PreferenceActivity {
}
boolean needsRefresh = mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue()));
needsRefresh |= mAccount.setFolderSyncMode(Account.FolderMode.valueOf(mSyncMode.getValue()));
needsRefresh |= mAccount.setFolderSyncMode(FolderMode.valueOf(mSyncMode.getValue()));
boolean displayModeChanged = mAccount.setFolderDisplayMode(Account.FolderMode.valueOf(mDisplayMode.getValue()));
boolean displayModeChanged = mAccount.setFolderDisplayMode(FolderMode.valueOf(mDisplayMode.getValue()));
SharedPreferences prefs = mAccountRingtone.getPreferenceManager().getSharedPreferences();
String newRingtone = prefs.getString(PREFERENCE_RINGTONE, null);
@ -803,11 +808,11 @@ public class AccountSettings extends K9PreferenceActivity {
}
}
mAccount.setShowPictures(Account.ShowPictures.valueOf(mAccountShowPictures.getValue()));
mAccount.setShowPictures(ShowPictures.valueOf(mAccountShowPictures.getValue()));
//IMAP specific stuff
if (mIsPushCapable) {
boolean needsPushRestart = mAccount.setFolderPushMode(Account.FolderMode.valueOf(mPushMode.getValue()));
boolean needsPushRestart = mAccount.setFolderPushMode(FolderMode.valueOf(mPushMode.getValue()));
if (mAccount.getFolderPushMode() != FolderMode.NONE) {
needsPushRestart |= displayModeChanged;
needsPushRestart |= mIncomingChanged;

View file

@ -7,7 +7,6 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
@ -41,9 +40,9 @@ public class AccountSetupAccountType extends K9Activity implements OnClickListen
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.account_setup_account_type);
((Button)findViewById(R.id.pop)).setOnClickListener(this);
((Button)findViewById(R.id.imap)).setOnClickListener(this);
((Button)findViewById(R.id.webdav)).setOnClickListener(this);
findViewById(R.id.pop).setOnClickListener(this);
findViewById(R.id.imap).setOnClickListener(this);
findViewById(R.id.webdav).setOnClickListener(this);
String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);

View file

@ -27,6 +27,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import com.fsck.k9.Account;
import com.fsck.k9.Account.DeletePolicy;
import com.fsck.k9.EmailAddressValidator;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
@ -331,9 +332,9 @@ public class AccountSetupBasics extends K9Activity
}
mAccount.setSentFolderName(getString(R.string.special_mailbox_name_sent));
if (incomingUri.toString().startsWith("imap")) {
mAccount.setDeletePolicy(Account.DELETE_POLICY_ON_DELETE);
mAccount.setDeletePolicy(DeletePolicy.ON_DELETE);
} else if (incomingUri.toString().startsWith("pop3")) {
mAccount.setDeletePolicy(Account.DELETE_POLICY_NEVER);
mAccount.setDeletePolicy(DeletePolicy.NEVER);
}
// Check incoming here. Then check outgoing in onActivityResult()
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);

View file

@ -16,7 +16,9 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.CompoundButton.OnCheckedChangeListener;
import com.fsck.k9.*;
import com.fsck.k9.Account.DeletePolicy;
import com.fsck.k9.Account.FolderMode;
import com.fsck.k9.Account.NetworkType;
import com.fsck.k9.activity.K9Activity;
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
import com.fsck.k9.helper.Utility;
@ -200,7 +202,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
findViewById(R.id.compression_section).setVisibility(View.GONE);
findViewById(R.id.compression_label).setVisibility(View.GONE);
mSubscribedFoldersOnly.setVisibility(View.GONE);
mAccount.setDeletePolicy(Account.DELETE_POLICY_NEVER);
mAccount.setDeletePolicy(DeletePolicy.NEVER);
} else if (ImapStore.STORE_TYPE.equals(settings.type)) {
serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);
mDefaultPort = IMAP_PORT;
@ -217,7 +219,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
mAccount.setDeletePolicy(Account.DELETE_POLICY_ON_DELETE);
mAccount.setDeletePolicy(DeletePolicy.ON_DELETE);
if (!Intent.ACTION_EDIT.equals(getIntent().getAction())) {
findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
@ -251,7 +253,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
if (webDavSettings.mailboxPath != null) {
mWebdavMailboxPathView.setText(webDavSettings.mailboxPath);
}
mAccount.setDeletePolicy(Account.DELETE_POLICY_ON_DELETE);
mAccount.setDeletePolicy(DeletePolicy.ON_DELETE);
} else {
throw new Exception("Unknown account type: " + mAccount.getStoreUri());
}
@ -280,9 +282,9 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
updateAuthPlainTextFromSecurityType(settings.connectionSecurity);
mCompressionMobile.setChecked(mAccount.useCompression(Account.TYPE_MOBILE));
mCompressionWifi.setChecked(mAccount.useCompression(Account.TYPE_WIFI));
mCompressionOther.setChecked(mAccount.useCompression(Account.TYPE_OTHER));
mCompressionMobile.setChecked(mAccount.useCompression(NetworkType.MOBILE));
mCompressionWifi.setChecked(mAccount.useCompression(NetworkType.WIFI));
mCompressionOther.setChecked(mAccount.useCompression(NetworkType.OTHER));
if (settings.host != null) {
mServerView.setText(settings.host);
@ -607,9 +609,9 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
mAccount.setStoreUri(RemoteStore.createStoreUri(settings));
mAccount.setCompression(Account.TYPE_MOBILE, mCompressionMobile.isChecked());
mAccount.setCompression(Account.TYPE_WIFI, mCompressionWifi.isChecked());
mAccount.setCompression(Account.TYPE_OTHER, mCompressionOther.isChecked());
mAccount.setCompression(NetworkType.MOBILE, mCompressionMobile.isChecked());
mAccount.setCompression(NetworkType.WIFI, mCompressionWifi.isChecked());
mAccount.setCompression(NetworkType.OTHER, mCompressionOther.isChecked());
mAccount.setSubscribedFoldersOnly(mSubscribedFoldersOnly.isChecked());
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);

View file

@ -33,8 +33,8 @@ public class WelcomeMessage extends K9Activity implements OnClickListener{
welcome.setText(HtmlConverter.htmlToSpanned(getString(R.string.accounts_welcome)));
welcome.setMovementMethod(LinkMovementMethod.getInstance());
((Button) findViewById(R.id.next)).setOnClickListener(this);
((Button) findViewById(R.id.import_settings)).setOnClickListener(this);
findViewById(R.id.next).setOnClickListener(this);
findViewById(R.id.import_settings).setOnClickListener(this);
}
@Override

View file

@ -42,6 +42,8 @@ import android.text.style.TextAppearanceSpan;
import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.Account.DeletePolicy;
import com.fsck.k9.Account.Expunge;
import com.fsck.k9.AccountStats;
import com.fsck.k9.K9;
import com.fsck.k9.K9.NotificationHideSubject;
@ -1007,7 +1009,7 @@ public class MessagingController implements Runnable {
Log.v(K9.LOG_TAG, "SYNC: About to open remote folder " + folder);
remoteFolder.open(Folder.OPEN_MODE_RW);
if (Account.EXPUNGE_ON_POLL.equals(account.getExpungePolicy())) {
if (Expunge.EXPUNGE_ON_POLL == account.getExpungePolicy()) {
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "SYNC: Expunging folder " + account.getDescription() + ":" + folder);
remoteFolder.expunge();
@ -2124,7 +2126,7 @@ public class MessagingController implements Runnable {
}
if (remoteDate != null) {
remoteMessage.setFlag(Flag.DELETED, true);
if (Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
if (Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
remoteFolder.expunge();
}
}
@ -2301,7 +2303,7 @@ public class MessagingController implements Runnable {
remoteUidMap = remoteSrcFolder.moveMessages(messages, remoteDestFolder);
}
}
if (!isCopy && Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
if (!isCopy && Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "processingPendingMoveOrCopy expunging folder " + account.getDescription() + ":" + srcFolder);
@ -4060,14 +4062,14 @@ public class MessagingController implements Runnable {
queuePendingCommand(account, command);
}
processPendingCommands(account);
} else if (account.getDeletePolicy() == Account.DELETE_POLICY_ON_DELETE) {
} else if (account.getDeletePolicy() == DeletePolicy.ON_DELETE) {
if (folder.equals(account.getTrashFolderName())) {
queueSetFlag(account, folder, Boolean.toString(true), Flag.DELETED.toString(), uids);
} else {
queueMoveOrCopy(account, folder, account.getTrashFolderName(), false, uids, uidMap);
}
processPendingCommands(account);
} else if (account.getDeletePolicy() == Account.DELETE_POLICY_MARK_AS_READ) {
} else if (account.getDeletePolicy() == DeletePolicy.MARK_AS_READ) {
queueSetFlag(account, folder, Boolean.toString(true), Flag.SEEN.toString(), uids);
processPendingCommands(account);
} else {
@ -4105,7 +4107,7 @@ public class MessagingController implements Runnable {
if (remoteFolder.exists()) {
remoteFolder.open(Folder.OPEN_MODE_RW);
remoteFolder.setFlags(Collections.singleton(Flag.DELETED), true);
if (Account.EXPUNGE_IMMEDIATELY.equals(account.getExpungePolicy())) {
if (Expunge.EXPUNGE_IMMEDIATELY == account.getExpungePolicy()) {
remoteFolder.expunge();
}

View file

@ -2072,7 +2072,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
}
if (holder.from != null ) {
holder.from.setTypeface(null, maybeBoldTypeface);
holder.from.setTypeface(holder.from.getTypeface(), maybeBoldTypeface);
if (mSenderAboveSubject) {
holder.from.setCompoundDrawablesWithIntrinsicBounds(
statusHolder, // left
@ -2095,7 +2095,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
null); // bottom
}
holder.subject.setTypeface(null, maybeBoldTypeface);
holder.subject.setTypeface(holder.subject.getTypeface(), maybeBoldTypeface);
holder.subject.setText(subject);
}

View file

@ -9,10 +9,16 @@ import java.util.TreeMap;
import android.content.SharedPreferences;
import com.fsck.k9.Account;
import com.fsck.k9.Account.DeletePolicy;
import com.fsck.k9.Account.Expunge;
import com.fsck.k9.Account.FolderMode;
import com.fsck.k9.Account.MessageFormat;
import com.fsck.k9.Account.QuoteStyle;
import com.fsck.k9.Account.Searchable;
import com.fsck.k9.Account.ShowPictures;
import com.fsck.k9.Account.SortType;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.Account.FolderMode;
import com.fsck.k9.mailstore.StorageManager;
import com.fsck.k9.preferences.Settings.*;
@ -56,7 +62,7 @@ public class AccountSettings {
new V(1, new BooleanSetting(Account.DEFAULT_QUOTED_TEXT_SHOWN))
));
s.put("deletePolicy", Settings.versions(
new V(1, new DeletePolicySetting(Account.DELETE_POLICY_NEVER))
new V(1, new DeletePolicySetting(DeletePolicy.NEVER))
));
s.put("displayCount", Settings.versions(
new V(1, new IntegerResourceSetting(K9.DEFAULT_VISIBLE_LIMIT,
@ -66,7 +72,7 @@ public class AccountSettings {
new V(1, new StringSetting("Drafts"))
));
s.put("expungePolicy", Settings.versions(
new V(1, new StringResourceSetting(Account.EXPUNGE_IMMEDIATELY,
new V(1, new StringResourceSetting(Expunge.EXPUNGE_IMMEDIATELY.name(),
R.array.account_setup_expunge_policy_values))
));
s.put("folderDisplayMode", Settings.versions(
@ -114,8 +120,8 @@ public class AccountSettings {
R.array.account_settings_message_age_values))
));
s.put("messageFormat", Settings.versions(
new V(1, new EnumSetting<Account.MessageFormat>(
Account.MessageFormat.class, Account.DEFAULT_MESSAGE_FORMAT))
new V(1, new EnumSetting<MessageFormat>(
MessageFormat.class, Account.DEFAULT_MESSAGE_FORMAT))
));
s.put("messageFormatAuto", Settings.versions(
new V(2, new BooleanSetting(Account.DEFAULT_MESSAGE_FORMAT_AUTO))
@ -142,8 +148,8 @@ public class AccountSettings {
new V(1, new StringSetting(Account.DEFAULT_QUOTE_PREFIX))
));
s.put("quoteStyle", Settings.versions(
new V(1, new EnumSetting<Account.QuoteStyle>(
Account.QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
new V(1, new EnumSetting<QuoteStyle>(
QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
));
s.put("replyAfterQuote", Settings.versions(
new V(1, new BooleanSetting(Account.DEFAULT_REPLY_AFTER_QUOTE))
@ -155,8 +161,8 @@ public class AccountSettings {
new V(1, new RingtoneSetting("content://settings/system/notification_sound"))
));
s.put("searchableFolders", Settings.versions(
new V(1, new EnumSetting<Account.Searchable>(
Account.Searchable.class, Account.Searchable.ALL))
new V(1, new EnumSetting<Searchable>(
Searchable.class, Searchable.ALL))
));
s.put("sentFolderName", Settings.versions(
new V(1, new StringSetting("Sent"))
@ -168,8 +174,8 @@ public class AccountSettings {
new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
));
s.put("showPicturesEnum", Settings.versions(
new V(1, new EnumSetting<Account.ShowPictures>(
Account.ShowPictures.class, Account.ShowPictures.NEVER))
new V(1, new EnumSetting<ShowPictures>(
ShowPictures.class, ShowPictures.NEVER))
));
s.put("signatureBeforeQuotedText", Settings.versions(
new V(1, new BooleanSetting(false))
@ -363,18 +369,15 @@ public class AccountSettings {
}
}
/**
* The delete policy setting.
*/
public static class DeletePolicySetting extends PseudoEnumSetting<Integer> {
private Map<Integer, String> mMapping;
public DeletePolicySetting(int defaultValue) {
public DeletePolicySetting(DeletePolicy defaultValue) {
super(defaultValue);
Map<Integer, String> mapping = new HashMap<Integer, String>();
mapping.put(Account.DELETE_POLICY_NEVER, "NEVER");
mapping.put(Account.DELETE_POLICY_ON_DELETE, "DELETE");
mapping.put(Account.DELETE_POLICY_MARK_AS_READ, "MARK_AS_READ");
mapping.put(DeletePolicy.NEVER.setting, "NEVER");
mapping.put(DeletePolicy.ON_DELETE.setting, "DELETE");
mapping.put(DeletePolicy.MARK_AS_READ.setting, "MARK_AS_READ");
mMapping = Collections.unmodifiableMap(mapping);
}

View file

@ -15,6 +15,7 @@ import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.BuildConfig;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.mail.MessagingException;
@ -28,7 +29,8 @@ import org.openintents.openpgp.util.ParcelFileDescriptorUtil;
* A simple ContentProvider that allows file access to attachments.
*/
public class AttachmentProvider extends ContentProvider {
public static final Uri CONTENT_URI = Uri.parse("content://com.fsck.k9.attachmentprovider");
private static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".attachmentprovider";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
private static final String[] DEFAULT_PROJECTION = new String[] {
AttachmentProviderColumns._ID,

View file

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import com.fsck.k9.Account;
import com.fsck.k9.BuildConfig;
import com.fsck.k9.Preferences;
import com.fsck.k9.cache.EmailProviderCacheCursor;
import com.fsck.k9.helper.Utility;
@ -43,7 +44,7 @@ import android.text.TextUtils;
public class EmailProvider extends ContentProvider {
private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
public static final String AUTHORITY = "com.fsck.k9.provider.email";
public static final String AUTHORITY = BuildConfig.APPLICATION_ID +".provider.email";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);

View file

@ -21,6 +21,7 @@ import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.AccountStats;
import com.fsck.k9.BuildConfig;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.activity.FolderInfoHolder;
@ -940,7 +941,7 @@ public class MessageProvider extends ContentProvider {
}
}
public static final String AUTHORITY = "com.fsck.k9.messageprovider";
public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".messageprovider";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);

View file

@ -5,6 +5,8 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import com.fsck.k9.BuildConfig;
/**
* Utillity definitions for Android applications to control the behavior of K-9 Mail. All such applications must declare the following permission:
* <uses-permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"/>
@ -24,14 +26,14 @@ public class K9RemoteControl {
* Permission that every application sending a broadcast to K-9 for Remote Control purposes should send on every broadcast.
* Prevent other applications from intercepting the broadcasts.
*/
public final static String K9_REMOTE_CONTROL_PERMISSION = "com.fsck.k9.permission.REMOTE_CONTROL";
public final static String K9_REMOTE_CONTROL_PERMISSION = BuildConfig.APPLICATION_ID + ".permission.REMOTE_CONTROL";
/**
* {@link Intent} Action to be sent to K-9 using {@link ContextWrapper.sendOrderedBroadcast} in order to fetch the list of configured Accounts.
* The responseData will contain two String[] with keys K9_ACCOUNT_UUIDS and K9_ACCOUNT_DESCRIPTIONS
*/
public final static String K9_REQUEST_ACCOUNTS = "com.fsck.k9.K9RemoteControl.requestAccounts";
public final static String K9_ACCOUNT_UUIDS = "com.fsck.k9.K9RemoteControl.accountUuids";
public final static String K9_ACCOUNT_DESCRIPTIONS = "com.fsck.k9.K9RemoteControl.accountDescriptions";
public final static String K9_REQUEST_ACCOUNTS = BuildConfig.APPLICATION_ID + ".K9RemoteControl.requestAccounts";
public final static String K9_ACCOUNT_UUIDS = BuildConfig.APPLICATION_ID + ".K9RemoteControl.accountUuids";
public final static String K9_ACCOUNT_DESCRIPTIONS = BuildConfig.APPLICATION_ID + ".K9RemoteControl.accountDescriptions";
/**
* The {@link {@link Intent}} Action to set in order to cause K-9 to check mail. (Not yet implemented)
@ -41,17 +43,17 @@ public class K9RemoteControl {
/**
* The {@link {@link Intent}} Action to set when remotely changing K-9 Mail settings
*/
public final static String K9_SET = "com.fsck.k9.K9RemoteControl.set";
public final static String K9_SET = BuildConfig.APPLICATION_ID + ".K9RemoteControl.set";
/**
* The key of the {@link Intent} Extra to set to hold the UUID of a single Account's settings to change. Used only if K9_ALL_ACCOUNTS
* is absent or false.
*/
public final static String K9_ACCOUNT_UUID = "com.fsck.k9.K9RemoteControl.accountUuid";
public final static String K9_ACCOUNT_UUID = BuildConfig.APPLICATION_ID + ".K9RemoteControl.accountUuid";
/**
* The key of the {@link Intent} Extra to set to control if the settings will apply to all Accounts, or to the one
* specified with K9_ACCOUNT_UUID
*/
public final static String K9_ALL_ACCOUNTS = "com.fsck.k9.K9RemoteControl.allAccounts";
public final static String K9_ALL_ACCOUNTS = BuildConfig.APPLICATION_ID + ".K9RemoteControl.allAccounts";
public final static String K9_ENABLED = "true";
public final static String K9_DISABLED = "false";
@ -60,17 +62,17 @@ public class K9RemoteControl {
* Key for the {@link Intent} Extra for controlling whether notifications will be generated for new unread mail.
* Acceptable values are K9_ENABLED and K9_DISABLED
*/
public final static String K9_NOTIFICATION_ENABLED = "com.fsck.k9.K9RemoteControl.notificationEnabled";
public final static String K9_NOTIFICATION_ENABLED = BuildConfig.APPLICATION_ID + ".K9RemoteControl.notificationEnabled";
/*
* Key for the {@link Intent} Extra for controlling whether K-9 will sound the ringtone for new unread mail.
* Acceptable values are K9_ENABLED and K9_DISABLED
*/
public final static String K9_RING_ENABLED = "com.fsck.k9.K9RemoteControl.ringEnabled";
public final static String K9_RING_ENABLED = BuildConfig.APPLICATION_ID + ".K9RemoteControl.ringEnabled";
/*
* Key for the {@link Intent} Extra for controlling whether K-9 will activate the vibrator for new unread mail.
* Acceptable values are K9_ENABLED and K9_DISABLED
*/
public final static String K9_VIBRATE_ENABLED = "com.fsck.k9.K9RemoteControl.vibrateEnabled";
public final static String K9_VIBRATE_ENABLED = BuildConfig.APPLICATION_ID + ".K9RemoteControl.vibrateEnabled";
public final static String K9_FOLDERS_NONE = "NONE";
public final static String K9_FOLDERS_ALL = "ALL";
@ -82,27 +84,27 @@ public class K9RemoteControl {
* Acceptable values are K9_FOLDERS_ALL, K9_FOLDERS_FIRST_CLASS, K9_FOLDERS_FIRST_AND_SECOND_CLASS,
* K9_FOLDERS_NOT_SECOND_CLASS, K9_FOLDERS_NONE
*/
public final static String K9_PUSH_CLASSES = "com.fsck.k9.K9RemoteControl.pushClasses";
public final static String K9_PUSH_CLASSES = BuildConfig.APPLICATION_ID + ".K9RemoteControl.pushClasses";
/**
* Key for the {@link Intent} Extra to set for controlling which folders to be synchronized with Poll.
* Acceptable values are K9_FOLDERS_ALL, K9_FOLDERS_FIRST_CLASS, K9_FOLDERS_FIRST_AND_SECOND_CLASS,
* K9_FOLDERS_NOT_SECOND_CLASS, K9_FOLDERS_NONE
*/
public final static String K9_POLL_CLASSES = "com.fsck.k9.K9RemoteControl.pollClasses";
public final static String K9_POLL_CLASSES = BuildConfig.APPLICATION_ID + ".K9RemoteControl.pollClasses";
public final static String[] K9_POLL_FREQUENCIES = { "-1", "1", "5", "10", "15", "30", "60", "120", "180", "360", "720", "1440"};
/**
* Key for the {@link Intent} Extra to set with the desired poll frequency. The value is a String representing a number of minutes.
* Acceptable values are available in K9_POLL_FREQUENCIES
*/
public final static String K9_POLL_FREQUENCY = "com.fsck.k9.K9RemoteControl.pollFrequency";
public final static String K9_POLL_FREQUENCY = BuildConfig.APPLICATION_ID + ".K9RemoteControl.pollFrequency";
/**
* Key for the {@link Intent} Extra to set for controlling K-9's global "Background sync" setting.
* Acceptable values are K9_BACKGROUND_OPERATIONS_ALWAYS, K9_BACKGROUND_OPERATIONS_NEVER
* K9_BACKGROUND_OPERATIONS_WHEN_CHECKED_AUTO_SYNC
*/
public final static String K9_BACKGROUND_OPERATIONS = "com.fsck.k9.K9RemoteControl.backgroundOperations";
public final static String K9_BACKGROUND_OPERATIONS = BuildConfig.APPLICATION_ID + ".K9RemoteControl.backgroundOperations";
public final static String K9_BACKGROUND_OPERATIONS_ALWAYS = "ALWAYS";
public final static String K9_BACKGROUND_OPERATIONS_NEVER = "NEVER";
public final static String K9_BACKGROUND_OPERATIONS_WHEN_CHECKED_AUTO_SYNC = "WHEN_CHECKED_AUTO_SYNC";
@ -111,7 +113,7 @@ public class K9RemoteControl {
* Key for the {@link Intent} Extra to set for controlling which display theme K-9 will use. Acceptable values are
* K9_THEME_LIGHT, K9_THEME_DARK
*/
public final static String K9_THEME = "com.fsck.k9.K9RemoteControl.theme";
public final static String K9_THEME = BuildConfig.APPLICATION_ID + ".K9RemoteControl.theme";
public final static String K9_THEME_LIGHT = "LIGHT";
public final static String K9_THEME_DARK = "DARK";

View file

@ -163,8 +163,7 @@ public class MailService extends CoreService {
}
private void cancel() {
Intent i = new Intent();
i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService");
Intent i = new Intent(this, MailService.class);
i.setAction(ACTION_CHECK_MAIL);
BootReceiver.cancelIntent(this, i);
}
@ -304,8 +303,7 @@ public class MailService extends CoreService {
Log.e(K9.LOG_TAG, "Exception while logging", e);
}
Intent i = new Intent();
i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService");
Intent i = new Intent(this, MailService.class);
i.setAction(ACTION_CHECK_MAIL);
BootReceiver.scheduleIntent(MailService.this, nextTime, i);
}
@ -410,8 +408,7 @@ public class MailService extends CoreService {
long nextTime = System.currentTimeMillis() + minInterval;
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "Next pusher refresh scheduled for " + new Date(nextTime));
Intent i = new Intent();
i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService");
Intent i = new Intent(this, MailService.class);
i.setAction(ACTION_REFRESH_PUSHERS);
BootReceiver.scheduleIntent(MailService.this, nextTime, i);
}

View file

@ -134,15 +134,13 @@ public class RemoteControlService extends CoreService {
editor.commit();
if (needsReschedule) {
Intent i = new Intent();
i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.RemoteControlService");
Intent i = new Intent(RemoteControlService.this, RemoteControlService.class);
i.setAction(RESCHEDULE_ACTION);
long nextTime = System.currentTimeMillis() + 10000;
BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i);
}
if (needsPushRestart) {
Intent i = new Intent();
i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.RemoteControlService");
Intent i = new Intent(RemoteControlService.this, RemoteControlService.class);
i.setAction(PUSH_RESTART_ACTION);
long nextTime = System.currentTimeMillis() + 10000;
BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i);

View file

@ -31,8 +31,7 @@ public class SleepService extends CoreService {
sleepDatum.reacquireLatch = new CountDownLatch(1);
sleepData.put(id, sleepDatum);
Intent i = new Intent();
i.setClassName(context.getPackageName(), "com.fsck.k9.service.SleepService");
Intent i = new Intent(context, SleepService.class);
i.putExtra(LATCH_ID, id);
i.setAction(ALARM_FIRED + "." + id);
long startTime = System.currentTimeMillis();

View file

@ -17,7 +17,7 @@
android:id="@+id/manual_setup"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selectable_item_background"
android:text="@string/account_setup_basics_manual_setup_action" />
@ -26,7 +26,7 @@
android:id="@+id/next"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selectable_item_background"
android:text="@string/next_action" />

View file

@ -17,7 +17,7 @@
android:id="@+id/import_settings"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selectable_item_background"
android:text="@string/settings_import" />
@ -26,7 +26,7 @@
android:id="@+id/next"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selectable_item_background"
android:text="@string/next_action" />