persist dialog counters

This commit is contained in:
Vincent Breitmoser 2017-04-12 18:05:02 +02:00
parent 009b40ccad
commit 9e74faf6de
2 changed files with 17 additions and 0 deletions

View file

@ -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<Void,Void,Void>() {
@Override
protected Void doInBackground(Void... voids) {
Preferences prefs = Preferences.getPreferences(app);
StorageEditor editor = prefs.getStorage().edit();
save(editor);
editor.commit();
return null;
}
}.execute();
}
}

View file

@ -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;