Remove "backgroundOps" methods from 'K9'

This commit is contained in:
cketti 2019-05-21 23:50:05 +02:00
parent 04f200ce02
commit 55f4484e15
4 changed files with 16 additions and 30 deletions

View file

@ -178,7 +178,8 @@ object K9 : KoinComponent {
@JvmStatic
val fontSizes = FontSizes()
private var backgroundOps = BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC
@JvmStatic
var backgroundOps = BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC
private var animations = true
@ -301,22 +302,6 @@ object K9 : KoinComponent {
updateLoggingStatus()
}
@JvmStatic
fun getBackgroundOps(): BACKGROUND_OPS {
return backgroundOps
}
@JvmStatic
fun setBackgroundOps(backgroundOps: BACKGROUND_OPS): Boolean {
val oldBackgroundOps = K9.backgroundOps
K9.backgroundOps = backgroundOps
return backgroundOps != oldBackgroundOps
}
fun setBackgroundOps(backgroundOps: String): Boolean {
return setBackgroundOps(BACKGROUND_OPS.valueOf(backgroundOps))
}
fun gesturesEnabled(): Boolean {
return gesturesEnabled
}
@ -703,12 +688,11 @@ object K9 : KoinComponent {
isThreadedViewEnabled = storage.getBoolean("threadedView", true)
fontSizes.load(storage)
try {
setBackgroundOps(BACKGROUND_OPS.valueOf(
storage.getString("backgroundOperations", BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC.name)
))
backgroundOps = try {
val settingValue = storage.getString("backgroundOperations", BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC.name)
BACKGROUND_OPS.valueOf(settingValue)
} catch (e: Exception) {
setBackgroundOps(BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC)
BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC
}
isColorizeMissingContactPictures = storage.getBoolean("colorizeMissingContactPictures", true)

View file

@ -26,7 +26,7 @@ class BootReceiver : CoreReceiver(), KoinComponent {
//K9.setServicesEnabled(context, tmpWakeLockId);
//tmpWakeLockId = null;
} else if ("com.android.sync.SYNC_CONN_STATUS_CHANGED" == action) {
val bOps = K9.getBackgroundOps()
val bOps = K9.backgroundOps
if (bOps == K9.BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC) {
jobManager.scheduleAllMailJobs()
}

View file

@ -13,7 +13,6 @@ 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.Storage;
import com.fsck.k9.preferences.StorageEditor;
import com.fsck.k9.service.BootReceiver;
import com.fsck.k9.service.CoreService;
@ -129,9 +128,12 @@ public class RemoteControlService extends CoreService {
|| K9RemoteControl.K9_BACKGROUND_OPERATIONS_NEVER.equals(backgroundOps)
|| K9RemoteControl.K9_BACKGROUND_OPERATIONS_WHEN_CHECKED_AUTO_SYNC.equals(backgroundOps)) {
BACKGROUND_OPS newBackgroundOps = BACKGROUND_OPS.valueOf(backgroundOps);
boolean needsReset = K9.setBackgroundOps(newBackgroundOps);
needsPushRestart |= needsReset;
needsReschedule |= needsReset;
BACKGROUND_OPS currentBackgroundOps = K9.getBackgroundOps();
if (newBackgroundOps != currentBackgroundOps) {
K9.setBackgroundOps(newBackgroundOps);
needsPushRestart = true;
needsReschedule = true;
}
}
String theme = intent.getStringExtra(K9_THEME);

View file

@ -112,7 +112,7 @@ class GeneralSettingsDataStore(
"splitview_mode" -> K9.splitViewMode.name
"notification_quick_delete" -> K9.notificationQuickDeleteBehaviour.name
"lock_screen_notification_visibility" -> K9.lockScreenNotificationVisibility.name
"background_ops" -> K9.getBackgroundOps().name
"background_ops" -> K9.backgroundOps.name
"notification_hide_subject" -> K9.notificationHideSubject.name
"quiet_time_starts" -> K9.quietTimeStarts
"quiet_time_ends" -> K9.quietTimeEnds
@ -240,8 +240,8 @@ class GeneralSettingsDataStore(
private fun setBackgroundOps(value: String) {
val newBackgroundOps = K9.BACKGROUND_OPS.valueOf(value)
if (newBackgroundOps != K9.getBackgroundOps()) {
K9.setBackgroundOps(value)
if (newBackgroundOps != K9.backgroundOps) {
K9.backgroundOps = newBackgroundOps
jobManager.scheduleAllMailJobs()
}
}