From d19dca6ea597ea851efea005b8ff02e9e0352953 Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Sun, 24 Sep 2017 15:31:44 +0200 Subject: [PATCH] Add a (currently unimplemented) anonymous data collection option --- Configuration/UserConfig.cs | 3 +- Core/Bridge/TweetDeckBridge.cs | 4 +- Core/FormBrowser.cs | 9 +- Core/Other/FormSettings.cs | 1 + .../Settings/TabSettingsFeedback.Designer.cs | 119 ++++++++++++++++++ Core/Other/Settings/TabSettingsFeedback.cs | 25 ++++ Resources/Scripts/introduction.js | 25 +++- TweetDuck.csproj | 6 + 8 files changed, 184 insertions(+), 8 deletions(-) create mode 100644 Core/Other/Settings/TabSettingsFeedback.Designer.cs create mode 100644 Core/Other/Settings/TabSettingsFeedback.cs diff --git a/Configuration/UserConfig.cs b/Configuration/UserConfig.cs index 67d2a773..e3192573 100644 --- a/Configuration/UserConfig.cs +++ b/Configuration/UserConfig.cs @@ -44,7 +44,8 @@ static UserConfig(){ // CONFIGURATION DATA - public bool FirstRun { get; set; } = true; + public bool FirstRun { get; set; } = true; + public bool AllowDataCollection { get; set; } = false; public WindowState BrowserWindow { get; set; } = new WindowState(); public WindowState PluginsWindow { get; set; } = new WindowState(); diff --git a/Core/Bridge/TweetDeckBridge.cs b/Core/Bridge/TweetDeckBridge.cs index 8c2ef7ae..50889bb7 100644 --- a/Core/Bridge/TweetDeckBridge.cs +++ b/Core/Bridge/TweetDeckBridge.cs @@ -50,9 +50,9 @@ public TweetDeckBridge(FormBrowser form, FormNotificationMain notification){ this.notification = notification; } - public void OnIntroductionClosed(bool showGuide){ + public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){ form.InvokeAsyncSafe(() => { - form.OnIntroductionClosed(showGuide); + form.OnIntroductionClosed(showGuide, allowDataCollection); }); } diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index 1516ba15..4195b859 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -448,9 +448,12 @@ public void ReloadToTweetDeck(){ // callback handlers - public void OnIntroductionClosed(bool showGuide){ - Config.FirstRun = false; - Config.Save(); + public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){ + if (Config.FirstRun){ + Config.FirstRun = false; + Config.AllowDataCollection = allowDataCollection; + Config.Save(); + } if (showGuide){ ShowChildForm(new FormGuide()); diff --git a/Core/Other/FormSettings.cs b/Core/Other/FormSettings.cs index 39268cac..8ba97299 100644 --- a/Core/Other/FormSettings.cs +++ b/Core/Other/FormSettings.cs @@ -37,6 +37,7 @@ public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler up AddButton("System Tray", () => new TabSettingsTray()); AddButton("Notifications", () => new TabSettingsNotifications(browser.CreateNotificationForm(false))); AddButton("Sounds", () => new TabSettingsSounds()); + AddButton("Feedback", () => new TabSettingsFeedback()); AddButton("Advanced", () => new TabSettingsAdvanced(browser.ReinjectCustomCSS)); SelectTab(tabs[startTab ?? typeof(TabSettingsGeneral)]); diff --git a/Core/Other/Settings/TabSettingsFeedback.Designer.cs b/Core/Other/Settings/TabSettingsFeedback.Designer.cs new file mode 100644 index 00000000..348cec0c --- /dev/null +++ b/Core/Other/Settings/TabSettingsFeedback.Designer.cs @@ -0,0 +1,119 @@ +namespace TweetDuck.Core.Other.Settings { + partial class TabSettingsFeedback { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.panelFeedback = new System.Windows.Forms.Panel(); + this.labelDataCollectionLink = new System.Windows.Forms.LinkLabel(); + this.checkDataCollection = new System.Windows.Forms.CheckBox(); + this.labelDataCollection = new System.Windows.Forms.Label(); + this.labelFeedback = new System.Windows.Forms.Label(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.panelFeedback.SuspendLayout(); + this.SuspendLayout(); + // + // panelFeedback + // + this.panelFeedback.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panelFeedback.Controls.Add(this.labelDataCollectionLink); + this.panelFeedback.Controls.Add(this.checkDataCollection); + this.panelFeedback.Controls.Add(this.labelDataCollection); + this.panelFeedback.Location = new System.Drawing.Point(9, 31); + this.panelFeedback.Name = "panelFeedback"; + this.panelFeedback.Size = new System.Drawing.Size(322, 44); + this.panelFeedback.TabIndex = 1; + // + // labelDataCollectionLink + // + this.labelDataCollectionLink.AutoSize = true; + this.labelDataCollectionLink.LinkArea = new System.Windows.Forms.LinkArea(1, 10); + this.labelDataCollectionLink.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline; + this.labelDataCollectionLink.Location = new System.Drawing.Point(141, 24); + this.labelDataCollectionLink.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); + this.labelDataCollectionLink.Name = "labelDataCollectionLink"; + this.labelDataCollectionLink.Size = new System.Drawing.Size(66, 17); + this.labelDataCollectionLink.TabIndex = 3; + this.labelDataCollectionLink.TabStop = true; + this.labelDataCollectionLink.Text = "(learn more)"; + this.labelDataCollectionLink.UseCompatibleTextRendering = true; + this.labelDataCollectionLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.labelDataCollectionLink_LinkClicked); + // + // checkDataCollection + // + this.checkDataCollection.AutoSize = true; + this.checkDataCollection.Location = new System.Drawing.Point(6, 23); + this.checkDataCollection.Margin = new System.Windows.Forms.Padding(6, 5, 0, 3); + this.checkDataCollection.Name = "checkDataCollection"; + this.checkDataCollection.Size = new System.Drawing.Size(135, 17); + this.checkDataCollection.TabIndex = 2; + this.checkDataCollection.Text = "Send Anonymous Data"; + this.checkDataCollection.UseVisualStyleBackColor = true; + // + // labelDataCollection + // + this.labelDataCollection.AutoSize = true; + this.labelDataCollection.Location = new System.Drawing.Point(3, 5); + this.labelDataCollection.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0); + this.labelDataCollection.Name = "labelDataCollection"; + this.labelDataCollection.Size = new System.Drawing.Size(79, 13); + this.labelDataCollection.TabIndex = 1; + this.labelDataCollection.Text = "Data Collection"; + // + // labelFeedback + // + this.labelFeedback.AutoSize = true; + this.labelFeedback.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.labelFeedback.Location = new System.Drawing.Point(6, 8); + this.labelFeedback.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0); + this.labelFeedback.Name = "labelFeedback"; + this.labelFeedback.Size = new System.Drawing.Size(80, 20); + this.labelFeedback.TabIndex = 0; + this.labelFeedback.Text = "Feedback"; + // + // TabSettingsFeedback + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.panelFeedback); + this.Controls.Add(this.labelFeedback); + this.Name = "TabSettingsFeedback"; + this.Size = new System.Drawing.Size(340, 86); + this.panelFeedback.ResumeLayout(false); + this.panelFeedback.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel panelFeedback; + private System.Windows.Forms.CheckBox checkDataCollection; + private System.Windows.Forms.Label labelDataCollection; + private System.Windows.Forms.Label labelFeedback; + private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.LinkLabel labelDataCollectionLink; + } +} diff --git a/Core/Other/Settings/TabSettingsFeedback.cs b/Core/Other/Settings/TabSettingsFeedback.cs new file mode 100644 index 00000000..75891188 --- /dev/null +++ b/Core/Other/Settings/TabSettingsFeedback.cs @@ -0,0 +1,25 @@ +using System; +using System.Windows.Forms; +using TweetDuck.Core.Utils; + +namespace TweetDuck.Core.Other.Settings{ + sealed partial class TabSettingsFeedback : BaseTabSettings{ + public TabSettingsFeedback(){ + InitializeComponent(); + + checkDataCollection.Checked = Config.AllowDataCollection; + } + + public override void OnReady(){ + checkDataCollection.CheckedChanged += checkDataCollection_CheckedChanged; + } + + private void checkDataCollection_CheckedChanged(object sender, EventArgs e){ + Config.AllowDataCollection = checkDataCollection.Checked; + } + + private void labelDataCollectionLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e){ + BrowserUtils.OpenExternalBrowserUnsafe("https://github.com/chylex/TweetDuck/wiki/Send-anonymous-data"); + } + } +} diff --git a/Resources/Scripts/introduction.js b/Resources/Scripts/introduction.js index 427b7a9e..b99b3743 100644 --- a/Resources/Scripts/introduction.js +++ b/Resources/Scripts/introduction.js @@ -38,6 +38,21 @@ #td-introduction-modal button { margin-left: 8px; } + +#td-introduction-modal .anondata { + float: left; + margin: 5px 7px; +} + +#td-introduction-modal .anondata input { + vertical-align: -10%; +} + +#td-introduction-modal .anondata label { + cursor: pointer; + display: inline-block; + font-size: 14px; +} </style>`).appendTo(document.head); let ele = $(` @@ -56,6 +71,11 @@ <p>You can also view the guide by opening the main menu, going to <strong>About TweetDuck</strong> and clicking the help button.</p> </div> <footer class="txt-right"> + <div class="anondata"> + <input id="td-anonymous-data" type="checkbox" checked> + <label for="td-anonymous-data">Send anonymous usage data</label> + <label> (<a href="https://github.com/chylex/TweetDuck/wiki/Send-anonymous-data" rel="nofollow">learn more</a>)</label> + </div> <button class="btn btn-positive" data-guide><span class="label">Show Guide</span></button> <button class="btn btn-positive"><span class="label">Close</span</button> </footer> @@ -63,11 +83,12 @@ </div> </div>`).appendTo(".js-app"); - ele.find("button, a").click(function(){ + ele.find("button, a.mdl-dismiss").click(function(){ let showGuide = $(this)[0].hasAttribute("data-guide"); + let allowDataCollection = $("#td-anonymous-data").is(":checked"); ele.fadeOut(200, function(){ - $TD.onIntroductionClosed(showGuide); + $TD.onIntroductionClosed(showGuide, allowDataCollection); ele.remove(); css.remove(); }); diff --git a/TweetDuck.csproj b/TweetDuck.csproj index 1abd7908..e704e06b 100644 --- a/TweetDuck.csproj +++ b/TweetDuck.csproj @@ -178,6 +178,12 @@ <DependentUpon>DialogSettingsRestart.cs</DependentUpon> </Compile> <Compile Include="Core\Other\Management\BrowserProcesses.cs" /> + <Compile Include="Core\Other\Settings\TabSettingsFeedback.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Core\Other\Settings\TabSettingsFeedback.Designer.cs"> + <DependentUpon>TabSettingsFeedback.cs</DependentUpon> + </Compile> <Compile Include="Core\Other\Settings\TabSettingsTray.cs"> <SubType>UserControl</SubType> </Compile>