OUT-507: Add IsUXImprovementEnabled setting and only hide messages if this setting is set to true
authorThomas
Fri, 14 Dec 2018 15:22:58 +0100
changeset 250924395aeaba47
parent 2507 69af585f9277
child 2510 bdde985d91ac
OUT-507: Add IsUXImprovementEnabled setting and only hide messages if this setting is set to true
CryptableMailItem.cs
PEPSettings.cs
ThisAddIn.cs
     1.1 --- a/CryptableMailItem.cs	Fri Dec 14 13:27:10 2018 +0100
     1.2 +++ b/CryptableMailItem.cs	Fri Dec 14 15:22:58 2018 +0100
     1.3 @@ -1346,8 +1346,10 @@
     1.4                      }
     1.5  
     1.6                      // Remove the pEp Processing category if needed
     1.7 -                    if (this.internalMailItem.RemovePEPProcessingCategory())
     1.8 +                    if (Globals.ThisAddIn.Settings.IsUXImprovementEnabled &&
     1.9 +                        this.internalMailItem.RemovePEPProcessingCategory())
    1.10                      {
    1.11 +                        this.internalMailItem.UnRead = true;
    1.12                          saveInternalMailItem = true;
    1.13                      }
    1.14  
     2.1 --- a/PEPSettings.cs	Fri Dec 14 13:27:10 2018 +0100
     2.2 +++ b/PEPSettings.cs	Fri Dec 14 15:22:58 2018 +0100
     2.3 @@ -71,6 +71,7 @@
     2.4          public const string REG_NAME_IS_SYNC_ENABLED_FOR_ALL_ACCOUNTS           = "IsSyncEnabledForAllAccounts";
     2.5          public const string REG_NAME_IS_TNEF_DISABLED                           = "DisableTNEF"; // Name defined by Microsoft
     2.6          public const string REG_NAME_IS_UNENCRYPTED_SUBJECT_ENABLED             = "IsUnencryptedSubjectEnabled";
     2.7 +        public const string REG_NAME_IS_UX_IMPROVEMENT_ENABLED                  = "IsUXImprovementEnabled";
     2.8          public const string REG_NAME_IS_VERBOSE_LOGGING_ENABLED                 = "IsVerboseLoggingEnabled";
     2.9          public const string REG_NAME_TRUSTWORDS_CULTURE                         = "TrustwordsCulture";
    2.10  
    2.11 @@ -109,6 +110,7 @@
    2.12          public const bool                  IS_SYNC_ENABLED_FOR_ALL_ACCOUNTS_DEFAULT           = true;
    2.13          public const bool                  IS_TNEF_DISABLED_DEFAULT                           = false;
    2.14          public const bool                  IS_UNENCRYPTED_SUBJECT_ENABLED_DEFAULT             = true;
    2.15 +        public const bool                  IS_UX_IMPROVEMENT_ENABLED_DEFAULT                  = true;
    2.16          public const bool                  IS_VERBOSE_LOGGING_ENABLED_DEFAULT                 = false;
    2.17  
    2.18          private ObservableCollection<PEPAccountSettings> _AccountSettingsList;
    2.19 @@ -133,6 +135,7 @@
    2.20          private bool                                     _IsSyncEnabledForAllAccounts;
    2.21          private bool                                     _IsTNEFDisabled;
    2.22          private bool                                     _IsUnencryptedSubjectEnabled;
    2.23 +        private bool                                     _IsUXImprovementEnabled;
    2.24          private bool                                     _IsVerboseLoggingEnabled;
    2.25          private CultureInfo                              _TrustwordsCulture;
    2.26  
    2.27 @@ -471,6 +474,22 @@
    2.28          }
    2.29  
    2.30          /// <summary>
    2.31 +        /// Gets or sets whether to enable the UX improvement.
    2.32 +        /// </summary>
    2.33 +        public bool IsUXImprovementEnabled
    2.34 +        {
    2.35 +            get { return (this._IsUXImprovementEnabled); }
    2.36 +            set
    2.37 +            {
    2.38 +                if (object.Equals(this._IsUXImprovementEnabled, value) == false)
    2.39 +                {
    2.40 +                    this._IsUXImprovementEnabled = value;
    2.41 +                    this.RaisePropertyChangedEvent(nameof(this.IsUXImprovementEnabled));
    2.42 +                }
    2.43 +            }
    2.44 +        }
    2.45 +
    2.46 +        /// <summary>
    2.47          /// Gets or sets whether verbose logging is enabled.
    2.48          /// </summary>
    2.49          public bool IsVerboseLoggingEnabled
    2.50 @@ -556,6 +575,7 @@
    2.51              this._IsSyncEnabledForAllAccounts = PEPSettings.IS_SYNC_ENABLED_FOR_ALL_ACCOUNTS_DEFAULT;
    2.52              this._IsTNEFDisabled = PEPSettings.IS_TNEF_DISABLED_DEFAULT;
    2.53              this._IsUnencryptedSubjectEnabled = PEPSettings.IS_UNENCRYPTED_SUBJECT_ENABLED_DEFAULT;
    2.54 +            this._IsUXImprovementEnabled = PEPSettings.IS_UX_IMPROVEMENT_ENABLED_DEFAULT;
    2.55              this._IsVerboseLoggingEnabled = PEPSettings.IS_VERBOSE_LOGGING_ENABLED_DEFAULT;
    2.56              this._TrustwordsCulture = null; // Allow application to decide since default is UI language
    2.57  
    2.58 @@ -584,6 +604,7 @@
    2.59              this.RaisePropertyChangedEvent(nameof(this.IsSyncEnabledForAllAccounts));
    2.60              this.RaisePropertyChangedEvent(nameof(this.IsTNEFDisabled));
    2.61              this.RaisePropertyChangedEvent(nameof(this.IsUnencryptedSubjectEnabled));
    2.62 +            this.RaisePropertyChangedEvent(nameof(this.IsUXImprovementEnabled));
    2.63              this.RaisePropertyChangedEvent(nameof(this.IsVerboseLoggingEnabled));
    2.64              this.RaisePropertyChangedEvent(nameof(this.TrustwordsCulture));
    2.65  
    2.66 @@ -711,6 +732,7 @@
    2.67                  Comparisons.Equals(this.IsSyncEnabledForAllAccounts, obj.IsSyncEnabledForAllAccounts) &&
    2.68                  Comparisons.Equals(this.IsTNEFDisabled, obj.IsTNEFDisabled) &&
    2.69                  Comparisons.Equals(this.IsUnencryptedSubjectEnabled, obj.IsUnencryptedSubjectEnabled) &&
    2.70 +                Comparisons.Equals(this.IsUXImprovementEnabled, obj.IsUXImprovementEnabled) &&
    2.71                  Comparisons.Equals(this.IsVerboseLoggingEnabled, obj.IsVerboseLoggingEnabled) &&
    2.72                  Comparisons.Equals(this.TrustwordsCulture, obj.TrustwordsCulture))
    2.73              {
    2.74 @@ -1756,6 +1778,31 @@
    2.75                              this.RaisePropertyChangedEvent(nameof(this.IsUnencryptedSubjectEnabled));
    2.76                          }
    2.77  
    2.78 +                        // Attempt to get IsUXImprovementEnabled value
    2.79 +                        isPropertySet = false;
    2.80 +                        try
    2.81 +                        {
    2.82 +                            keyValue = pEpKey.GetValue(PEPSettings.REG_NAME_IS_UX_IMPROVEMENT_ENABLED, PEPSettings.IS_UX_IMPROVEMENT_ENABLED_DEFAULT) as string;
    2.83 +                            if (bool.TryParse(keyValue, out parsedBoolValue))
    2.84 +                            {
    2.85 +                                this._IsUXImprovementEnabled = parsedBoolValue;
    2.86 +                                isPropertySet = true;
    2.87 +                            }
    2.88 +                        }
    2.89 +                        catch
    2.90 +                        {
    2.91 +                            Log.Warning("LoadFromRegistry: Unable to read IsUXImprovementEnabled");
    2.92 +                        }
    2.93 +                        finally
    2.94 +                        {
    2.95 +                            if (isPropertySet == false)
    2.96 +                            {
    2.97 +                                this._IsUXImprovementEnabled = PEPSettings.IS_UX_IMPROVEMENT_ENABLED_DEFAULT;
    2.98 +                            }
    2.99 +
   2.100 +                            this.RaisePropertyChangedEvent(nameof(this.IsUXImprovementEnabled));
   2.101 +                        }
   2.102 +
   2.103                          // Attempt to get IsVerboseLoggingEnabled value
   2.104                          isPropertySet = false;
   2.105                          try
     3.1 --- a/ThisAddIn.cs	Fri Dec 14 13:27:10 2018 +0100
     3.2 +++ b/ThisAddIn.cs	Fri Dec 14 15:22:58 2018 +0100
     3.3 @@ -3884,10 +3884,12 @@
     3.4                               * the 'pEp Processing' category. As this means that in those environments, this category doesn't get removed correctly
     3.5                               * and the mail item remains hidden until a restart of Outlook. Therefore, don't hide messages on IMAP.
     3.6                               */ 
     3.7 -                            if ((omi?.Attachments?.Count == 2) &&
     3.8 +                            if ((Globals.ThisAddIn.Settings.IsUXImprovementEnabled) &&
     3.9 +                                (omi?.Attachments?.Count == 2) &&
    3.10                                  (omi.GetAccountType() != Outlook.OlAccountType.olImap))
    3.11                              {
    3.12                                  omi.AddPEPProcessingCategory();
    3.13 +                                omi.UnRead = false;
    3.14                                  omi.Save();
    3.15                              }
    3.16