Loading app/core/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ dependencies { implementation "com.squareup.moshi:moshi:1.2.0" implementation "com.jakewharton.timber:timber:${versions.timber}" implementation "org.apache.james:apache-mime4j-core:${versions.mime4j}" implementation 'com.evernote:android-job:1.2.6' testImplementation project(':mail:testing') testImplementation project(":backend:imap") Loading app/core/src/main/java/com/fsck/k9/Account.java +2 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,8 @@ public class Account implements BaseAccount, StoreConfig { public static final long NO_OPENPGP_KEY = 0; public static final int UNASSIGNED_ACCOUNT_NUMBER = -1; public static final int INTERVAL_MINUTES_NEVER = -1; private DeletePolicy deletePolicy = DeletePolicy.NEVER; private final String accountUuid; Loading app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt +2 −2 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class AccountPreferenceSerializer( transportUri = Base64.decode(storage.getString("$accountUuid.transportUri", null)) description = storage.getString("$accountUuid.description", null) alwaysBcc = storage.getString("$accountUuid.alwaysBcc", alwaysBcc) automaticCheckIntervalMinutes = storage.getInt("$accountUuid.automaticCheckIntervalMinutes", -1) automaticCheckIntervalMinutes = storage.getInt("$accountUuid.automaticCheckIntervalMinutes", Account.INTERVAL_MINUTES_NEVER) idleRefreshMinutes = storage.getInt("$accountUuid.idleRefreshMinutes", 24) isPushPollOnConnect = storage.getBoolean("$accountUuid.pushPollOnConnect", true) displayCount = storage.getInt("$accountUuid.displayCount", K9.DEFAULT_VISIBLE_LIMIT) Loading Loading @@ -499,7 +499,7 @@ class AccountPreferenceSerializer( fun loadDefaults(account: Account) { with (account) { localStorageProviderId = storageManager.defaultProviderId automaticCheckIntervalMinutes = -1 automaticCheckIntervalMinutes = Account.INTERVAL_MINUTES_NEVER idleRefreshMinutes = 24 isPushPollOnConnect = true displayCount = K9.DEFAULT_VISIBLE_LIMIT Loading app/core/src/main/java/com/fsck/k9/Core.kt +11 −34 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ import android.os.StrictMode import com.fsck.k9.autocrypt.autocryptModule import com.fsck.k9.controller.controllerModule import com.fsck.k9.crypto.openPgpModule import com.fsck.k9.job.K9JobManager import com.fsck.k9.job.jobModule import com.fsck.k9.mail.internet.BinaryTempFileBody import com.fsck.k9.mail.ssl.LocalKeyStore import com.fsck.k9.mailstore.mailStoreModule Loading @@ -18,10 +20,8 @@ import com.fsck.k9.message.extractors.extractorModule import com.fsck.k9.message.html.htmlModule import com.fsck.k9.message.quote.quoteModule import com.fsck.k9.notification.coreNotificationModule import com.fsck.k9.power.DeviceIdleManager import com.fsck.k9.search.searchModule import com.fsck.k9.service.BootReceiver import com.fsck.k9.service.MailService import com.fsck.k9.service.ShutdownReceiver import com.fsck.k9.service.StorageGoneReceiver import org.koin.standalone.KoinComponent Loading @@ -31,8 +31,9 @@ import java.util.concurrent.SynchronousQueue object Core : KoinComponent { private val appConfig: AppConfig by inject() private val jobManager: K9JobManager by inject() private val componentsToDisable = listOf(BootReceiver::class.java, MailService::class.java) private val componentsToDisable = listOf(BootReceiver::class.java) @JvmStatic val coreModules = listOf( Loading @@ -45,7 +46,8 @@ object Core : KoinComponent { htmlModule, quoteModule, coreNotificationModule, controllerModule controllerModule, jobModule ) /** Loading Loading @@ -81,33 +83,12 @@ object Core : KoinComponent { val acctLength = Preferences.getPreferences(appContext).availableAccounts.size val enable = acctLength > 0 setServicesEnabled(appContext, enable, null) updateDeviceIdleReceiver(appContext, enable) } private fun updateDeviceIdleReceiver(context: Context, enable: Boolean) { val deviceIdleManager = DeviceIdleManager.getInstance(context) if (enable) { deviceIdleManager.registerReceiver() } else { deviceIdleManager.unregisterReceiver() } setServicesEnabled(appContext, enable) } private fun setServicesEnabled(context: Context, enabled: Boolean, wakeLockId: Int?) { private fun setServicesEnabled(context: Context, enabled: Boolean) { val pm = context.packageManager if (!enabled && pm.getComponentEnabledSetting(ComponentName(context, MailService::class.java)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { /* * If no accounts now exist but the service is still enabled we're about to disable it * so we'll reschedule to kill off any existing alarms. */ MailService.actionReset(context, wakeLockId) } val classes = componentsToDisable + appConfig.componentsToDisable for (clazz in classes) { val alreadyEnabled = pm.getComponentEnabledSetting(ComponentName(context, clazz)) == Loading @@ -124,14 +105,10 @@ object Core : KoinComponent { } } if (enabled && pm.getComponentEnabledSetting(ComponentName(context, MailService::class.java)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { /* * And now if accounts do exist then we've just enabled the service and we want to * schedule alarms for the new accounts. */ MailService.actionReset(context, wakeLockId) if (enabled) { jobManager.scheduleAllMailJobs() } } /** Loading app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +24 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; Loading Loading @@ -2403,6 +2404,25 @@ public class MessagingController { context.startActivity(chooserIntent); } public void checkMailBlocking(Account account) { final CountDownLatch latch = new CountDownLatch(1); checkMail(context, account, true, false, new SimpleMessagingListener() { @Override public void checkMailFinished(Context context, Account account) { latch.countDown(); } }); Timber.v("checkMailBlocking(%s) about to await latch release", account.getDescription()); try { latch.await(); Timber.v("checkMailBlocking(%s) got latch release", account.getDescription()); } catch (Exception e) { Timber.e(e, "Interrupted while awaiting latch release"); } } /** * Checks mail for one or multiple accounts. If account is null all accounts * are checked. Loading Loading @@ -2862,6 +2882,10 @@ public class MessagingController { return pushers.values(); } public Pusher getPusher(Account account) { return pushers.get(account); } public boolean setupPushing(final Account account) { try { Pusher previousPusher = pushers.remove(account); Loading Loading
app/core/build.gradle +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ dependencies { implementation "com.squareup.moshi:moshi:1.2.0" implementation "com.jakewharton.timber:timber:${versions.timber}" implementation "org.apache.james:apache-mime4j-core:${versions.mime4j}" implementation 'com.evernote:android-job:1.2.6' testImplementation project(':mail:testing') testImplementation project(":backend:imap") Loading
app/core/src/main/java/com/fsck/k9/Account.java +2 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,8 @@ public class Account implements BaseAccount, StoreConfig { public static final long NO_OPENPGP_KEY = 0; public static final int UNASSIGNED_ACCOUNT_NUMBER = -1; public static final int INTERVAL_MINUTES_NEVER = -1; private DeletePolicy deletePolicy = DeletePolicy.NEVER; private final String accountUuid; Loading
app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt +2 −2 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class AccountPreferenceSerializer( transportUri = Base64.decode(storage.getString("$accountUuid.transportUri", null)) description = storage.getString("$accountUuid.description", null) alwaysBcc = storage.getString("$accountUuid.alwaysBcc", alwaysBcc) automaticCheckIntervalMinutes = storage.getInt("$accountUuid.automaticCheckIntervalMinutes", -1) automaticCheckIntervalMinutes = storage.getInt("$accountUuid.automaticCheckIntervalMinutes", Account.INTERVAL_MINUTES_NEVER) idleRefreshMinutes = storage.getInt("$accountUuid.idleRefreshMinutes", 24) isPushPollOnConnect = storage.getBoolean("$accountUuid.pushPollOnConnect", true) displayCount = storage.getInt("$accountUuid.displayCount", K9.DEFAULT_VISIBLE_LIMIT) Loading Loading @@ -499,7 +499,7 @@ class AccountPreferenceSerializer( fun loadDefaults(account: Account) { with (account) { localStorageProviderId = storageManager.defaultProviderId automaticCheckIntervalMinutes = -1 automaticCheckIntervalMinutes = Account.INTERVAL_MINUTES_NEVER idleRefreshMinutes = 24 isPushPollOnConnect = true displayCount = K9.DEFAULT_VISIBLE_LIMIT Loading
app/core/src/main/java/com/fsck/k9/Core.kt +11 −34 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ import android.os.StrictMode import com.fsck.k9.autocrypt.autocryptModule import com.fsck.k9.controller.controllerModule import com.fsck.k9.crypto.openPgpModule import com.fsck.k9.job.K9JobManager import com.fsck.k9.job.jobModule import com.fsck.k9.mail.internet.BinaryTempFileBody import com.fsck.k9.mail.ssl.LocalKeyStore import com.fsck.k9.mailstore.mailStoreModule Loading @@ -18,10 +20,8 @@ import com.fsck.k9.message.extractors.extractorModule import com.fsck.k9.message.html.htmlModule import com.fsck.k9.message.quote.quoteModule import com.fsck.k9.notification.coreNotificationModule import com.fsck.k9.power.DeviceIdleManager import com.fsck.k9.search.searchModule import com.fsck.k9.service.BootReceiver import com.fsck.k9.service.MailService import com.fsck.k9.service.ShutdownReceiver import com.fsck.k9.service.StorageGoneReceiver import org.koin.standalone.KoinComponent Loading @@ -31,8 +31,9 @@ import java.util.concurrent.SynchronousQueue object Core : KoinComponent { private val appConfig: AppConfig by inject() private val jobManager: K9JobManager by inject() private val componentsToDisable = listOf(BootReceiver::class.java, MailService::class.java) private val componentsToDisable = listOf(BootReceiver::class.java) @JvmStatic val coreModules = listOf( Loading @@ -45,7 +46,8 @@ object Core : KoinComponent { htmlModule, quoteModule, coreNotificationModule, controllerModule controllerModule, jobModule ) /** Loading Loading @@ -81,33 +83,12 @@ object Core : KoinComponent { val acctLength = Preferences.getPreferences(appContext).availableAccounts.size val enable = acctLength > 0 setServicesEnabled(appContext, enable, null) updateDeviceIdleReceiver(appContext, enable) } private fun updateDeviceIdleReceiver(context: Context, enable: Boolean) { val deviceIdleManager = DeviceIdleManager.getInstance(context) if (enable) { deviceIdleManager.registerReceiver() } else { deviceIdleManager.unregisterReceiver() } setServicesEnabled(appContext, enable) } private fun setServicesEnabled(context: Context, enabled: Boolean, wakeLockId: Int?) { private fun setServicesEnabled(context: Context, enabled: Boolean) { val pm = context.packageManager if (!enabled && pm.getComponentEnabledSetting(ComponentName(context, MailService::class.java)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { /* * If no accounts now exist but the service is still enabled we're about to disable it * so we'll reschedule to kill off any existing alarms. */ MailService.actionReset(context, wakeLockId) } val classes = componentsToDisable + appConfig.componentsToDisable for (clazz in classes) { val alreadyEnabled = pm.getComponentEnabledSetting(ComponentName(context, clazz)) == Loading @@ -124,14 +105,10 @@ object Core : KoinComponent { } } if (enabled && pm.getComponentEnabledSetting(ComponentName(context, MailService::class.java)) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { /* * And now if accounts do exist then we've just enabled the service and we want to * schedule alarms for the new accounts. */ MailService.actionReset(context, wakeLockId) if (enabled) { jobManager.scheduleAllMailJobs() } } /** Loading
app/core/src/main/java/com/fsck/k9/controller/MessagingController.java +24 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; Loading Loading @@ -2403,6 +2404,25 @@ public class MessagingController { context.startActivity(chooserIntent); } public void checkMailBlocking(Account account) { final CountDownLatch latch = new CountDownLatch(1); checkMail(context, account, true, false, new SimpleMessagingListener() { @Override public void checkMailFinished(Context context, Account account) { latch.countDown(); } }); Timber.v("checkMailBlocking(%s) about to await latch release", account.getDescription()); try { latch.await(); Timber.v("checkMailBlocking(%s) got latch release", account.getDescription()); } catch (Exception e) { Timber.e(e, "Interrupted while awaiting latch release"); } } /** * Checks mail for one or multiple accounts. If account is null all accounts * are checked. Loading Loading @@ -2862,6 +2882,10 @@ public class MessagingController { return pushers.values(); } public Pusher getPusher(Account account) { return pushers.get(account); } public boolean setupPushing(final Account account) { try { Pusher previousPusher = pushers.remove(account); Loading