Merge pull request #1688 from k9mail/limit-pgp-inline-dialog-displays
Limit number of times the PGP/Inline info dialog is displayed Fixes #1595
This commit is contained in:
commit
327a47d2ef
4 changed files with 32 additions and 2 deletions
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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,10 +716,22 @@ public class RecipientPresenter implements PermissionPingCallback {
|
|||
cryptoEnablePgpInline = enablePgpInline;
|
||||
updateCryptoStatus();
|
||||
if (enablePgpInline) {
|
||||
recipientMvpView.showOpenPgpInlineDialog(true);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue