Merge pull request #3477 from k9mail/move_to_k9mail_module
Move interface for third-party apps to k9mail module
This commit is contained in:
commit
ede38b517d
11 changed files with 71 additions and 76 deletions
|
@ -18,7 +18,6 @@ import com.fsck.k9.mailstore.mailStoreModule
|
|||
import com.fsck.k9.message.extractors.extractorModule
|
||||
import com.fsck.k9.message.html.htmlModule
|
||||
import com.fsck.k9.power.DeviceIdleManager
|
||||
import com.fsck.k9.remotecontrol.K9RemoteControl
|
||||
import com.fsck.k9.service.BootReceiver
|
||||
import com.fsck.k9.service.MailService
|
||||
import com.fsck.k9.service.ShutdownReceiver
|
||||
|
@ -54,7 +53,6 @@ object Core {
|
|||
PRNGFixes.apply()
|
||||
|
||||
val packageName = context.packageName
|
||||
K9RemoteControl.init(packageName)
|
||||
K9.Intents.init(packageName)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
package com.fsck.k9.provider;
|
||||
package com.fsck.k9.external;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
|
@ -7,16 +10,12 @@ import android.test.ProviderTestCase2;
|
|||
import android.test.mock.MockContentResolver;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.Preferences;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class MessageProviderTest extends ProviderTestCase2 {
|
||||
|
|
@ -347,7 +347,7 @@
|
|||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".service.RemoteControlReceiver"
|
||||
android:name=".external.remotecontrol.RemoteControlReceiver"
|
||||
android:enabled="true"
|
||||
android:permission="${applicationId}.permission.REMOTE_CONTROL">
|
||||
<intent-filter>
|
||||
|
@ -432,7 +432,7 @@
|
|||
android:enabled="true"/>
|
||||
|
||||
<service
|
||||
android:name=".service.RemoteControlService"
|
||||
android:name=".external.remotecontrol.RemoteControlService"
|
||||
android:enabled="true"
|
||||
android:permission="${applicationId}.permission.REMOTE_CONTROL"/>
|
||||
|
||||
|
@ -477,7 +477,7 @@
|
|||
</provider>
|
||||
|
||||
<provider
|
||||
android:name=".provider.MessageProvider"
|
||||
android:name=".external.MessageProvider"
|
||||
android:authorities="${applicationId}.messageprovider"
|
||||
android:exported="true"
|
||||
android:grantUriPermissions="true"
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.fsck.k9
|
|||
|
||||
import android.app.Application
|
||||
import com.fsck.k9.controller.MessagingController
|
||||
import com.fsck.k9.provider.MessageProvider
|
||||
import com.fsck.k9.external.MessageProvider
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class App : Application() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.fsck.k9.provider;
|
||||
package com.fsck.k9.external;
|
||||
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
@ -35,11 +35,10 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import com.fsck.k9.DI;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.AccountStats;
|
||||
import com.fsck.k9.BuildConfig;
|
||||
import com.fsck.k9.DI;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.activity.FolderInfoHolder;
|
||||
import com.fsck.k9.activity.MessageInfoHolder;
|
||||
|
@ -53,11 +52,12 @@ import com.fsck.k9.mail.MessagingException;
|
|||
import com.fsck.k9.mailstore.LocalFolder;
|
||||
import com.fsck.k9.mailstore.LocalMessage;
|
||||
import com.fsck.k9.search.SearchAccount;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
||||
public class MessageProvider extends ContentProvider {
|
||||
public static String AUTHORITY;
|
||||
public static Uri CONTENT_URI;
|
||||
public static String AUTHORITY = BuildConfig.APPLICATION_ID + ".messageprovider";
|
||||
public static Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
|
||||
|
||||
private static final String[] DEFAULT_MESSAGE_PROJECTION = new String[] {
|
||||
MessageColumns._ID,
|
||||
|
@ -94,10 +94,6 @@ public class MessageProvider extends ContentProvider {
|
|||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
String packageName = getContext().getPackageName();
|
||||
AUTHORITY = packageName + ".messageprovider";
|
||||
CONTENT_URI = Uri.parse("content://" + AUTHORITY);
|
||||
|
||||
messageHelper = MessageHelper.getInstance(getContext());
|
||||
|
||||
registerQueryHandler(new ThrottlingQueryHandler(new AccountsQueryHandler()));
|
|
@ -1,9 +1,11 @@
|
|||
package com.fsck.k9.remotecontrol;
|
||||
package com.fsck.k9.external.remotecontrol;
|
||||
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
class AccountReceiver extends BroadcastReceiver {
|
|
@ -1,4 +1,4 @@
|
|||
package com.fsck.k9.remotecontrol;
|
||||
package com.fsck.k9.external.remotecontrol;
|
||||
/**
|
||||
*
|
||||
* @author Daniel I. Applebaum
|
|
@ -1,10 +1,13 @@
|
|||
package com.fsck.k9.remotecontrol;
|
||||
package com.fsck.k9.external.remotecontrol;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.fsck.k9.BuildConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Utility definitions for Android applications to control the behavior of K-9 Mail. All such applications must declare the following permission:
|
||||
* <uses-permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"/>
|
||||
|
@ -24,14 +27,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 static String K9_REMOTE_CONTROL_PERMISSION;
|
||||
public 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 static String K9_REQUEST_ACCOUNTS;
|
||||
public static String K9_ACCOUNT_UUIDS;
|
||||
public static String K9_ACCOUNT_DESCRIPTIONS;
|
||||
public static String K9_REQUEST_ACCOUNTS = BuildConfig.APPLICATION_ID + ".K9RemoteControl.requestAccounts";
|
||||
public static String K9_ACCOUNT_UUIDS = BuildConfig.APPLICATION_ID + ".K9RemoteControl.accountUuids";
|
||||
public 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 +44,17 @@ public class K9RemoteControl {
|
|||
/**
|
||||
* The {@link {@link Intent}} Action to set when remotely changing K-9 Mail settings
|
||||
*/
|
||||
public static String K9_SET;
|
||||
public 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 static String K9_ACCOUNT_UUID;
|
||||
public 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 static String K9_ALL_ACCOUNTS;
|
||||
public 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 +63,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 static String K9_NOTIFICATION_ENABLED;
|
||||
public 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 static String K9_RING_ENABLED;
|
||||
public 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 static String K9_VIBRATE_ENABLED;
|
||||
public 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 +85,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 static String K9_PUSH_CLASSES;
|
||||
public 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 static String K9_POLL_CLASSES;
|
||||
public 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 static String K9_POLL_FREQUENCY;
|
||||
public 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 static String K9_BACKGROUND_OPERATIONS;
|
||||
public 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,29 +114,12 @@ 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 static String K9_THEME;
|
||||
public 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";
|
||||
|
||||
protected static final String LOG_TAG = "K9RemoteControl";
|
||||
|
||||
public static void init(String packageName) {
|
||||
K9_REMOTE_CONTROL_PERMISSION = packageName + ".permission.REMOTE_CONTROL";
|
||||
K9_REQUEST_ACCOUNTS = packageName + ".K9RemoteControl.requestAccounts";
|
||||
K9_ACCOUNT_UUIDS = packageName + ".K9RemoteControl.accountUuids";
|
||||
K9_ACCOUNT_DESCRIPTIONS = packageName + ".K9RemoteControl.accountDescriptions";
|
||||
K9_SET = packageName + ".K9RemoteControl.set";
|
||||
K9_ACCOUNT_UUID = packageName + ".K9RemoteControl.accountUuid";
|
||||
K9_ALL_ACCOUNTS = packageName + ".K9RemoteControl.allAccounts";
|
||||
K9_NOTIFICATION_ENABLED = packageName + ".K9RemoteControl.notificationEnabled";
|
||||
K9_RING_ENABLED = packageName + ".K9RemoteControl.ringEnabled";
|
||||
K9_VIBRATE_ENABLED = packageName + ".K9RemoteControl.vibrateEnabled";
|
||||
K9_PUSH_CLASSES = packageName + ".K9RemoteControl.pushClasses";
|
||||
K9_POLL_CLASSES = packageName + ".K9RemoteControl.pollClasses";
|
||||
K9_POLL_FREQUENCY = packageName + ".K9RemoteControl.pollFrequency";
|
||||
K9_BACKGROUND_OPERATIONS = packageName + ".K9RemoteControl.backgroundOperations";
|
||||
K9_THEME = packageName + ".K9RemoteControl.theme";
|
||||
}
|
||||
|
||||
public static void set(Context context, Intent broadcastIntent) {
|
||||
broadcastIntent.setAction(K9RemoteControl.K9_SET);
|
|
@ -1,18 +1,20 @@
|
|||
|
||||
package com.fsck.k9.service;
|
||||
package com.fsck.k9.external.remotecontrol;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.remotecontrol.K9RemoteControl;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.service.CoreReceiver;
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.fsck.k9.remotecontrol.K9RemoteControl.*;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_ACCOUNT_DESCRIPTIONS;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_ACCOUNT_UUIDS;
|
||||
|
||||
public class RemoteControlReceiver extends CoreReceiver {
|
||||
@Override
|
|
@ -1,23 +1,35 @@
|
|||
package com.fsck.k9.service;
|
||||
package com.fsck.k9.external.remotecontrol;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.preferences.Storage;
|
||||
import com.fsck.k9.preferences.StorageEditor;
|
||||
import com.fsck.k9.remotecontrol.K9RemoteControl;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.core.R;
|
||||
import com.fsck.k9.Account.FolderMode;
|
||||
import com.fsck.k9.K9.BACKGROUND_OPS;
|
||||
|
||||
import static com.fsck.k9.remotecontrol.K9RemoteControl.*;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import timber.log.Timber;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.Account.FolderMode;
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.K9.BACKGROUND_OPS;
|
||||
import com.fsck.k9.Preferences;
|
||||
import com.fsck.k9.core.R;
|
||||
import com.fsck.k9.preferences.Storage;
|
||||
import com.fsck.k9.preferences.StorageEditor;
|
||||
import com.fsck.k9.service.BootReceiver;
|
||||
import com.fsck.k9.service.CoreService;
|
||||
import com.fsck.k9.service.MailService;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_ACCOUNT_UUID;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_ALL_ACCOUNTS;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_BACKGROUND_OPERATIONS;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_NOTIFICATION_ENABLED;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_POLL_CLASSES;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_POLL_FREQUENCY;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_PUSH_CLASSES;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_RING_ENABLED;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_THEME;
|
||||
import static com.fsck.k9.external.remotecontrol.K9RemoteControl.K9_VIBRATE_ENABLED;
|
||||
|
||||
public class RemoteControlService extends CoreService {
|
||||
private final static String RESCHEDULE_ACTION = "com.fsck.k9.service.RemoteControlService.RESCHEDULE_ACTION";
|
|
@ -20,7 +20,7 @@ import android.widget.RemoteViewsService;
|
|||
|
||||
import com.fsck.k9.K9;
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.provider.MessageProvider;
|
||||
import com.fsck.k9.external.MessageProvider;
|
||||
|
||||
|
||||
public class MessageListRemoteViewFactory implements RemoteViewsService.RemoteViewsFactory {
|
||||
|
|
Loading…
Reference in a new issue