diff --git a/Configuration/UserConfig.cs b/Configuration/UserConfig.cs index 5c43c2b7..963a87c8 100644 --- a/Configuration/UserConfig.cs +++ b/Configuration/UserConfig.cs @@ -34,8 +34,9 @@ static UserConfig(){ // CONFIGURATION DATA - public bool FirstRun { get; set; } = true; - public bool AllowDataCollection { get; set; } = false; + public bool FirstRun { get; set; } = true; + public bool AllowDataCollection { get; set; } = false; + public bool ShowDataCollectionNotification { get; set; } = true; public WindowState BrowserWindow { get; set; } = new WindowState(); public WindowState PluginsWindow { get; set; } = new WindowState(); diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index 240f2318..67f50ebf 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -68,6 +68,8 @@ public FormBrowser(UpdaterSettings updaterSettings){ this.notification.Show(); this.browser = new TweetDeckBrowser(this, plugins, new TweetDeckBridge(this, notification)); + this.browser.PageLoaded += browser_PageLoaded; + this.contextMenu = ContextMenuBrowser.CreateMenu(this); Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update @@ -205,6 +207,38 @@ private void trayIcon_ClickRestore(object sender, EventArgs e){ private void trayIcon_ClickClose(object sender, EventArgs e){ ForceClose(); } + + private void browser_PageLoaded(object sender, EventArgs e){ + if (Config.ShowDataCollectionNotification){ + this.InvokeAsyncSafe(() => { + if (!Config.FirstRun && Config.AllowDataCollection){ + FormMessage form = new FormMessage("Anonymous Data Update", "Hi! You can now review your anonymous data report, and opt-out if you've changed your mind. Collected data will be used to focus development on most commonly used features. If you want to opt-out but still support the project, any feedback and donations are appreciated.", MessageBoxIcon.Information); + form.AddButton("OK", ControlType.Accept | ControlType.Focused); + + Button btnReviewSettings = new Button{ + Anchor = AnchorStyles.Bottom | AnchorStyles.Left, + Font = SystemFonts.MessageBoxFont, + Location = new Point(9, 12), + Margin = new Padding(0, 0, 48, 0), + Size = new Size(160, 26), + Text = "Review Feedback Options", + UseVisualStyleBackColor = true + }; + + btnReviewSettings.Click += (sender2, args2) => { + form.Close(); + OpenSettings(typeof(TabSettingsFeedback)); + }; + + form.AddActionControl(btnReviewSettings); + ShowChildForm(form); + } + + Config.ShowDataCollectionNotification = false; + Config.Save(); + }); + } + } private void plugins_Reloaded(object sender, PluginErrorEventArgs e){ if (e.HasErrors){ @@ -327,6 +361,7 @@ public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){ if (Config.FirstRun){ Config.FirstRun = false; Config.AllowDataCollection = allowDataCollection; + Config.ShowDataCollectionNotification = false; Config.Save(); if (allowDataCollection && analytics == null){ diff --git a/Core/TweetDeckBrowser.cs b/Core/TweetDeckBrowser.cs index 012af918..639d04a2 100644 --- a/Core/TweetDeckBrowser.cs +++ b/Core/TweetDeckBrowser.cs @@ -32,6 +32,8 @@ public bool IsTweetDeckWebsite{ } } + public event EventHandler PageLoaded; + private readonly ChromiumWebBrowser browser; private readonly PluginManager plugins; private readonly MemoryUsageTracker memoryUsageTracker; @@ -145,6 +147,8 @@ private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){ if (Program.UserConfig.FirstRun){ ScriptLoader.ExecuteFile(e.Frame, "introduction.js"); } + + PageLoaded?.Invoke(this, EventArgs.Empty); } }