From c473ddc90a29311a1ae9863b13be6e2f1d991176 Mon Sep 17 00:00:00 2001 From: Frank Du Date: Sat, 20 Dec 2014 14:50:15 -0800 Subject: [PATCH 01/14] Make sure to keep font meta info on view recycling --- .../main/java/com/fsck/k9/fragment/MessageListFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/fragment/MessageListFragment.java b/k9mail/src/main/java/com/fsck/k9/fragment/MessageListFragment.java index c14c4fc96..bf13fcdae 100644 --- a/k9mail/src/main/java/com/fsck/k9/fragment/MessageListFragment.java +++ b/k9mail/src/main/java/com/fsck/k9/fragment/MessageListFragment.java @@ -2072,7 +2072,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener } if (holder.from != null ) { - holder.from.setTypeface(null, maybeBoldTypeface); + holder.from.setTypeface(Typeface.create(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(Typeface.create(holder.subject.getTypeface(), maybeBoldTypeface)); holder.subject.setText(subject); } From 5013f36ba4876850ee715cc295792b417da111c5 Mon Sep 17 00:00:00 2001 From: qvandekadsye Date: Fri, 13 Feb 2015 14:52:18 +0100 Subject: [PATCH 02/14] re-correcting String glitch by changing layout-height attribute --- k9mail/src/main/res/layout/wizard_setup.xml | 2 +- k9mail/src/main/res/layout/wizard_welcome.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/k9mail/src/main/res/layout/wizard_setup.xml b/k9mail/src/main/res/layout/wizard_setup.xml index 2a447e6a9..154dbb3e2 100644 --- a/k9mail/src/main/res/layout/wizard_setup.xml +++ b/k9mail/src/main/res/layout/wizard_setup.xml @@ -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" /> diff --git a/k9mail/src/main/res/layout/wizard_welcome.xml b/k9mail/src/main/res/layout/wizard_welcome.xml index 30877890e..85bb142cf 100644 --- a/k9mail/src/main/res/layout/wizard_welcome.xml +++ b/k9mail/src/main/res/layout/wizard_welcome.xml @@ -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" /> From 9df1a3ee80214f48f02dc8a9d3e01441ee37a24b Mon Sep 17 00:00:00 2001 From: cketti Date: Sun, 15 Feb 2015 17:38:10 +0100 Subject: [PATCH 03/14] Potentially avoid creating new Typeface instances --- .../main/java/com/fsck/k9/fragment/MessageListFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/fragment/MessageListFragment.java b/k9mail/src/main/java/com/fsck/k9/fragment/MessageListFragment.java index bf13fcdae..7f5a64035 100644 --- a/k9mail/src/main/java/com/fsck/k9/fragment/MessageListFragment.java +++ b/k9mail/src/main/java/com/fsck/k9/fragment/MessageListFragment.java @@ -2072,7 +2072,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener } if (holder.from != null ) { - holder.from.setTypeface(Typeface.create(holder.from.getTypeface(), 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(Typeface.create(holder.subject.getTypeface(), maybeBoldTypeface)); + holder.subject.setTypeface(holder.subject.getTypeface(), maybeBoldTypeface); holder.subject.setText(subject); } From 9b1a0b3614fb67997893c95ff6c15d03d5ac2f27 Mon Sep 17 00:00:00 2001 From: qvandekadsye Date: Mon, 16 Feb 2015 13:48:31 +0100 Subject: [PATCH 04/14] Applying "match-parent" value to "next" buttons. --- k9mail/src/main/res/layout/wizard_setup.xml | 2 +- k9mail/src/main/res/layout/wizard_welcome.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/k9mail/src/main/res/layout/wizard_setup.xml b/k9mail/src/main/res/layout/wizard_setup.xml index 154dbb3e2..a98ebdaf2 100644 --- a/k9mail/src/main/res/layout/wizard_setup.xml +++ b/k9mail/src/main/res/layout/wizard_setup.xml @@ -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" /> diff --git a/k9mail/src/main/res/layout/wizard_welcome.xml b/k9mail/src/main/res/layout/wizard_welcome.xml index 85bb142cf..8c4c83f1f 100644 --- a/k9mail/src/main/res/layout/wizard_welcome.xml +++ b/k9mail/src/main/res/layout/wizard_welcome.xml @@ -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" /> From 63047e0ac6ba3e67df4c611c15d67113052741bf Mon Sep 17 00:00:00 2001 From: Marine Date: Mon, 16 Feb 2015 15:03:11 +0100 Subject: [PATCH 05/14] remove redundant cast (Button) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit findViewById(R.id.pop) , findViewById(R.id.imap) and findViewById(R.id.webdav) are Button so it’s redundant to cast it to Button --- .../fsck/k9/activity/setup/AccountSetupAccountType.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupAccountType.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupAccountType.java index 1e07fc6c0..5bc9f4130 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupAccountType.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupAccountType.java @@ -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); From f5cac2c71f54af3efc2b1b8a5b61e8c6f2266335 Mon Sep 17 00:00:00 2001 From: Marine Date: Mon, 16 Feb 2015 15:10:34 +0100 Subject: [PATCH 06/14] remove redundant cast Button to WelcomeMessage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit findViewById(R.id.next) and findViewById(R.id.import_settings) are Button so it’s redundant to cast it to Button --- .../main/java/com/fsck/k9/activity/setup/WelcomeMessage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/WelcomeMessage.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/WelcomeMessage.java index 9c30bb0c2..afc4aabd2 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/WelcomeMessage.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/WelcomeMessage.java @@ -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 From 0d0b80f142a986b98e064acbddfad4708b01caf3 Mon Sep 17 00:00:00 2001 From: Levrifon Date: Mon, 16 Feb 2015 16:11:38 +0100 Subject: [PATCH 07/14] Added placeholder for application ID --- k9mail/src/main/AndroidManifest.xml | 38 ++++++++--------- k9mail/src/main/java/com/fsck/k9/K9.java | 26 ++++++------ .../com/fsck/k9/activity/ChooseFolder.java | 17 ++++---- .../com/fsck/k9/activity/ChooseIdentity.java | 5 ++- .../com/fsck/k9/activity/EditIdentity.java | 7 ++-- .../fsck/k9/activity/ManageIdentities.java | 3 +- .../com/fsck/k9/activity/MessageCompose.java | 41 ++++++++++--------- .../com/fsck/k9/activity/MessageList.java | 5 ++- .../k9/activity/setup/AccountSetupBasics.java | 7 ++-- .../k9/activity/setup/FolderSettings.java | 4 +- .../k9/controller/MessagingController.java | 19 +++++---- .../com/fsck/k9/provider/EmailProvider.java | 3 +- .../com/fsck/k9/provider/MessageProvider.java | 3 +- .../k9/remotecontrol/K9RemoteControl.java | 32 ++++++++------- .../com/fsck/k9/service/BootReceiver.java | 11 ++--- .../com/fsck/k9/service/CoreReceiver.java | 5 ++- .../java/com/fsck/k9/service/CoreService.java | 4 +- .../k9/service/DatabaseUpgradeService.java | 3 +- .../java/com/fsck/k9/service/MailService.java | 23 ++++++----- .../k9/service/NotificationActionService.java | 9 ++-- .../java/com/fsck/k9/service/PollService.java | 4 +- .../java/com/fsck/k9/service/PushService.java | 6 ++- .../fsck/k9/service/RemoteControlService.java | 11 ++--- .../com/fsck/k9/service/SleepService.java | 8 ++-- 24 files changed, 159 insertions(+), 135 deletions(-) diff --git a/k9mail/src/main/AndroidManifest.xml b/k9mail/src/main/AndroidManifest.xml index 16ce08390..5867dc199 100644 --- a/k9mail/src/main/AndroidManifest.xml +++ b/k9mail/src/main/AndroidManifest.xml @@ -29,36 +29,36 @@ - + - + - + - + + android:taskAffinity="${applicationId}.activity.setup.Prefs"/> + android:permission="${applicationId}.permission.REMOTE_CONTROL"> - + - + @@ -383,7 +383,7 @@ + android:permission="${applicationId}.permission.REMOTE_CONTROL"/> + android:readPermission="${applicationId}.permission.READ_ATTACHMENT"/> + android:readPermission="${applicationId}.permission.READ_MESSAGES" + android:writePermission="${applicationId}.permission.DELETE_MESSAGES"/> diff --git a/k9mail/src/main/java/com/fsck/k9/K9.java b/k9mail/src/main/java/com/fsck/k9/K9.java index 7789e6608..c4b51b4f3 100644 --- a/k9mail/src/main/java/com/fsck/k9/K9.java +++ b/k9mail/src/main/java/com/fsck/k9/K9.java @@ -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"; } } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java b/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java index 08f25ac6f..030feee9e 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java @@ -22,6 +22,7 @@ import android.widget.TextView; import com.fsck.k9.Account; import com.fsck.k9.Account.FolderMode; +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.R; @@ -31,14 +32,14 @@ import com.fsck.k9.mail.Folder; public class ChooseFolder extends K9ListActivity { - public static final String EXTRA_ACCOUNT = "com.fsck.k9.ChooseFolder_account"; - public static final String EXTRA_CUR_FOLDER = "com.fsck.k9.ChooseFolder_curfolder"; - public static final String EXTRA_SEL_FOLDER = "com.fsck.k9.ChooseFolder_selfolder"; - public static final String EXTRA_NEW_FOLDER = "com.fsck.k9.ChooseFolder_newfolder"; - public static final String EXTRA_MESSAGE = "com.fsck.k9.ChooseFolder_message"; - public static final String EXTRA_SHOW_CURRENT = "com.fsck.k9.ChooseFolder_showcurrent"; - public static final String EXTRA_SHOW_FOLDER_NONE = "com.fsck.k9.ChooseFolder_showOptionNone"; - public static final String EXTRA_SHOW_DISPLAYABLE_ONLY = "com.fsck.k9.ChooseFolder_showDisplayableOnly"; + public static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".ChooseFolder_account"; + public static final String EXTRA_CUR_FOLDER = BuildConfig.APPLICATION_ID + ".ChooseFolder_curfolder"; + public static final String EXTRA_SEL_FOLDER = BuildConfig.APPLICATION_ID + ".ChooseFolder_selfolder"; + public static final String EXTRA_NEW_FOLDER = BuildConfig.APPLICATION_ID + ".ChooseFolder_newfolder"; + public static final String EXTRA_MESSAGE = BuildConfig.APPLICATION_ID + ".ChooseFolder_message"; + public static final String EXTRA_SHOW_CURRENT = BuildConfig.APPLICATION_ID + ".ChooseFolder_showcurrent"; + public static final String EXTRA_SHOW_FOLDER_NONE = BuildConfig.APPLICATION_ID + ".ChooseFolder_showOptionNone"; + public static final String EXTRA_SHOW_DISPLAYABLE_ONLY = BuildConfig.APPLICATION_ID + ".ChooseFolder_showDisplayableOnly"; String mFolder; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/ChooseIdentity.java b/k9mail/src/main/java/com/fsck/k9/activity/ChooseIdentity.java index 6795ea0b9..456413027 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/ChooseIdentity.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/ChooseIdentity.java @@ -10,6 +10,7 @@ import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import com.fsck.k9.Account; +import com.fsck.k9.BuildConfig; import com.fsck.k9.Identity; import com.fsck.k9.Preferences; import com.fsck.k9.R; @@ -19,8 +20,8 @@ public class ChooseIdentity extends K9ListActivity { Account mAccount; ArrayAdapter adapter; - public static final String EXTRA_ACCOUNT = "com.fsck.k9.ChooseIdentity_account"; - public static final String EXTRA_IDENTITY = "com.fsck.k9.ChooseIdentity_identity"; + public static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".ChooseIdentity_account"; + public static final String EXTRA_IDENTITY = BuildConfig.APPLICATION_ID + ".ChooseIdentity_identity"; protected List identities = null; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/EditIdentity.java b/k9mail/src/main/java/com/fsck/k9/activity/EditIdentity.java index bf9eeced8..8050643a2 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/EditIdentity.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/EditIdentity.java @@ -7,6 +7,7 @@ import android.widget.CompoundButton; import android.widget.EditText; import android.widget.LinearLayout; import com.fsck.k9.Account; +import com.fsck.k9.BuildConfig; import com.fsck.k9.Identity; import com.fsck.k9.Preferences; import com.fsck.k9.R; @@ -14,9 +15,9 @@ import java.util.List; public class EditIdentity extends K9Activity { - public static final String EXTRA_IDENTITY = "com.fsck.k9.EditIdentity_identity"; - public static final String EXTRA_IDENTITY_INDEX = "com.fsck.k9.EditIdentity_identity_index"; - public static final String EXTRA_ACCOUNT = "com.fsck.k9.EditIdentity_account"; + public static final String EXTRA_IDENTITY = BuildConfig.APPLICATION_ID + ".EditIdentity_identity"; + public static final String EXTRA_IDENTITY_INDEX = BuildConfig.APPLICATION_ID + ".EditIdentity_identity_index"; + public static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".EditIdentity_account"; private Account mAccount; private Identity mIdentity; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/ManageIdentities.java b/k9mail/src/main/java/com/fsck/k9/activity/ManageIdentities.java index a808c89b4..2eb539254 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/ManageIdentities.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/ManageIdentities.java @@ -11,13 +11,14 @@ import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.ListView; import android.widget.Toast; +import com.fsck.k9.BuildConfig; import com.fsck.k9.Identity; import com.fsck.k9.Preferences; 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"; + public static final String EXTRA_IDENTITIES = BuildConfig.APPLICATION_ID + ".EditIdentity_identities"; private static final int ACTIVITY_EDIT_IDENTITY = 1; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java index 0129b82e1..b93030eec 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java @@ -72,6 +72,7 @@ import android.widget.Toast; import com.fsck.k9.Account; import com.fsck.k9.Account.MessageFormat; import com.fsck.k9.Account.QuoteStyle; +import com.fsck.k9.BuildConfig; import com.fsck.k9.EmailAddressAdapter; import com.fsck.k9.EmailAddressValidator; import com.fsck.k9.FontSizes; @@ -135,41 +136,41 @@ public class MessageCompose extends K9Activity implements OnClickListener, private static final long INVALID_DRAFT_ID = MessagingController.INVALID_MESSAGE_ID; - private static final String ACTION_COMPOSE = "com.fsck.k9.intent.action.COMPOSE"; - private static final String ACTION_REPLY = "com.fsck.k9.intent.action.REPLY"; - private static final String ACTION_REPLY_ALL = "com.fsck.k9.intent.action.REPLY_ALL"; - private static final String ACTION_FORWARD = "com.fsck.k9.intent.action.FORWARD"; - private static final String ACTION_EDIT_DRAFT = "com.fsck.k9.intent.action.EDIT_DRAFT"; + private static final String ACTION_COMPOSE = BuildConfig.APPLICATION_ID + ".intent.action.COMPOSE"; + private static final String ACTION_REPLY = BuildConfig.APPLICATION_ID + ".intent.action.REPLY"; + private static final String ACTION_REPLY_ALL = BuildConfig.APPLICATION_ID + ".intent.action.REPLY_ALL"; + private static final String ACTION_FORWARD = BuildConfig.APPLICATION_ID + ".intent.action.FORWARD"; + private static final String ACTION_EDIT_DRAFT = BuildConfig.APPLICATION_ID + ".intent.action.EDIT_DRAFT"; private static final String EXTRA_ACCOUNT = "account"; private static final String EXTRA_MESSAGE_BODY = "messageBody"; private static final String EXTRA_MESSAGE_REFERENCE = "message_reference"; private static final String STATE_KEY_ATTACHMENTS = - "com.fsck.k9.activity.MessageCompose.attachments"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.attachments"; private static final String STATE_KEY_CC_SHOWN = - "com.fsck.k9.activity.MessageCompose.ccShown"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.ccShown"; private static final String STATE_KEY_BCC_SHOWN = - "com.fsck.k9.activity.MessageCompose.bccShown"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.bccShown"; private static final String STATE_KEY_QUOTED_TEXT_MODE = - "com.fsck.k9.activity.MessageCompose.QuotedTextShown"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.QuotedTextShown"; private static final String STATE_KEY_SOURCE_MESSAGE_PROCED = - "com.fsck.k9.activity.MessageCompose.stateKeySourceMessageProced"; - private static final String STATE_KEY_DRAFT_ID = "com.fsck.k9.activity.MessageCompose.draftId"; - private static final String STATE_KEY_HTML_QUOTE = "com.fsck.k9.activity.MessageCompose.HTMLQuote"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.stateKeySourceMessageProced"; + private static final String STATE_KEY_DRAFT_ID = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.draftId"; + private static final String STATE_KEY_HTML_QUOTE = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.HTMLQuote"; private static final String STATE_IDENTITY_CHANGED = - "com.fsck.k9.activity.MessageCompose.identityChanged"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.identityChanged"; private static final String STATE_IDENTITY = - "com.fsck.k9.activity.MessageCompose.identity"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.identity"; private static final String STATE_PGP_DATA = "pgpData"; - private static final String STATE_IN_REPLY_TO = "com.fsck.k9.activity.MessageCompose.inReplyTo"; - private static final String STATE_REFERENCES = "com.fsck.k9.activity.MessageCompose.references"; - private static final String STATE_KEY_READ_RECEIPT = "com.fsck.k9.activity.MessageCompose.messageReadReceipt"; - private static final String STATE_KEY_DRAFT_NEEDS_SAVING = "com.fsck.k9.activity.MessageCompose.mDraftNeedsSaving"; + private static final String STATE_IN_REPLY_TO = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.inReplyTo"; + private static final String STATE_REFERENCES = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.references"; + private static final String STATE_KEY_READ_RECEIPT = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.messageReadReceipt"; + private static final String STATE_KEY_DRAFT_NEEDS_SAVING = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.mDraftNeedsSaving"; private static final String STATE_KEY_FORCE_PLAIN_TEXT = - "com.fsck.k9.activity.MessageCompose.forcePlainText"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.forcePlainText"; private static final String STATE_KEY_QUOTED_TEXT_FORMAT = - "com.fsck.k9.activity.MessageCompose.quotedTextFormat"; + BuildConfig.APPLICATION_ID + ".activity.MessageCompose.quotedTextFormat"; private static final String STATE_KEY_NUM_ATTACHMENTS_LOADING = "numAttachmentsLoading"; private static final String STATE_KEY_WAITING_FOR_ATTACHMENTS = "waitingForAttachments"; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java b/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java index 2d75c1633..d93f1a810 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java @@ -29,6 +29,7 @@ import android.widget.Toast; import com.fsck.k9.Account; import com.fsck.k9.Account.SortType; +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.K9.SplitViewMode; import com.fsck.k9.Preferences; @@ -78,8 +79,8 @@ public class MessageList extends K9Activity implements MessageListFragmentListen private static final String EXTRA_MESSAGE_REFERENCE = "message_reference"; // used for remote search - public static final String EXTRA_SEARCH_ACCOUNT = "com.fsck.k9.search_account"; - private static final String EXTRA_SEARCH_FOLDER = "com.fsck.k9.search_folder"; + public static final String EXTRA_SEARCH_ACCOUNT = BuildConfig.APPLICATION_ID + ".search_account"; + private static final String EXTRA_SEARCH_FOLDER = BuildConfig.APPLICATION_ID + ".search_folder"; private static final String STATE_DISPLAY_MODE = "displayMode"; private static final String STATE_MESSAGE_LIST_WAS_DISPLAYED = "messageListWasDisplayed"; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java index a0c129541..18ea93de3 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java @@ -27,6 +27,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.EditText; import com.fsck.k9.Account; +import com.fsck.k9.BuildConfig; import com.fsck.k9.EmailAddressValidator; import com.fsck.k9.K9; import com.fsck.k9.Preferences; @@ -54,12 +55,12 @@ import com.fsck.k9.view.ClientCertificateSpinner.OnClientCertificateChangedListe */ public class AccountSetupBasics extends K9Activity implements OnClickListener, TextWatcher, OnCheckedChangeListener, OnClientCertificateChangedListener { - private final static String EXTRA_ACCOUNT = "com.fsck.k9.AccountSetupBasics.account"; + private final static String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".AccountSetupBasics.account"; private final static int DIALOG_NOTE = 1; private final static String STATE_KEY_PROVIDER = - "com.fsck.k9.AccountSetupBasics.provider"; + BuildConfig.APPLICATION_ID + ".AccountSetupBasics.provider"; private final static String STATE_KEY_CHECKED_INCOMING = - "com.fsck.k9.AccountSetupBasics.checkedIncoming"; + BuildConfig.APPLICATION_ID + ".AccountSetupBasics.checkedIncoming"; private EditText mEmailView; private EditText mPasswordView; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/FolderSettings.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/FolderSettings.java index 737e2ffc3..4ddb3b05d 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/FolderSettings.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/FolderSettings.java @@ -22,8 +22,8 @@ import com.fsck.k9.service.MailService; public class FolderSettings extends K9PreferenceActivity { - private static final String EXTRA_FOLDER_NAME = "com.fsck.k9.folderName"; - private static final String EXTRA_ACCOUNT = "com.fsck.k9.account"; + private static final String EXTRA_FOLDER_NAME = BuildConfig.APPLICATION_ID + ".folderName"; + private static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".account"; private static final String PREFERENCE_TOP_CATERGORY = "folder_settings"; private static final String PREFERENCE_DISPLAY_CLASS = "folder_settings_folder_display_mode"; diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java index 8d0dd8f20..0ef3b354d 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -43,6 +43,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.K9.NotificationHideSubject; import com.fsck.k9.K9.Intents; @@ -140,15 +141,15 @@ public class MessagingController implements Runnable { * So 25k gives good performance and a reasonable data footprint. Sounds good to me. */ - private static final String PENDING_COMMAND_MOVE_OR_COPY = "com.fsck.k9.MessagingController.moveOrCopy"; - private static final String PENDING_COMMAND_MOVE_OR_COPY_BULK = "com.fsck.k9.MessagingController.moveOrCopyBulk"; - private static final String PENDING_COMMAND_MOVE_OR_COPY_BULK_NEW = "com.fsck.k9.MessagingController.moveOrCopyBulkNew"; - private static final String PENDING_COMMAND_EMPTY_TRASH = "com.fsck.k9.MessagingController.emptyTrash"; - private static final String PENDING_COMMAND_SET_FLAG_BULK = "com.fsck.k9.MessagingController.setFlagBulk"; - private static final String PENDING_COMMAND_SET_FLAG = "com.fsck.k9.MessagingController.setFlag"; - private static final String PENDING_COMMAND_APPEND = "com.fsck.k9.MessagingController.append"; - private static final String PENDING_COMMAND_MARK_ALL_AS_READ = "com.fsck.k9.MessagingController.markAllAsRead"; - private static final String PENDING_COMMAND_EXPUNGE = "com.fsck.k9.MessagingController.expunge"; + private static final String PENDING_COMMAND_MOVE_OR_COPY = BuildConfig.APPLICATION_ID + ".MessagingController.moveOrCopy"; + private static final String PENDING_COMMAND_MOVE_OR_COPY_BULK = BuildConfig.APPLICATION_ID + ".MessagingController.moveOrCopyBulk"; + private static final String PENDING_COMMAND_MOVE_OR_COPY_BULK_NEW = BuildConfig.APPLICATION_ID + ".MessagingController.moveOrCopyBulkNew"; + private static final String PENDING_COMMAND_EMPTY_TRASH = BuildConfig.APPLICATION_ID + ".MessagingController.emptyTrash"; + private static final String PENDING_COMMAND_SET_FLAG_BULK = BuildConfig.APPLICATION_ID + ".MessagingController.setFlagBulk"; + private static final String PENDING_COMMAND_SET_FLAG = BuildConfig.APPLICATION_ID + ".MessagingController.setFlag"; + private static final String PENDING_COMMAND_APPEND = BuildConfig.APPLICATION_ID + ".MessagingController.append"; + private static final String PENDING_COMMAND_MARK_ALL_AS_READ = BuildConfig.APPLICATION_ID + ".MessagingController.markAllAsRead"; + private static final String PENDING_COMMAND_EXPUNGE = BuildConfig.APPLICATION_ID + ".MessagingController.expunge"; public static class UidReverseComparator implements Comparator { @Override diff --git a/k9mail/src/main/java/com/fsck/k9/provider/EmailProvider.java b/k9mail/src/main/java/com/fsck/k9/provider/EmailProvider.java index d599f4ac7..87c9b69fa 100644 --- a/k9mail/src/main/java/com/fsck/k9/provider/EmailProvider.java +++ b/k9mail/src/main/java/com/fsck/k9/provider/EmailProvider.java @@ -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); diff --git a/k9mail/src/main/java/com/fsck/k9/provider/MessageProvider.java b/k9mail/src/main/java/com/fsck/k9/provider/MessageProvider.java index 2917eab0b..f6fb010e8 100644 --- a/k9mail/src/main/java/com/fsck/k9/provider/MessageProvider.java +++ b/k9mail/src/main/java/com/fsck/k9/provider/MessageProvider.java @@ -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); diff --git a/k9mail/src/main/java/com/fsck/k9/remotecontrol/K9RemoteControl.java b/k9mail/src/main/java/com/fsck/k9/remotecontrol/K9RemoteControl.java index 754ba8e25..b5fa15cba 100644 --- a/k9mail/src/main/java/com/fsck/k9/remotecontrol/K9RemoteControl.java +++ b/k9mail/src/main/java/com/fsck/k9/remotecontrol/K9RemoteControl.java @@ -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: * @@ -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"; diff --git a/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java b/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java index dec7cb1ef..e856eeb6b 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java +++ b/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java @@ -11,16 +11,17 @@ import android.net.ConnectivityManager; import android.net.Uri; import android.util.Log; +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; public class BootReceiver extends CoreReceiver { - public static final String FIRE_INTENT = "com.fsck.k9.service.BroadcastReceiver.fireIntent"; - public static final String SCHEDULE_INTENT = "com.fsck.k9.service.BroadcastReceiver.scheduleIntent"; - public static final String CANCEL_INTENT = "com.fsck.k9.service.BroadcastReceiver.cancelIntent"; + public static final String FIRE_INTENT = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.fireIntent"; + public static final String SCHEDULE_INTENT = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.scheduleIntent"; + public static final String CANCEL_INTENT = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.cancelIntent"; - public static final String ALARMED_INTENT = "com.fsck.k9.service.BroadcastReceiver.pendingIntent"; - public static final String AT_TIME = "com.fsck.k9.service.BroadcastReceiver.atTime"; + public static final String ALARMED_INTENT = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.pendingIntent"; + public static final String AT_TIME = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.atTime"; @Override public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) { diff --git a/k9mail/src/main/java/com/fsck/k9/service/CoreReceiver.java b/k9mail/src/main/java/com/fsck/k9/service/CoreReceiver.java index 50b899f2f..c7195e1e1 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/CoreReceiver.java +++ b/k9mail/src/main/java/com/fsck/k9/service/CoreReceiver.java @@ -10,15 +10,16 @@ import android.content.Intent; import android.os.PowerManager; import android.util.Log; +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.mail.power.TracingPowerManager; import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock; public class CoreReceiver extends BroadcastReceiver { - public static final String WAKE_LOCK_RELEASE = "com.fsck.k9.service.CoreReceiver.wakeLockRelease"; + public static final String WAKE_LOCK_RELEASE = BuildConfig.APPLICATION_ID + ".service.CoreReceiver.wakeLockRelease"; - public static final String WAKE_LOCK_ID = "com.fsck.k9.service.CoreReceiver.wakeLockId"; + public static final String WAKE_LOCK_ID = BuildConfig.APPLICATION_ID + ".service.CoreReceiver.wakeLockId"; private static ConcurrentHashMap wakeLocks = new ConcurrentHashMap(); private static AtomicInteger wakeLockSeq = new AtomicInteger(0); diff --git a/k9mail/src/main/java/com/fsck/k9/service/CoreService.java b/k9mail/src/main/java/com/fsck/k9/service/CoreService.java index 0ed8a496c..54e53887c 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/CoreService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/CoreService.java @@ -12,6 +12,8 @@ import android.content.Intent; import android.os.IBinder; import android.os.PowerManager; import android.util.Log; + +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.controller.MessagingController; import com.fsck.k9.mail.power.TracingPowerManager; @@ -57,7 +59,7 @@ import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock; */ public abstract class CoreService extends Service { - public static final String WAKE_LOCK_ID = "com.fsck.k9.service.CoreService.wakeLockId"; + public static final String WAKE_LOCK_ID = BuildConfig.APPLICATION_ID + ".service.CoreService.wakeLockId"; private static ConcurrentHashMap sWakeLocks = new ConcurrentHashMap(); diff --git a/k9mail/src/main/java/com/fsck/k9/service/DatabaseUpgradeService.java b/k9mail/src/main/java/com/fsck/k9/service/DatabaseUpgradeService.java index fd89659e8..4fc5dd86d 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/DatabaseUpgradeService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/DatabaseUpgradeService.java @@ -12,6 +12,7 @@ import android.support.v4.content.LocalBroadcastManager; 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.activity.UpgradeDatabases; @@ -69,7 +70,7 @@ public class DatabaseUpgradeService extends Service { * Action used to start this service. */ private static final String ACTION_START_SERVICE = - "com.fsck.k9.service.DatabaseUpgradeService.startService"; + BuildConfig.APPLICATION_ID + ".service.DatabaseUpgradeService.startService"; private static final String WAKELOCK_TAG = "DatabaseUpgradeService"; private static final long WAKELOCK_TIMEOUT = 10 * 60 * 1000; // 10 minutes diff --git a/k9mail/src/main/java/com/fsck/k9/service/MailService.java b/k9mail/src/main/java/com/fsck/k9/service/MailService.java index 6a1fde5b0..971c11781 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/MailService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/MailService.java @@ -12,6 +12,7 @@ import android.os.IBinder; 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.Account.FolderMode; @@ -20,14 +21,14 @@ import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.Pusher; public class MailService extends CoreService { - private static final String ACTION_CHECK_MAIL = "com.fsck.k9.intent.action.MAIL_SERVICE_WAKEUP"; - private static final String ACTION_RESET = "com.fsck.k9.intent.action.MAIL_SERVICE_RESET"; - private static final String ACTION_RESCHEDULE_POLL = "com.fsck.k9.intent.action.MAIL_SERVICE_RESCHEDULE_POLL"; - private static final String ACTION_CANCEL = "com.fsck.k9.intent.action.MAIL_SERVICE_CANCEL"; - private static final String ACTION_REFRESH_PUSHERS = "com.fsck.k9.intent.action.MAIL_SERVICE_REFRESH_PUSHERS"; - private static final String ACTION_RESTART_PUSHERS = "com.fsck.k9.intent.action.MAIL_SERVICE_RESTART_PUSHERS"; - private static final String CONNECTIVITY_CHANGE = "com.fsck.k9.intent.action.MAIL_SERVICE_CONNECTIVITY_CHANGE"; - private static final String CANCEL_CONNECTIVITY_NOTICE = "com.fsck.k9.intent.action.MAIL_SERVICE_CANCEL_CONNECTIVITY_NOTICE"; + private static final String ACTION_CHECK_MAIL = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_WAKEUP"; + private static final String ACTION_RESET = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_RESET"; + private static final String ACTION_RESCHEDULE_POLL = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_RESCHEDULE_POLL"; + private static final String ACTION_CANCEL = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_CANCEL"; + private static final String ACTION_REFRESH_PUSHERS = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_REFRESH_PUSHERS"; + private static final String ACTION_RESTART_PUSHERS = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_RESTART_PUSHERS"; + private static final String CONNECTIVITY_CHANGE = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_CONNECTIVITY_CHANGE"; + private static final String CANCEL_CONNECTIVITY_NOTICE = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_CANCEL_CONNECTIVITY_NOTICE"; private static long nextCheck = -1; private static boolean pushingRequested = false; @@ -164,7 +165,7 @@ public class MailService extends CoreService { private void cancel() { Intent i = new Intent(); - i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService"); + i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID +".service.MailService"); i.setAction(ACTION_CHECK_MAIL); BootReceiver.cancelIntent(this, i); } @@ -305,7 +306,7 @@ public class MailService extends CoreService { } Intent i = new Intent(); - i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService"); + i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID +".service.MailService"); i.setAction(ACTION_CHECK_MAIL); BootReceiver.scheduleIntent(MailService.this, nextTime, i); } @@ -411,7 +412,7 @@ public class MailService extends CoreService { 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"); + i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID +".service.MailService"); i.setAction(ACTION_REFRESH_PUSHERS); BootReceiver.scheduleIntent(MailService.this, nextTime, i); } diff --git a/k9mail/src/main/java/com/fsck/k9/service/NotificationActionService.java b/k9mail/src/main/java/com/fsck/k9/service/NotificationActionService.java index 50f14bc15..c0a0b7769 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/NotificationActionService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/NotificationActionService.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; import com.fsck.k9.Account; +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.activity.MessageCompose; @@ -19,10 +20,10 @@ import android.content.Intent; import android.util.Log; public class NotificationActionService extends CoreService { - private final static String REPLY_ACTION = "com.fsck.k9.service.NotificationActionService.REPLY_ACTION"; - private final static String READ_ALL_ACTION = "com.fsck.k9.service.NotificationActionService.READ_ALL_ACTION"; - private final static String DELETE_ALL_ACTION = "com.fsck.k9.service.NotificationActionService.DELETE_ALL_ACTION"; - private final static String ACKNOWLEDGE_ACTION = "com.fsck.k9.service.NotificationActionService.ACKNOWLEDGE_ACTION"; + private final static String REPLY_ACTION = BuildConfig.APPLICATION_ID + ".service.NotificationActionService.REPLY_ACTION"; + private final static String READ_ALL_ACTION = BuildConfig.APPLICATION_ID + ".service.NotificationActionService.READ_ALL_ACTION"; + private final static String DELETE_ALL_ACTION = BuildConfig.APPLICATION_ID + ".service.NotificationActionService.DELETE_ALL_ACTION"; + private final static String ACKNOWLEDGE_ACTION = BuildConfig.APPLICATION_ID + ".service.NotificationActionService.ACKNOWLEDGE_ACTION"; private final static String EXTRA_ACCOUNT = "account"; private final static String EXTRA_MESSAGE = "message"; diff --git a/k9mail/src/main/java/com/fsck/k9/service/PollService.java b/k9mail/src/main/java/com/fsck/k9/service/PollService.java index f47c4e3b8..6af6ba076 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/PollService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/PollService.java @@ -15,8 +15,8 @@ import java.util.HashMap; import java.util.Map; public class PollService extends CoreService { - private static String START_SERVICE = "com.fsck.k9.service.PollService.startService"; - private static String STOP_SERVICE = "com.fsck.k9.service.PollService.stopService"; + private static String START_SERVICE = BuildConfig.APPLICATION_ID + ".service.PollService.startService"; + private static String STOP_SERVICE = BuildConfig.APPLICATION_ID + ".service.PollService.stopService"; private Listener mListener = new Listener(); diff --git a/k9mail/src/main/java/com/fsck/k9/service/PushService.java b/k9mail/src/main/java/com/fsck/k9/service/PushService.java index 19de1ecf0..4f13c372a 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/PushService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/PushService.java @@ -4,11 +4,13 @@ import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; + +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; public class PushService extends CoreService { - private static String START_SERVICE = "com.fsck.k9.service.PushService.startService"; - private static String STOP_SERVICE = "com.fsck.k9.service.PushService.stopService"; + private static String START_SERVICE = BuildConfig.APPLICATION_ID + ".service.PushService.startService"; + private static String STOP_SERVICE = BuildConfig.APPLICATION_ID + ".service.PushService.stopService"; public static void startService(Context context) { Intent i = new Intent(); diff --git a/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java b/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java index e942f4d23..dcec96b6c 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java @@ -1,6 +1,7 @@ package com.fsck.k9.service; import com.fsck.k9.Account; +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.remotecontrol.K9RemoteControl; import com.fsck.k9.Preferences; @@ -20,10 +21,10 @@ import android.widget.Toast; import java.util.List; public class RemoteControlService extends CoreService { - private final static String RESCHEDULE_ACTION = "com.fsck.k9.service.RemoteControlService.RESCHEDULE_ACTION"; - private final static String PUSH_RESTART_ACTION = "com.fsck.k9.service.RemoteControlService.PUSH_RESTART_ACTION"; + private final static String RESCHEDULE_ACTION = BuildConfig.APPLICATION_ID + ".service.RemoteControlService.RESCHEDULE_ACTION"; + private final static String PUSH_RESTART_ACTION = BuildConfig.APPLICATION_ID + ".service.RemoteControlService.PUSH_RESTART_ACTION"; - private final static String SET_ACTION = "com.fsck.k9.service.RemoteControlService.SET_ACTION"; + private final static String SET_ACTION = BuildConfig.APPLICATION_ID + ".service.RemoteControlService.SET_ACTION"; public static void set(Context context, Intent i, Integer wakeLockId) { // Intent i = new Intent(); @@ -135,14 +136,14 @@ public class RemoteControlService extends CoreService { if (needsReschedule) { Intent i = new Intent(); - i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.RemoteControlService"); + i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID + ".service.RemoteControlService"); 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"); + i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID + ".service.RemoteControlService"); i.setAction(PUSH_RESTART_ACTION); long nextTime = System.currentTimeMillis() + 10000; BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i); diff --git a/k9mail/src/main/java/com/fsck/k9/service/SleepService.java b/k9mail/src/main/java/com/fsck/k9/service/SleepService.java index 937f97dc3..2d909eb20 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/SleepService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/SleepService.java @@ -3,6 +3,8 @@ package com.fsck.k9.service; import android.content.Context; import android.content.Intent; import android.util.Log; + +import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock; @@ -13,8 +15,8 @@ import java.util.concurrent.atomic.AtomicInteger; public class SleepService extends CoreService { - private static String ALARM_FIRED = "com.fsck.k9.service.SleepService.ALARM_FIRED"; - private static String LATCH_ID = "com.fsck.k9.service.SleepService.LATCH_ID_EXTRA"; + private static String ALARM_FIRED = BuildConfig.APPLICATION_ID + ".service.SleepService.ALARM_FIRED"; + private static String LATCH_ID = BuildConfig.APPLICATION_ID + ".SleepService.LATCH_ID_EXTRA"; private static ConcurrentHashMap sleepData = new ConcurrentHashMap(); @@ -32,7 +34,7 @@ public class SleepService extends CoreService { sleepData.put(id, sleepDatum); Intent i = new Intent(); - i.setClassName(context.getPackageName(), "com.fsck.k9.service.SleepService"); + i.setClassName(context.getPackageName(), BuildConfig.APPLICATION_ID + ".service.SleepService"); i.putExtra(LATCH_ID, id); i.setAction(ALARM_FIRED + "." + id); long startTime = System.currentTimeMillis(); From 80f8e4a81deddef408ed0b10d6104510b282be41 Mon Sep 17 00:00:00 2001 From: Valentin CAULIER Date: Mon, 16 Feb 2015 17:37:15 +0100 Subject: [PATCH 08/14] Removing java.util.Arrays import --- k9mail/src/main/java/com/fsck/k9/activity/AccountList.java | 1 - 1 file changed, 1 deletion(-) diff --git a/k9mail/src/main/java/com/fsck/k9/activity/AccountList.java b/k9mail/src/main/java/com/fsck/k9/activity/AccountList.java index 571dfc907..aad882323 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/AccountList.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/AccountList.java @@ -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; From d703ac91482b6d096d00ca056cb2cbcd57bf0c80 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 16 Feb 2015 21:02:52 +0100 Subject: [PATCH 09/14] Revert substitution of "com.fsck.k9" in implementation details We don't need to change strings that are not exposed to the system/users. --- .../com/fsck/k9/activity/ChooseFolder.java | 17 ++++---- .../com/fsck/k9/activity/ChooseIdentity.java | 5 +-- .../com/fsck/k9/activity/EditIdentity.java | 7 ++-- .../fsck/k9/activity/ManageIdentities.java | 2 - .../com/fsck/k9/activity/MessageCompose.java | 41 +++++++++---------- .../com/fsck/k9/activity/MessageList.java | 5 +-- .../k9/activity/setup/AccountSetupBasics.java | 7 ++-- .../k9/activity/setup/FolderSettings.java | 4 +- .../k9/controller/MessagingController.java | 19 ++++----- .../com/fsck/k9/service/BootReceiver.java | 11 +++-- .../com/fsck/k9/service/CoreReceiver.java | 5 +-- .../java/com/fsck/k9/service/CoreService.java | 4 +- .../k9/service/DatabaseUpgradeService.java | 3 +- .../java/com/fsck/k9/service/MailService.java | 23 +++++------ .../k9/service/NotificationActionService.java | 9 ++-- .../java/com/fsck/k9/service/PollService.java | 4 +- .../java/com/fsck/k9/service/PushService.java | 6 +-- .../fsck/k9/service/RemoteControlService.java | 11 +++-- .../com/fsck/k9/service/SleepService.java | 8 ++-- 19 files changed, 85 insertions(+), 106 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java b/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java index 030feee9e..08f25ac6f 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/ChooseFolder.java @@ -22,7 +22,6 @@ import android.widget.TextView; import com.fsck.k9.Account; import com.fsck.k9.Account.FolderMode; -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.R; @@ -32,14 +31,14 @@ import com.fsck.k9.mail.Folder; public class ChooseFolder extends K9ListActivity { - public static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".ChooseFolder_account"; - public static final String EXTRA_CUR_FOLDER = BuildConfig.APPLICATION_ID + ".ChooseFolder_curfolder"; - public static final String EXTRA_SEL_FOLDER = BuildConfig.APPLICATION_ID + ".ChooseFolder_selfolder"; - public static final String EXTRA_NEW_FOLDER = BuildConfig.APPLICATION_ID + ".ChooseFolder_newfolder"; - public static final String EXTRA_MESSAGE = BuildConfig.APPLICATION_ID + ".ChooseFolder_message"; - public static final String EXTRA_SHOW_CURRENT = BuildConfig.APPLICATION_ID + ".ChooseFolder_showcurrent"; - public static final String EXTRA_SHOW_FOLDER_NONE = BuildConfig.APPLICATION_ID + ".ChooseFolder_showOptionNone"; - public static final String EXTRA_SHOW_DISPLAYABLE_ONLY = BuildConfig.APPLICATION_ID + ".ChooseFolder_showDisplayableOnly"; + public static final String EXTRA_ACCOUNT = "com.fsck.k9.ChooseFolder_account"; + public static final String EXTRA_CUR_FOLDER = "com.fsck.k9.ChooseFolder_curfolder"; + public static final String EXTRA_SEL_FOLDER = "com.fsck.k9.ChooseFolder_selfolder"; + public static final String EXTRA_NEW_FOLDER = "com.fsck.k9.ChooseFolder_newfolder"; + public static final String EXTRA_MESSAGE = "com.fsck.k9.ChooseFolder_message"; + public static final String EXTRA_SHOW_CURRENT = "com.fsck.k9.ChooseFolder_showcurrent"; + public static final String EXTRA_SHOW_FOLDER_NONE = "com.fsck.k9.ChooseFolder_showOptionNone"; + public static final String EXTRA_SHOW_DISPLAYABLE_ONLY = "com.fsck.k9.ChooseFolder_showDisplayableOnly"; String mFolder; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/ChooseIdentity.java b/k9mail/src/main/java/com/fsck/k9/activity/ChooseIdentity.java index 456413027..6795ea0b9 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/ChooseIdentity.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/ChooseIdentity.java @@ -10,7 +10,6 @@ import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import com.fsck.k9.Account; -import com.fsck.k9.BuildConfig; import com.fsck.k9.Identity; import com.fsck.k9.Preferences; import com.fsck.k9.R; @@ -20,8 +19,8 @@ public class ChooseIdentity extends K9ListActivity { Account mAccount; ArrayAdapter adapter; - public static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".ChooseIdentity_account"; - public static final String EXTRA_IDENTITY = BuildConfig.APPLICATION_ID + ".ChooseIdentity_identity"; + public static final String EXTRA_ACCOUNT = "com.fsck.k9.ChooseIdentity_account"; + public static final String EXTRA_IDENTITY = "com.fsck.k9.ChooseIdentity_identity"; protected List identities = null; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/EditIdentity.java b/k9mail/src/main/java/com/fsck/k9/activity/EditIdentity.java index 8050643a2..bf9eeced8 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/EditIdentity.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/EditIdentity.java @@ -7,7 +7,6 @@ import android.widget.CompoundButton; import android.widget.EditText; import android.widget.LinearLayout; import com.fsck.k9.Account; -import com.fsck.k9.BuildConfig; import com.fsck.k9.Identity; import com.fsck.k9.Preferences; import com.fsck.k9.R; @@ -15,9 +14,9 @@ import java.util.List; public class EditIdentity extends K9Activity { - public static final String EXTRA_IDENTITY = BuildConfig.APPLICATION_ID + ".EditIdentity_identity"; - public static final String EXTRA_IDENTITY_INDEX = BuildConfig.APPLICATION_ID + ".EditIdentity_identity_index"; - public static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".EditIdentity_account"; + public static final String EXTRA_IDENTITY = "com.fsck.k9.EditIdentity_identity"; + public static final String EXTRA_IDENTITY_INDEX = "com.fsck.k9.EditIdentity_identity_index"; + public static final String EXTRA_ACCOUNT = "com.fsck.k9.EditIdentity_account"; private Account mAccount; private Identity mIdentity; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/ManageIdentities.java b/k9mail/src/main/java/com/fsck/k9/activity/ManageIdentities.java index 2eb539254..41d3d3e34 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/ManageIdentities.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/ManageIdentities.java @@ -11,14 +11,12 @@ import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.ListView; import android.widget.Toast; -import com.fsck.k9.BuildConfig; import com.fsck.k9.Identity; import com.fsck.k9.Preferences; import com.fsck.k9.R; public class ManageIdentities extends ChooseIdentity { private boolean mIdentitiesChanged = false; - public static final String EXTRA_IDENTITIES = BuildConfig.APPLICATION_ID + ".EditIdentity_identities"; private static final int ACTIVITY_EDIT_IDENTITY = 1; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java index b93030eec..0129b82e1 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java @@ -72,7 +72,6 @@ import android.widget.Toast; import com.fsck.k9.Account; import com.fsck.k9.Account.MessageFormat; import com.fsck.k9.Account.QuoteStyle; -import com.fsck.k9.BuildConfig; import com.fsck.k9.EmailAddressAdapter; import com.fsck.k9.EmailAddressValidator; import com.fsck.k9.FontSizes; @@ -136,41 +135,41 @@ public class MessageCompose extends K9Activity implements OnClickListener, private static final long INVALID_DRAFT_ID = MessagingController.INVALID_MESSAGE_ID; - private static final String ACTION_COMPOSE = BuildConfig.APPLICATION_ID + ".intent.action.COMPOSE"; - private static final String ACTION_REPLY = BuildConfig.APPLICATION_ID + ".intent.action.REPLY"; - private static final String ACTION_REPLY_ALL = BuildConfig.APPLICATION_ID + ".intent.action.REPLY_ALL"; - private static final String ACTION_FORWARD = BuildConfig.APPLICATION_ID + ".intent.action.FORWARD"; - private static final String ACTION_EDIT_DRAFT = BuildConfig.APPLICATION_ID + ".intent.action.EDIT_DRAFT"; + private static final String ACTION_COMPOSE = "com.fsck.k9.intent.action.COMPOSE"; + private static final String ACTION_REPLY = "com.fsck.k9.intent.action.REPLY"; + private static final String ACTION_REPLY_ALL = "com.fsck.k9.intent.action.REPLY_ALL"; + private static final String ACTION_FORWARD = "com.fsck.k9.intent.action.FORWARD"; + private static final String ACTION_EDIT_DRAFT = "com.fsck.k9.intent.action.EDIT_DRAFT"; private static final String EXTRA_ACCOUNT = "account"; private static final String EXTRA_MESSAGE_BODY = "messageBody"; private static final String EXTRA_MESSAGE_REFERENCE = "message_reference"; private static final String STATE_KEY_ATTACHMENTS = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.attachments"; + "com.fsck.k9.activity.MessageCompose.attachments"; private static final String STATE_KEY_CC_SHOWN = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.ccShown"; + "com.fsck.k9.activity.MessageCompose.ccShown"; private static final String STATE_KEY_BCC_SHOWN = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.bccShown"; + "com.fsck.k9.activity.MessageCompose.bccShown"; private static final String STATE_KEY_QUOTED_TEXT_MODE = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.QuotedTextShown"; + "com.fsck.k9.activity.MessageCompose.QuotedTextShown"; private static final String STATE_KEY_SOURCE_MESSAGE_PROCED = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.stateKeySourceMessageProced"; - private static final String STATE_KEY_DRAFT_ID = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.draftId"; - private static final String STATE_KEY_HTML_QUOTE = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.HTMLQuote"; + "com.fsck.k9.activity.MessageCompose.stateKeySourceMessageProced"; + private static final String STATE_KEY_DRAFT_ID = "com.fsck.k9.activity.MessageCompose.draftId"; + private static final String STATE_KEY_HTML_QUOTE = "com.fsck.k9.activity.MessageCompose.HTMLQuote"; private static final String STATE_IDENTITY_CHANGED = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.identityChanged"; + "com.fsck.k9.activity.MessageCompose.identityChanged"; private static final String STATE_IDENTITY = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.identity"; + "com.fsck.k9.activity.MessageCompose.identity"; private static final String STATE_PGP_DATA = "pgpData"; - private static final String STATE_IN_REPLY_TO = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.inReplyTo"; - private static final String STATE_REFERENCES = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.references"; - private static final String STATE_KEY_READ_RECEIPT = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.messageReadReceipt"; - private static final String STATE_KEY_DRAFT_NEEDS_SAVING = BuildConfig.APPLICATION_ID + ".activity.MessageCompose.mDraftNeedsSaving"; + private static final String STATE_IN_REPLY_TO = "com.fsck.k9.activity.MessageCompose.inReplyTo"; + private static final String STATE_REFERENCES = "com.fsck.k9.activity.MessageCompose.references"; + private static final String STATE_KEY_READ_RECEIPT = "com.fsck.k9.activity.MessageCompose.messageReadReceipt"; + private static final String STATE_KEY_DRAFT_NEEDS_SAVING = "com.fsck.k9.activity.MessageCompose.mDraftNeedsSaving"; private static final String STATE_KEY_FORCE_PLAIN_TEXT = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.forcePlainText"; + "com.fsck.k9.activity.MessageCompose.forcePlainText"; private static final String STATE_KEY_QUOTED_TEXT_FORMAT = - BuildConfig.APPLICATION_ID + ".activity.MessageCompose.quotedTextFormat"; + "com.fsck.k9.activity.MessageCompose.quotedTextFormat"; private static final String STATE_KEY_NUM_ATTACHMENTS_LOADING = "numAttachmentsLoading"; private static final String STATE_KEY_WAITING_FOR_ATTACHMENTS = "waitingForAttachments"; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java b/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java index d93f1a810..2d75c1633 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/MessageList.java @@ -29,7 +29,6 @@ import android.widget.Toast; import com.fsck.k9.Account; import com.fsck.k9.Account.SortType; -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.K9.SplitViewMode; import com.fsck.k9.Preferences; @@ -79,8 +78,8 @@ public class MessageList extends K9Activity implements MessageListFragmentListen private static final String EXTRA_MESSAGE_REFERENCE = "message_reference"; // used for remote search - public static final String EXTRA_SEARCH_ACCOUNT = BuildConfig.APPLICATION_ID + ".search_account"; - private static final String EXTRA_SEARCH_FOLDER = BuildConfig.APPLICATION_ID + ".search_folder"; + public static final String EXTRA_SEARCH_ACCOUNT = "com.fsck.k9.search_account"; + private static final String EXTRA_SEARCH_FOLDER = "com.fsck.k9.search_folder"; private static final String STATE_DISPLAY_MODE = "displayMode"; private static final String STATE_MESSAGE_LIST_WAS_DISPLAYED = "messageListWasDisplayed"; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java index 18ea93de3..a0c129541 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java @@ -27,7 +27,6 @@ import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.EditText; import com.fsck.k9.Account; -import com.fsck.k9.BuildConfig; import com.fsck.k9.EmailAddressValidator; import com.fsck.k9.K9; import com.fsck.k9.Preferences; @@ -55,12 +54,12 @@ import com.fsck.k9.view.ClientCertificateSpinner.OnClientCertificateChangedListe */ public class AccountSetupBasics extends K9Activity implements OnClickListener, TextWatcher, OnCheckedChangeListener, OnClientCertificateChangedListener { - private final static String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".AccountSetupBasics.account"; + private final static String EXTRA_ACCOUNT = "com.fsck.k9.AccountSetupBasics.account"; private final static int DIALOG_NOTE = 1; private final static String STATE_KEY_PROVIDER = - BuildConfig.APPLICATION_ID + ".AccountSetupBasics.provider"; + "com.fsck.k9.AccountSetupBasics.provider"; private final static String STATE_KEY_CHECKED_INCOMING = - BuildConfig.APPLICATION_ID + ".AccountSetupBasics.checkedIncoming"; + "com.fsck.k9.AccountSetupBasics.checkedIncoming"; private EditText mEmailView; private EditText mPasswordView; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/FolderSettings.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/FolderSettings.java index 4ddb3b05d..737e2ffc3 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/FolderSettings.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/FolderSettings.java @@ -22,8 +22,8 @@ import com.fsck.k9.service.MailService; public class FolderSettings extends K9PreferenceActivity { - private static final String EXTRA_FOLDER_NAME = BuildConfig.APPLICATION_ID + ".folderName"; - private static final String EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".account"; + private static final String EXTRA_FOLDER_NAME = "com.fsck.k9.folderName"; + private static final String EXTRA_ACCOUNT = "com.fsck.k9.account"; private static final String PREFERENCE_TOP_CATERGORY = "folder_settings"; private static final String PREFERENCE_DISPLAY_CLASS = "folder_settings_folder_display_mode"; diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java index 0ef3b354d..8d0dd8f20 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -43,7 +43,6 @@ 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.K9.NotificationHideSubject; import com.fsck.k9.K9.Intents; @@ -141,15 +140,15 @@ public class MessagingController implements Runnable { * So 25k gives good performance and a reasonable data footprint. Sounds good to me. */ - private static final String PENDING_COMMAND_MOVE_OR_COPY = BuildConfig.APPLICATION_ID + ".MessagingController.moveOrCopy"; - private static final String PENDING_COMMAND_MOVE_OR_COPY_BULK = BuildConfig.APPLICATION_ID + ".MessagingController.moveOrCopyBulk"; - private static final String PENDING_COMMAND_MOVE_OR_COPY_BULK_NEW = BuildConfig.APPLICATION_ID + ".MessagingController.moveOrCopyBulkNew"; - private static final String PENDING_COMMAND_EMPTY_TRASH = BuildConfig.APPLICATION_ID + ".MessagingController.emptyTrash"; - private static final String PENDING_COMMAND_SET_FLAG_BULK = BuildConfig.APPLICATION_ID + ".MessagingController.setFlagBulk"; - private static final String PENDING_COMMAND_SET_FLAG = BuildConfig.APPLICATION_ID + ".MessagingController.setFlag"; - private static final String PENDING_COMMAND_APPEND = BuildConfig.APPLICATION_ID + ".MessagingController.append"; - private static final String PENDING_COMMAND_MARK_ALL_AS_READ = BuildConfig.APPLICATION_ID + ".MessagingController.markAllAsRead"; - private static final String PENDING_COMMAND_EXPUNGE = BuildConfig.APPLICATION_ID + ".MessagingController.expunge"; + private static final String PENDING_COMMAND_MOVE_OR_COPY = "com.fsck.k9.MessagingController.moveOrCopy"; + private static final String PENDING_COMMAND_MOVE_OR_COPY_BULK = "com.fsck.k9.MessagingController.moveOrCopyBulk"; + private static final String PENDING_COMMAND_MOVE_OR_COPY_BULK_NEW = "com.fsck.k9.MessagingController.moveOrCopyBulkNew"; + private static final String PENDING_COMMAND_EMPTY_TRASH = "com.fsck.k9.MessagingController.emptyTrash"; + private static final String PENDING_COMMAND_SET_FLAG_BULK = "com.fsck.k9.MessagingController.setFlagBulk"; + private static final String PENDING_COMMAND_SET_FLAG = "com.fsck.k9.MessagingController.setFlag"; + private static final String PENDING_COMMAND_APPEND = "com.fsck.k9.MessagingController.append"; + private static final String PENDING_COMMAND_MARK_ALL_AS_READ = "com.fsck.k9.MessagingController.markAllAsRead"; + private static final String PENDING_COMMAND_EXPUNGE = "com.fsck.k9.MessagingController.expunge"; public static class UidReverseComparator implements Comparator { @Override diff --git a/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java b/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java index e856eeb6b..dec7cb1ef 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java +++ b/k9mail/src/main/java/com/fsck/k9/service/BootReceiver.java @@ -11,17 +11,16 @@ import android.net.ConnectivityManager; import android.net.Uri; import android.util.Log; -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; public class BootReceiver extends CoreReceiver { - public static final String FIRE_INTENT = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.fireIntent"; - public static final String SCHEDULE_INTENT = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.scheduleIntent"; - public static final String CANCEL_INTENT = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.cancelIntent"; + public static final String FIRE_INTENT = "com.fsck.k9.service.BroadcastReceiver.fireIntent"; + public static final String SCHEDULE_INTENT = "com.fsck.k9.service.BroadcastReceiver.scheduleIntent"; + public static final String CANCEL_INTENT = "com.fsck.k9.service.BroadcastReceiver.cancelIntent"; - public static final String ALARMED_INTENT = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.pendingIntent"; - public static final String AT_TIME = BuildConfig.APPLICATION_ID + ".service.BroadcastReceiver.atTime"; + public static final String ALARMED_INTENT = "com.fsck.k9.service.BroadcastReceiver.pendingIntent"; + public static final String AT_TIME = "com.fsck.k9.service.BroadcastReceiver.atTime"; @Override public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) { diff --git a/k9mail/src/main/java/com/fsck/k9/service/CoreReceiver.java b/k9mail/src/main/java/com/fsck/k9/service/CoreReceiver.java index c7195e1e1..50b899f2f 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/CoreReceiver.java +++ b/k9mail/src/main/java/com/fsck/k9/service/CoreReceiver.java @@ -10,16 +10,15 @@ import android.content.Intent; import android.os.PowerManager; import android.util.Log; -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.mail.power.TracingPowerManager; import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock; public class CoreReceiver extends BroadcastReceiver { - public static final String WAKE_LOCK_RELEASE = BuildConfig.APPLICATION_ID + ".service.CoreReceiver.wakeLockRelease"; + public static final String WAKE_LOCK_RELEASE = "com.fsck.k9.service.CoreReceiver.wakeLockRelease"; - public static final String WAKE_LOCK_ID = BuildConfig.APPLICATION_ID + ".service.CoreReceiver.wakeLockId"; + public static final String WAKE_LOCK_ID = "com.fsck.k9.service.CoreReceiver.wakeLockId"; private static ConcurrentHashMap wakeLocks = new ConcurrentHashMap(); private static AtomicInteger wakeLockSeq = new AtomicInteger(0); diff --git a/k9mail/src/main/java/com/fsck/k9/service/CoreService.java b/k9mail/src/main/java/com/fsck/k9/service/CoreService.java index 54e53887c..0ed8a496c 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/CoreService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/CoreService.java @@ -12,8 +12,6 @@ import android.content.Intent; import android.os.IBinder; import android.os.PowerManager; import android.util.Log; - -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.controller.MessagingController; import com.fsck.k9.mail.power.TracingPowerManager; @@ -59,7 +57,7 @@ import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock; */ public abstract class CoreService extends Service { - public static final String WAKE_LOCK_ID = BuildConfig.APPLICATION_ID + ".service.CoreService.wakeLockId"; + public static final String WAKE_LOCK_ID = "com.fsck.k9.service.CoreService.wakeLockId"; private static ConcurrentHashMap sWakeLocks = new ConcurrentHashMap(); diff --git a/k9mail/src/main/java/com/fsck/k9/service/DatabaseUpgradeService.java b/k9mail/src/main/java/com/fsck/k9/service/DatabaseUpgradeService.java index 4fc5dd86d..fd89659e8 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/DatabaseUpgradeService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/DatabaseUpgradeService.java @@ -12,7 +12,6 @@ import android.support.v4.content.LocalBroadcastManager; 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.activity.UpgradeDatabases; @@ -70,7 +69,7 @@ public class DatabaseUpgradeService extends Service { * Action used to start this service. */ private static final String ACTION_START_SERVICE = - BuildConfig.APPLICATION_ID + ".service.DatabaseUpgradeService.startService"; + "com.fsck.k9.service.DatabaseUpgradeService.startService"; private static final String WAKELOCK_TAG = "DatabaseUpgradeService"; private static final long WAKELOCK_TIMEOUT = 10 * 60 * 1000; // 10 minutes diff --git a/k9mail/src/main/java/com/fsck/k9/service/MailService.java b/k9mail/src/main/java/com/fsck/k9/service/MailService.java index 971c11781..6a1fde5b0 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/MailService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/MailService.java @@ -12,7 +12,6 @@ import android.os.IBinder; 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.Account.FolderMode; @@ -21,14 +20,14 @@ import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.Pusher; public class MailService extends CoreService { - private static final String ACTION_CHECK_MAIL = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_WAKEUP"; - private static final String ACTION_RESET = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_RESET"; - private static final String ACTION_RESCHEDULE_POLL = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_RESCHEDULE_POLL"; - private static final String ACTION_CANCEL = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_CANCEL"; - private static final String ACTION_REFRESH_PUSHERS = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_REFRESH_PUSHERS"; - private static final String ACTION_RESTART_PUSHERS = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_RESTART_PUSHERS"; - private static final String CONNECTIVITY_CHANGE = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_CONNECTIVITY_CHANGE"; - private static final String CANCEL_CONNECTIVITY_NOTICE = BuildConfig.APPLICATION_ID + ".intent.action.MAIL_SERVICE_CANCEL_CONNECTIVITY_NOTICE"; + private static final String ACTION_CHECK_MAIL = "com.fsck.k9.intent.action.MAIL_SERVICE_WAKEUP"; + private static final String ACTION_RESET = "com.fsck.k9.intent.action.MAIL_SERVICE_RESET"; + private static final String ACTION_RESCHEDULE_POLL = "com.fsck.k9.intent.action.MAIL_SERVICE_RESCHEDULE_POLL"; + private static final String ACTION_CANCEL = "com.fsck.k9.intent.action.MAIL_SERVICE_CANCEL"; + private static final String ACTION_REFRESH_PUSHERS = "com.fsck.k9.intent.action.MAIL_SERVICE_REFRESH_PUSHERS"; + private static final String ACTION_RESTART_PUSHERS = "com.fsck.k9.intent.action.MAIL_SERVICE_RESTART_PUSHERS"; + private static final String CONNECTIVITY_CHANGE = "com.fsck.k9.intent.action.MAIL_SERVICE_CONNECTIVITY_CHANGE"; + private static final String CANCEL_CONNECTIVITY_NOTICE = "com.fsck.k9.intent.action.MAIL_SERVICE_CANCEL_CONNECTIVITY_NOTICE"; private static long nextCheck = -1; private static boolean pushingRequested = false; @@ -165,7 +164,7 @@ public class MailService extends CoreService { private void cancel() { Intent i = new Intent(); - i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID +".service.MailService"); + i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService"); i.setAction(ACTION_CHECK_MAIL); BootReceiver.cancelIntent(this, i); } @@ -306,7 +305,7 @@ public class MailService extends CoreService { } Intent i = new Intent(); - i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID +".service.MailService"); + i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService"); i.setAction(ACTION_CHECK_MAIL); BootReceiver.scheduleIntent(MailService.this, nextTime, i); } @@ -412,7 +411,7 @@ public class MailService extends CoreService { if (K9.DEBUG) Log.d(K9.LOG_TAG, "Next pusher refresh scheduled for " + new Date(nextTime)); Intent i = new Intent(); - i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID +".service.MailService"); + i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.MailService"); i.setAction(ACTION_REFRESH_PUSHERS); BootReceiver.scheduleIntent(MailService.this, nextTime, i); } diff --git a/k9mail/src/main/java/com/fsck/k9/service/NotificationActionService.java b/k9mail/src/main/java/com/fsck/k9/service/NotificationActionService.java index c0a0b7769..50f14bc15 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/NotificationActionService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/NotificationActionService.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.List; import com.fsck.k9.Account; -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.activity.MessageCompose; @@ -20,10 +19,10 @@ import android.content.Intent; import android.util.Log; public class NotificationActionService extends CoreService { - private final static String REPLY_ACTION = BuildConfig.APPLICATION_ID + ".service.NotificationActionService.REPLY_ACTION"; - private final static String READ_ALL_ACTION = BuildConfig.APPLICATION_ID + ".service.NotificationActionService.READ_ALL_ACTION"; - private final static String DELETE_ALL_ACTION = BuildConfig.APPLICATION_ID + ".service.NotificationActionService.DELETE_ALL_ACTION"; - private final static String ACKNOWLEDGE_ACTION = BuildConfig.APPLICATION_ID + ".service.NotificationActionService.ACKNOWLEDGE_ACTION"; + private final static String REPLY_ACTION = "com.fsck.k9.service.NotificationActionService.REPLY_ACTION"; + private final static String READ_ALL_ACTION = "com.fsck.k9.service.NotificationActionService.READ_ALL_ACTION"; + private final static String DELETE_ALL_ACTION = "com.fsck.k9.service.NotificationActionService.DELETE_ALL_ACTION"; + private final static String ACKNOWLEDGE_ACTION = "com.fsck.k9.service.NotificationActionService.ACKNOWLEDGE_ACTION"; private final static String EXTRA_ACCOUNT = "account"; private final static String EXTRA_MESSAGE = "message"; diff --git a/k9mail/src/main/java/com/fsck/k9/service/PollService.java b/k9mail/src/main/java/com/fsck/k9/service/PollService.java index 6af6ba076..f47c4e3b8 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/PollService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/PollService.java @@ -15,8 +15,8 @@ import java.util.HashMap; import java.util.Map; public class PollService extends CoreService { - private static String START_SERVICE = BuildConfig.APPLICATION_ID + ".service.PollService.startService"; - private static String STOP_SERVICE = BuildConfig.APPLICATION_ID + ".service.PollService.stopService"; + private static String START_SERVICE = "com.fsck.k9.service.PollService.startService"; + private static String STOP_SERVICE = "com.fsck.k9.service.PollService.stopService"; private Listener mListener = new Listener(); diff --git a/k9mail/src/main/java/com/fsck/k9/service/PushService.java b/k9mail/src/main/java/com/fsck/k9/service/PushService.java index 4f13c372a..19de1ecf0 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/PushService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/PushService.java @@ -4,13 +4,11 @@ import android.content.Context; import android.content.Intent; import android.os.IBinder; import android.util.Log; - -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; public class PushService extends CoreService { - private static String START_SERVICE = BuildConfig.APPLICATION_ID + ".service.PushService.startService"; - private static String STOP_SERVICE = BuildConfig.APPLICATION_ID + ".service.PushService.stopService"; + private static String START_SERVICE = "com.fsck.k9.service.PushService.startService"; + private static String STOP_SERVICE = "com.fsck.k9.service.PushService.stopService"; public static void startService(Context context) { Intent i = new Intent(); diff --git a/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java b/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java index dcec96b6c..e942f4d23 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java @@ -1,7 +1,6 @@ package com.fsck.k9.service; import com.fsck.k9.Account; -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.remotecontrol.K9RemoteControl; import com.fsck.k9.Preferences; @@ -21,10 +20,10 @@ import android.widget.Toast; import java.util.List; public class RemoteControlService extends CoreService { - private final static String RESCHEDULE_ACTION = BuildConfig.APPLICATION_ID + ".service.RemoteControlService.RESCHEDULE_ACTION"; - private final static String PUSH_RESTART_ACTION = BuildConfig.APPLICATION_ID + ".service.RemoteControlService.PUSH_RESTART_ACTION"; + private final static String RESCHEDULE_ACTION = "com.fsck.k9.service.RemoteControlService.RESCHEDULE_ACTION"; + private final static String PUSH_RESTART_ACTION = "com.fsck.k9.service.RemoteControlService.PUSH_RESTART_ACTION"; - private final static String SET_ACTION = BuildConfig.APPLICATION_ID + ".service.RemoteControlService.SET_ACTION"; + private final static String SET_ACTION = "com.fsck.k9.service.RemoteControlService.SET_ACTION"; public static void set(Context context, Intent i, Integer wakeLockId) { // Intent i = new Intent(); @@ -136,14 +135,14 @@ public class RemoteControlService extends CoreService { if (needsReschedule) { Intent i = new Intent(); - i.setClassName(getApplication().getPackageName(), BuildConfig.APPLICATION_ID + ".service.RemoteControlService"); + i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.RemoteControlService"); 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(), BuildConfig.APPLICATION_ID + ".service.RemoteControlService"); + i.setClassName(getApplication().getPackageName(), "com.fsck.k9.service.RemoteControlService"); i.setAction(PUSH_RESTART_ACTION); long nextTime = System.currentTimeMillis() + 10000; BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i); diff --git a/k9mail/src/main/java/com/fsck/k9/service/SleepService.java b/k9mail/src/main/java/com/fsck/k9/service/SleepService.java index 2d909eb20..937f97dc3 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/SleepService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/SleepService.java @@ -3,8 +3,6 @@ package com.fsck.k9.service; import android.content.Context; import android.content.Intent; import android.util.Log; - -import com.fsck.k9.BuildConfig; import com.fsck.k9.K9; import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock; @@ -15,8 +13,8 @@ import java.util.concurrent.atomic.AtomicInteger; public class SleepService extends CoreService { - private static String ALARM_FIRED = BuildConfig.APPLICATION_ID + ".service.SleepService.ALARM_FIRED"; - private static String LATCH_ID = BuildConfig.APPLICATION_ID + ".SleepService.LATCH_ID_EXTRA"; + private static String ALARM_FIRED = "com.fsck.k9.service.SleepService.ALARM_FIRED"; + private static String LATCH_ID = "com.fsck.k9.service.SleepService.LATCH_ID_EXTRA"; private static ConcurrentHashMap sleepData = new ConcurrentHashMap(); @@ -34,7 +32,7 @@ public class SleepService extends CoreService { sleepData.put(id, sleepDatum); Intent i = new Intent(); - i.setClassName(context.getPackageName(), BuildConfig.APPLICATION_ID + ".service.SleepService"); + i.setClassName(context.getPackageName(), "com.fsck.k9.service.SleepService"); i.putExtra(LATCH_ID, id); i.setAction(ALARM_FIRED + "." + id); long startTime = System.currentTimeMillis(); From ebeed31705a6e465685adacd6c81b1585f44fa1a Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 16 Feb 2015 21:38:16 +0100 Subject: [PATCH 10/14] Fix search for non-default application ID --- k9mail/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k9mail/src/main/AndroidManifest.xml b/k9mail/src/main/AndroidManifest.xml index 5867dc199..694602bb0 100644 --- a/k9mail/src/main/AndroidManifest.xml +++ b/k9mail/src/main/AndroidManifest.xml @@ -70,7 +70,7 @@ + android:value="com.fsck.k9.activity.Search"/> Date: Mon, 16 Feb 2015 21:45:04 +0100 Subject: [PATCH 11/14] Use different application ID for debug builds This way debug builds can be installed next to the release version. --- k9mail/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/k9mail/build.gradle b/k9mail/build.gradle index ac4fe6ddb..59d8577c8 100644 --- a/k9mail/build.gradle +++ b/k9mail/build.gradle @@ -52,6 +52,7 @@ android { } debug { + applicationIdSuffix ".debug" testCoverageEnabled rootProject.testCoverage } } From 24e6b39dc0366547311481adc2780517c2225d57 Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 16 Feb 2015 22:27:44 +0100 Subject: [PATCH 12/14] Stop using Intent.setClassName() Use the type-safe Intent constructor to reference internal classes. --- .../src/main/java/com/fsck/k9/service/MailService.java | 9 +++------ .../java/com/fsck/k9/service/RemoteControlService.java | 6 ++---- .../src/main/java/com/fsck/k9/service/SleepService.java | 3 +-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/service/MailService.java b/k9mail/src/main/java/com/fsck/k9/service/MailService.java index 6a1fde5b0..601dbd5b9 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/MailService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/MailService.java @@ -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); } diff --git a/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java b/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java index e942f4d23..4db3597dc 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/RemoteControlService.java @@ -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); diff --git a/k9mail/src/main/java/com/fsck/k9/service/SleepService.java b/k9mail/src/main/java/com/fsck/k9/service/SleepService.java index 937f97dc3..ba0b8436e 100644 --- a/k9mail/src/main/java/com/fsck/k9/service/SleepService.java +++ b/k9mail/src/main/java/com/fsck/k9/service/SleepService.java @@ -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(); From ffb4507776c1b3fdda9854d26ccf7cd95eeb6e37 Mon Sep 17 00:00:00 2001 From: Art O Cathain Date: Sun, 15 Feb 2015 07:37:52 +0000 Subject: [PATCH 13/14] Enums instead of int/String constants (#547) simplify and add logging simplify use == for enum comparison to avoid type mistakes enum name needs to match previous constant simplify Address review comments - formatting, and remove superfluous comment Shorten DeletePolicy values since not used in settings strings; import enums to reduce clutter fix whitespace remove comment per review address review comment review comments remove another superfluous qualification Last changes --- k9mail/src/main/java/com/fsck/k9/Account.java | 160 ++++++++---------- .../main/java/com/fsck/k9/Preferences.java | 19 +++ .../k9/activity/setup/AccountSettings.java | 31 ++-- .../k9/activity/setup/AccountSetupBasics.java | 5 +- .../activity/setup/AccountSetupIncoming.java | 20 ++- .../k9/controller/MessagingController.java | 14 +- .../fsck/k9/preferences/AccountSettings.java | 39 +++-- 7 files changed, 149 insertions(+), 139 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/Account.java b/k9mail/src/main/java/com/fsck/k9/Account.java index 8f85570d9..b75932e54 100644 --- a/k9mail/src/main/java/com/fsck/k9/Account.java +++ b/k9mail/src/main/java/com/fsck/k9/Account.java @@ -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 = ""; - - /** - *
-     * 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)
-     * 
- */ - 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 mSortAscending = new HashMap(); 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 compressionMap = new ConcurrentHashMap(); + private final Map compressionMap = new ConcurrentHashMap(); 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); diff --git a/k9mail/src/main/java/com/fsck/k9/Preferences.java b/k9mail/src/main/java/com/fsck/k9/Preferences.java index 7d03b668e..eea45c144 100644 --- a/k9mail/src/main/java/com/fsck/k9/Preferences.java +++ b/k9mail/src/main/java/com/fsck/k9/Preferences.java @@ -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 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 getAvailableAccounts() { @@ -164,4 +166,21 @@ public class Preferences { public SharedPreferences getPreferences() { return mStorage; } + + public static > 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; + } + } + } } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java index c9127b2d7..9ebeee4f9 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java @@ -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; diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java index a0c129541..91cd119ba 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.java @@ -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); diff --git a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupIncoming.java b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupIncoming.java index 2a97b0f93..07281a48b 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupIncoming.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSetupIncoming.java @@ -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); diff --git a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java index 8d0dd8f20..9a5c356f9 100644 --- a/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +++ b/k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java @@ -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); @@ -4088,14 +4090,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 { @@ -4133,7 +4135,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(); } diff --git a/k9mail/src/main/java/com/fsck/k9/preferences/AccountSettings.java b/k9mail/src/main/java/com/fsck/k9/preferences/AccountSettings.java index 6bdcb4699..fd63c4d8f 100644 --- a/k9mail/src/main/java/com/fsck/k9/preferences/AccountSettings.java +++ b/k9mail/src/main/java/com/fsck/k9/preferences/AccountSettings.java @@ -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.class, Account.DEFAULT_MESSAGE_FORMAT)) + new V(1, new EnumSetting( + 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.class, Account.DEFAULT_QUOTE_STYLE)) + new V(1, new EnumSetting( + 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.class, Account.Searchable.ALL)) + new V(1, new EnumSetting( + 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.class, Account.ShowPictures.NEVER)) + new V(1, new EnumSetting( + 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 { private Map mMapping; - public DeletePolicySetting(int defaultValue) { + public DeletePolicySetting(DeletePolicy defaultValue) { super(defaultValue); Map mapping = new HashMap(); - 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); } From ebef8eccb91d705887a3dc3887b89cb28e63cfa6 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 17 Feb 2015 00:45:36 +0100 Subject: [PATCH 14/14] Add missing placeholder for application ID --- .../main/java/com/fsck/k9/provider/AttachmentProvider.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/k9mail/src/main/java/com/fsck/k9/provider/AttachmentProvider.java b/k9mail/src/main/java/com/fsck/k9/provider/AttachmentProvider.java index d59de5592..89d1fec69 100644 --- a/k9mail/src/main/java/com/fsck/k9/provider/AttachmentProvider.java +++ b/k9mail/src/main/java/com/fsck/k9/provider/AttachmentProvider.java @@ -11,6 +11,7 @@ import android.net.Uri; 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; @@ -31,7 +32,8 @@ import java.util.List; *

*/ 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 FORMAT_RAW = "RAW"; private static final String FORMAT_VIEW = "VIEW";