From 9e74faf6de95f19ff66443cf64d6320f7c469106 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 12 Apr 2017 18:05:02 +0200 Subject: [PATCH] persist dialog counters --- k9mail/src/main/java/com/fsck/k9/K9.java | 15 +++++++++++++++ .../k9/activity/compose/RecipientPresenter.java | 2 ++ 2 files changed, 17 insertions(+) diff --git a/k9mail/src/main/java/com/fsck/k9/K9.java b/k9mail/src/main/java/com/fsck/k9/K9.java index 8b64f696d..36eaedf6d 100644 --- a/k9mail/src/main/java/com/fsck/k9/K9.java +++ b/k9mail/src/main/java/com/fsck/k9/K9.java @@ -21,6 +21,7 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.pm.PackageManager; import android.net.Uri; +import android.os.AsyncTask; import android.os.Environment; import android.os.Handler; import android.os.Looper; @@ -1435,4 +1436,18 @@ public class K9 extends Application { } } + public static void saveSettingsAsync() { + new AsyncTask() { + @Override + protected Void doInBackground(Void... voids) { + Preferences prefs = Preferences.getPreferences(app); + StorageEditor editor = prefs.getStorage().edit(); + save(editor); + editor.commit(); + + return null; + } + }.execute(); + } + } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java index ec326a1f0..a66209300 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java @@ -756,6 +756,7 @@ public class RecipientPresenter implements PermissionPingCallback { int pgpInlineDialogCounter = K9.getPgpInlineDialogCounter(); if (pgpInlineDialogCounter < PGP_DIALOG_DISPLAY_THRESHOLD) { K9.setPgpInlineDialogCounter(pgpInlineDialogCounter + 1); + K9.saveSettingsAsync(); return true; } return false; @@ -765,6 +766,7 @@ public class RecipientPresenter implements PermissionPingCallback { int pgpSignOnlyDialogCounter = K9.getPgpSignOnlyDialogCounter(); if (pgpSignOnlyDialogCounter < PGP_DIALOG_DISPLAY_THRESHOLD) { K9.setPgpSignOnlyDialogCounter(pgpSignOnlyDialogCounter + 1); + K9.saveSettingsAsync(); return true; } return false;