1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-09-14 10:32:10 +02:00

Compare commits

..

77 Commits
1.7.5 ... 1.8

Author SHA1 Message Date
fb13695ca5 Release 1.8 2017-06-16 19:56:57 +02:00
20c76d06f7 Fix templates not triggering textarea change 2017-06-16 19:43:48 +02:00
339a11f649 Remove empty line in unit test code 2017-06-16 19:43:25 +02:00
0989400d87 Fix column header icon position with old icons in edit-design plugin 2017-06-16 18:32:19 +02:00
52aacf602d Tweak formatting of edit-design plugin 2017-06-16 18:30:36 +02:00
54d70a6a17 Fix edit-design plugin to revert icons in notifications too 2017-06-16 08:03:22 +02:00
d980e09e0f Fix {ajax} token resolve order in template plugin 2017-06-16 04:22:44 +02:00
2e4cb12817 Add template name check and safeguard empty ajax token in template plugin 2017-06-16 03:50:16 +02:00
7b91cb2e96 Fix escaping and update modal text in template plugin 2017-06-16 03:34:30 +02:00
95c04a8abc Work on template plugin (keep button active, tweak code) 2017-06-16 02:04:44 +02:00
25822fefdb Add option to revert icons to edit-design plugin 2017-06-16 00:40:23 +02:00
d800ee2d28 Fix template plugin to handle combining {ajax} and {cursor} together 2017-06-11 01:05:15 +02:00
2a51371aca Add {ajax} token to template plugin 2017-06-11 00:25:42 +02:00
ee5d1a47dc Add {cursor} token to template plugin 2017-06-10 23:26:04 +02:00
b330b74347 Implement token reading in template plugin 2017-06-10 23:25:55 +02:00
11fa13f0bb Tweak google analytics detection to work on twitter.com 2017-06-08 18:43:46 +02:00
21400d72b3 Block TweetDeck's google analytics script 2017-06-08 18:39:40 +02:00
a710cb9d4f Make middle click on tweet reply icon open the compose drawer 2017-06-08 14:17:46 +02:00
3326ad52ce Work on template plugin (basic template impl, modal tweaks) 2017-06-07 19:25:38 +02:00
c9560df851 Implement template management, buttons, and persistency in template plugin 2017-06-07 17:22:31 +02:00
74cb45118e Force tweet actions to stay visible when replying in edit-design plugin 2017-06-07 14:41:39 +02:00
c79bf19e51 Add a section with advanced tips to template plugin and update layout 2017-06-07 00:34:27 +02:00
961bec0a2f Add basic layout and styles for the template plugin 2017-06-06 23:23:06 +02:00
89e4977cd1 Bump version of emoji keyboard plugin 2017-06-06 11:11:57 +02:00
bfe16475db Tweak update installer to explicitly list needed files instead of excluding unneeded ones 2017-06-06 04:41:17 +02:00
915d36867c Fix emoji keyboard position and leaking outside the window 2017-06-06 03:27:30 +02:00
48435af407 Add emoji search 2017-06-05 23:07:31 +02:00
86b6ec5212 Tweak emoji names to only use one array when loading file 2017-06-05 21:56:43 +02:00
775e70bc45 Rewrite HTML generation in emoji-keyboard & add emoji names to elements 2017-06-05 21:54:39 +02:00
9f565447d0 Remove emoji characters from emoji-ordering.txt 2017-06-05 19:35:41 +02:00
88d27bc29d Add instructions for updating the emoji order file in emoji-keyboard plugin 2017-06-05 19:32:04 +02:00
172ae87ac6 Merge pull request #129 from chylex/remove_legacy
Remove legacy code (plugins and installers)
2017-06-05 17:49:19 +02:00
91d572235e Make $id and $token properties in plugin objects unmodifiable 2017-06-05 17:28:45 +02:00
64d32dcb75 Delete plugin properties when disabling them 2017-06-05 17:28:01 +02:00
564b4283b6 Rewrite plugin reloading when enabled/disabled and refactor core plugin scripts 2017-06-05 14:49:34 +02:00
ca4d374a81 Fix errors in edit-design plugin when disabling/enabling 2017-06-05 14:43:14 +02:00
a753806d7b Fix 'Edit CEF arguments' restart prompt and tweak dialog text 2017-06-03 18:03:34 +02:00
bd1692cea3 Rename Settings to Options 2017-06-03 17:24:43 +02:00
b7ce089f08 Fix audio playback error leading to the wrong tab in Settings 2017-06-03 17:03:33 +02:00
8a6b47c5db Fix naming and tooltips in profile export/import UI 2017-06-03 16:37:23 +02:00
9f1fc4df18 Decrease compression level in update installer 2017-06-03 16:03:31 +02:00
c018a2a7bc Move sound notification handling to a separate library 2017-06-03 15:32:18 +02:00
a1aebab114 Update installers (remove outdated code, exclude .txt files in updater) 2017-06-03 15:30:10 +02:00
e30702e1d8 Move CefSharp license to bld/Resources/ 2017-06-03 13:01:39 +02:00
008ff4b055 Fix edit-design plugin resetting TweetDeck settings on first run 2017-05-31 18:33:21 +02:00
d7bba22e19 Remove legacy configuration for list of disabled plugins 2017-05-31 17:57:55 +02:00
2b9a910533 Remove legacy installation data from installers 2017-05-31 17:17:47 +02:00
118ebcc627 Fix update installer removing devtools_resources.pak 2017-05-28 18:19:37 +02:00
c741767b11 Release 1.7.7 2017-05-28 18:12:34 +02:00
4a09358e14 Make browser process LARGEADDRESSAWARE to fix crash with high memory usage 2017-05-28 03:33:09 +02:00
3f4ea1af08 Remove old plugin config migration code 2017-05-27 13:30:57 +02:00
35bb196832 Refactor file and folder paths in Program 2017-05-27 13:26:02 +02:00
cb5b50dd42 Fix one pixel line between column header and content 2017-05-26 16:34:42 +02:00
8652272526 Fix column header icons not showing tooltips with mouse near their edge 2017-05-26 16:14:02 +02:00
0f32504fde Add tooltips to clear-columns plugin 2017-05-26 15:50:07 +02:00
4735c21fc0 Rename "Reset" to "Restore" in clear-columns plugin and code.js 2017-05-26 15:17:12 +02:00
ecbcbcaed4 Release 1.7.6 2017-05-24 20:31:50 +02:00
1677b73ff8 Add protection to prevent code.js from crashing if Twitter changes something again 2017-05-24 19:21:13 +02:00
5929067a3d Add a function to code.js that checks if an object contains a nested property 2017-05-24 18:52:55 +02:00
d06834617b Remove code that broke after TweetDeck updated
Closes #125
2017-05-24 18:32:28 +02:00
9d048efe06 Cleanup code in TweetNotification 2017-05-24 18:31:42 +02:00
6a379bc2cd Make hardware acceleration setting use a new system config file
Closes #123
2017-05-24 14:06:10 +02:00
9f415b11b5 Fuck you and your stupid cmd line MS 2017-05-24 13:20:41 +02:00
b9b9193222 Push devtools_resources.pak 2017-05-19 19:46:06 +02:00
867c2d1632 Make static regexes lazily initialized 2017-05-19 15:53:26 +02:00
5447afc3f5 Make dev tools work in release if devtools_resources.pak is present 2017-05-19 15:14:46 +02:00
b5e58db242 Rewrite pre-login page skip to be instant 2017-05-19 14:24:51 +02:00
8ab99619d6 Fix project file 2017-05-19 14:24:29 +02:00
4c7660ee65 Restire browser window when the browser process is killed 2017-05-19 13:23:52 +02:00
c1b9bde7b0 Add an abstract request handler 2017-05-19 04:14:58 +02:00
0e8c6c066f Rewrite update system to predownload update installers 2017-05-17 18:21:06 +02:00
9e44a86be0 Make BrowserUtils.DownloadFileAsync return WebClient and delete the file when cancelled 2017-05-17 17:25:44 +02:00
b61479f84f Add WindowsUtils.TryDeleteFolderWhenAble for async folder deletion 2017-05-17 15:09:07 +02:00
e3c709b005 Add success action parameter to BrowserUtils.DownloadFileAsync 2017-05-17 14:19:35 +02:00
b2b3dba504 Make 'Edit CEF' and 'Edit CSS' dialogs not block the browser window 2017-05-17 14:05:23 +02:00
4d05441aa8 Rename root namespace to TweetDuck 2017-05-17 13:00:17 +02:00
419b3ee850 Make browser subprocess a custom project with custom assembly info 2017-05-17 00:54:15 +02:00
146 changed files with 3735 additions and 2517 deletions

View File

@@ -1,7 +1,7 @@
using System; using System;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Configuration{ namespace TweetDuck.Configuration{
static class Arguments{ static class Arguments{
// public args // public args
public const string ArgDataFolder = "-datafolder"; public const string ArgDataFolder = "-datafolder";
@@ -12,6 +12,7 @@ namespace TweetDck.Configuration{
// internal args // internal args
public const string ArgRestart = "-restart"; public const string ArgRestart = "-restart";
public const string ArgImportCookies = "-importcookies"; public const string ArgImportCookies = "-importcookies";
public const string ArgUpdated = "-updated";
// class data and methods // class data and methods
private static readonly CommandLineArgs Current = CommandLineArgs.FromStringArray('-', Environment.GetCommandLineArgs()); private static readonly CommandLineArgs Current = CommandLineArgs.FromStringArray('-', Environment.GetCommandLineArgs());
@@ -28,7 +29,18 @@ namespace TweetDck.Configuration{
CommandLineArgs args = Current.Clone(); CommandLineArgs args = Current.Clone();
args.RemoveFlag(ArgRestart); args.RemoveFlag(ArgRestart);
args.RemoveFlag(ArgImportCookies); args.RemoveFlag(ArgImportCookies);
args.RemoveFlag(ArgUpdated);
return args; return args;
} }
public static CommandLineArgs GetCurrentForInstaller(){
CommandLineArgs args = GetCurrentClean();
args.AddFlag(ArgUpdated);
return args;
}
public static string GetCurrentForInstallerCmd(){
return GetCurrentForInstaller().ToString().Replace("\"", "::");
}
} }
} }

View File

@@ -2,9 +2,9 @@
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Configuration{ namespace TweetDuck.Configuration{
sealed class LockManager{ sealed class LockManager{
public enum Result{ public enum Result{
Success, HasProcess, Fail Success, HasProcess, Fail

View File

@@ -0,0 +1,66 @@
using System;
using System.IO;
namespace TweetDuck.Configuration{
sealed class SystemConfig{
public static readonly bool IsHardwareAccelerationSupported = File.Exists(Path.Combine(Program.ProgramPath, "libEGL.dll")) &&
File.Exists(Path.Combine(Program.ProgramPath, "libGLESv2.dll"));
public bool HardwareAcceleration{
get => hardwareAcceleration && IsHardwareAccelerationSupported;
set => hardwareAcceleration = value;
}
private readonly string file;
private bool hardwareAcceleration;
private SystemConfig(string file){
this.file = file;
HardwareAcceleration = true;
}
private void WriteToStream(Stream stream){
stream.WriteByte((byte)(HardwareAcceleration ? 1 : 0));
}
private void ReadFromStream(Stream stream){
HardwareAcceleration = stream.ReadByte() > 0;
}
public bool Save(){
try{
string directory = Path.GetDirectoryName(file);
if (directory == null)return false;
Directory.CreateDirectory(directory);
using(Stream stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None)){
WriteToStream(stream);
}
return true;
}catch(Exception e){
Program.Reporter.HandleException("Configuration Error", "Could not save the system configuration file.", true, e);
return false;
}
}
public static SystemConfig Load(string file){
SystemConfig config = new SystemConfig(file);
try{
using(Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)){
config.ReadFromStream(stream);
}
}catch(FileNotFoundException){
}catch(DirectoryNotFoundException){
}catch(Exception e){
Program.Reporter.HandleException("Configuration Error", "Could not open the system configuration file. If you continue, you will lose system specific configuration such as Hardware Acceleration.", true, e);
}
return config;
}
}
}

View File

@@ -3,16 +3,22 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
using TweetDck.Core; using TweetDuck.Core;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Notification; using TweetDuck.Core.Notification;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
using TweetDck.Plugins; using TweetDuck.Plugins;
namespace TweetDck.Configuration{ namespace TweetDuck.Configuration{
[Serializable] [Serializable]
sealed class UserConfig{ sealed class UserConfig{
private static readonly IFormatter Formatter = new BinaryFormatter(); private static readonly IFormatter Formatter = new BinaryFormatter{ Binder = new LegacyBinder() };
private class LegacyBinder : SerializationBinder{
public override Type BindToType(string assemblyName, string typeName){
return Type.GetType(string.Format("{0}, {1}", typeName.Replace("TweetDck", "TweetDuck"), assemblyName.Replace("TweetDck", "TweetDuck")));
}
}
private const int CurrentFileVersion = 9; private const int CurrentFileVersion = 9;
@@ -40,7 +46,6 @@ namespace TweetDck.Configuration{
public bool EnableUpdateCheck { get; set; } public bool EnableUpdateCheck { get; set; }
public string DismissedUpdate { get; set; } public string DismissedUpdate { get; set; }
[Obsolete] public PluginConfig Plugins { get; set; } // TODO remove eventually
public WindowState PluginsWindow { get; set; } public WindowState PluginsWindow { get; set; }
public string CustomCefArgs { get; set; } public string CustomCefArgs { get; set; }
@@ -231,7 +236,7 @@ namespace TweetDck.Configuration{
Program.Reporter.Log(e.ToString()); Program.Reporter.Log(e.ToString());
} }
else if (firstException != null){ else if (firstException != null){
Program.Reporter.HandleException("Configuration Error", "Could not open the backup configuration file. If you continue, you may lose your settings and list of enabled plugins.", true, e); Program.Reporter.HandleException("Configuration Error", "Could not open the backup configuration file. If you continue, your program options will be reset.", true, e);
} }
} }
} }

View File

@@ -1,8 +1,8 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
namespace TweetDck.Core.Bridge{ namespace TweetDuck.Core.Bridge{
sealed class CallbackBridge{ sealed class CallbackBridge{
private readonly Control owner; private readonly Control owner;
private readonly Action safeCallback; private readonly Action safeCallback;

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Text; using System.Text;
namespace TweetDck.Core.Bridge{ namespace TweetDuck.Core.Bridge{
static class PropertyBridge{ static class PropertyBridge{
[Flags] [Flags]
public enum Properties{ public enum Properties{

View File

@@ -1,9 +1,9 @@
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Notification; using TweetDuck.Core.Notification;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Bridge{ namespace TweetDuck.Core.Bridge{
sealed class TweetDeckBridge{ sealed class TweetDeckBridge{
public static string LastRightClickedLink = string.Empty; public static string LastRightClickedLink = string.Empty;
public static string LastHighlightedTweet = string.Empty; public static string LastHighlightedTweet = string.Empty;
@@ -104,6 +104,13 @@ namespace TweetDck.Core.Bridge{
MessageBox.Show(contents, Program.BrandName+" Browser Message", MessageBoxButtons.OK, icon); MessageBox.Show(contents, Program.BrandName+" Browser Message", MessageBoxButtons.OK, icon);
} }
public void CrashDebug(string message){
#if DEBUG
Log(message);
System.Diagnostics.Debugger.Break();
#endif
}
public void Log(string data){ public void Log(string data){
System.Diagnostics.Debug.WriteLine(data); System.Diagnostics.Debug.WriteLine(data);
} }

View File

@@ -2,9 +2,9 @@
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Controls{ namespace TweetDuck.Core.Controls{
static class ControlExtensions{ static class ControlExtensions{
public static readonly Point InvisibleLocation = new Point(-32000, -32000); public static readonly Point InvisibleLocation = new Point(-32000, -32000);

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Controls{ namespace TweetDuck.Core.Controls{
class FlatButton : Button{ class FlatButton : Button{
protected override bool ShowFocusCues => false; protected override bool ShowFocusCues => false;

View File

@@ -1,7 +1,7 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Controls{ namespace TweetDuck.Core.Controls{
sealed class FlatProgressBar : ProgressBar{ sealed class FlatProgressBar : ProgressBar{
private readonly SolidBrush brush; private readonly SolidBrush brush;

View File

@@ -2,7 +2,7 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Controls{ namespace TweetDuck.Core.Controls{
sealed class TabButton : FlatButton{ sealed class TabButton : FlatButton{
public Action Callback { get; private set; } public Action Callback { get; private set; }

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Controls { namespace TweetDuck.Core.Controls {
partial class TabPanel { partial class TabPanel {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -4,7 +4,7 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Controls{ namespace TweetDuck.Core.Controls{
sealed partial class TabPanel : UserControl{ sealed partial class TabPanel : UserControl{
public Panel Content => panelContent; public Panel Content => panelContent;
public IEnumerable<TabButton> Buttons => panelButtons.Controls.Cast<TabButton>(); public IEnumerable<TabButton> Buttons => panelButtons.Controls.Cast<TabButton>();

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core { namespace TweetDuck.Core {
sealed partial class FormBrowser { sealed partial class FormBrowser {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -24,7 +24,7 @@
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.trayIcon = new TweetDck.Core.TrayIcon(this.components); this.trayIcon = new TweetDuck.Core.TrayIcon(this.components);
this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -32,15 +32,16 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = TweetDck.Core.Utils.BrowserUtils.BackgroundColor; this.BackColor = TweetDuck.Core.Utils.BrowserUtils.BackgroundColor;
this.ClientSize = new System.Drawing.Size(324, 386); this.ClientSize = new System.Drawing.Size(324, 386);
this.Icon = Properties.Resources.icon; this.Icon = Properties.Resources.icon;
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation; this.Location = TweetDuck.Core.Controls.ControlExtensions.InvisibleLocation;
this.MinimumSize = new System.Drawing.Size(340, 424); this.MinimumSize = new System.Drawing.Size(340, 424);
this.Name = "FormBrowser"; this.Name = "FormBrowser";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Activated += new System.EventHandler(this.FormBrowser_Activated); this.Activated += new System.EventHandler(this.FormBrowser_Activated);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormBrowser_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormBrowser_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FormBrowser_FormClosed);
this.ResizeEnd += new System.EventHandler(this.FormBrowser_ResizeEnd); this.ResizeEnd += new System.EventHandler(this.FormBrowser_ResizeEnd);
this.Resize += new System.EventHandler(this.FormBrowser_Resize); this.Resize += new System.EventHandler(this.FormBrowser_Resize);
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@@ -5,23 +5,23 @@ using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Configuration; using TweetDuck.Configuration;
using TweetDck.Core.Bridge; using TweetDuck.Core.Bridge;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Handling; using TweetDuck.Core.Handling;
using TweetDck.Core.Notification; using TweetDuck.Core.Notification;
using TweetDck.Core.Notification.Screenshot; using TweetDuck.Core.Notification.Screenshot;
using TweetDck.Core.Notification.Sound; using TweetDuck.Core.Other;
using TweetDck.Core.Other; using TweetDuck.Core.Utils;
using TweetDck.Core.Utils; using TweetDuck.Plugins;
using TweetDck.Plugins; using TweetDuck.Plugins.Enums;
using TweetDck.Plugins.Enums; using TweetDuck.Plugins.Events;
using TweetDck.Plugins.Events; using TweetDuck.Resources;
using TweetDck.Resources; using TweetDuck.Updates;
using TweetDck.Updates; using TweetDuck.Updates.Events;
using TweetDck.Updates.Events; using TweetLib.Audio.Utils;
namespace TweetDck.Core{ namespace TweetDuck.Core{
sealed partial class FormBrowser : Form{ sealed partial class FormBrowser : Form{
private static UserConfig Config => Program.UserConfig; private static UserConfig Config => Program.UserConfig;
@@ -38,7 +38,7 @@ namespace TweetDck.Core{
private FormWindowState prevState; private FormWindowState prevState;
private TweetScreenshotManager notificationScreenshotManager; private TweetScreenshotManager notificationScreenshotManager;
private ISoundNotificationPlayer soundNotification; private SoundNotification soundNotification;
public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings){ public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings){
InitializeComponent(); InitializeComponent();
@@ -64,7 +64,8 @@ namespace TweetDck.Core{
this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){ this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){
MenuHandler = new ContextMenuBrowser(this), MenuHandler = new ContextMenuBrowser(this),
JsDialogHandler = new JavaScriptDialogHandler(), JsDialogHandler = new JavaScriptDialogHandler(),
LifeSpanHandler = new LifeSpanHandler() LifeSpanHandler = new LifeSpanHandler(),
RequestHandler = new RequestHandlerBrowser()
}; };
#if DEBUG #if DEBUG
@@ -247,6 +248,12 @@ namespace TweetDck.Core{
} }
} }
private void FormBrowser_FormClosed(object sender, FormClosedEventArgs e){
if (isLoaded && UpdateInstallerPath == null){
updates.CleanupDownload();
}
}
private void Config_MuteToggled(object sender, EventArgs e){ private void Config_MuteToggled(object sender, EventArgs e){
UpdateProperties(PropertyBridge.Properties.MuteNotifications); UpdateProperties(PropertyBridge.Properties.MuteNotifications);
} }
@@ -285,23 +292,13 @@ namespace TweetDck.Core{
} }
} }
Hide(); updates.BeginUpdateDownload(this, e.UpdateInfo, update => {
if (update.DownloadStatus == UpdateDownloadStatus.Done){
UpdateInstallerPath = update.InstallerPath;
}
FormUpdateDownload downloadForm = new FormUpdateDownload(e.UpdateInfo);
downloadForm.MoveToCenter(this);
downloadForm.ShowDialog();
downloadForm.Dispose();
if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Succeeded){
UpdateInstallerPath = downloadForm.InstallerPath;
ForceClose(); ForceClose();
} });
else if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Manual){
ForceClose();
}
else{
Show();
}
} }
private void updates_UpdateDismissed(object sender, UpdateDismissedEventArgs e){ private void updates_UpdateDismissed(object sender, UpdateDismissedEventArgs e){
@@ -315,12 +312,12 @@ namespace TweetDck.Core{
using(FormMessage form = new FormMessage("Notification Sound Error", "Could not play custom notification sound."+Environment.NewLine+e.Message, MessageBoxIcon.Error)){ using(FormMessage form = new FormMessage("Notification Sound Error", "Could not play custom notification sound."+Environment.NewLine+e.Message, MessageBoxIcon.Error)){
form.CancelButton = form.AddButton("Ignore"); form.CancelButton = form.AddButton("Ignore");
Button btnOpenSettings = form.AddButton("Open Settings"); Button btnOpenSettings = form.AddButton("View Options");
btnOpenSettings.Width += 16; btnOpenSettings.Width += 16;
btnOpenSettings.Location = new Point(btnOpenSettings.Location.X-16, btnOpenSettings.Location.Y); btnOpenSettings.Location = new Point(btnOpenSettings.Location.X-16, btnOpenSettings.Location.Y);
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnOpenSettings){ if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnOpenSettings){
OpenSettings(FormSettings.TabIndexNotification); OpenSettings(FormSettings.TabIndexSounds);
} }
} }
} }
@@ -430,7 +427,7 @@ namespace TweetDck.Core{
} }
if (soundNotification == null){ if (soundNotification == null){
soundNotification = SoundNotification.New(); soundNotification = new SoundNotification();
soundNotification.PlaybackError += soundNotification_PlaybackError; soundNotification.PlaybackError += soundNotification_PlaybackError;
} }

View File

@@ -1,7 +1,7 @@
using CefSharp; using CefSharp;
using System; using System;
namespace TweetDck.Core.Handling{ namespace TweetDuck.Core.Handling{
class BrowserProcessHandler : IBrowserProcessHandler{ class BrowserProcessHandler : IBrowserProcessHandler{
void IBrowserProcessHandler.OnContextInitialized(){ void IBrowserProcessHandler.OnContextInitialized(){
using(IRequestContext ctx = Cef.GetGlobalRequestContext()){ using(IRequestContext ctx = Cef.GetGlobalRequestContext()){

View File

@@ -3,13 +3,14 @@ using System;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Bridge; using TweetDuck.Core.Bridge;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Handling{ namespace TweetDuck.Core.Handling{
abstract class ContextMenuBase : IContextMenuHandler{ abstract class ContextMenuBase : IContextMenuHandler{
private static readonly Regex RegexTwitterAccount = new Regex(@"^https?://twitter\.com/([^/]+)/?$", RegexOptions.Compiled); private static readonly Lazy<Regex> RegexTwitterAccount = new Lazy<Regex>(() => new Regex(@"^https?://twitter\.com/([^/]+)/?$", RegexOptions.Compiled), false);
protected static readonly bool HasDevTools = File.Exists(Path.Combine(Program.ProgramPath, "devtools_resources.pak"));
private const int MenuOpenLinkUrl = 26500; private const int MenuOpenLinkUrl = 26500;
private const int MenuCopyLinkUrl = 26501; private const int MenuCopyLinkUrl = 26501;
@@ -17,15 +18,8 @@ namespace TweetDck.Core.Handling{
private const int MenuOpenImage = 26503; private const int MenuOpenImage = 26503;
private const int MenuSaveImage = 26504; private const int MenuSaveImage = 26504;
private const int MenuCopyImageUrl = 26505; private const int MenuCopyImageUrl = 26505;
#if DEBUG
private const int MenuOpenDevTools = 26599; private const int MenuOpenDevTools = 26599;
protected void AddDebugMenuItems(IMenuModel model){
model.AddItem((CefMenuCommand)MenuOpenDevTools, "Open dev tools");
}
#endif
private readonly Form form; private readonly Form form;
protected ContextMenuBase(Form form){ protected ContextMenuBase(Form form){
@@ -34,7 +28,7 @@ namespace TweetDck.Core.Handling{
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){ public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && !parameters.UnfilteredLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){ if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && !parameters.UnfilteredLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){
if (RegexTwitterAccount.IsMatch(parameters.UnfilteredLinkUrl)){ if (RegexTwitterAccount.Value.IsMatch(parameters.UnfilteredLinkUrl)){
model.AddItem((CefMenuCommand)MenuOpenLinkUrl, "Open account in browser"); model.AddItem((CefMenuCommand)MenuOpenLinkUrl, "Open account in browser");
model.AddItem((CefMenuCommand)MenuCopyLinkUrl, "Copy account address"); model.AddItem((CefMenuCommand)MenuCopyLinkUrl, "Copy account address");
model.AddItem((CefMenuCommand)MenuCopyUsername, "Copy account username"); model.AddItem((CefMenuCommand)MenuCopyUsername, "Copy account username");
@@ -85,7 +79,7 @@ namespace TweetDck.Core.Handling{
} }
if (saveTarget != null){ if (saveTarget != null){
BrowserUtils.DownloadFileAsync(parameters.SourceUrl, saveTarget, ex => { BrowserUtils.DownloadFileAsync(parameters.SourceUrl, saveTarget, null, ex => {
MessageBox.Show("An error occurred while downloading the image: "+ex.Message, Program.BrandName+" Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("An error occurred while downloading the image: "+ex.Message, Program.BrandName+" Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error);
}); });
} }
@@ -97,15 +91,13 @@ namespace TweetDck.Core.Handling{
break; break;
case MenuCopyUsername: case MenuCopyUsername:
Match match = RegexTwitterAccount.Match(parameters.UnfilteredLinkUrl); Match match = RegexTwitterAccount.Value.Match(parameters.UnfilteredLinkUrl);
SetClipboardText(match.Success ? match.Groups[1].Value : parameters.UnfilteredLinkUrl); SetClipboardText(match.Success ? match.Groups[1].Value : parameters.UnfilteredLinkUrl);
break; break;
#if DEBUG
case MenuOpenDevTools: case MenuOpenDevTools:
browserControl.ShowDevTools(); browserControl.ShowDevTools();
break; break;
#endif
} }
return false; return false;
@@ -121,6 +113,10 @@ namespace TweetDck.Core.Handling{
form.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text, TextDataFormat.UnicodeText)); form.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text, TextDataFormat.UnicodeText));
} }
protected void AddDebugMenuItems(IMenuModel model){
model.AddItem((CefMenuCommand)MenuOpenDevTools, "Open dev tools");
}
protected static void RemoveSeparatorIfLast(IMenuModel model){ protected static void RemoveSeparatorIfLast(IMenuModel model){
if (model.Count > 0 && model.GetTypeAt(model.Count-1) == MenuItemType.Separator){ if (model.Count > 0 && model.GetTypeAt(model.Count-1) == MenuItemType.Separator){
model.RemoveAt(model.Count-1); model.RemoveAt(model.Count-1);

View File

@@ -1,10 +1,10 @@
using CefSharp; using CefSharp;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Bridge; using TweetDuck.Core.Bridge;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Handling{ namespace TweetDuck.Core.Handling{
class ContextMenuBrowser : ContextMenuBase{ class ContextMenuBrowser : ContextMenuBase{
private const int MenuGlobal = 26600; private const int MenuGlobal = 26600;
private const int MenuMute = 26601; private const int MenuMute = 26601;
@@ -20,7 +20,7 @@ namespace TweetDck.Core.Handling{
private const string TitleReloadBrowser = "Reload browser"; private const string TitleReloadBrowser = "Reload browser";
private const string TitleMuteNotifications = "Mute notifications"; private const string TitleMuteNotifications = "Mute notifications";
private const string TitleSettings = "Settings"; private const string TitleSettings = "Options";
private const string TitlePlugins = "Plugins"; private const string TitlePlugins = "Plugins";
private const string TitleAboutProgram = "About "+Program.BrandName; private const string TitleAboutProgram = "About "+Program.BrandName;
@@ -82,10 +82,10 @@ namespace TweetDck.Core.Handling{
globalMenu.AddItem((CefMenuCommand)MenuPlugins, TitlePlugins); globalMenu.AddItem((CefMenuCommand)MenuPlugins, TitlePlugins);
globalMenu.AddItem((CefMenuCommand)MenuAbout, TitleAboutProgram); globalMenu.AddItem((CefMenuCommand)MenuAbout, TitleAboutProgram);
#if DEBUG if (HasDevTools){
globalMenu.AddSeparator(); globalMenu.AddSeparator();
AddDebugMenuItems(globalMenu); AddDebugMenuItems(globalMenu);
#endif }
} }
RemoveSeparatorIfLast(model); RemoveSeparatorIfLast(model);

View File

@@ -1,8 +1,8 @@
using CefSharp; using CefSharp;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Notification; using TweetDuck.Core.Notification;
namespace TweetDck.Core.Handling{ namespace TweetDuck.Core.Handling{
class ContextMenuNotification : ContextMenuBase{ class ContextMenuNotification : ContextMenuBase{
private const int MenuSkipTweet = 26600; private const int MenuSkipTweet = 26600;
private const int MenuFreeze = 26601; private const int MenuFreeze = 26601;
@@ -44,9 +44,9 @@ namespace TweetDck.Core.Handling{
} }
} }
#if DEBUG if (HasDevTools){
AddDebugMenuItems(model); AddDebugMenuItems(model);
#endif }
RemoveSeparatorIfLast(model); RemoveSeparatorIfLast(model);

View File

@@ -2,10 +2,10 @@
using CefSharp.WinForms; using CefSharp.WinForms;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Other; using TweetDuck.Core.Other;
namespace TweetDck.Core.Handling { namespace TweetDuck.Core.Handling {
class JavaScriptDialogHandler : IJsDialogHandler{ class JavaScriptDialogHandler : IJsDialogHandler{
bool IJsDialogHandler.OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage){ bool IJsDialogHandler.OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage){
((ChromiumWebBrowser)browserControl).InvokeSafe(() => { ((ChromiumWebBrowser)browserControl).InvokeSafe(() => {

View File

@@ -1,7 +1,7 @@
using CefSharp; using CefSharp;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Handling{ namespace TweetDuck.Core.Handling{
class LifeSpanHandler : ILifeSpanHandler{ class LifeSpanHandler : ILifeSpanHandler{
public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser){ public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser){
newBrowser = null; newBrowser = null;

View File

@@ -0,0 +1,68 @@
using System.Security.Cryptography.X509Certificates;
using CefSharp;
namespace TweetDuck.Core.Handling{
abstract class RequestHandler : IRequestHandler{
// Browser
public virtual void OnRenderViewReady(IWebBrowser browserControl, IBrowser browser){}
public virtual void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status){}
public virtual bool OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool isRedirect){
return false;
}
public virtual bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture){
return false;
}
public virtual bool OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url){
return false;
}
// Resources
public virtual CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
return CefReturnValue.Continue;
}
public virtual void OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl){}
public virtual bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
return false;
}
public virtual IResponseFilter GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
return null;
}
public virtual void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength){}
// JavaScript & Plugins
public virtual bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback){
callback.Dispose();
return false;
}
public virtual void OnPluginCrashed(IWebBrowser browserControl, IBrowser browser, string pluginPath){}
// Auth
public virtual bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback){
callback.Dispose();
return false;
}
public virtual bool OnSelectClientCertificate(IWebBrowser browserControl, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback){
callback.Dispose();
return false;
}
public virtual bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback){
callback.Dispose();
return false;
}
}
}

View File

@@ -0,0 +1,17 @@
using CefSharp;
namespace TweetDuck.Core.Handling{
class RequestHandlerBrowser : RequestHandler{
public override void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status){
browser.Reload();
}
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
if (request.ResourceType == ResourceType.Script && request.Url.Contains("analytics.")){
return CefReturnValue.Cancel;
}
return CefReturnValue.Continue;
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Collections.Specialized;
using System.IO; using System.IO;
using System.Text; using System.Text;
namespace TweetDck.Core.Handling{ namespace TweetDuck.Core.Handling{
class ResourceHandlerNotification : IResourceHandler{ class ResourceHandlerNotification : IResourceHandler{
private readonly NameValueCollection headers = new NameValueCollection(0); private readonly NameValueCollection headers = new NameValueCollection(0);
private MemoryStream dataIn; private MemoryStream dataIn;

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Notification { namespace TweetDuck.Core.Notification {
partial class FormNotificationBase { partial class FormNotificationBase {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -34,7 +34,7 @@
this.BackColor = System.Drawing.SystemColors.Control; this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(284, 122); this.ClientSize = new System.Drawing.Size(284, 122);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation; this.Location = TweetDuck.Core.Controls.ControlExtensions.InvisibleLocation;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "FormNotification"; this.Name = "FormNotification";

View File

@@ -3,12 +3,12 @@ using CefSharp.WinForms;
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Configuration; using TweetDuck.Configuration;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Handling; using TweetDuck.Core.Handling;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Notification{ namespace TweetDuck.Core.Notification{
partial class FormNotificationBase : Form{ partial class FormNotificationBase : Form{
protected Point PrimaryLocation{ protected Point PrimaryLocation{
get{ get{

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Notification { namespace TweetDuck.Core.Notification {
partial class FormNotificationMain { partial class FormNotificationMain {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -26,7 +26,7 @@
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.timerDisplayDelay = new System.Windows.Forms.Timer(this.components); this.timerDisplayDelay = new System.Windows.Forms.Timer(this.components);
this.timerProgress = new System.Windows.Forms.Timer(this.components); this.timerProgress = new System.Windows.Forms.Timer(this.components);
this.progressBarTimer = new TweetDck.Core.Controls.FlatProgressBar(); this.progressBarTimer = new TweetDuck.Core.Controls.FlatProgressBar();
this.SuspendLayout(); this.SuspendLayout();
// //
// timerDisplayDelay // timerDisplayDelay

View File

@@ -2,14 +2,14 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Bridge; using TweetDuck.Core.Bridge;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
using TweetDck.Plugins; using TweetDuck.Plugins;
using TweetDck.Plugins.Enums; using TweetDuck.Plugins.Enums;
using TweetDck.Resources; using TweetDuck.Resources;
namespace TweetDck.Core.Notification{ namespace TweetDuck.Core.Notification{
partial class FormNotificationMain : FormNotificationBase{ partial class FormNotificationMain : FormNotificationBase{
private const string NotificationScriptFile = "notification.js"; private const string NotificationScriptFile = "notification.js";

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Notification { namespace TweetDuck.Core.Notification {
partial class FormNotificationTweet { partial class FormNotificationTweet {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -1,11 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using TweetDck.Plugins; using TweetDuck.Plugins;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Notification{ namespace TweetDuck.Core.Notification{
sealed partial class FormNotificationTweet : FormNotificationMain{ sealed partial class FormNotificationTweet : FormNotificationMain{
private const int NonIntrusiveIdleLimit = 30; private const int NonIntrusiveIdleLimit = 30;
private const int TrimMinimum = 32; private const int TrimMinimum = 32;

View File

@@ -2,11 +2,11 @@
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Bridge; using TweetDuck.Core.Bridge;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
using TweetDck.Resources; using TweetDuck.Resources;
namespace TweetDck.Core.Notification.Screenshot{ namespace TweetDuck.Core.Notification.Screenshot{
sealed class FormNotificationScreenshotable : FormNotificationBase{ sealed class FormNotificationScreenshotable : FormNotificationBase{
public FormNotificationScreenshotable(Action callback, Form owner) : base(owner, false){ public FormNotificationScreenshotable(Action callback, Form owner) : base(owner, false){
browser.RegisterAsyncJsObject("$TD_NotificationScreenshot", new CallbackBridge(this, callback)); browser.RegisterAsyncJsObject("$TD_NotificationScreenshot", new CallbackBridge(this, callback));

View File

@@ -3,9 +3,9 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
namespace TweetDck.Core.Notification.Screenshot{ namespace TweetDuck.Core.Notification.Screenshot{
sealed class TweetScreenshotManager : IDisposable{ sealed class TweetScreenshotManager : IDisposable{
private readonly Form owner; private readonly Form owner;
private readonly Timer timeout; private readonly Timer timeout;

View File

@@ -1,12 +0,0 @@
using System;
namespace TweetDck.Core.Notification.Sound{
interface ISoundNotificationPlayer : IDisposable{
string SupportedFormats { get; }
event EventHandler<PlaybackErrorEventArgs> PlaybackError;
void Play(string file);
void Stop();
}
}

View File

@@ -1,28 +1,29 @@
using System.Runtime.InteropServices; using System;
using TweetDck.Core.Notification.Sound; using TweetLib.Audio;
using TweetLib.Audio.Utils;
namespace TweetDck.Core.Notification{ namespace TweetDuck.Core.Notification{
static class SoundNotification{ sealed class SoundNotification : IDisposable{
private static bool? IsWMPAvailable; public string SupportedFormats => player.SupportedFormats;
public event EventHandler<PlaybackErrorEventArgs> PlaybackError;
public static ISoundNotificationPlayer New(){ private readonly AudioPlayer player;
if (IsWMPAvailable.HasValue){
if (IsWMPAvailable.Value){
return new SoundPlayerImplWMP();
}
else{
return new SoundPlayerImplFallback();
}
}
try{ public SoundNotification(){
SoundPlayerImplWMP implWMP = new SoundPlayerImplWMP(); this.player = AudioPlayer.New();
IsWMPAvailable = true; this.player.PlaybackError += Player_PlaybackError;
return implWMP; }
}catch(COMException){
IsWMPAvailable = false; public void Play(string file){
return new SoundPlayerImplFallback(); player.Play(file);
} }
private void Player_PlaybackError(object sender, PlaybackErrorEventArgs e){
PlaybackError?.Invoke(this, e);
}
public void Dispose(){
player.Dispose();
} }
} }
} }

View File

@@ -1,8 +1,8 @@
using System; using System;
using System.Text; using System.Text;
using TweetDck.Resources; using TweetDuck.Resources;
namespace TweetDck.Core.Notification{ namespace TweetDuck.Core.Notification{
sealed class TweetNotification{ sealed class TweetNotification{
private static string FontSizeClass { get; set; } private static string FontSizeClass { get; set; }
private static string HeadTag { get; set; } private static string HeadTag { get; set; }
@@ -51,24 +51,22 @@ namespace TweetDck.Core.Notification{
TopLeft, TopRight, BottomLeft, BottomRight, Custom TopLeft, TopRight, BottomLeft, BottomRight, Custom
} }
public string Column => column; public string Column { get; }
public string TweetUrl => tweetUrl; public string TweetUrl { get; }
public string QuoteUrl => quoteUrl; public string QuoteUrl { get; }
private readonly string column;
private readonly string html; private readonly string html;
private readonly int characters; private readonly int characters;
private readonly string tweetUrl;
private readonly string quoteUrl;
private readonly bool isExample; private readonly bool isExample;
public TweetNotification(string column, string html, int characters, string tweetUrl, string quoteUrl) : this(column, html, characters, tweetUrl, quoteUrl, false){} public TweetNotification(string column, string html, int characters, string tweetUrl, string quoteUrl) : this(column, html, characters, tweetUrl, quoteUrl, false){}
private TweetNotification(string column, string html, int characters, string tweetUrl, string quoteUrl, bool isExample){ private TweetNotification(string column, string html, int characters, string tweetUrl, string quoteUrl, bool isExample){
this.column = column; this.Column = column;
this.TweetUrl = tweetUrl;
this.QuoteUrl = quoteUrl;
this.html = html; this.html = html;
this.tweetUrl = tweetUrl;
this.quoteUrl = quoteUrl;
this.characters = characters; this.characters = characters;
this.isExample = isExample; this.isExample = isExample;
} }

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other { namespace TweetDuck.Core.Other {
sealed partial class FormAbout { sealed partial class FormAbout {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -1,7 +1,7 @@
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Other{ namespace TweetDuck.Core.Other{
sealed partial class FormAbout : Form{ sealed partial class FormAbout : Form{
private const string TipsLink = "https://github.com/chylex/TweetDuck/wiki"; private const string TipsLink = "https://github.com/chylex/TweetDuck/wiki";
private const string IssuesLink = "https://github.com/chylex/TweetDuck/issues"; private const string IssuesLink = "https://github.com/chylex/TweetDuck/issues";

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other { namespace TweetDuck.Core.Other {
partial class FormMessage { partial class FormMessage {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -2,7 +2,7 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Other{ namespace TweetDuck.Core.Other{
sealed partial class FormMessage : Form{ sealed partial class FormMessage : Form{
public Button ClickedButton { get; private set; } public Button ClickedButton { get; private set; }

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other { namespace TweetDuck.Core.Other {
partial class FormPlugins { partial class FormPlugins {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -26,7 +26,7 @@
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.btnReload = new System.Windows.Forms.Button(); this.btnReload = new System.Windows.Forms.Button();
this.btnOpenFolder = new System.Windows.Forms.Button(); this.btnOpenFolder = new System.Windows.Forms.Button();
this.tabPanelPlugins = new TweetDck.Core.Controls.TabPanel(); this.tabPanelPlugins = new TweetDuck.Core.Controls.TabPanel();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnClose // btnClose
@@ -87,7 +87,7 @@
this.Controls.Add(this.btnOpenFolder); this.Controls.Add(this.btnOpenFolder);
this.Controls.Add(this.btnReload); this.Controls.Add(this.btnReload);
this.Controls.Add(this.btnClose); this.Controls.Add(this.btnClose);
this.Icon = global::TweetDck.Properties.Resources.icon; this.Icon = global::TweetDuck.Properties.Resources.icon;
this.MinimumSize = new System.Drawing.Size(480, 320); this.MinimumSize = new System.Drawing.Size(480, 320);
this.Name = "FormPlugins"; this.Name = "FormPlugins";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
@@ -101,6 +101,6 @@
private System.Windows.Forms.Button btnClose; private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnReload; private System.Windows.Forms.Button btnReload;
private System.Windows.Forms.Button btnOpenFolder; private System.Windows.Forms.Button btnOpenFolder;
private TweetDck.Core.Controls.TabPanel tabPanelPlugins; private TweetDuck.Core.Controls.TabPanel tabPanelPlugins;
} }
} }

View File

@@ -3,13 +3,13 @@ using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Plugins; using TweetDuck.Plugins;
using TweetDck.Plugins.Controls; using TweetDuck.Plugins.Controls;
using TweetDck.Plugins.Enums; using TweetDuck.Plugins.Enums;
using TweetDck.Plugins.Events; using TweetDuck.Plugins.Events;
namespace TweetDck.Core.Other{ namespace TweetDuck.Core.Other{
sealed partial class FormPlugins : Form{ sealed partial class FormPlugins : Form{
private readonly PluginManager pluginManager; private readonly PluginManager pluginManager;
private readonly TabButton tabBtnOfficial, tabBtnCustom; private readonly TabButton tabBtnOfficial, tabBtnCustom;

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other { namespace TweetDuck.Core.Other {
sealed partial class FormSettings { sealed partial class FormSettings {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -25,7 +25,7 @@
private void InitializeComponent() { private void InitializeComponent() {
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.labelTip = new System.Windows.Forms.Label(); this.labelTip = new System.Windows.Forms.Label();
this.tabPanel = new TweetDck.Core.Controls.TabPanel(); this.tabPanel = new TweetDuck.Core.Controls.TabPanel();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnClose // btnClose
@@ -70,7 +70,7 @@
this.Controls.Add(this.btnClose); this.Controls.Add(this.btnClose);
this.Controls.Add(this.tabPanel); this.Controls.Add(this.tabPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::TweetDck.Properties.Resources.icon; this.Icon = global::TweetDuck.Properties.Resources.icon;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "FormSettings"; this.Name = "FormSettings";

View File

@@ -2,13 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Other.Settings; using TweetDuck.Core.Other.Settings;
using TweetDck.Plugins; using TweetDuck.Plugins;
using TweetDck.Updates; using TweetDuck.Updates;
namespace TweetDck.Core.Other{ namespace TweetDuck.Core.Other{
sealed partial class FormSettings : Form{ sealed partial class FormSettings : Form{
public const int TabIndexNotification = 1; public const int TabIndexSounds = 2;
private readonly FormBrowser browser; private readonly FormBrowser browser;
private readonly Dictionary<Type, BaseTabSettings> tabs = new Dictionary<Type, BaseTabSettings>(4); private readonly Dictionary<Type, BaseTabSettings> tabs = new Dictionary<Type, BaseTabSettings>(4);
@@ -16,7 +16,7 @@ namespace TweetDck.Core.Other{
public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates, int startTabIndex = 0){ public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates, int startTabIndex = 0){
InitializeComponent(); InitializeComponent();
Text = Program.BrandName+" Settings"; Text = Program.BrandName+" Options";
this.browser = browser; this.browser = browser;
this.browser.PauseNotification(); this.browser.PauseNotification();

View File

@@ -1,7 +1,7 @@
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Configuration; using TweetDuck.Configuration;
namespace TweetDck.Core.Other.Settings{ namespace TweetDuck.Core.Other.Settings{
class BaseTabSettings : UserControl{ class BaseTabSettings : UserControl{
protected static UserConfig Config => Program.UserConfig; protected static UserConfig Config => Program.UserConfig;
@@ -13,7 +13,7 @@ namespace TweetDck.Core.Other.Settings{
public virtual void OnClosing(){} public virtual void OnClosing(){}
protected static void PromptRestart(){ protected static void PromptRestart(){
if (MessageBox.Show("The application must restart for the setting to take place. Do you want to restart now?", Program.BrandName+" Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes){ if (MessageBox.Show("The application must restart for the option to take place. Do you want to restart now?", Program.BrandName+" Options", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes){
Program.Restart(); Program.Restart();
} }
} }

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other.Settings.Dialogs { namespace TweetDuck.Core.Other.Settings.Dialogs {
partial class DialogSettingsCSS { partial class DialogSettingsCSS {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Other.Settings.Dialogs{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsCSS : Form{ sealed partial class DialogSettingsCSS : Form{
public string BrowserCSS => textBoxBrowserCSS.Text; public string BrowserCSS => textBoxBrowserCSS.Text;
public string NotificationCSS => textBoxNotificationCSS.Text; public string NotificationCSS => textBoxNotificationCSS.Text;
@@ -13,7 +13,7 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
public DialogSettingsCSS(Action<string> reinjectBrowserCSS){ public DialogSettingsCSS(Action<string> reinjectBrowserCSS){
InitializeComponent(); InitializeComponent();
Text = Program.BrandName+" Settings - CSS"; Text = Program.BrandName+" Options - CSS";
this.reinjectBrowserCSS = reinjectBrowserCSS; this.reinjectBrowserCSS = reinjectBrowserCSS;

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other.Settings.Dialogs { namespace TweetDuck.Core.Other.Settings.Dialogs {
partial class DialogSettingsCefArgs { partial class DialogSettingsCefArgs {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -1,16 +1,16 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Other.Settings.Dialogs{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsCefArgs : Form{ sealed partial class DialogSettingsCefArgs : Form{
public string CefArgs => textBoxArgs.Text; public string CefArgs => textBoxArgs.Text;
public DialogSettingsCefArgs(){ public DialogSettingsCefArgs(){
InitializeComponent(); InitializeComponent();
Text = Program.BrandName+" Settings - CEF Arguments"; Text = Program.BrandName+" Options - CEF Arguments";
textBoxArgs.EnableMultilineShortcuts(); textBoxArgs.EnableMultilineShortcuts();
textBoxArgs.Text = Program.UserConfig.CustomCefArgs ?? ""; textBoxArgs.Text = Program.UserConfig.CustomCefArgs ?? "";
@@ -31,7 +31,7 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
} }
int count = CommandLineArgsParser.ReadCefArguments(CefArgs).Count; int count = CommandLineArgsParser.ReadCefArguments(CefArgs).Count;
string prompt = count == 0 && !string.IsNullOrWhiteSpace(prevArgs) ? "All arguments will be removed from the settings. Continue?" : count+(count == 1 ? " argument" : " arguments")+" will be added to the settings. Continue?"; string prompt = count == 0 && !string.IsNullOrWhiteSpace(prevArgs) ? "All current arguments will be removed. Continue?" : count+(count == 1 ? " argument was" : " arguments were")+" detected. Continue?";
if (MessageBox.Show(prompt, "Confirm CEF Arguments", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK){ if (MessageBox.Show(prompt, "Confirm CEF Arguments", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK){
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other.Settings.Dialogs { namespace TweetDuck.Core.Other.Settings.Dialogs {
partial class DialogSettingsExport { partial class DialogSettingsExport {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -66,9 +66,8 @@
this.cbConfig.Name = "cbConfig"; this.cbConfig.Name = "cbConfig";
this.cbConfig.Size = new System.Drawing.Size(106, 17); this.cbConfig.Size = new System.Drawing.Size(106, 17);
this.cbConfig.TabIndex = 0; this.cbConfig.TabIndex = 0;
this.cbConfig.Text = "Program Settings"; this.cbConfig.Text = "Program Options";
this.toolTip.SetToolTip(this.cbConfig, "Interface, notification, and update settings.\r\nIncludes a list of disabled plugin" + this.toolTip.SetToolTip(this.cbConfig, "Interface, notification, and update options.");
"s.");
this.cbConfig.UseVisualStyleBackColor = true; this.cbConfig.UseVisualStyleBackColor = true;
this.cbConfig.CheckedChanged += new System.EventHandler(this.cbConfig_CheckedChanged); this.cbConfig.CheckedChanged += new System.EventHandler(this.cbConfig_CheckedChanged);
// //

View File

@@ -1,8 +1,8 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Other.Settings.Export; using TweetDuck.Core.Other.Settings.Export;
namespace TweetDck.Core.Other.Settings.Dialogs{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsExport : Form{ sealed partial class DialogSettingsExport : Form{
public static DialogSettingsExport Import(ExportFileFlags flags){ public static DialogSettingsExport Import(ExportFileFlags flags){
return new DialogSettingsExport(flags); return new DialogSettingsExport(flags);

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other.Settings.Dialogs { namespace TweetDuck.Core.Other.Settings.Dialogs {
partial class DialogSettingsRestart { partial class DialogSettingsRestart {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -2,10 +2,10 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Configuration; using TweetDuck.Configuration;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Core.Other.Settings.Dialogs{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsRestart : Form{ sealed partial class DialogSettingsRestart : Form{
private const string DefaultLocale = "en-US"; private const string DefaultLocale = "en-US";

View File

@@ -2,7 +2,7 @@
using System.IO; using System.IO;
using System.Text; using System.Text;
namespace TweetDck.Core.Other.Settings.Export{ namespace TweetDuck.Core.Other.Settings.Export{
class CombinedFileStream : IDisposable{ class CombinedFileStream : IDisposable{
public const char KeySeparator = '|'; public const char KeySeparator = '|';

View File

@@ -1,6 +1,6 @@
using System; using System;
namespace TweetDck.Core.Other.Settings.Export{ namespace TweetDuck.Core.Other.Settings.Export{
[Flags] [Flags]
enum ExportFileFlags{ enum ExportFileFlags{
None = 0, None = 0,

View File

@@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Configuration; using TweetDuck.Configuration;
using TweetDck.Plugins; using TweetDuck.Plugins;
using TweetDck.Plugins.Enums; using TweetDuck.Plugins.Enums;
namespace TweetDck.Core.Other.Settings.Export{ namespace TweetDuck.Core.Other.Settings.Export{
sealed class ExportManager{ sealed class ExportManager{
private static readonly string CookiesPath = Path.Combine(Program.StoragePath, "Cookies"); private static readonly string CookiesPath = Path.Combine(Program.StoragePath, "Cookies");
private static readonly string TempCookiesPath = Path.Combine(Program.StoragePath, "CookiesTmp"); private static readonly string TempCookiesPath = Path.Combine(Program.StoragePath, "CookiesTmp");
@@ -27,7 +27,7 @@ namespace TweetDck.Core.Other.Settings.Export{
try{ try{
using(CombinedFileStream stream = new CombinedFileStream(new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None))){ using(CombinedFileStream stream = new CombinedFileStream(new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None))){
if (flags.HasFlag(ExportFileFlags.Config)){ if (flags.HasFlag(ExportFileFlags.Config)){
stream.WriteFile("config", Program.ConfigFilePath); stream.WriteFile("config", Program.UserConfigFilePath);
} }
if (flags.HasFlag(ExportFileFlags.PluginData)){ if (flags.HasFlag(ExportFileFlags.PluginData)){
@@ -101,7 +101,7 @@ namespace TweetDck.Core.Other.Settings.Export{
switch(entry.KeyName){ switch(entry.KeyName){
case "config": case "config":
if (flags.HasFlag(ExportFileFlags.Config)){ if (flags.HasFlag(ExportFileFlags.Config)){
entry.WriteToFile(Program.ConfigFilePath); entry.WriteToFile(Program.UserConfigFilePath);
} }
break; break;

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other.Settings { namespace TweetDuck.Core.Other.Settings {
partial class TabSettingsAdvanced { partial class TabSettingsAdvanced {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -1,14 +1,14 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Configuration; using TweetDuck.Configuration;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Other.Settings.Dialogs; using TweetDuck.Core.Other.Settings.Dialogs;
using TweetDck.Core.Other.Settings.Export; using TweetDuck.Core.Other.Settings.Export;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
using TweetDck.Plugins; using TweetDuck.Plugins;
namespace TweetDck.Core.Other.Settings{ namespace TweetDuck.Core.Other.Settings{
partial class TabSettingsAdvanced : BaseTabSettings{ partial class TabSettingsAdvanced : BaseTabSettings{
private readonly Action<string> reinjectBrowserCSS; private readonly Action<string> reinjectBrowserCSS;
private readonly PluginManager plugins; private readonly PluginManager plugins;
@@ -19,7 +19,13 @@ namespace TweetDck.Core.Other.Settings{
this.reinjectBrowserCSS = reinjectBrowserCSS; this.reinjectBrowserCSS = reinjectBrowserCSS;
this.plugins = plugins; this.plugins = plugins;
checkHardwareAcceleration.Checked = HardwareAcceleration.IsEnabled; if (SystemConfig.IsHardwareAccelerationSupported){
checkHardwareAcceleration.Checked = Program.SystemConfig.HardwareAcceleration;
}
else{
checkHardwareAcceleration.Enabled = false;
checkHardwareAcceleration.Checked = false;
}
BrowserCache.CalculateCacheSize(bytes => this.InvokeSafe(() => { BrowserCache.CalculateCacheSize(bytes => this.InvokeSafe(() => {
if (bytes == -1L){ if (bytes == -1L){
@@ -56,52 +62,54 @@ namespace TweetDck.Core.Other.Settings{
} }
private void checkHardwareAcceleration_CheckedChanged(object sender, EventArgs e){ private void checkHardwareAcceleration_CheckedChanged(object sender, EventArgs e){
bool succeeded = false; Program.SystemConfig.HardwareAcceleration = checkHardwareAcceleration.Checked;
Program.SystemConfig.Save();
if (checkHardwareAcceleration.Checked){ PromptRestart();
if (HardwareAcceleration.CanEnable){
succeeded = HardwareAcceleration.Enable();
}
else{
MessageBox.Show("Cannot enable hardware acceleration, the libraries libEGL.dll and libGLESv2.dll could not be restored.", Program.BrandName+" Settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else{
succeeded = HardwareAcceleration.Disable();
}
if (succeeded){
PromptRestart();
}
else{
checkHardwareAcceleration.CheckedChanged -= checkHardwareAcceleration_CheckedChanged;
checkHardwareAcceleration.Checked = HardwareAcceleration.IsEnabled;
checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged;
}
} }
private void btnEditCefArgs_Click(object sender, EventArgs e){ private void btnEditCefArgs_Click(object sender, EventArgs e){
DialogSettingsCefArgs form = new DialogSettingsCefArgs(); DialogSettingsCefArgs form = new DialogSettingsCefArgs();
if (form.ShowDialog(ParentForm) == DialogResult.OK){ form.VisibleChanged += (sender2, args2) => {
Config.CustomCefArgs = form.CefArgs; form.MoveToCenter(ParentForm);
form.Dispose(); };
PromptRestart();
} form.FormClosed += (sender2, args2) => {
else{ NativeMethods.SetFormDisabled(ParentForm, false);
form.Dispose();
} if (form.DialogResult == DialogResult.OK){
Config.CustomCefArgs = form.CefArgs;
PromptRestart();
form.Dispose();
}
else form.Dispose();
};
form.Show(ParentForm);
NativeMethods.SetFormDisabled(ParentForm, true);
} }
private void btnEditCSS_Click(object sender, EventArgs e){ private void btnEditCSS_Click(object sender, EventArgs e){
using(DialogSettingsCSS form = new DialogSettingsCSS(reinjectBrowserCSS)){ DialogSettingsCSS form = new DialogSettingsCSS(reinjectBrowserCSS);
if (form.ShowDialog(ParentForm) == DialogResult.OK){
form.VisibleChanged += (sender2, args2) => {
form.MoveToCenter(ParentForm);
};
form.FormClosed += (sender2, args2) => {
NativeMethods.SetFormDisabled(ParentForm, false);
if (form.DialogResult == DialogResult.OK){
Config.CustomBrowserCSS = form.BrowserCSS; Config.CustomBrowserCSS = form.BrowserCSS;
Config.CustomNotificationCSS = form.NotificationCSS; Config.CustomNotificationCSS = form.NotificationCSS;
} }
reinjectBrowserCSS(Config.CustomBrowserCSS); // reinject on cancel too, because the CSS is updated while typing reinjectBrowserCSS(Config.CustomBrowserCSS); // reinject on cancel too, because the CSS is updated while typing
} form.Dispose();
};
form.Show(ParentForm);
NativeMethods.SetFormDisabled(ParentForm, true);
} }
private void btnExport_Click(object sender, EventArgs e){ private void btnExport_Click(object sender, EventArgs e){
@@ -123,8 +131,8 @@ namespace TweetDck.Core.Other.Settings{
OverwritePrompt = true, OverwritePrompt = true,
DefaultExt = "tdsettings", DefaultExt = "tdsettings",
FileName = Program.BrandName+".tdsettings", FileName = Program.BrandName+".tdsettings",
Title = "Export "+Program.BrandName+" Settings", Title = "Export "+Program.BrandName+" Profile",
Filter = Program.BrandName+" Settings (*.tdsettings)|*.tdsettings" Filter = Program.BrandName+" Profile (*.tdsettings)|*.tdsettings"
}){ }){
if (dialog.ShowDialog() != DialogResult.OK){ if (dialog.ShowDialog() != DialogResult.OK){
return; return;
@@ -138,7 +146,7 @@ namespace TweetDck.Core.Other.Settings{
ExportManager manager = new ExportManager(file, plugins); ExportManager manager = new ExportManager(file, plugins);
if (!manager.Export(flags)){ if (!manager.Export(flags)){
Program.Reporter.HandleException("Profile Export Error", "An exception happened while exporting "+Program.BrandName+" settings.", true, manager.LastException); Program.Reporter.HandleException("Profile Export Error", "An exception happened while exporting "+Program.BrandName+" profile.", true, manager.LastException);
} }
} }
@@ -148,8 +156,8 @@ namespace TweetDck.Core.Other.Settings{
using(OpenFileDialog dialog = new OpenFileDialog{ using(OpenFileDialog dialog = new OpenFileDialog{
AutoUpgradeEnabled = true, AutoUpgradeEnabled = true,
DereferenceLinks = true, DereferenceLinks = true,
Title = "Import "+Program.BrandName+" Settings", Title = "Import "+Program.BrandName+" Profile",
Filter = Program.BrandName+" Settings (*.tdsettings)|*.tdsettings" Filter = Program.BrandName+" Profile (*.tdsettings)|*.tdsettings"
}){ }){
if (dialog.ShowDialog() != DialogResult.OK){ if (dialog.ShowDialog() != DialogResult.OK){
return; return;
@@ -175,12 +183,12 @@ namespace TweetDck.Core.Other.Settings{
} }
} }
else{ else{
Program.Reporter.HandleException("Profile Import Error", "An exception happened while importing "+Program.BrandName+" settings.", true, manager.LastException); Program.Reporter.HandleException("Profile Import Error", "An exception happened while importing "+Program.BrandName+" profile.", true, manager.LastException);
} }
} }
private void btnReset_Click(object sender, EventArgs e){ private void btnReset_Click(object sender, EventArgs e){
if (MessageBox.Show("This will reset all of your program settings. Plugins will not be affected. Do you want to proceed?", "Reset "+Program.BrandName+" Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes){ if (MessageBox.Show("This will reset all of your program options. Plugins will not be affected. Do you want to proceed?", "Reset "+Program.BrandName+" Options", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes){
Program.ResetConfig(); Program.ResetConfig();
((FormSettings)ParentForm).ReloadUI(); ((FormSettings)ParentForm).ReloadUI();
} }

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other.Settings { namespace TweetDuck.Core.Other.Settings {
partial class TabSettingsGeneral { partial class TabSettingsGeneral {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -1,10 +1,10 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Updates; using TweetDuck.Updates;
using TweetDck.Updates.Events; using TweetDuck.Updates.Events;
namespace TweetDck.Core.Other.Settings{ namespace TweetDuck.Core.Other.Settings{
partial class TabSettingsGeneral : BaseTabSettings{ partial class TabSettingsGeneral : BaseTabSettings{
private readonly UpdateHandler updates; private readonly UpdateHandler updates;
private int updateCheckEventId = -1; private int updateCheckEventId = -1;

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other.Settings { namespace TweetDuck.Core.Other.Settings {
partial class TabSettingsNotifications { partial class TabSettingsNotifications {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -37,9 +37,9 @@
this.trackBarEdgeDistance = new System.Windows.Forms.TrackBar(); this.trackBarEdgeDistance = new System.Windows.Forms.TrackBar();
this.groupNotificationDuration = new System.Windows.Forms.GroupBox(); this.groupNotificationDuration = new System.Windows.Forms.GroupBox();
this.tableLayoutDurationButtons = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutDurationButtons = new System.Windows.Forms.TableLayoutPanel();
this.btnDurationMedium = new TweetDck.Core.Controls.FlatButton(); this.btnDurationMedium = new TweetDuck.Core.Controls.FlatButton();
this.btnDurationLong = new TweetDck.Core.Controls.FlatButton(); this.btnDurationLong = new TweetDuck.Core.Controls.FlatButton();
this.btnDurationShort = new TweetDck.Core.Controls.FlatButton(); this.btnDurationShort = new TweetDuck.Core.Controls.FlatButton();
this.labelDurationValue = new System.Windows.Forms.Label(); this.labelDurationValue = new System.Windows.Forms.Label();
this.trackBarDuration = new System.Windows.Forms.TrackBar(); this.trackBarDuration = new System.Windows.Forms.TrackBar();
this.groupUserInterface = new System.Windows.Forms.GroupBox(); this.groupUserInterface = new System.Windows.Forms.GroupBox();
@@ -440,9 +440,9 @@
private System.Windows.Forms.Label labelDurationValue; private System.Windows.Forms.Label labelDurationValue;
private System.Windows.Forms.TrackBar trackBarDuration; private System.Windows.Forms.TrackBar trackBarDuration;
private System.Windows.Forms.TableLayoutPanel tableLayoutDurationButtons; private System.Windows.Forms.TableLayoutPanel tableLayoutDurationButtons;
private TweetDck.Core.Controls.FlatButton btnDurationMedium; private TweetDuck.Core.Controls.FlatButton btnDurationMedium;
private TweetDck.Core.Controls.FlatButton btnDurationLong; private TweetDuck.Core.Controls.FlatButton btnDurationLong;
private TweetDck.Core.Controls.FlatButton btnDurationShort; private TweetDuck.Core.Controls.FlatButton btnDurationShort;
private System.Windows.Forms.CheckBox checkNonIntrusive; private System.Windows.Forms.CheckBox checkNonIntrusive;
private System.Windows.Forms.Label labelIdlePause; private System.Windows.Forms.Label labelIdlePause;
private System.Windows.Forms.ComboBox comboBoxIdlePause; private System.Windows.Forms.ComboBox comboBoxIdlePause;

View File

@@ -1,10 +1,10 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
using TweetDck.Core.Notification; using TweetDuck.Core.Notification;
namespace TweetDck.Core.Other.Settings{ namespace TweetDuck.Core.Other.Settings{
partial class TabSettingsNotifications : BaseTabSettings{ partial class TabSettingsNotifications : BaseTabSettings{
private static readonly int[] IdlePauseSeconds = { 0, 30, 60, 120, 300 }; private static readonly int[] IdlePauseSeconds = { 0, 30, 60, 120, 300 };

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core.Other.Settings { namespace TweetDuck.Core.Other.Settings {
partial class TabSettingsSounds { partial class TabSettingsSounds {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -2,17 +2,17 @@
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Notification; using TweetDuck.Core.Notification;
using TweetDck.Core.Notification.Sound; using TweetLib.Audio.Utils;
namespace TweetDck.Core.Other.Settings{ namespace TweetDuck.Core.Other.Settings{
partial class TabSettingsSounds : BaseTabSettings{ partial class TabSettingsSounds : BaseTabSettings{
private readonly ISoundNotificationPlayer soundNotification; private readonly SoundNotification soundNotification;
public TabSettingsSounds(){ public TabSettingsSounds(){
InitializeComponent(); InitializeComponent();
soundNotification = SoundNotification.New(); soundNotification = new SoundNotification();
soundNotification.PlaybackError += sound_PlaybackError; soundNotification.PlaybackError += sound_PlaybackError;
tbCustomSound.Text = Config.NotificationSoundPath; tbCustomSound.Text = Config.NotificationSoundPath;

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Core { namespace TweetDuck.Core {
partial class TrayIcon { partial class TrayIcon {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -2,7 +2,7 @@
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core{ namespace TweetDuck.Core{
partial class TrayIcon : Component{ partial class TrayIcon : Component{
public enum Behavior{ // keep order public enum Behavior{ // keep order
Disabled, DisplayOnly, MinimizeToTray, CloseToTray, Combined Disabled, DisplayOnly, MinimizeToTray, CloseToTray, Combined

View File

@@ -4,7 +4,7 @@ using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Linq; using System.Linq;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
static class BrowserCache{ static class BrowserCache{
private static bool ClearOnExit { get; set; } private static bool ClearOnExit { get; set; }

View File

@@ -8,7 +8,7 @@ using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
static class BrowserUtils{ static class BrowserUtils{
public static string HeaderAcceptLanguage{ public static string HeaderAcceptLanguage{
get{ get{
@@ -69,17 +69,28 @@ namespace TweetDck.Core.Utils{
return ConvertPascalCaseToScreamingSnakeCase(Enum.GetName(typeof(CefErrorCode), code) ?? string.Empty); return ConvertPascalCaseToScreamingSnakeCase(Enum.GetName(typeof(CefErrorCode), code) ?? string.Empty);
} }
public static void DownloadFileAsync(string url, string target, Action<Exception> onFailure){ public static WebClient DownloadFileAsync(string url, string target, Action onSuccess, Action<Exception> onFailure){
WebClient client = new WebClient{ Proxy = null }; WebClient client = new WebClient{ Proxy = null };
client.Headers[HttpRequestHeader.UserAgent] = HeaderUserAgent; client.Headers[HttpRequestHeader.UserAgent] = HeaderUserAgent;
client.DownloadFileCompleted += (sender, args) => { client.DownloadFileCompleted += (sender, args) => {
if (args.Error != null){ if (args.Cancelled){
onFailure(args.Error); try{
File.Delete(target);
}catch{
// didn't want it deleted anyways
}
}
else if (args.Error != null){
onFailure?.Invoke(args.Error);
}
else{
onSuccess?.Invoke();
} }
}; };
client.DownloadFileAsync(new Uri(url), target); client.DownloadFileAsync(new Uri(url), target);
return client;
} }
public static void SetZoomLevel(IBrowser browser, int percentage){ public static void SetZoomLevel(IBrowser browser, int percentage){

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
class CommandLineArgs{ class CommandLineArgs{
public static CommandLineArgs FromStringArray(char entryChar, string[] array){ public static CommandLineArgs FromStringArray(char entryChar, string[] array){
CommandLineArgs args = new CommandLineArgs(); CommandLineArgs args = new CommandLineArgs();

View File

@@ -1,10 +1,9 @@
using System.Text.RegularExpressions; using System;
using System.Text.RegularExpressions;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
static class CommandLineArgsParser{ static class CommandLineArgsParser{
private static Regex splitRegex; private static readonly Lazy<Regex> SplitRegex = new Lazy<Regex>(() => new Regex(@"([^=\s]+(?:=(?:[^ ]*""[^""]*?""[^ ]*|[^ ]*))?)", RegexOptions.Compiled), false);
private static Regex SplitRegex => splitRegex ?? (splitRegex = new Regex(@"([^=\s]+(?:=(?:[^ ]*""[^""]*?""[^ ]*|[^ ]*))?)", RegexOptions.Compiled));
public static CommandLineArgs ReadCefArguments(string argumentString){ public static CommandLineArgs ReadCefArguments(string argumentString){
CommandLineArgs args = new CommandLineArgs(); CommandLineArgs args = new CommandLineArgs();
@@ -13,7 +12,7 @@ namespace TweetDck.Core.Utils{
return args; return args;
} }
foreach(Match match in SplitRegex.Matches(argumentString)){ foreach(Match match in SplitRegex.Value.Matches(argumentString)){
string matchValue = match.Value; string matchValue = match.Value;
int indexEquals = matchValue.IndexOf('='); int indexEquals = matchValue.IndexOf('=');

View File

@@ -1,51 +0,0 @@
using System;
using System.IO;
namespace TweetDck.Core.Utils{
static class HardwareAcceleration{
private static readonly string LibEGL = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libEGL.dll");
private static readonly string LibGLES = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libGLESv2.dll");
private static readonly string DisabledLibEGL = LibEGL+".bak";
private static readonly string DisabledLibGLES = LibGLES+".bak";
public static bool IsEnabled => File.Exists(LibEGL) && File.Exists(LibGLES);
public static bool CanEnable => File.Exists(DisabledLibEGL) && File.Exists(DisabledLibGLES);
public static bool Enable(){
if (IsEnabled)return false;
try{
File.Move(DisabledLibEGL, LibEGL);
File.Move(DisabledLibGLES, LibGLES);
return true;
}catch{
return false;
}
}
public static bool Disable(){
if (!IsEnabled)return false;
try{
if (File.Exists(DisabledLibEGL)){
File.Delete(DisabledLibEGL);
}
if (File.Exists(DisabledLibGLES)){
File.Delete(DisabledLibGLES);
}
}catch{
// woops
}
try{
File.Move(LibEGL, DisabledLibEGL);
File.Move(LibGLES, DisabledLibGLES);
return true;
}catch{
return false;
}
}
}
}

View File

@@ -1,6 +1,6 @@
using System; using System;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
class InjectedHTML{ class InjectedHTML{
public enum Position{ public enum Position{
Before, After Before, After

View File

@@ -4,7 +4,7 @@ using System.Drawing;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")] [SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Local")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Local")]
static class NativeMethods{ static class NativeMethods{
@@ -13,6 +13,8 @@ namespace TweetDck.Core.Utils{
public const int HWND_TOPMOST = -1; public const int HWND_TOPMOST = -1;
public const uint SWP_NOACTIVATE = 0x0010; public const uint SWP_NOACTIVATE = 0x0010;
public const int WS_DISABLED = 0x08000000;
public const int GWL_STYLE = -16;
public const int SB_HORZ = 0; public const int SB_HORZ = 0;
public const int BCM_SETSHIELD = 0x160C; public const int BCM_SETSHIELD = 0x160C;
@@ -83,10 +85,25 @@ namespace TweetDck.Core.Utils{
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam); public static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
public static void SetFormPos(Form form, int hWndOrder, uint flags){ public static void SetFormPos(Form form, int hWndOrder, uint flags){
SetWindowPos(form.Handle.ToInt32(), hWndOrder, form.Left, form.Top, form.Width, form.Height, flags); SetWindowPos(form.Handle.ToInt32(), hWndOrder, form.Left, form.Top, form.Width, form.Height, flags);
} }
public static void SetFormDisabled(Form form, bool disabled){
if (disabled){
SetWindowLong(form.Handle, GWL_STYLE, GetWindowLong(form.Handle, GWL_STYLE) | WS_DISABLED);
}
else{
SetWindowLong(form.Handle, GWL_STYLE, GetWindowLong(form.Handle, GWL_STYLE) & ~WS_DISABLED);
}
}
public static int GetMouseHookData(IntPtr ptr){ public static int GetMouseHookData(IntPtr ptr){
return Marshal.PtrToStructure<MSLLHOOKSTRUCT>(ptr).mouseData >> 16; return Marshal.PtrToStructure<MSLLHOOKSTRUCT>(ptr).mouseData >> 16;
} }

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
class TwoKeyDictionary<K1, K2, V>{ class TwoKeyDictionary<K1, K2, V>{
private readonly Dictionary<K1, Dictionary<K2, V>> dict; private readonly Dictionary<K1, Dictionary<K2, V>> dict;
private readonly int innerCapacity; private readonly int innerCapacity;

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDuck.Core.Controls;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
[Serializable] [Serializable]
class WindowState{ class WindowState{
private Rectangle rect; private Rectangle rect;

View File

@@ -6,8 +6,11 @@ using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Utils{ namespace TweetDuck.Core.Utils{
static class WindowsUtils{ static class WindowsUtils{
private static readonly Lazy<Regex> RegexStripHtmlStyles = new Lazy<Regex>(() => new Regex(@"\s?(?:style|class)="".*?"""), false);
private static readonly Lazy<Regex> RegexOffsetClipboardHtml = new Lazy<Regex>(() => new Regex(@"(?<=EndHTML:|EndFragment:)(\d+)"), false);
public static bool ShouldAvoidToolWindow { get; } public static bool ShouldAvoidToolWindow { get; }
static WindowsUtils(){ static WindowsUtils(){
@@ -54,6 +57,21 @@ namespace TweetDck.Core.Utils{
return false; return false;
} }
public static void TryDeleteFolderWhenAble(string path, int timeout){
new Thread(() => {
TrySleepUntil(() => {
try{
Directory.Delete(path, true);
return true;
}catch(DirectoryNotFoundException){
return true;
}catch{
return false;
}
}, timeout, 500);
}).Start();
}
public static void ClipboardStripHtmlStyles(){ public static void ClipboardStripHtmlStyles(){
if (!Clipboard.ContainsText(TextDataFormat.Html)){ if (!Clipboard.ContainsText(TextDataFormat.Html)){
return; return;
@@ -62,10 +80,10 @@ namespace TweetDck.Core.Utils{
string originalText = Clipboard.GetText(TextDataFormat.UnicodeText); string originalText = Clipboard.GetText(TextDataFormat.UnicodeText);
string originalHtml = Clipboard.GetText(TextDataFormat.Html); string originalHtml = Clipboard.GetText(TextDataFormat.Html);
string updatedHtml = ClipboardRegexes.RegexStripHtmlStyles.Replace(originalHtml, string.Empty); string updatedHtml = RegexStripHtmlStyles.Value.Replace(originalHtml, string.Empty);
int removed = originalHtml.Length-updatedHtml.Length; int removed = originalHtml.Length-updatedHtml.Length;
updatedHtml = ClipboardRegexes.RegexOffsetClipboardHtml.Replace(updatedHtml, match => (int.Parse(match.Value)-removed).ToString().PadLeft(match.Value.Length, '0')); updatedHtml = RegexOffsetClipboardHtml.Value.Replace(updatedHtml, match => (int.Parse(match.Value)-removed).ToString().PadLeft(match.Value.Length, '0'));
DataObject obj = new DataObject(); DataObject obj = new DataObject();
obj.SetText(originalText, TextDataFormat.UnicodeText); obj.SetText(originalText, TextDataFormat.UnicodeText);
@@ -90,10 +108,5 @@ namespace TweetDck.Core.Utils{
Program.Reporter.HandleException("Clipboard Error", Program.BrandName+" could not access the clipboard as it is currently used by another process.", true, e); Program.Reporter.HandleException("Clipboard Error", Program.BrandName+" could not access the clipboard as it is currently used by another process.", true, e);
} }
} }
private static class ClipboardRegexes{ // delays construction of regular expressions until needed
public static readonly Regex RegexStripHtmlStyles = new Regex(@"\s?(?:style|class)="".*?""");
public static readonly Regex RegexOffsetClipboardHtml = new Regex(@"(?<=EndHTML:|EndFragment:)(\d+)");
}
} }
} }

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Plugins.Controls { namespace TweetDuck.Plugins.Controls {
partial class PluginControl { partial class PluginControl {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -3,9 +3,9 @@ using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Plugins.Controls{ namespace TweetDuck.Plugins.Controls{
partial class PluginControl : UserControl{ partial class PluginControl : UserControl{
private readonly PluginManager pluginManager; private readonly PluginManager pluginManager;
private readonly Plugin plugin; private readonly Plugin plugin;

View File

@@ -1,7 +1,7 @@
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDck.Plugins.Controls{ namespace TweetDuck.Plugins.Controls{
sealed class PluginListFlowLayout : FlowLayoutPanel{ sealed class PluginListFlowLayout : FlowLayoutPanel{
public PluginListFlowLayout(){ public PluginListFlowLayout(){
FlowDirection = FlowDirection.TopDown; FlowDirection = FlowDirection.TopDown;

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace TweetDck.Plugins.Enums{ namespace TweetDuck.Plugins.Enums{
[Flags] [Flags]
enum PluginEnvironment{ enum PluginEnvironment{
None = 0, None = 0,

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Plugins.Enums{ namespace TweetDuck.Plugins.Enums{
enum PluginFolder{ enum PluginFolder{
Root, Data Root, Data
} }

View File

@@ -1,4 +1,4 @@
namespace TweetDck.Plugins.Enums{ namespace TweetDuck.Plugins.Enums{
enum PluginGroup{ enum PluginGroup{
Official, Custom Official, Custom
} }

View File

@@ -1,6 +1,6 @@
using System; using System;
namespace TweetDck.Plugins.Events{ namespace TweetDuck.Plugins.Events{
class PluginChangedStateEventArgs : EventArgs{ class PluginChangedStateEventArgs : EventArgs{
public Plugin Plugin { get; } public Plugin Plugin { get; }
public bool IsEnabled { get; } public bool IsEnabled { get; }

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace TweetDck.Plugins.Events{ namespace TweetDuck.Plugins.Events{
class PluginErrorEventArgs : EventArgs{ class PluginErrorEventArgs : EventArgs{
public bool HasErrors => Errors.Count > 0; public bool HasErrors => Errors.Count > 0;

View File

@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using TweetDck.Plugins.Enums; using TweetDuck.Plugins.Enums;
namespace TweetDck.Plugins{ namespace TweetDuck.Plugins{
class Plugin{ class Plugin{
public string Identifier { get; } public string Identifier { get; }
public PluginGroup Group { get; } public PluginGroup Group { get; }
@@ -73,22 +73,6 @@ namespace TweetDck.Plugins{
if (configPath.Length > 0 && defaultConfigPath.Length > 0 && !File.Exists(configPath) && File.Exists(defaultConfigPath)){ if (configPath.Length > 0 && defaultConfigPath.Length > 0 && !File.Exists(configPath) && File.Exists(defaultConfigPath)){
string dataFolder = GetPluginFolder(PluginFolder.Data); string dataFolder = GetPluginFolder(PluginFolder.Data);
if (!Directory.Exists(dataFolder)){ // config migration
string originalFile = Path.Combine(GetPluginFolder(PluginFolder.Root), ConfigFile);
if (File.Exists(originalFile)){
try{
Directory.CreateDirectory(dataFolder);
File.Copy(originalFile, configPath, false);
File.Delete(originalFile); // will fail without write perms in program folder, ignore if so
}catch{
// ignore
}
return;
}
}
try{ try{
Directory.CreateDirectory(dataFolder); Directory.CreateDirectory(dataFolder);
File.Copy(defaultConfigPath, configPath, false); File.Copy(defaultConfigPath, configPath, false);

View File

@@ -2,11 +2,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
using TweetDck.Plugins.Enums; using TweetDuck.Plugins.Enums;
using TweetDck.Plugins.Events; using TweetDuck.Plugins.Events;
namespace TweetDck.Plugins{ namespace TweetDuck.Plugins{
class PluginBridge{ class PluginBridge{
private static string SanitizeCacheKey(string key){ private static string SanitizeCacheKey(string key){
return key.Replace('\\', '/').Trim(); return key.Replace('\\', '/').Trim();

View File

@@ -2,12 +2,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using TweetDck.Plugins.Events; using TweetDuck.Plugins.Events;
namespace TweetDck.Plugins{ namespace TweetDuck.Plugins{
[Serializable]
sealed class PluginConfig{ sealed class PluginConfig{
[field:NonSerialized]
public event EventHandler<PluginChangedStateEventArgs> InternalPluginChangedState; // should only be accessed from PluginManager public event EventHandler<PluginChangedStateEventArgs> InternalPluginChangedState; // should only be accessed from PluginManager
public IEnumerable<string> DisabledPlugins => Disabled; public IEnumerable<string> DisabledPlugins => Disabled;
@@ -18,14 +16,6 @@ namespace TweetDck.Plugins{
"official/reply-account" "official/reply-account"
}; };
public void ImportLegacy(PluginConfig config){
Disabled.Clear();
foreach(string plugin in config.Disabled){
Disabled.Add(plugin);
}
}
public void SetEnabled(Plugin plugin, bool enabled){ public void SetEnabled(Plugin plugin, bool enabled){
if ((enabled && Disabled.Remove(plugin.Identifier)) || (!enabled && Disabled.Add(plugin.Identifier))){ if ((enabled && Disabled.Remove(plugin.Identifier)) || (!enabled && Disabled.Add(plugin.Identifier))){
InternalPluginChangedState?.Invoke(this, new PluginChangedStateEventArgs(plugin, enabled)); InternalPluginChangedState?.Invoke(this, new PluginChangedStateEventArgs(plugin, enabled));

View File

@@ -3,11 +3,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using TweetDck.Plugins.Enums; using TweetDuck.Plugins.Enums;
using TweetDck.Plugins.Events; using TweetDuck.Plugins.Events;
using TweetDck.Resources; using TweetDuck.Resources;
namespace TweetDck.Plugins{ namespace TweetDuck.Plugins{
sealed class PluginManager{ sealed class PluginManager{
public const string PluginBrowserScriptFile = "plugins.browser.js"; public const string PluginBrowserScriptFile = "plugins.browser.js";
public const string PluginNotificationScriptFile = "plugins.notification.js"; public const string PluginNotificationScriptFile = "plugins.notification.js";
@@ -42,29 +42,14 @@ namespace TweetDck.Plugins{
this.Config = new PluginConfig(); this.Config = new PluginConfig();
this.Bridge = new PluginBridge(this); this.Bridge = new PluginBridge(this);
LoadConfig(); Config.Load(configPath);
Config.InternalPluginChangedState += Config_InternalPluginChangedState; Config.InternalPluginChangedState += Config_InternalPluginChangedState;
Program.UserConfigReplaced += Program_UserConfigReplaced; Program.UserConfigReplaced += Program_UserConfigReplaced;
} }
private void LoadConfig(){
#pragma warning disable 612
if (Program.UserConfig.Plugins != null){
Config.ImportLegacy(Program.UserConfig.Plugins);
Config.Save(configPath);
Program.UserConfig.Plugins = null;
Program.UserConfig.Save();
}
#pragma warning restore 612
else{
Config.Load(configPath);
}
}
private void Program_UserConfigReplaced(object sender, EventArgs e){ private void Program_UserConfigReplaced(object sender, EventArgs e){
LoadConfig(); Config.Load(configPath);
Reload(); Reload();
} }

View File

@@ -1,29 +1,36 @@
using System.Text; using System.Globalization;
using TweetDck.Plugins.Enums; using TweetDuck.Plugins.Enums;
namespace TweetDck.Plugins{ namespace TweetDuck.Plugins{
static class PluginScriptGenerator{ static class PluginScriptGenerator{
public static string GenerateConfig(PluginConfig config){ public static string GenerateConfig(PluginConfig config){
return config.AnyDisabled ? "window.TD_PLUGINS.disabled = [\""+string.Join("\",\"", config.DisabledPlugins)+"\"];" : string.Empty; return config.AnyDisabled ? "window.TD_PLUGINS.disabled = [\""+string.Join("\",\"", config.DisabledPlugins)+"\"];" : string.Empty;
} }
public static string GeneratePlugin(string pluginIdentifier, string pluginContents, int pluginToken, PluginEnvironment environment){ public static string GeneratePlugin(string pluginIdentifier, string pluginContents, int pluginToken, PluginEnvironment environment){
StringBuilder build = new StringBuilder(2*pluginIdentifier.Length+pluginContents.Length+165); return PluginGen
.Replace("%params", environment.GetScriptVariables())
build.Append("(function(").Append(environment.GetScriptVariables()).Append("){"); .Replace("%id", pluginIdentifier)
.Replace("%token", pluginToken.ToString(CultureInfo.InvariantCulture))
build.Append("let tmp={"); .Replace("%contents", pluginContents);
build.Append("id:\"").Append(pluginIdentifier).Append("\",");
build.Append("obj:new class extends PluginBase{").Append(pluginContents).Append("}");
build.Append("};");
build.Append("tmp.obj.$id=\"").Append(pluginIdentifier).Append("\";");
build.Append("tmp.obj.$token=").Append(pluginToken).Append(";");
build.Append("window.TD_PLUGINS.install(tmp);");
build.Append("})(").Append(environment.GetScriptVariables()).Append(");");
return build.ToString();
} }
private const string PluginGen = "(function(%params,$d){let tmp={id:'%id',obj:new class extends PluginBase{%contents}};$d(tmp.obj,'$id',{value:'%id'});$d(tmp.obj,'$token',{value:%token});window.TD_PLUGINS.install(tmp);})(%params,Object.defineProperty);";
/* PluginGen
(function(%params, $i, $d){
let tmp = {
id: '%id',
obj: new class extends PluginBase{%contents}
};
$d(tmp.obj, '$id', { value: '%id' });
$d(tmp.obj, '$token', { value: %token });
window.TD_PLUGINS.install(tmp);
})(%params, Object.defineProperty);
*/
} }
} }

View File

@@ -5,23 +5,23 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Configuration; using TweetDuck.Configuration;
using TweetDck.Core; using TweetDuck.Core;
using TweetDck.Core.Handling; using TweetDuck.Core.Handling;
using TweetDck.Core.Other; using TweetDuck.Core.Other;
using TweetDck.Core.Other.Settings.Export; using TweetDuck.Core.Other.Settings.Export;
using TweetDck.Core.Utils; using TweetDuck.Core.Utils;
using TweetDck.Plugins; using TweetDuck.Plugins;
using TweetDck.Plugins.Events; using TweetDuck.Plugins.Events;
using TweetDck.Updates; using TweetDuck.Updates;
namespace TweetDck{ namespace TweetDuck{
static class Program{ static class Program{
public const string BrandName = "TweetDuck"; public const string BrandName = "TweetDuck";
public const string Website = "https://tweetduck.chylex.com"; public const string Website = "https://tweetduck.chylex.com";
public const string VersionTag = "1.7.5"; public const string VersionTag = "1.8";
public const string VersionFull = "1.7.5.0"; public const string VersionFull = "1.8.0.0";
public static readonly Version Version = new Version(VersionTag); public static readonly Version Version = new Version(VersionTag);
public static readonly bool IsPortable = File.Exists("makeportable"); public static readonly bool IsPortable = File.Exists("makeportable");
@@ -29,21 +29,26 @@ namespace TweetDck{
public static readonly string ProgramPath = AppDomain.CurrentDomain.BaseDirectory; public static readonly string ProgramPath = AppDomain.CurrentDomain.BaseDirectory;
public static readonly string StoragePath = IsPortable ? Path.Combine(ProgramPath, "portable", "storage") : GetDataStoragePath(); public static readonly string StoragePath = IsPortable ? Path.Combine(ProgramPath, "portable", "storage") : GetDataStoragePath();
public static readonly string ConfigFilePath = Path.Combine(StoragePath, "TD_UserConfig.cfg");
public static readonly string PluginDataPath = Path.Combine(StoragePath, "TD_Plugins");
public static readonly string PluginConfigFilePath = Path.Combine(StoragePath, "TD_PluginConfig.cfg");
private static readonly string ErrorLogFilePath = Path.Combine(StoragePath, "TD_Log.txt");
private static readonly string ConsoleLogFilePath = Path.Combine(StoragePath, "TD_Console.txt");
public static readonly string ScriptPath = Path.Combine(ProgramPath, "scripts"); public static readonly string ScriptPath = Path.Combine(ProgramPath, "scripts");
public static readonly string PluginPath = Path.Combine(ProgramPath, "plugins"); public static readonly string PluginPath = Path.Combine(ProgramPath, "plugins");
public static readonly string UserConfigFilePath = Path.Combine(StoragePath, "TD_UserConfig.cfg");
public static readonly string SystemConfigFilePath = Path.Combine(StoragePath, "TD_SystemConfig.cfg");
public static readonly string PluginConfigFilePath = Path.Combine(StoragePath, "TD_PluginConfig.cfg");
public static readonly string PluginDataPath = Path.Combine(StoragePath, "TD_Plugins");
private static readonly string InstallerPath = Path.Combine(StoragePath, "TD_Updates");
private static string ErrorLogFilePath => Path.Combine(StoragePath, "TD_Log.txt");
private static string ConsoleLogFilePath => Path.Combine(StoragePath, "TD_Console.txt");
public static uint WindowRestoreMessage; public static uint WindowRestoreMessage;
private static readonly LockManager LockManager = new LockManager(Path.Combine(StoragePath, ".lock")); private static readonly LockManager LockManager = new LockManager(Path.Combine(StoragePath, ".lock"));
private static bool HasCleanedUp; private static bool HasCleanedUp;
public static UserConfig UserConfig { get; private set; } public static UserConfig UserConfig { get; private set; }
public static SystemConfig SystemConfig { get; private set; }
public static Reporter Reporter { get; private set; } public static Reporter Reporter { get; private set; }
public static event EventHandler UserConfigReplaced; public static event EventHandler UserConfigReplaced;
@@ -122,28 +127,33 @@ namespace TweetDck{
} }
ReloadConfig(); ReloadConfig();
SystemConfig = SystemConfig.Load(SystemConfigFilePath);
if (Arguments.HasFlag(Arguments.ArgImportCookies)){ if (Arguments.HasFlag(Arguments.ArgImportCookies)){
ExportManager.ImportCookies(); ExportManager.ImportCookies();
} }
if (Arguments.HasFlag(Arguments.ArgUpdated)){
WindowsUtils.TryDeleteFolderWhenAble(InstallerPath, 8000);
}
CefSharpSettings.WcfEnabled = false; CefSharpSettings.WcfEnabled = false;
CefSettings settings = new CefSettings{ CefSettings settings = new CefSettings{
AcceptLanguageList = BrowserUtils.HeaderAcceptLanguage, AcceptLanguageList = BrowserUtils.HeaderAcceptLanguage,
UserAgent = BrowserUtils.HeaderUserAgent, UserAgent = BrowserUtils.HeaderUserAgent,
Locale = Arguments.GetValue(Arguments.ArgLocale, string.Empty), Locale = Arguments.GetValue(Arguments.ArgLocale, string.Empty),
BrowserSubprocessPath = BrandName+".Browser.exe",
CachePath = StoragePath, CachePath = StoragePath,
LogFile = ConsoleLogFilePath, LogFile = ConsoleLogFilePath,
#if !DEBUG #if !DEBUG
BrowserSubprocessPath = BrandName+".Browser.exe",
LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable
#endif #endif
}; };
CommandLineArgsParser.ReadCefArguments(UserConfig.CustomCefArgs).ToDictionary(settings.CefCommandLineArgs); CommandLineArgsParser.ReadCefArguments(UserConfig.CustomCefArgs).ToDictionary(settings.CefCommandLineArgs);
if (!HardwareAcceleration.IsEnabled){ if (!SystemConfig.HardwareAcceleration){
settings.CefCommandLineArgs["disable-gpu"] = "1"; settings.CefCommandLineArgs["disable-gpu"] = "1";
settings.CefCommandLineArgs["disable-gpu-vsync"] = "1"; settings.CefCommandLineArgs["disable-gpu-vsync"] = "1";
} }
@@ -163,7 +173,8 @@ namespace TweetDck{
FormBrowser mainForm = new FormBrowser(plugins, new UpdaterSettings{ FormBrowser mainForm = new FormBrowser(plugins, new UpdaterSettings{
AllowPreReleases = Arguments.HasFlag(Arguments.ArgDebugUpdates), AllowPreReleases = Arguments.HasFlag(Arguments.ArgDebugUpdates),
DismissedUpdate = UserConfig.DismissedUpdate DismissedUpdate = UserConfig.DismissedUpdate,
InstallerDownloadFolder = InstallerPath
}); });
Application.Run(mainForm); Application.Run(mainForm);
@@ -172,7 +183,7 @@ namespace TweetDck{
ExitCleanup(); ExitCleanup();
// ProgramPath has a trailing backslash // ProgramPath has a trailing backslash
string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\""+ProgramPath+"\" /RUNARGS=\""+Arguments.GetCurrentClean().ToString().Replace("\"", "^\"")+"\""+(IsPortable ? " /PORTABLE=1" : ""); string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\""+ProgramPath+"\" /RUNARGS=\""+Arguments.GetCurrentForInstallerCmd()+"\""+(IsPortable ? " /PORTABLE=1" : "");
bool runElevated = !IsPortable || !WindowsUtils.CheckFolderWritePermission(ProgramPath); bool runElevated = !IsPortable || !WindowsUtils.CheckFolderWritePermission(ProgramPath);
WindowsUtils.StartProcess(mainForm.UpdateInstallerPath, updaterArgs, runElevated); WindowsUtils.StartProcess(mainForm.UpdateInstallerPath, updaterArgs, runElevated);
@@ -213,16 +224,16 @@ namespace TweetDck{
} }
public static void ReloadConfig(){ public static void ReloadConfig(){
UserConfig = UserConfig.Load(ConfigFilePath); UserConfig = UserConfig.Load(UserConfigFilePath);
UserConfigReplaced?.Invoke(UserConfig, new EventArgs()); UserConfigReplaced?.Invoke(UserConfig, new EventArgs());
} }
public static void ResetConfig(){ public static void ResetConfig(){
try{ try{
File.Delete(ConfigFilePath); File.Delete(UserConfigFilePath);
File.Delete(UserConfig.GetBackupFile(ConfigFilePath)); File.Delete(UserConfig.GetBackupFile(UserConfigFilePath));
}catch(Exception e){ }catch(Exception e){
Reporter.HandleException("Configuration Reset Error", "Could not delete configuration files to reset the settings.", true, e); Reporter.HandleException("Configuration Reset Error", "Could not delete configuration files to reset the options.", true, e);
return; return;
} }

View File

@@ -2,7 +2,7 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using TweetDck; using TweetDuck;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
@@ -37,9 +37,9 @@ using TweetDck;
[assembly: AssemblyVersion(Program.VersionFull)] [assembly: AssemblyVersion(Program.VersionFull)]
[assembly: AssemblyFileVersion(Program.VersionFull)] [assembly: AssemblyFileVersion(Program.VersionFull)]
[assembly: NeutralResourcesLanguageAttribute("en")] [assembly: NeutralResourcesLanguage("en")]
[assembly: CLSCompliant(false)] [assembly: CLSCompliant(true)]
#if DEBUG #if DEBUG
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("UnitTests")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("UnitTests")]

View File

@@ -8,7 +8,8 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace TweetDck.Properties { namespace TweetDuck.Properties {
using System;
/// <summary> /// <summary>
@@ -38,7 +39,7 @@ namespace TweetDck.Properties {
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TweetDck.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TweetDuck.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;

View File

@@ -5,9 +5,9 @@ using System.Globalization;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Other; using TweetDuck.Core.Other;
namespace TweetDck{ namespace TweetDuck{
class Reporter{ class Reporter{
private readonly string logFile; private readonly string logFile;

View File

@@ -3,7 +3,7 @@ Clear columns
[description] [description]
- Adds buttons and keyboard shortcuts to quickly clear columns - Adds buttons and keyboard shortcuts to quickly clear columns
- Hold Shift when clicking or using a keyboard shortcut to reset the column instead - Hold Shift when clicking or using a keyboard shortcut to restore the column instead
[author] [author]
chylex chylex

View File

@@ -38,7 +38,7 @@ enabled(){
$(document).off("mousemove", this.eventKeyUp); $(document).off("mousemove", this.eventKeyUp);
} }
$("#clear-columns-btn-all").text(pressed ? "Reset all" : "Clear all"); $("#clear-columns-btn-all").text(pressed ? "Restore columns" : "Clear columns");
} }
}; };
@@ -84,7 +84,7 @@ enabled(){
replaceMustache("column/column_header.mustache", "</header>", [ replaceMustache("column/column_header.mustache", "</header>", [
'{{^isTemporary}}', '{{^isTemporary}}',
'<a class="column-header-link" href="#" data-action="td-clearcolumns-dosingle" style="right:34px">', '<a class="column-header-link" href="#" data-action="td-clearcolumns-dosingle" style="right:34px">',
'<i class="icon icon-clear-timeline"></i>', '<i class="icon icon-clear-timeline js-show-tip" data-placement="bottom" data-original-title="Clear column (hold Shift to restore)"></i>',
'</a>', '</a>',
'{{/isTemporary}}', '{{/isTemporary}}',
'</header>' '</header>'
@@ -94,7 +94,7 @@ enabled(){
'<dd class="keyboard-shortcut-definition" style="white-space:nowrap">', '<dd class="keyboard-shortcut-definition" style="white-space:nowrap">',
'<span class="text-like-keyboard-key">1</span> … <span class="text-like-keyboard-key">9</span> + <span class="text-like-keyboard-key">Del</span> Clear column 19', '<span class="text-like-keyboard-key">1</span> … <span class="text-like-keyboard-key">9</span> + <span class="text-like-keyboard-key">Del</span> Clear column 19',
'</dd><dd class="keyboard-shortcut-definition">', '</dd><dd class="keyboard-shortcut-definition">',
'<span class="text-like-keyboard-key">Alt</span> + <span class="text-like-keyboard-key">Del</span> Clear all', '<span class="text-like-keyboard-key">Alt</span> + <span class="text-like-keyboard-key">Del</span> Clear all columns',
'</dd></dl><dl' '</dd></dl><dl'
].join("")); ].join(""));
@@ -116,11 +116,18 @@ ready(){
// add clear all button // add clear all button
$("nav.app-navigator").first().append([ $("nav.app-navigator").first().append([
'<a class="link-clean cf app-nav-link padding-h--10" data-title="Clear all" data-action="td-clearcolumns-doall">', '<a id="clear-columns-btn-all-parent" class="js-header-action link-clean cf app-nav-link padding-h--10" data-title="Clear columns (hold Shift to restore)" data-action="td-clearcolumns-doall">',
'<div class="obj-left margin-l--2"><i class="icon icon-medium icon-clear-timeline"></i></div>', '<div class="obj-left margin-l--2"><i class="icon icon-medium icon-clear-timeline"></i></div>',
'<div id="clear-columns-btn-all" class="nbfc padding-ts hide-condensed txt-size--16">Clear all</div>', '<div id="clear-columns-btn-all" class="nbfc padding-ts hide-condensed txt-size--16">Clear columns</div>',
'</a></nav>' '</a></nav>'
].join("")); ].join(""));
// setup tooltip handling
var tooltipEvents = $._data($(".js-header-action")[0]).events;
if (tooltipEvents.mouseover && tooltipEvents.mouseover.length && tooltipEvents.mouseout && tooltipEvents.mouseout.length){
$("#clear-columns-btn-all-parent").on("mouseover", tooltipEvents.mouseover[0].handler).on("mouseout", tooltipEvents.mouseout[0].handler);
}
} }
disabled(){ disabled(){

View File

@@ -8,7 +8,7 @@ Edit layout & design
chylex chylex
[version] [version]
1.0 1.1
[website] [website]
https://tweetduck.chylex.com https://tweetduck.chylex.com

View File

@@ -7,6 +7,7 @@ constructor(){
enabled(){ enabled(){
// elements & data // elements & data
this.css = null; this.css = null;
this.icons = null;
this.htmlModal = null; this.htmlModal = null;
this.config = null; this.config = null;
@@ -18,11 +19,14 @@ enabled(){
revertReplies: false, revertReplies: false,
themeColorTweaks: true, themeColorTweaks: true,
roundedScrollBars: false, roundedScrollBars: false,
revertIcons: true,
smallComposeTextSize: false, smallComposeTextSize: false,
optimizeAnimations: true, optimizeAnimations: true,
avatarRadius: 10 avatarRadius: 10
}; };
this.firstTimeLoad = null;
// modal dialog loading // modal dialog loading
$TDP.readFileRoot(this.$token, "modal.html").then(contents => { $TDP.readFileRoot(this.$token, "modal.html").then(contents => {
this.htmlModal = contents; this.htmlModal = contents;
@@ -32,30 +36,58 @@ enabled(){
// configuration // configuration
const configFile = "config.json"; const configFile = "config.json";
this.tmpConfig = null; this.tmpConfig = null;
this.currentStage = 0;
var loadConfigObject = obj => { this.onStageReady = () => {
this.tmpConfig = obj || {}; if (this.currentStage === 0){
this.currentStage = 1;
if (TD.ready){
this.onAppReady();
} }
else if (this.tmpConfig !== null){
this.injectDeciderReplyHook(this.tmpConfig.revertReplies);
};
this.onAppReady = () => {
if (this.tmpConfig !== null){
this.config = $.extend(this.defaultConfig, this.tmpConfig); this.config = $.extend(this.defaultConfig, this.tmpConfig);
this.tmpConfig = null; this.tmpConfig = null;
this.reinjectAll(); this.reinjectAll();
if (this.firstTimeLoad){
$TDP.writeFile(this.$token, configFile, JSON.stringify(this.config));
}
} }
}; };
var loadConfigObject = obj => {
this.tmpConfig = obj || {};
this.firstTimeLoad = obj === null;
this.onStageReady();
this.injectDeciderReplyHook(obj && obj.revertReplies);
};
if (this.$$wasLoadedBefore){
this.onStageReady();
}
else{
$(document).one("dataSettingsValues", () => {
switch(TD.settings.getColumnWidth()){
case "wide": this.defaultConfig.columnWidth = "350px"; break;
case "narrow": this.defaultConfig.columnWidth = "270px"; break;
}
switch(TD.settings.getFontSize()){
case "small": this.defaultConfig.fontSize = "13px"; break;
case "medium": this.defaultConfig.fontSize = "14px"; break;
case "large": this.defaultConfig.fontSize = "15px"; break;
case "largest": this.defaultConfig.fontSize = "16px"; break;
}
this.$$wasLoadedBefore = true;
this.onStageReady();
});
}
$TDP.checkFileExists(this.$token, configFile).then(exists => { $TDP.checkFileExists(this.$token, configFile).then(exists => {
if (!exists){ if (!exists){
loadConfigObject(null); loadConfigObject(null);
$TDP.writeFile(this.$token, configFile, JSON.stringify(this.defaultConfig));
} }
else{ else{
$TDP.readFile(this.$token, configFile, true).then(contents => { $TDP.readFile(this.$token, configFile, true).then(contents => {
@@ -208,7 +240,7 @@ enabled(){
_render: () => $(this.htmlModal), _render: () => $(this.htmlModal),
destroy: function(){ destroy: function(){
if (this.reloadPage){ if (this.reloadPage){
location.reload(); window.TDPF_requestReload();
return; return;
} }
@@ -227,7 +259,7 @@ enabled(){
}; };
TD.decider.updateForGuestId(); TD.decider.updateForGuestId();
this.$pluginSettings.requiresPageReload = enable; this.$requiresReload = enable;
}; };
// animation optimization // animation optimization
@@ -282,13 +314,13 @@ enabled(){
}; };
this.onWindowFocusEvent = () => { this.onWindowFocusEvent = () => {
if (this.config.optimizeAnimations){ if (this.config && this.config.optimizeAnimations){
injectOptimizations(true); injectOptimizations(true);
} }
}; };
this.onWindowBlurEvent = () => { this.onWindowBlurEvent = () => {
if (this.config.optimizeAnimations){ if (this.config && this.config.optimizeAnimations){
disableOptimizations(); disableOptimizations();
clearOptimizationTimer(); clearOptimizationTimer();
} }
@@ -301,6 +333,11 @@ enabled(){
} }
this.css = window.TDPF_createCustomStyle(this); this.css = window.TDPF_createCustomStyle(this);
if (this.icons){
document.head.removeChild(this.icons);
this.icons = null;
}
}; };
this.reinjectAll = () => { this.reinjectAll = () => {
@@ -338,8 +375,9 @@ enabled(){
if (this.config.hideTweetActions){ if (this.config.hideTweetActions){
this.css.insert(".tweet-action { opacity: 0; }"); this.css.insert(".tweet-action { opacity: 0; }");
this.css.insert(".tweet-actions.is-visible .tweet-action { opacity: 0.5; }");
this.css.insert(".is-favorite .tweet-action, .is-retweet .tweet-action { opacity: 0.5; visibility: visible !important }"); this.css.insert(".is-favorite .tweet-action, .is-retweet .tweet-action { opacity: 0.5; visibility: visible !important }");
this.css.insert(".tweet:hover .tweet-action, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1; visibility: visible !important }"); this.css.insert(".tweet:hover .tweet-action, .tweet-action.is-selected, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1 !important; visibility: visible !important }");
} }
if (this.config.moveTweetActionsToRight){ if (this.config.moveTweetActionsToRight){
@@ -367,6 +405,98 @@ enabled(){
this.css.insert(".activity-header + .tweet .tweet-context .obj-left { margin-right: 5px }"); this.css.insert(".activity-header + .tweet .tweet-context .obj-left { margin-right: 5px }");
} }
if (this.config.revertIcons){
this.icons = document.createElement("style");
this.icons.innerHTML = `
@font-face {
font-family: 'tweetdeckold';
src: url("https://ton.twimg.com/tweetdeck-web/web/assets/fonts/tweetdeck-regular-webfont.5f4ea87976.woff") format("woff");
font-weight: normal;
font-style: normal;
}
.icon-twitter-bird:before{content:"\\f000";font-family:tweetdeckold}
.icon-mention:before{content:"\\f001";font-family:tweetdeckold}
.icon-following:before{content:"\\f002";font-family:tweetdeckold}
.icon-message:before{content:"\\f003";font-family:tweetdeckold}
.icon-home:before{content:"\\f004";font-family:tweetdeckold}
.icon-hashtag:before{content:"\\f005";font-family:tweetdeckold}
.icon-reply:before{content:"\\f006";font-family:tweetdeckold}
.icon-favorite:before{content:"\\f055";font-family:tweetdeckold}
.icon-retweet:before{content:"\\f008";font-family:tweetdeckold}
.icon-drafts:before{content:"\\f009";font-family:tweetdeckold}
.icon-search:before{content:"\\f00a";font-family:tweetdeckold}
.icon-trash:before{content:"\\f00c";font-family:tweetdeckold}
.icon-close:before{content:"\\f00d";font-family:tweetdeckold}
.icon-arrow-r:before,.Icon--caretRight:before{content:"\\f00e";font-family:tweetdeckold}
.icon-arrow-l:before,.Icon--caretLeft:before{content:"\\f00f";font-family:tweetdeckold}
.icon-protected:before{content:"\\f013";font-family:tweetdeckold}
.icon-list:before{content:"\\f014";font-family:tweetdeckold}
.icon-camera:before{content:"\\f015";font-family:tweetdeckold}
.icon-more:before{content:"\\f016";font-family:tweetdeckold}
.icon-settings:before{content:"\\f018";font-family:tweetdeckold}
.icon-notifications:before{content:"\\f019";font-family:tweetdeckold}
.icon-user-dd:before{content:"\\f01a";font-family:tweetdeckold}
.icon-activity:before{content:"\\f01c";font-family:tweetdeckold}
.icon-trending:before{content:"\\f01d";font-family:tweetdeckold}
.icon-minus:before{content:"\\f01e";font-family:tweetdeckold}
.icon-plus:before{content:"\\f01f";font-family:tweetdeckold}
.icon-geo:before{content:"\\f020";font-family:tweetdeckold}
.icon-check:before{content:"\\f021";font-family:tweetdeckold}
.icon-schedule:before{content:"\\f022";font-family:tweetdeckold}
.icon-dot:before{content:"\\f023";font-family:tweetdeckold}
.icon-user:before{content:"\\f024";font-family:tweetdeckold}
.icon-content:before{content:"\\f025";font-family:tweetdeckold}
.icon-arrow-d:before,.Icon--caretDown:before{content:"\\f026";font-family:tweetdeckold}
.icon-arrow-u:before{content:"\\f027";font-family:tweetdeckold}
.icon-share:before{content:"\\f028";font-family:tweetdeckold}
.icon-info:before{content:"\\f029";font-family:tweetdeckold}
.icon-verified:before{content:"\\f02a";font-family:tweetdeckold}
.icon-translator:before{content:"\\f02b";font-family:tweetdeckold}
.icon-blocked:before{content:"\\f02c";font-family:tweetdeckold}
.icon-constrain:before{content:"\\f02d";font-family:tweetdeckold}
.icon-play-video:before{content:"\\f02e";font-family:tweetdeckold}
.icon-empty:before{content:"\\f02f";font-family:tweetdeckold}
.icon-clear-input:before{content:"\\f030";font-family:tweetdeckold}
.icon-compose:before{content:"\\f031";font-family:tweetdeckold}
.icon-mark-read:before{content:"\\f032";font-family:tweetdeckold}
.icon-arrow-r-double:before{content:"\\f033";font-family:tweetdeckold}
.icon-arrow-l-double:before{content:"\\f034";font-family:tweetdeckold}
.icon-follow:before{content:"\\f035";font-family:tweetdeckold}
.icon-image:before{content:"\\f036";font-family:tweetdeckold}
.icon-popout:before{content:"\\f037";font-family:tweetdeckold}
.icon-move:before{content:"\\f039";font-family:tweetdeckold}
.icon-compose-grid:before{content:"\\f03a";font-family:tweetdeckold}
.icon-compose-minigrid:before{content:"\\f03b";font-family:tweetdeckold}
.icon-compose-list:before{content:"\\f03c";font-family:tweetdeckold}
.icon-edit:before{content:"\\f040";font-family:tweetdeckold}
.icon-clear-timeline:before{content:"\\f041";font-family:tweetdeckold}
.icon-sliders:before{content:"\\f042";font-family:tweetdeckold}
.icon-custom-timeline:before{content:"\\f043";font-family:tweetdeckold}
.icon-compose-dm:before{content:"\\f044";font-family:tweetdeckold}
.icon-bg-dot:before{content:"\\f045";font-family:tweetdeckold}
.icon-user-team-mgr:before{content:"\\f046";font-family:tweetdeckold}
.icon-user-switch:before{content:"\\f047";font-family:tweetdeckold}
.icon-conversation:before{content:"\\f048";font-family:tweetdeckold}
.icon-dataminr:before{content:"\\f049";font-family:tweetdeckold}
.icon-link:before{content:"\\f04a";font-family:tweetdeckold}
.icon-flash:before{content:"\\f050";font-family:tweetdeckold}
.icon-pointer-u:before{content:"\\f051";font-family:tweetdeckold}
.icon-analytics:before{content:"\\f054";font-family:tweetdeckold}
.icon-heart:before{content:"\\f055";font-family:tweetdeckold}
.icon-calendar:before{content:"\\f056";font-family:tweetdeckold}
.icon-attachment:before{content:"\\f057";font-family:tweetdeckold}
.icon-play:before{content:"\\f058";font-family:tweetdeckold}
.icon-bookmark:before{content:"\\f059";font-family:tweetdeckold}
.icon-play-badge:before{content:"\\f060";font-family:tweetdeckold}
.icon-gif-badge:before{content:"\\f061";font-family:tweetdeckold}
.icon-poll:before{content:"\\f062";font-family:tweetdeckold}
.column-header .column-type-icon { bottom: 26px !important }`;
document.head.appendChild(this.icons);
}
if (this.config.columnWidth[0] === '/'){ if (this.config.columnWidth[0] === '/'){
let cols = this.config.columnWidth.slice(1); let cols = this.config.columnWidth.slice(1);
@@ -399,13 +529,25 @@ enabled(){
default: TD.settings.setFontSize(parseInt(this.config.fontSize, 10) >= 16 ? "largest" : "smallest"); break; default: TD.settings.setFontSize(parseInt(this.config.fontSize, 10) >= 16 ? "largest" : "smallest"); break;
} }
$TDP.injectIntoNotificationsBefore(this.$token, "css", "</head>", [ $TDP.injectIntoNotificationsBefore(this.$token, "css", "</head>", `
"<style type='text/css'>", <style type='text/css'>
".txt-base-smallest:not(.icon), .txt-base-largest:not(.icon) { font-size: "+this.config.fontSize+" !important }", .txt-base-smallest:not(.icon), .txt-base-largest:not(.icon) { font-size: ${this.config.fontSize} !important }
".avatar { border-radius: "+this.config.avatarRadius+"% !important }", .avatar { border-radius: ${this.config.avatarRadius}% !important }
(this.config.revertReplies ? ".activity-header + .tweet .tweet-context { margin-left: -35px } .activity-header + .tweet .tweet-context .obj-left { margin-right: 5px }" : ""),
"</style>" ${this.config.revertReplies ? `
].join("")); .activity-header + .tweet .tweet-context { margin-left: -35px }
.activity-header + .tweet .tweet-context .obj-left { margin-right: 5px }
` : ``}
${this.config.revertIcons ? `
@font-face { font-family: 'tweetdeckold'; src: url(\"https://ton.twimg.com/tweetdeck-web/web/assets/fonts/tweetdeck-regular-webfont.5f4ea87976.woff\") format(\"woff\"); font-weight: normal; font-style: normal }
.icon-reply:before{content:"\\f006";font-family:tweetdeckold}
.icon-favorite:before{content:"\\f055";font-family:tweetdeckold}
.icon-retweet:before{content:"\\f008";font-family:tweetdeckold}
.icon-follow:before{content:"\\f035";font-family:tweetdeckold}
.icon-user-dd:before{content:"\\f01a";font-family:tweetdeckold}
` : ``}
</style>`);
}; };
this.uiShowActionsMenuEvent = () => { this.uiShowActionsMenuEvent = () => {
@@ -416,21 +558,6 @@ enabled(){
} }
ready(){ ready(){
// configuration
switch(TD.settings.getColumnWidth()){
case "wide": this.defaultConfig.columnWidth = "350px"; break;
case "narrow": this.defaultConfig.columnWidth = "270px"; break;
}
switch(TD.settings.getFontSize()){
case "small": this.defaultConfig.fontSize = "13px"; break;
case "medium": this.defaultConfig.fontSize = "14px"; break;
case "large": this.defaultConfig.fontSize = "15px"; break;
case "largest": this.defaultConfig.fontSize = "16px"; break;
}
this.onAppReady();
// optimization events // optimization events
$(window).on("focus", this.onWindowFocusEvent); $(window).on("focus", this.onWindowFocusEvent);
$(window).on("blur", this.onWindowBlurEvent); $(window).on("blur", this.onWindowBlurEvent);
@@ -448,6 +575,10 @@ disabled(){
this.css.remove(); this.css.remove();
} }
if (this.icons){
document.head.removeChild(this.icons);
}
if (this.optimizations){ if (this.optimizations){
this.optimizations.remove(); this.optimizations.remove();
} }

View File

@@ -106,6 +106,10 @@
<input data-td-key="roundedScrollBars" class="js-theme-checkbox touch-larger-label" type="checkbox"> <input data-td-key="roundedScrollBars" class="js-theme-checkbox touch-larger-label" type="checkbox">
Rounded scroll bars Rounded scroll bars
</label> </label>
<label class="checkbox">
<input data-td-key="revertIcons" class="js-theme-checkbox touch-larger-label" type="checkbox">
Revert icon design
</label>
<label class="checkbox"> <label class="checkbox">
<input data-td-key="smallComposeTextSize" class="js-theme-checkbox touch-larger-label" type="checkbox"> <input data-td-key="smallComposeTextSize" class="js-theme-checkbox touch-larger-label" type="checkbox">
Small compose tweet font size Small compose tweet font size

View File

@@ -9,7 +9,7 @@ Emoji keyboard
chylex chylex
[version] [version]
1.0 1.1
[website] [website]
https://tweetduck.chylex.com https://tweetduck.chylex.com

View File

@@ -1,5 +1,6 @@
enabled(){ enabled(){
this.selectedSkinTone = ""; this.selectedSkinTone = "";
this.currentKeywords = [];
this.skinToneList = [ this.skinToneList = [
"", "1F3FB", "1F3FC", "1F3FD", "1F3FE", "1F3FF" "", "1F3FB", "1F3FC", "1F3FD", "1F3FE", "1F3FF"
@@ -20,9 +21,10 @@ enabled(){
this.emojiURL = "https://ton.twimg.com/tweetdeck-web/web/assets/emoji/"; this.emojiURL = "https://ton.twimg.com/tweetdeck-web/web/assets/emoji/";
this.emojiHTML1 = ""; // no skin tones, prepended this.emojiData1 = []; // no skin tones, prepended
this.emojiHTML2 = {}; // contains emojis with skin tones this.emojiData2 = {}; // contains emojis with skin tones
this.emojiHTML3 = ""; // no skin tones, appended this.emojiData3 = []; // no skin tones, appended
this.emojiNames = [];
var me = this; var me = this;
@@ -33,6 +35,8 @@ enabled(){
this.css.insert(".emoji-keyboard-list { height: 10.14em; padding: 0.1em; box-sizing: border-box; overflow-y: auto }"); this.css.insert(".emoji-keyboard-list { height: 10.14em; padding: 0.1em; box-sizing: border-box; overflow-y: auto }");
this.css.insert(".emoji-keyboard-list .separator { height: 26px }"); this.css.insert(".emoji-keyboard-list .separator { height: 26px }");
this.css.insert(".emoji-keyboard-list img { padding: 0.1em !important; width: 1em; height: 1em; vertical-align: -0.1em; cursor: pointer }"); this.css.insert(".emoji-keyboard-list img { padding: 0.1em !important; width: 1em; height: 1em; vertical-align: -0.1em; cursor: pointer }");
this.css.insert(".emoji-keyboard-search { height: auto; padding: 4px 10px 8px; background-color: #292f33; border-radius: 2px 2px 0 0 }");
this.css.insert(".emoji-keyboard-search input { width: 100%; border-radius: 1px; }");
this.css.insert(".emoji-keyboard-skintones { height: 1.3em; text-align: center; background-color: #292f33; border-radius: 0 0 2px 2px }"); this.css.insert(".emoji-keyboard-skintones { height: 1.3em; text-align: center; background-color: #292f33; border-radius: 0 0 2px 2px }");
this.css.insert(".emoji-keyboard-skintones div { width: 0.8em; height: 0.8em; margin: 0.25em 0.1em; border-radius: 50%; display: inline-block; box-sizing: border-box; cursor: pointer }"); this.css.insert(".emoji-keyboard-skintones div { width: 0.8em; height: 0.8em; margin: 0.25em 0.1em; border-radius: 50%; display: inline-block; box-sizing: border-box; cursor: pointer }");
this.css.insert(".emoji-keyboard-skintones .sel { border: 2px solid rgba(0, 0, 0, 0.35); box-shadow: 0 0 2px 0 rgba(255, 255, 255, 0.65), 0 0 1px 0 rgba(255, 255, 255, 0.4) inset }"); this.css.insert(".emoji-keyboard-skintones .sel { border: 2px solid rgba(0, 0, 0, 0.35); box-shadow: 0 0 2px 0 rgba(255, 255, 255, 0.65), 0 0 1px 0 rgba(255, 255, 255, 0.4) inset }");
@@ -54,26 +58,70 @@ enabled(){
// keyboard generation // keyboard generation
this.currentKeyboard = null; this.currentKeyboard = null;
this.currentSpanner = null;
var hideKeyboard = () => { var hideKeyboard = () => {
$(this.currentKeyboard).remove(); $(this.currentKeyboard).remove();
this.currentKeyboard = null; this.currentKeyboard = null;
$(this.currentSpanner).remove();
this.currentSpanner = null;
this.composePanelScroller.trigger("scroll");
$(".emoji-keyboard-popup-btn").removeClass("is-selected"); $(".emoji-keyboard-popup-btn").removeClass("is-selected");
$(".js-compose-text").first().focus(); $(".js-compose-text").first().focus();
}; };
var generateEmojiHTML = skinTone => { var generateEmojiHTML = skinTone => {
return (this.emojiHTML1+this.emojiHTML2[skinTone]+this.emojiHTML3).replace(/u#/g, this.emojiURL); let index = 0;
let html = [ "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that most emoji will not show up properly in the text box above, but they will display in the tweet.</p>" ];
for(let array of [ this.emojiData1, this.emojiData2[skinTone], this.emojiData3 ]){
for(let emoji of array){
if (emoji === "___"){
html.push("<div class='separator'></div>");
}
else{
html.push(TD.util.cleanWithEmoji(emoji).replace(' class="emoji" draggable="false"', ''));
index++;
}
}
}
return html.join("");
};
var updateFilters = () => {
let keywords = this.currentKeywords;
let container = $(this.currentKeyboard.children[1]);
let emoji = container.children("img");
let info = container.children("p:first");
let separators = container.children("div");
if (keywords.length === 0){
info.css("display", "block");
separators.css("display", "block");
emoji.css("display", "inline");
}
else{
info.css("display", "none");
separators.css("display", "none");
emoji.css("display", "none");
emoji.filter(index => keywords.every(kw => me.emojiNames[index].includes(kw))).css("display", "inline");
}
}; };
var selectSkinTone = skinTone => { var selectSkinTone = skinTone => {
let selectedEle = this.currentKeyboard.children[1].querySelector("[data-tone='"+this.selectedSkinTone+"']"); let selectedEle = this.currentKeyboard.children[2].querySelector("[data-tone='"+this.selectedSkinTone+"']");
selectedEle && selectedEle.classList.remove("sel"); selectedEle && selectedEle.classList.remove("sel");
this.selectedSkinTone = skinTone; this.selectedSkinTone = skinTone;
this.currentKeyboard.children[0].innerHTML = generateEmojiHTML(skinTone); this.currentKeyboard.children[1].innerHTML = generateEmojiHTML(skinTone);
this.currentKeyboard.children[1].querySelector("[data-tone='"+this.selectedSkinTone+"']").classList.add("sel"); this.currentKeyboard.children[2].querySelector("[data-tone='"+this.selectedSkinTone+"']").classList.add("sel");
updateFilters();
}; };
this.generateKeyboard = (input, left, top) => { this.generateKeyboard = (input, left, top) => {
@@ -103,10 +151,19 @@ enabled(){
e.stopPropagation(); e.stopPropagation();
}); });
var search = document.createElement("div");
search.innerHTML = "<input type='text' placeholder='Search...'>";
search.classList.add("emoji-keyboard-search");
var skintones = document.createElement("div"); var skintones = document.createElement("div");
skintones.innerHTML = me.skinToneData.map(entry => "<div data-tone='"+entry[0]+"' style='background-color:"+entry[1]+"'></div>").join(""); skintones.innerHTML = me.skinToneData.map(entry => "<div data-tone='"+entry[0]+"' style='background-color:"+entry[1]+"'></div>").join("");
skintones.classList.add("emoji-keyboard-skintones"); skintones.classList.add("emoji-keyboard-skintones");
outer.appendChild(search);
outer.appendChild(keyboard);
outer.appendChild(skintones);
$(".js-app").append(outer);
skintones.addEventListener("click", function(e){ skintones.addEventListener("click", function(e){
if (e.target.hasAttribute("data-tone")){ if (e.target.hasAttribute("data-tone")){
selectSkinTone(e.target.getAttribute("data-tone") || ""); selectSkinTone(e.target.getAttribute("data-tone") || "");
@@ -115,23 +172,36 @@ enabled(){
e.stopPropagation(); e.stopPropagation();
}); });
outer.appendChild(keyboard); search.addEventListener("click", function(e){
outer.appendChild(skintones); e.stopPropagation();
document.body.appendChild(outer); });
var searchInput = search.children[0];
searchInput.focus();
searchInput.addEventListener("input", function(e){
me.currentKeywords = e.target.value.split(" ").filter(kw => kw.length > 0).map(kw => kw.toLowerCase());
updateFilters();
e.stopPropagation();
});
searchInput.addEventListener("focus", function(){
$(this).select();
});
this.currentKeyboard = outer; this.currentKeyboard = outer;
selectSkinTone(this.selectedSkinTone); selectSkinTone(this.selectedSkinTone);
this.currentSpanner = document.createElement("div");
this.currentSpanner.style.height = ($(this.currentKeyboard).height()-10)+"px";
$(".emoji-keyboard-popup-btn").parent().after(this.currentSpanner);
this.composePanelScroller.trigger("scroll");
}; };
this.prevTryPasteImage = window.TDGF_tryPasteImage; var getKeyboardTop = () => {
var prevTryPasteImageF = this.prevTryPasteImage; let button = $(".emoji-keyboard-popup-btn");
return button.offset().top+button.outerHeight()+me.composePanelScroller.scrollTop()+8;
window.TDGF_tryPasteImage = function(){
if (me.currentKeyboard){
hideKeyboard();
}
return prevTryPasteImageF.apply(this, arguments);
}; };
// event handlers // event handlers
@@ -139,18 +209,22 @@ enabled(){
this.emojiKeyboardButtonClickEvent = function(e){ this.emojiKeyboardButtonClickEvent = function(e){
if (me.currentKeyboard){ if (me.currentKeyboard){
hideKeyboard(); hideKeyboard();
$(this).blur();
} }
else{ else{
var pos = $(this).offset(); me.generateKeyboard($(".js-compose-text").first(), $(this).offset().left, getKeyboardTop());
me.generateKeyboard($(".js-compose-text").first(), pos.left, pos.top+$(this).outerHeight()+8);
$(this).addClass("is-selected"); $(this).addClass("is-selected");
} }
$(this).blur();
e.stopPropagation(); e.stopPropagation();
}; };
this.composerScrollEvent = function(e){
if (me.currentKeyboard){
me.currentKeyboard.style.marginTop = (-$(this).scrollTop())+"px";
}
};
this.documentClickEvent = function(e){ this.documentClickEvent = function(e){
if (me.currentKeyboard && !e.target.classList.contains("js-compose-text")){ if (me.currentKeyboard && !e.target.classList.contains("js-compose-text")){
hideKeyboard(); hideKeyboard();
@@ -164,18 +238,21 @@ enabled(){
} }
}; };
/* this.uploadFilesEvent = function(e){
* TODO if (me.currentKeyboard){
* ---- me.currentKeyboard.style.top = getKeyboardTop()+"px";
* add emoji search if I can be bothered }
* lazy emoji loading }
*/
} }
ready(){ ready(){
this.composePanelScroller = $(".js-compose-scroller", ".js-docked-compose").first().children().first();
this.composePanelScroller.on("scroll", this.composerScrollEvent);
$(".emoji-keyboard-popup-btn").on("click", this.emojiKeyboardButtonClickEvent); $(".emoji-keyboard-popup-btn").on("click", this.emojiKeyboardButtonClickEvent);
$(document).on("click", this.documentClickEvent); $(document).on("click", this.documentClickEvent);
$(document).on("keydown", this.documentKeyEvent); $(document).on("keydown", this.documentKeyEvent);
$(document).on("uiComposeImageAdded", this.uploadFilesEvent);
// HTML generation // HTML generation
@@ -190,18 +267,14 @@ ready(){
}; };
$TDP.readFileRoot(this.$token, "emoji-ordering.txt").then(contents => { $TDP.readFileRoot(this.$token, "emoji-ordering.txt").then(contents => {
let generated1 = [];
let generated2 = {};
let generated3 = [];
for(let skinTone of this.skinToneList){ for(let skinTone of this.skinToneList){
generated2[skinTone] = []; this.emojiData2[skinTone] = [];
} }
// declaration inserters // declaration inserters
let addDeclaration1 = decl => { let addDeclaration1 = decl => {
generated1.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join("")); this.emojiData1.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join(""));
}; };
let addDeclaration2 = (tone, decl) => { let addDeclaration2 = (tone, decl) => {
@@ -209,16 +282,16 @@ ready(){
if (tone === null){ if (tone === null){
for(let skinTone of this.skinToneList){ for(let skinTone of this.skinToneList){
generated2[skinTone].push(gen); this.emojiData2[skinTone].push(gen);
} }
} }
else{ else{
generated2[tone].push(gen); this.emojiData2[tone].push(gen);
} }
}; };
let addDeclaration3 = decl => { let addDeclaration3 = decl => {
generated3.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join("")); this.emojiData3.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join(""));
}; };
// line reading // line reading
@@ -228,9 +301,9 @@ ready(){
for(let line of contents.split("\n")){ for(let line of contents.split("\n")){
if (line[0] === '@'){ if (line[0] === '@'){
switch(skinToneState){ switch(skinToneState){
case 0: generated1.push("___"); break; case 0: this.emojiData1.push("___"); break;
case 1: this.skinToneList.forEach(skinTone => generated2[skinTone].push("___")); break; case 1: this.skinToneList.forEach(skinTone => this.emojiData2[skinTone].push("___")); break;
case 2: generated3.push("___"); break; case 2: this.emojiData3.push("___"); break;
} }
if (line[1] === '1'){ if (line[1] === '1'){
@@ -239,9 +312,15 @@ ready(){
else if (line[1] === '2'){ else if (line[1] === '2'){
skinToneState = 2; skinToneState = 2;
} }
continue;
} }
else if (skinToneState === 1){
let decl = line.slice(0, line.indexOf(';')); let semicolon = line.indexOf(';');
let decl = line.slice(0, semicolon);
let desc = line.slice(semicolon+1).toLowerCase();
if (skinToneState === 1){
let skinIndex = decl.indexOf('$'); let skinIndex = decl.indexOf('$');
if (skinIndex !== -1){ if (skinIndex !== -1){
@@ -249,35 +328,24 @@ ready(){
let declPost = decl.slice(skinIndex+1); let declPost = decl.slice(skinIndex+1);
for(let skinTone of this.skinToneNonDefaultList){ for(let skinTone of this.skinToneNonDefaultList){
generated2[skinTone].pop(); this.emojiData2[skinTone].pop();
addDeclaration2(skinTone, declPre+skinTone+declPost); addDeclaration2(skinTone, declPre+skinTone+declPost);
} }
} }
else{ else{
addDeclaration2(null, decl); addDeclaration2(null, decl);
this.emojiNames.push(desc);
} }
} }
else if (skinToneState === 2){ else if (skinToneState === 2){
addDeclaration3(line.slice(0, line.indexOf(';'))); addDeclaration3(decl);
this.emojiNames.push(desc);
} }
else if (skinToneState === 0){ else if (skinToneState === 0){
addDeclaration1(line.slice(0, line.indexOf(';'))); addDeclaration1(decl);
this.emojiNames.push(desc);
} }
} }
// final processing
let urlRegex = new RegExp(this.emojiURL.replace(/\./g, "\\."), "g");
let process = str => TD.util.cleanWithEmoji(str).replace(/ class=\"emoji\" draggable=\"false\"/g, "").replace(urlRegex, "u#").replace(/___/g, "<div class='separator'></div>");
let start = "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that most emoji will not show up properly in the text box above, but they will display in the tweet.</p>";
this.emojiHTML1 = start+process(generated1.join(""));
for(let skinTone of this.skinToneList){
this.emojiHTML2[skinTone] = process(generated2[skinTone].join(""));
}
this.emojiHTML3 = process(generated3.join(""));
}).catch(err => { }).catch(err => {
$TD.alert("error", "Problem loading emoji keyboard: "+err.message); $TD.alert("error", "Problem loading emoji keyboard: "+err.message);
}); });
@@ -290,12 +358,17 @@ disabled(){
$(this.currentKeyboard).remove(); $(this.currentKeyboard).remove();
} }
window.TDGF_tryPasteImage = this.prevTryPasteImage; if (this.currentSpanner){
$(this.currentSpanner).remove();
}
this.composePanelScroller.off("scroll", this.composerScrollEvent);
$(".emoji-keyboard-popup-btn").off("click", this.emojiKeyboardButtonClickEvent); $(".emoji-keyboard-popup-btn").off("click", this.emojiKeyboardButtonClickEvent);
$(".emoji-keyboard-popup-btn").remove(); $(".emoji-keyboard-popup-btn").remove();
$(document).off("click", this.documentClickEvent); $(document).off("click", this.documentClickEvent);
$(document).off("keydown", this.documentKeyEvent); $(document).off("keydown", this.documentKeyEvent);
$(document).off("uiComposeImageAdded", this.uploadFilesEvent);
TD.mustaches["compose/docked_compose.mustache"] = this.prevComposeMustache; TD.mustaches["compose/docked_compose.mustache"] = this.prevComposeMustache;
} }

View File

@@ -0,0 +1,70 @@
Emoji list: http://unicode.org/emoji/charts/emoji-ordering.html
Emoji order: http://unicode.org/emoji/charts/emoji-ordering.txt
------------------------
Remove unnecessary info:
Search: \s;.+?#.+?\s
Replace: ;
Search: U+
Replace:
-----------------------------
Replace skin tone variations:
Example:
1F9D2;child
1F9D2 1F3FB; child: light skin tone
1F9D2 1F3FC; child: medium-light skin tone
1F9D2 1F3FD; child: medium skin tone
1F9D2 1F3FE; child: medium-dark skin tone
1F9D2 1F3FF; child: dark skin tone
1F9D2;child
1F9D2 $;child
TODO: Update this section with exact regexes
----------------
Move some emoji:
1F443 $;nose
> 1F91D;handshake
1F463;footprints
1F939 $ 200D 2640 FE0F;woman juggling
> 1F6CC;person in bed
> 1F6CC $;person in bed
> 1F6C0;person taking bath
> 1F6C0 $;person taking bath
1F46B;man and woman holding hands
------------------
Remove some emoji:
1F469 $ 200D 1F692;woman firefighter
> remove all non-gendered duplicates below here
3030;wavy dash
> remove copyright
> remove registered trademark
> remove trademark
0023 FE0F 20E3;keycap
1F441;eye
> remove eye in speech bubble
1F445;tongue
-------------------------
Add preprocessor symbols:
@ = group separator
@1 = enable skin tones below
@2 = disable skin tones below

Some files were not shown because too many files have changed in this diff Show More