Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 327a47d2 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #1688 from k9mail/limit-pgp-inline-dialog-displays

Limit number of times the PGP/Inline info dialog is displayed

Fixes #1595
parents 88eb0f66 a8d4655e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -255,6 +255,8 @@ public class K9 extends Application {
    private static boolean sMessageViewCopyActionVisible = false;
    private static boolean sMessageViewSpamActionVisible = false;

    private static int sPgpInlineDialogCounter;


    /**
     * @see #areDatabasesUpToDate()
@@ -492,6 +494,8 @@ public class K9 extends Application {
        editor.putBoolean("messageViewCopyActionVisible", sMessageViewCopyActionVisible);
        editor.putBoolean("messageViewSpamActionVisible", sMessageViewSpamActionVisible);

        editor.putInt("pgpInlineDialogCounter", sPgpInlineDialogCounter);

        fontSizes.save(editor);
    }

@@ -738,6 +742,7 @@ public class K9 extends Application {
        sMessageViewCopyActionVisible = storage.getBoolean("messageViewCopyActionVisible", false);
        sMessageViewSpamActionVisible = storage.getBoolean("messageViewSpamActionVisible", false);

        sPgpInlineDialogCounter = storage.getInt("pgpInlineDialogCounter", 0);

        K9.setK9Language(storage.getString("language", ""));

@@ -1316,6 +1321,14 @@ public class K9 extends Application {
        sMessageViewSpamActionVisible = visible;
    }

    public static int getPgpInlineDialogCounter() {
        return sPgpInlineDialogCounter;
    }

    public static void setPgpInlineDialogCounter(int pgpInlineDialogCounter) {
        K9.sPgpInlineDialogCounter = pgpInlineDialogCounter;
    }

    /**
     * Check if we already know whether all databases are using the current database schema.
     *
+15 −1
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ public class RecipientPresenter implements PermissionPingCallback {
    private static final int CONTACT_PICKER_BCC = 3;
    private static final int OPENPGP_USER_INTERACTION = 4;

    private static final int PGP_INLINE_DIALOG_DISPLAY_THRESHOLD = 2;


    // transient state, which is either obtained during construction and initialization, or cached
    private final Context context;
@@ -714,9 +716,21 @@ public class RecipientPresenter implements PermissionPingCallback {
        cryptoEnablePgpInline = enablePgpInline;
        updateCryptoStatus();
        if (enablePgpInline) {
            boolean shouldShowPgpInlineDialog = checkAndIncrementPgpInlineDialogCounter();
            if (shouldShowPgpInlineDialog) {
                recipientMvpView.showOpenPgpInlineDialog(true);
            }
        }
    }

    private boolean checkAndIncrementPgpInlineDialogCounter() {
        int pgpInlineDialogCounter = K9.getPgpInlineDialogCounter();
        if (pgpInlineDialogCounter < PGP_INLINE_DIALOG_DISPLAY_THRESHOLD) {
            K9.setPgpInlineDialogCounter(pgpInlineDialogCounter + 1);
            return true;
        }
        return false;
    }

    public void onClickPgpInlineIndicator() {
        recipientMvpView.showOpenPgpInlineDialog(false);
+3 −0
Original line number Diff line number Diff line
@@ -273,6 +273,9 @@ public class GlobalSettings {
        s.put("confirmDiscardMessage", Settings.versions(
                new V(40, new BooleanSetting(true))
            ));
        s.put("pgpInlineDialogCounter", Settings.versions(
                new V(43, new IntegerRangeSetting(0, Integer.MAX_VALUE, 0))
        ));

        SETTINGS = Collections.unmodifiableMap(s);

+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ public class Settings {
     *
     * @see SettingsExporter
     */
    public static final int VERSION = 42;
    public static final int VERSION = 43;

    public static Map<String, Object> validate(int version, Map<String,
            TreeMap<Integer, SettingsDescription>> settings,