diff --git a/build.xml b/build.xml index 29ef3a712..a51c20a4f 100644 --- a/build.xml +++ b/build.xml @@ -110,6 +110,9 @@ + + + @@ -201,6 +204,15 @@ + + Creating library ${rclib} for remote control + applications + + + + Converting compiled files and external libraries into ${out-folder}/${dex-file}... @@ -247,7 +259,7 @@ - + - * in their AndroidManifest.xml + * in their AndroidManifest.xml In addition, all applications sending remote control messages to K-9 Mail must * * An application that wishes to act on a particular Account in K-9 needs to fetch the list of configured Accounts by broadcasting an * {@link Intent} using K9_REQUEST_ACCOUNTS as the Action. The broadcast must be made using the {@link ContextWrapper} @@ -15,6 +24,11 @@ package com.fsck.k9; */ 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"; /** * {@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 @@ -105,4 +119,22 @@ public class K9RemoteControl public final static String K9_THEME_LIGHT = "LIGHT"; public final static String K9_THEME_DARK = "DARK"; + protected static String LOG_TAG = "K9RemoteControl"; + + public static void set(Context context, Intent broadcastIntent) + { + broadcastIntent.setAction(K9RemoteControl.K9_SET); + context.sendBroadcast(broadcastIntent, K9RemoteControl.K9_REMOTE_CONTROL_PERMISSION); + } + + public static void fetchAccounts(Context context, K9AccountReceptor receptor) + { + Intent accountFetchIntent = new Intent(); + accountFetchIntent.setAction(K9RemoteControl.K9_REQUEST_ACCOUNTS); + AccountReceiver receiver = new AccountReceiver(receptor); + context.sendOrderedBroadcast(accountFetchIntent, K9RemoteControl.K9_REMOTE_CONTROL_PERMISSION, receiver, null, Activity.RESULT_OK, null, null); + } + } + +