Merge pull request #4278 from k9mail/remove_remote_control

Remove "remote control" functionality
This commit is contained in:
cketti 2019-11-22 04:04:49 +01:00 committed by GitHub
commit ba9a107884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 1 additions and 530 deletions

View file

@ -26,14 +26,6 @@
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<permission
android:name="${applicationId}.permission.REMOTE_CONTROL"
android:description="@string/remote_control_desc"
android:label="@string/remote_control_label"
android:permissionGroup="android.permission-group.MESSAGES"
android:protectionLevel="dangerous"/>
<uses-permission android:name="${applicationId}.permission.REMOTE_CONTROL"/>
<permission
android:name="${applicationId}.permission.READ_MESSAGES"
android:description="@string/read_messages_desc"
@ -326,18 +318,6 @@
</intent-filter>
</receiver>
<receiver
android:name=".external.remotecontrol.RemoteControlReceiver"
android:enabled="true"
android:permission="${applicationId}.permission.REMOTE_CONTROL">
<intent-filter>
<action android:name="${applicationId}.K9RemoteControl.set"/>
</intent-filter>
<intent-filter>
<action android:name="${applicationId}.K9RemoteControl.requestAccounts"/>
</intent-filter>
</receiver>
<receiver
android:name=".service.CoreReceiver"
android:exported="false"/>
@ -403,11 +383,6 @@
android:name=".service.PushService"
android:enabled="true"/>
<service
android:name=".external.remotecontrol.RemoteControlService"
android:enabled="true"
android:permission="${applicationId}.permission.REMOTE_CONTROL"/>
<service
android:name=".service.SleepService"
android:enabled="true"/>

View file

@ -4,8 +4,6 @@ import com.fsck.k9.backends.backendsModule
import com.fsck.k9.controller.ControllerExtension
import com.fsck.k9.crypto.EncryptionExtractor
import com.fsck.k9.crypto.openpgp.OpenPgpEncryptionExtractor
import com.fsck.k9.external.BroadcastSenderListener
import com.fsck.k9.external.externalModule
import com.fsck.k9.notification.notificationModule
import com.fsck.k9.preferences.K9StoragePersister
import com.fsck.k9.preferences.StoragePersister
@ -23,8 +21,7 @@ private val mainAppModule = module {
single { MessagingListenerProvider(
listOf(
get<UnreadWidgetUpdateListener>(),
get<MessageListWidgetUpdateListener>(),
get<BroadcastSenderListener>()
get<MessageListWidgetUpdateListener>()
))
}
single(named("controllerExtensions")) { emptyList<ControllerExtension>() }
@ -34,7 +31,6 @@ private val mainAppModule = module {
val appModules = listOf(
mainAppModule,
externalModule,
messageListWidgetModule,
unreadWidgetModule,
notificationModule,

View file

@ -1,18 +0,0 @@
package com.fsck.k9.external
import com.fsck.k9.BuildConfig
internal object BroadcastIntents {
const val ACTION_EMAIL_RECEIVED = BuildConfig.APPLICATION_ID + ".intent.action.EMAIL_RECEIVED"
const val ACTION_EMAIL_DELETED = BuildConfig.APPLICATION_ID + ".intent.action.EMAIL_DELETED"
const val ACTION_REFRESH_OBSERVER = BuildConfig.APPLICATION_ID + ".intent.action.REFRESH_OBSERVER"
const val EXTRA_ACCOUNT = BuildConfig.APPLICATION_ID + ".intent.extra.ACCOUNT"
const val EXTRA_FOLDER = BuildConfig.APPLICATION_ID + ".intent.extra.FOLDER"
const val EXTRA_SENT_DATE = BuildConfig.APPLICATION_ID + ".intent.extra.SENT_DATE"
const val EXTRA_FROM = BuildConfig.APPLICATION_ID + ".intent.extra.FROM"
const val EXTRA_TO = BuildConfig.APPLICATION_ID + ".intent.extra.TO"
const val EXTRA_CC = BuildConfig.APPLICATION_ID + ".intent.extra.CC"
const val EXTRA_BCC = BuildConfig.APPLICATION_ID + ".intent.extra.BCC"
const val EXTRA_SUBJECT = BuildConfig.APPLICATION_ID + ".intent.extra.SUBJECT"
const val EXTRA_FROM_SELF = BuildConfig.APPLICATION_ID + ".intent.extra.FROM_SELF"
}

View file

@ -1,68 +0,0 @@
package com.fsck.k9.external
import android.content.Context
import android.content.Intent
import android.net.Uri
import com.fsck.k9.Account
import com.fsck.k9.controller.SimpleMessagingListener
import com.fsck.k9.mail.Address
import com.fsck.k9.mail.Message
import timber.log.Timber
class BroadcastSenderListener(private val context: Context) : SimpleMessagingListener() {
private fun broadcastReceivedIntent(account: Account, folderServerId: String, message: Message) {
val uri = Uri.parse("email://messages/" + account.accountNumber + "/" +
Uri.encode(folderServerId) + "/" + Uri.encode(message.uid))
val intent = Intent(BroadcastIntents.ACTION_EMAIL_RECEIVED, uri)
intent.putExtra(BroadcastIntents.EXTRA_ACCOUNT, account.description)
intent.putExtra(BroadcastIntents.EXTRA_FOLDER, folderServerId)
intent.putExtra(BroadcastIntents.EXTRA_SENT_DATE, message.sentDate)
intent.putExtra(BroadcastIntents.EXTRA_FROM, Address.toString(message.from))
intent.putExtra(BroadcastIntents.EXTRA_TO, Address.toString(message.getRecipients(Message.RecipientType.TO)))
intent.putExtra(BroadcastIntents.EXTRA_CC, Address.toString(message.getRecipients(Message.RecipientType.CC)))
intent.putExtra(BroadcastIntents.EXTRA_BCC, Address.toString(message.getRecipients(Message.RecipientType.BCC)))
intent.putExtra(BroadcastIntents.EXTRA_SUBJECT, message.subject)
intent.putExtra(BroadcastIntents.EXTRA_FROM_SELF, account.isAnIdentity(message.from))
context.sendBroadcast(intent)
Timber.d("Broadcasted: action=ACTION_EMAIL_RECEIVED account=%s folder=%s message uid=%s",
account.description,
folderServerId,
message.uid)
}
private fun broadcastDeletedIntent(account: Account, folderServerId: String, messageServerId: String) {
val uri = Uri.parse("email://messages/" + account.accountNumber + "/" +
Uri.encode(folderServerId) + "/" + Uri.encode(messageServerId))
val intent = Intent(BroadcastIntents.ACTION_EMAIL_DELETED, uri)
intent.putExtra(BroadcastIntents.EXTRA_ACCOUNT, account.description)
intent.putExtra(BroadcastIntents.EXTRA_FOLDER, folderServerId)
context.sendBroadcast(intent)
Timber.d("Broadcasted: action=ACTION_EMAIL_DELETED account=%s folder=%s message uid=%s",
account.description,
folderServerId,
messageServerId)
}
override fun synchronizeMailboxRemovedMessage(account: Account, folderServerId: String, messageServerId: String) {
broadcastDeletedIntent(account, folderServerId, messageServerId)
}
override fun messageDeleted(account: Account, folderServerId: String, messageServerId: String) {
broadcastDeletedIntent(account, folderServerId, messageServerId)
}
override fun synchronizeMailboxNewMessage(account: Account, folderServerId: String, message: Message) {
broadcastReceivedIntent(account, folderServerId, message)
}
override fun folderStatusChanged(account: Account, folderServerId: String, unreadMessageCount: Int) {
// let observers know a change occurred
val intent = Intent(BroadcastIntents.ACTION_REFRESH_OBSERVER, null)
intent.putExtra(BroadcastIntents.EXTRA_ACCOUNT, account.description)
intent.putExtra(BroadcastIntents.EXTRA_FOLDER, folderServerId)
context.sendBroadcast(intent)
}
}

View file

@ -1,7 +0,0 @@
package com.fsck.k9.external
import org.koin.dsl.module
val externalModule = module {
single { BroadcastSenderListener(get()) }
}

View file

@ -1,30 +0,0 @@
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 {
K9AccountReceptor receptor = null;
protected AccountReceiver(K9AccountReceptor nReceptor) {
receptor = nReceptor;
}
@Override
public void onReceive(Context context, Intent intent) {
if (K9RemoteControl.K9_REQUEST_ACCOUNTS.equals(intent.getAction())) {
Bundle bundle = getResultExtras(false);
if (bundle == null) {
Timber.w("Response bundle is empty");
return;
}
receptor.accounts(bundle.getStringArray(K9RemoteControl.K9_ACCOUNT_UUIDS), bundle.getStringArray(K9RemoteControl.K9_ACCOUNT_DESCRIPTIONS));
}
}
}

View file

@ -1,10 +0,0 @@
package com.fsck.k9.external.remotecontrol;
/**
*
* @author Daniel I. Applebaum
* The interface to implement in order to accept the arrays containing the UUIDs and descriptions of
* the accounts configured in K-9 Mail. Should be passed to fetchAccounts(Context, K9AccountReceptor)
*/
public interface K9AccountReceptor {
void accounts(String[] uuids, String[] descriptions);
}

View file

@ -1,139 +0,0 @@
package com.fsck.k9.external.remotecontrol;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
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"/>
* 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}
* sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver,
* Handler scheduler, int initialCode, String initialData, Bundle initialExtras).sendOrderedBroadcast}
* method in order to receive the list of Account UUIDs and descriptions that K-9 will provide.
*
* @author Daniel I. Applebaum
*
*/
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 = BuildConfig.APPLICATION_ID + ".permission.REMOTE_CONTROL";
/**
* {@link Intent} Action to be sent to K-9 using {@link ContextWrapper#sendBroadcast(Intent)} 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 = 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)
*/
//public final static String K9_CHECK_MAIL = "com.fsck.k9.K9RemoteControl.checkMail";
/**
* The {@link {@link Intent}} Action to set when remotely changing K-9 Mail settings
*/
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 = 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 = BuildConfig.APPLICATION_ID + ".K9RemoteControl.allAccounts";
public final static String K9_ENABLED = "true";
public final static String K9_DISABLED = "false";
/*
* 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 = 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 = 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 = BuildConfig.APPLICATION_ID + ".K9RemoteControl.vibrateEnabled";
public final static String K9_FOLDERS_NONE = "NONE";
public final static String K9_FOLDERS_ALL = "ALL";
public final static String K9_FOLDERS_FIRST_CLASS = "FIRST_CLASS";
public final static String K9_FOLDERS_FIRST_AND_SECOND_CLASS = "FIRST_AND_SECOND_CLASS";
public final static String K9_FOLDERS_NOT_SECOND_CLASS = "NOT_SECOND_CLASS";
/**
* Key for the {@link Intent} Extra to set for controlling which folders to be synchronized with Push.
* 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 = 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 = 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 = 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 = 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";
/**
* 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 = 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 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);
}
}

View file

@ -1,52 +0,0 @@
package com.fsck.k9.external.remotecontrol;
import java.util.List;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.fsck.k9.Account;
import com.fsck.k9.Preferences;
import com.fsck.k9.service.CoreReceiver;
import timber.log.Timber;
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
public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) {
Timber.i("RemoteControlReceiver.onReceive %s", intent);
if (K9RemoteControl.K9_SET.equals(intent.getAction())) {
RemoteControlService.set(context, intent, tmpWakeLockId);
tmpWakeLockId = null;
} else if (K9RemoteControl.K9_REQUEST_ACCOUNTS.equals(intent.getAction())) {
try {
Preferences preferences = Preferences.getPreferences(context);
List<Account> accounts = preferences.getAccounts();
String[] uuids = new String[accounts.size()];
String[] descriptions = new String[accounts.size()];
for (int i = 0; i < accounts.size(); i++) {
//warning: account may not be isAvailable()
Account account = accounts.get(i);
uuids[i] = account.getUuid();
descriptions[i] = account.getDescription();
}
Bundle bundle = getResultExtras(true);
bundle.putStringArray(K9_ACCOUNT_UUIDS, uuids);
bundle.putStringArray(K9_ACCOUNT_DESCRIPTIONS, descriptions);
} catch (Exception e) {
Timber.e(e, "Could not handle K9_RESPONSE_INTENT");
}
}
return tmpWakeLockId;
}
}

View file

@ -1,173 +0,0 @@
package com.fsck.k9.external.remotecontrol;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import com.fsck.k9.Account;
import com.fsck.k9.Account.FolderMode;
import com.fsck.k9.DI;
import com.fsck.k9.K9;
import com.fsck.k9.K9.BACKGROUND_OPS;
import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.job.K9JobManager;
import com.fsck.k9.preferences.StorageEditor;
import com.fsck.k9.service.BootReceiver;
import com.fsck.k9.service.CoreService;
import java.util.List;
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";
private final static String PUSH_RESTART_ACTION = "com.fsck.k9.service.RemoteControlService.PUSH_RESTART_ACTION";
private final static String SET_ACTION = "com.fsck.k9.service.RemoteControlService.SET_ACTION";
private final Preferences preferences = DI.get(Preferences.class);
private final K9JobManager jobManager = DI.get(K9JobManager.class);
public static void set(Context context, Intent i, Integer wakeLockId) {
// Intent i = new Intent();
i.setClass(context, RemoteControlService.class);
i.setAction(RemoteControlService.SET_ACTION);
addWakeLockId(context, i, wakeLockId, true);
context.startService(i);
}
public static final int REMOTE_CONTROL_SERVICE_WAKE_LOCK_TIMEOUT = 20000;
@Override
public int startService(final Intent intent, final int startId) {
Timber.i("RemoteControlService started with startId = %d", startId);
if (RESCHEDULE_ACTION.equals(intent.getAction())) {
Timber.i("RemoteControlService requesting jobmanager mail poll reschedule");
jobManager.scheduleMailSync();
}
if (PUSH_RESTART_ACTION.equals(intent.getAction())) {
Timber.i("RemoteControlService requesting jobmanager push restart");
jobManager.schedulePusherRefresh();
} else if (RemoteControlService.SET_ACTION.equals(intent.getAction())) {
Timber.i("RemoteControlService got request to change settings");
execute(getApplication(), new Runnable() {
public void run() {
try {
boolean needsReschedule = false;
boolean needsPushRestart = false;
String uuid = intent.getStringExtra(K9_ACCOUNT_UUID);
boolean allAccounts = intent.getBooleanExtra(K9_ALL_ACCOUNTS, false);
if (allAccounts) {
Timber.i("RemoteControlService changing settings for all accounts");
} else {
Timber.i("RemoteControlService changing settings for account with UUID %s", uuid);
}
List<Account> accounts = preferences.getAccounts();
for (Account account : accounts) {
//warning: account may not be isAvailable()
if (allAccounts || account.getUuid().equals(uuid)) {
Timber.i("RemoteControlService changing settings for account %s",
account.getDescription());
String notificationEnabled = intent.getStringExtra(K9_NOTIFICATION_ENABLED);
String ringEnabled = intent.getStringExtra(K9_RING_ENABLED);
String vibrateEnabled = intent.getStringExtra(K9_VIBRATE_ENABLED);
String pushClasses = intent.getStringExtra(K9_PUSH_CLASSES);
String pollClasses = intent.getStringExtra(K9_POLL_CLASSES);
String pollFrequency = intent.getStringExtra(K9_POLL_FREQUENCY);
if (notificationEnabled != null) {
account.setNotifyNewMail(Boolean.parseBoolean(notificationEnabled));
}
if (ringEnabled != null) {
account.getNotificationSetting().setRingEnabled(Boolean.parseBoolean(ringEnabled));
}
if (vibrateEnabled != null) {
account.getNotificationSetting().setVibrateEnabled(Boolean.parseBoolean(vibrateEnabled));
}
if (pushClasses != null) {
needsPushRestart |= account.setFolderPushMode(FolderMode.valueOf(pushClasses));
}
if (pollClasses != null) {
needsReschedule |= account.setFolderSyncMode(FolderMode.valueOf(pollClasses));
}
if (pollFrequency != null) {
String[] allowedFrequencies = getResources().getStringArray(R.array.check_frequency_values);
for (String allowedFrequency : allowedFrequencies) {
if (allowedFrequency.equals(pollFrequency)) {
Integer newInterval = Integer.parseInt(allowedFrequency);
needsReschedule |= account.setAutomaticCheckIntervalMinutes(newInterval);
}
}
}
Preferences.getPreferences(getApplicationContext()).saveAccount(account);
}
}
Timber.i("RemoteControlService changing global settings");
String backgroundOps = intent.getStringExtra(K9_BACKGROUND_OPERATIONS);
if (K9RemoteControl.K9_BACKGROUND_OPERATIONS_ALWAYS.equals(backgroundOps)
|| K9RemoteControl.K9_BACKGROUND_OPERATIONS_NEVER.equals(backgroundOps)
|| K9RemoteControl.K9_BACKGROUND_OPERATIONS_WHEN_CHECKED_AUTO_SYNC.equals(backgroundOps)) {
BACKGROUND_OPS newBackgroundOps = BACKGROUND_OPS.valueOf(backgroundOps);
BACKGROUND_OPS currentBackgroundOps = K9.getBackgroundOps();
if (newBackgroundOps != currentBackgroundOps) {
K9.setBackgroundOps(newBackgroundOps);
needsPushRestart = true;
needsReschedule = true;
}
}
String theme = intent.getStringExtra(K9_THEME);
if (theme != null) {
K9.setAppTheme(K9RemoteControl.K9_THEME_DARK.equals(theme) ? K9.AppTheme.DARK : K9.AppTheme.LIGHT);
}
StorageEditor editor = preferences.createStorageEditor();
K9.save(editor);
editor.commit();
if (needsReschedule) {
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(RemoteControlService.this, RemoteControlService.class);
i.setAction(PUSH_RESTART_ACTION);
long nextTime = System.currentTimeMillis() + 10000;
BootReceiver.scheduleIntent(RemoteControlService.this, nextTime, i);
}
} catch (Exception e) {
Timber.e(e, "Could not handle K9_SET");
Toast toast = Toast.makeText(RemoteControlService.this, e.getMessage(), Toast.LENGTH_LONG);
toast.show();
}
}
}
, RemoteControlService.REMOTE_CONTROL_SERVICE_WAKE_LOCK_TIMEOUT, startId);
}
return START_NOT_STICKY;
}
}

View file

@ -10,9 +10,6 @@
<string name="shortcuts_title">K-9 Accounts</string>
<string name="unread_widget_label">K-9 Unread</string>
<string name="remote_control_label">K-9 Mail remote control</string>
<string name="remote_control_desc">Allows this application to control K-9 Mail activities and settings.</string>
<!-- Used in the about dialog -->
<string name="app_authors">The K-9 Dog Walkers</string>