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

Compare commits

...

38 Commits
1.1 ... 1.2

Author SHA1 Message Date
15a39de939 Update version to 1.2 2016-04-26 18:51:45 +02:00
4142206b65 Fix icon in Volume Mixer
Closes #20
2016-04-26 16:04:02 +02:00
6105658602 Temporarily re-add default sound notification, but make it work with Mute function 2016-04-26 15:49:24 +02:00
a6e40be79e Fix maximization resetting restore location and size 2016-04-26 15:19:54 +02:00
95fba6a99a Fix license file copying in post build events 2016-04-26 11:59:47 +02:00
aa2e4c9845 Implement multiple tray options and refactor tray icon handling 2016-04-26 02:41:19 +02:00
f4cfc40244 Redo locations and margins in settings Form 2016-04-26 01:01:16 +02:00
6c50bdba06 Rename 'Update Notifications' setting to 'Check for Updates' 2016-04-26 00:44:49 +02:00
1f6fc491ef Add a WIP sound notification hook 2016-04-26 00:43:44 +02:00
1c3a7b6ce7 Implement holding Ctrl to open clicked links in browser 2016-04-25 18:07:54 +02:00
b04e260fb7 Fix focus stealing issues when showing or hiding the notification Form 2016-04-25 17:58:10 +02:00
4a66486e1a Rename extendFunction to appendToFunction, and add prependToFunction to code.js 2016-04-25 17:01:56 +02:00
a335aa037a Fix clicking on nested/complex links in notification.js not triggering the hooks 2016-04-25 16:17:28 +02:00
dd4c89b9dd Add notification Form title changing with enqueued tweets 2016-04-25 16:12:58 +02:00
ddbf6da061 Fix double-clicking maximizing notification Form by setting MaximizeBox to false (thanks Microsoft...) 2016-04-25 16:06:07 +02:00
f85e0030a7 Add Mute Notifications setting (required changes to notification focus handling)
Closes #13
2016-04-25 15:51:14 +02:00
c0271d273f Remove unused fontSizeClasses from code.js 2016-04-25 12:49:57 +02:00
2a1dc8beab Bypass t.co links in context menu and hide url options for # links 2016-04-24 22:13:48 +02:00
c5b3bc1a0b Fix context menu not running any actions in notification Form 2016-04-24 22:04:41 +02:00
316b1db3f6 Force word-break:break-all on expanded links 2016-04-24 20:51:30 +02:00
49fa7626b6 Expand shortened links on hover
Closes #12
2016-04-24 20:47:10 +02:00
24edcc3402 Rewrite notification system to improve reliability and future extensibility
Closes #18
2016-04-24 16:37:27 +02:00
c53a1cbd01 Fix clicking on "Followed by:" users opening the browser 2016-04-24 14:53:11 +02:00
c138b13d01 Rewrite theme change handling 2016-04-24 14:28:39 +02:00
acc9b58660 Remove getFontSizeClass from code.js 2016-04-24 14:19:20 +02:00
b94a6acee6 Add address check to notification form before running notification.js 2016-04-24 14:15:04 +02:00
b2892cc834 Rewrite font size handling 2016-04-24 14:10:29 +02:00
82a1e17b1d Add extendFunction and refactor window.TD in code.js 2016-04-24 14:04:52 +02:00
82a3cd8df2 Add a simple context menu to the tray icon (Restore, Close) 2016-04-23 20:59:23 +02:00
b39a3a05fe Move update notification code to update.js and make the notification display without needing the app div 2016-04-23 17:54:15 +02:00
f4c7eb14ec Add ScriptLoader.LoadResources with unlimited parameters 2016-04-23 17:53:01 +02:00
92ac138183 Make sure tray icon brings the window to front
Closes #14
2016-04-23 17:06:59 +02:00
b0fe8cf53e Rename TweetD*ck settings option on the website for clarity 2016-04-23 17:00:23 +02:00
016e403309 Fix LockManager to check process name before reporting, and cleanup Close/Dispose code
Closes #17
2016-04-23 16:51:11 +02:00
4cef0fb60d Fix clipboard text formatting
Closes #19
2016-04-23 16:29:51 +02:00
d53eff6043 Update version to 1.1.1 2016-04-17 17:42:14 +02:00
f064912ac9 Prevent notifications from stealing focus from the client app 2016-04-17 17:42:00 +02:00
f9f0677da3 Fix broken pop-up notifications 2016-04-17 17:41:46 +02:00
23 changed files with 750 additions and 363 deletions

View File

@@ -54,7 +54,15 @@ namespace TweetDck.Configuration{
int pid = BitConverter.ToInt32(bytes,0);
try{
lockingProcess = Process.GetProcessById(pid);
Process foundProcess = Process.GetProcessById(pid);
using(Process currentProcess = Process.GetCurrentProcess()){
if (foundProcess.ProcessName == currentProcess.ProcessName){
lockingProcess = foundProcess;
}
currentProcess.Close();
}
}catch(ArgumentException){}
return lockingProcess == null && CreateLockFile();
@@ -76,7 +84,6 @@ namespace TweetDck.Configuration{
public void Unlock(){
if (lockStream != null){
lockStream.Close();
lockStream.Dispose();
File.Delete(file);
@@ -96,7 +103,7 @@ namespace TweetDck.Configuration{
}
if (lockingProcess.HasExited){
lockingProcess.Close();
lockingProcess.Dispose();
lockingProcess = null;
return true;
}

View File

@@ -3,6 +3,7 @@ using System.Drawing;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using TweetDck.Core;
using TweetDck.Core.Handling;
namespace TweetDck.Configuration{
@@ -22,8 +23,6 @@ namespace TweetDck.Configuration{
public bool IsMaximized { get; set; }
public Point WindowLocation { get; set; }
public Size WindowSize { get; set; }
public bool MinimizeToTray { get; set; }
public bool DisplayNotificationTimer { get; set; }
public TweetNotification.Duration NotificationDuration { get; set; }
@@ -47,12 +46,52 @@ namespace TweetDck.Configuration{
}
}
public bool MuteNotifications{
get{
return muteNotifications;
}
set{
if (muteNotifications == value)return;
muteNotifications = value;
if (MuteToggled != null){
MuteToggled(this,new EventArgs());
}
}
}
public TrayIcon.Behavior TrayBehavior{
get{
return trayBehavior;
}
set{
if (trayBehavior == value)return;
trayBehavior = value;
if (TrayBehaviorChanged != null){
TrayBehaviorChanged(this,new EventArgs());
}
}
}
// END OF CONFIGURATION
[field:NonSerialized]
public event EventHandler MuteToggled;
[field:NonSerialized]
public event EventHandler TrayBehaviorChanged;
[NonSerialized]
private string file;
private int fileVersion;
private bool muteNotifications;
private TrayIcon.Behavior trayBehavior;
private UserConfig(string file){
this.file = file;

View File

@@ -23,24 +23,23 @@
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.trayIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.trayIcon = new TweetDck.Core.TrayIcon();
this.SuspendLayout();
//
// trayIcon
//
this.trayIcon.Icon = global::TweetDck.Properties.Resources.icon;
this.trayIcon.Click += new System.EventHandler(this.trayIcon_Click);
this.trayIcon.Visible = false;
//
// FormBrowser
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Icon = global::TweetDck.Properties.Resources.icon;
this.Icon = ((System.Drawing.Icon)(TweetDck.Properties.Resources.ResourceManager.GetObject("icon")));
this.Location = new System.Drawing.Point(-32000, -32000);
this.Name = "FormBrowser";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormBrowser_FormClosing);
this.ResizeEnd += new System.EventHandler(this.FormBrowser_ResizeEnd);
this.Resize += new System.EventHandler(this.FormBrowser_Resize);
this.ResumeLayout(false);
@@ -49,7 +48,7 @@
#endregion
private System.Windows.Forms.NotifyIcon trayIcon;
private TrayIcon trayIcon;
}
}

View File

@@ -9,6 +9,7 @@ using TweetDck.Core.Other;
using TweetDck.Resources;
using TweetDck.Core.Utils;
using TweetDck.Core.Controls;
using System.ComponentModel;
namespace TweetDck.Core{
sealed partial class FormBrowser : Form{
@@ -46,10 +47,14 @@ namespace TweetDck.Core{
Disposed += (sender, args) => browser.Dispose();
trayIcon.ClickRestore += trayIcon_ClickRestore;
trayIcon.ClickClose += trayIcon_ClickClose;
Config.TrayBehaviorChanged += Config_TrayBehaviorChanged;
UpdateTrayIcon();
notification = new FormNotification(this,bridge,true){ CanMoveWindow = () => false };
notification.Show();
trayIcon.Text = Program.BrandName;
}
private void ShowChildForm(Form form){
@@ -76,6 +81,10 @@ namespace TweetDck.Core{
isLoaded = true;
}
private void UpdateTrayIcon(){
trayIcon.Visible = Config.TrayBehavior != TrayIcon.Behavior.Disabled;
}
// active event handlers
private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){
@@ -87,9 +96,7 @@ namespace TweetDck.Core{
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
if (e.Frame.IsMain){
string js = ScriptLoader.LoadResource("code.js");
if (js != null){
foreach(string js in ScriptLoader.LoadResources("code.js","update.js").Where(js => js != null)){
browser.ExecuteScriptAsync(js);
}
}
@@ -102,9 +109,8 @@ namespace TweetDck.Core{
prevState = WindowState;
if (WindowState == FormWindowState.Minimized){
if (Config.MinimizeToTray){
if (Config.TrayBehavior == TrayIcon.Behavior.MinimizeToTray){
Hide(); // hides taskbar too?! welp that works I guess
trayIcon.Visible = true;
}
}
else{
@@ -118,18 +124,46 @@ namespace TweetDck.Core{
if (Location.X != -32000){
Config.IsMaximized = WindowState == FormWindowState.Maximized;
Config.WindowLocation = Location;
Config.WindowSize = Size;
if (WindowState == FormWindowState.Normal){
Config.WindowLocation = Location;
Config.WindowSize = Size;
}
Config.Save();
}
}
private void trayIcon_Click(object sender, EventArgs e){
private void FormBrowser_FormClosing(object sender, FormClosingEventArgs e){
if (!isLoaded)return;
if (Config.TrayBehavior == TrayIcon.Behavior.CloseToTray && trayIcon.Visible && e.CloseReason == CloseReason.UserClosing){
Hide(); // hides taskbar too?! welp that works I guess
e.Cancel = true;
}
}
private void Config_TrayBehaviorChanged(object sender, EventArgs e){
if (!isLoaded)return;
UpdateTrayIcon();
}
private void trayIcon_ClickRestore(object sender, EventArgs e){
if (!isLoaded)return;
isLoaded = false;
Show();
SetupWindow();
Activate();
UpdateTrayIcon();
}
trayIcon.Visible = false;
private void trayIcon_ClickClose(object sender, EventArgs e){
if (!isLoaded)return;
trayIcon.Visible = false; // checked in FormClosing event
Close();
}
// callback handlers
@@ -177,6 +211,10 @@ namespace TweetDck.Core{
notification.ShowNotification(tweet);
}
public void OnTweetSound(){
}
public void BeginUpdateProcess(string versionTag, string downloadUrl){
Hide();

View File

@@ -28,7 +28,7 @@ namespace TweetDck.Core {
this.components = new System.ComponentModel.Container();
this.panelBrowser = new System.Windows.Forms.Panel();
this.timerProgress = new System.Windows.Forms.Timer(this.components);
this.progressBarTimer = new FlatProgressBar();
this.progressBarTimer = new TweetDck.Core.Controls.FlatProgressBar();
this.SuspendLayout();
//
// panelBrowser
@@ -68,6 +68,8 @@ namespace TweetDck.Core {
this.Controls.Add(this.panelBrowser);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Location = new System.Drawing.Point(-32000, -32000);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormNotification";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

View File

@@ -21,6 +21,12 @@ namespace TweetDck.Core{
private readonly string notificationJS;
protected override bool ShowWithoutActivation{
get{
return true;
}
}
public FormNotification(Form owner, TweetDeckBridge bridge, bool autoHide){
InitializeComponent();
@@ -42,17 +48,16 @@ namespace TweetDck.Core{
panelBrowser.Controls.Add(browser);
if (autoHide){
Program.UserConfig.MuteToggled += Config_MuteToggled;
Disposed += (sender, args) => Program.UserConfig.MuteToggled -= Config_MuteToggled;
}
Disposed += (sender, args) => browser.Dispose();
}
public FormNotification(Form owner, bool autoHide) : this(owner,null,autoHide){}
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
if (e.Frame.IsMain && notificationJS != null){
browser.ExecuteScriptAsync(notificationJS);
}
}
protected override void WndProc(ref Message m){
if (m.Msg == 0x0112 && (m.WParam.ToInt32() & 0xFFF0) == 0xF010 && !CanMoveWindow()){ // WM_SYSCOMMAND, SC_MOVE
return;
@@ -61,24 +66,77 @@ namespace TweetDck.Core{
base.WndProc(ref m);
}
public void ShowNotification(TweetNotification notification){
MoveToVisibleLocation();
// event handlers
tweetQueue.Enqueue(notification);
private void timerHideProgress_Tick(object sender, EventArgs e){
if (Bounds.Contains(Cursor.Position))return;
if (!timerProgress.Enabled){
LoadNextNotification();
timeLeft -= timerProgress.Interval;
progressBarTimer.SetValueInstant((int)Math.Min(1000,Math.Round(1050.0*(totalTime-timeLeft)/totalTime)));
if (timeLeft <= 0){
if (tweetQueue.Count > 0){
LoadNextNotification();
}
else if (autoHide){
HideNotification();
}
}
}
public void ShowNotificationForSettings(bool resetAnimation){
private void Config_MuteToggled(object sender, EventArgs e){
if (Program.UserConfig.MuteNotifications){
HideNotification();
}
else{
if (tweetQueue.Count > 0){
MoveToVisibleLocation();
LoadNextNotification();
}
}
}
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
if (e.Frame.IsMain && notificationJS != null && browser.Address != "about:blank"){
browser.ExecuteScriptAsync(notificationJS);
}
}
private void FormNotification_FormClosing(object sender, FormClosingEventArgs e){
if (e.CloseReason == CloseReason.UserClosing){
HideNotification();
tweetQueue.Clear();
e.Cancel = true;
}
}
// notification methods
public void ShowNotification(TweetNotification notification){
if (Program.UserConfig.MuteNotifications){
tweetQueue.Enqueue(notification);
}
else{
MoveToVisibleLocation();
tweetQueue.Enqueue(notification);
UpdateTitle();
if (!timerProgress.Enabled){
LoadNextNotification();
}
}
}
public void ShowNotificationForSettings(bool reset){
if (browser.Address == "about:blank"){
browser.Load("about:blank"); // required, otherwise shit breaks
browser.LoadHtml(TweetNotification.ExampleTweet.GenerateHtml(),"http://tweetdeck.twitter.com/");
resetAnimation = true;
reset = true;
}
if (resetAnimation){
if (reset){
browser.LoadHtml(TweetNotification.ExampleTweet.GenerateHtml(),"http://tweetdeck.twitter.com/");
totalTime = timeLeft = TweetNotification.ExampleTweet.GetDisplayDuration(Program.UserConfig.NotificationDuration);
timerProgress.Start();
}
@@ -89,7 +147,6 @@ namespace TweetDck.Core{
public void HideNotification(){
browser.LoadHtml("","about:blank");
Location = new Point(-32000,-32000);
TopMost = false;
timerProgress.Stop();
}
@@ -105,9 +162,13 @@ namespace TweetDck.Core{
totalTime = timeLeft = tweet.GetDisplayDuration(Program.UserConfig.NotificationDuration);
timerProgress.Stop();
timerProgress.Start();
UpdateTitle();
}
private void MoveToVisibleLocation(){
bool needsReactivating = Location.X == -32000;
UserConfig config = Program.UserConfig;
Screen screen = Screen.FromControl(owner);
@@ -153,31 +214,13 @@ namespace TweetDck.Core{
break;
}
TopMost = true;
}
private void timerHideProgress_Tick(object sender, EventArgs e){
if (Bounds.Contains(Cursor.Position))return;
timeLeft -= timerProgress.Interval;
progressBarTimer.SetValueInstant((int)Math.Min(1000,Math.Round(1050.0*(totalTime-timeLeft)/totalTime)));
if (timeLeft <= 0){
if (tweetQueue.Count > 0){
LoadNextNotification();
}
else if (autoHide){
HideNotification();
}
if (needsReactivating){
Program.SetWindowPos(Handle.ToInt32(),-1,Left,Top,Width,Height,0x0010); // HWND_TOPMOST, SWP_NOACTIVATE
}
}
private void FormNotification_FormClosing(object sender, FormClosingEventArgs e){
if (e.CloseReason == CloseReason.UserClosing){
HideNotification();
tweetQueue.Clear();
e.Cancel = true;
}
private void UpdateTitle(){
Text = tweetQueue.Count > 0 ? Program.BrandName+" ("+tweetQueue.Count+" more left)" : Program.BrandName;
}
}
}

View File

@@ -14,7 +14,7 @@ namespace TweetDck.Core.Handling{
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
RemoveSeparatorIfLast(model);
if (parameters.TypeFlags.HasFlag(ContextMenuType.Link)){
if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && !parameters.UnfilteredLinkUrl.EndsWith("tweetdeck.twitter.com/#")){
model.AddItem((CefMenuCommand)MenuOpenUrlInBrowser,"Open in browser");
model.AddItem((CefMenuCommand)MenuCopyUrl,"Copy link address");
model.AddSeparator();
@@ -35,7 +35,7 @@ namespace TweetDck.Core.Handling{
break;
case MenuCopyUrl:
Clipboard.SetText(parameters.UnfilteredLinkUrl,TextDataFormat.Text);
Clipboard.SetText(string.IsNullOrEmpty(TweetDeckBridge.LastRightClickedLink) ? parameters.UnfilteredLinkUrl : TweetDeckBridge.LastRightClickedLink,TextDataFormat.UnicodeText);
break;
case MenuOpenImageInBrowser:
@@ -66,7 +66,7 @@ namespace TweetDck.Core.Handling{
break;
case MenuCopyImageUrl:
Clipboard.SetText(parameters.SourceUrl,TextDataFormat.Text);
Clipboard.SetText(parameters.SourceUrl,TextDataFormat.UnicodeText);
break;
}

View File

@@ -4,6 +4,7 @@ namespace TweetDck.Core.Handling{
class ContextMenuBrowser : ContextMenuBase{
private const int MenuSettings = 26600;
private const int MenuAbout = 26601;
private const int MenuMute = 26602;
private readonly FormBrowser form;
@@ -22,6 +23,8 @@ namespace TweetDck.Core.Handling{
base.OnBeforeContextMenu(browserControl,browser,frame,parameters,model);
model.AddItem(CefMenuCommand.Reload,"Reload");
model.AddCheckItem((CefMenuCommand)MenuMute,"Mute Notifications");
model.SetChecked((CefMenuCommand)MenuMute,Program.UserConfig.MuteNotifications);
model.AddSeparator();
if (TweetNotification.IsReady){
@@ -49,6 +52,14 @@ namespace TweetDck.Core.Handling{
form.OpenAbout();
});
return true;
case MenuMute:
form.InvokeSafe(() => {
Program.UserConfig.MuteNotifications = !Program.UserConfig.MuteNotifications;
Program.UserConfig.Save();
});
return true;
}

View File

@@ -8,9 +8,5 @@ namespace TweetDck.Core.Handling{
base.OnBeforeContextMenu(browserControl,browser,frame,parameters,model);
RemoveSeparatorIfLast(model);
}
public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags){
return false;
}
}
}

View File

@@ -2,6 +2,8 @@
namespace TweetDck.Core.Handling{
class TweetDeckBridge{
public static string LastRightClickedLink = string.Empty;
private readonly FormBrowser form;
public string BrandName{
@@ -16,6 +18,12 @@ namespace TweetDck.Core.Handling{
}
}
public bool MuteNotifications{
get{
return Program.UserConfig.MuteNotifications;
}
}
public bool UpdateCheckEnabled{
get{
return Program.UserConfig.EnableUpdateCheck;
@@ -44,6 +52,12 @@ namespace TweetDck.Core.Handling{
});
}
public void SetLastRightClickedLink(string link){
form.InvokeSafe(() => {
LastRightClickedLink = link;
});
}
public void OpenSettingsMenu(){
form.InvokeSafe(() => {
form.OpenSettings();
@@ -56,6 +70,12 @@ namespace TweetDck.Core.Handling{
});
}
public void OnTweetSound(){
form.InvokeSafe(() => {
form.OnTweetSound();
});
}
public void OnUpdateAccepted(string versionTag, string downloadUrl){
form.InvokeSafe(() => {
form.BeginUpdateProcess(versionTag,downloadUrl);

View File

@@ -70,7 +70,7 @@ namespace TweetDck.Core.Handling{
public string GenerateHtml(){
StringBuilder build = new StringBuilder();
build.Append("<!DOCTYPE html>");
build.Append("<html class='os-windows ").Append(FontSizeClass).Append("'>");
build.Append("<html class='os-windows txt-base-").Append(FontSizeClass).Append("'>");
build.Append("<head>").Append(HeadTag).Append("</head>");
build.Append("<body class='hearty'><div class='app-columns-container'><div class='column' style='width:100%'>");
build.Append(html);

View File

@@ -36,14 +36,15 @@
this.tableLayout = new System.Windows.Forms.TableLayoutPanel();
this.tableColumn2Panel = new System.Windows.Forms.Panel();
this.groupUserInterface = new System.Windows.Forms.GroupBox();
this.comboBoxTrayType = new System.Windows.Forms.ComboBox();
this.labelTrayType = new System.Windows.Forms.Label();
this.checkUpdateNotifications = new System.Windows.Forms.CheckBox();
this.checkNotificationTimer = new System.Windows.Forms.CheckBox();
this.checkMinimizeTray = new System.Windows.Forms.CheckBox();
this.groupNotificationDuration = new System.Windows.Forms.GroupBox();
this.radioDurVeryLong = new System.Windows.Forms.RadioButton();
this.radioDurLong = new System.Windows.Forms.RadioButton();
this.radioDurMedium = new System.Windows.Forms.RadioButton();
this.radioDurShort = new System.Windows.Forms.RadioButton();
this.checkUpdateNotifications = new System.Windows.Forms.CheckBox();
this.groupNotificationLocation.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
this.tableLayout.SuspendLayout();
@@ -75,9 +76,9 @@
//
// labelDisplay
//
this.labelDisplay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelDisplay.AutoSize = true;
this.labelDisplay.Location = new System.Drawing.Point(6, 154);
this.labelDisplay.Location = new System.Drawing.Point(6, 148);
this.labelDisplay.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelDisplay.Name = "labelDisplay";
this.labelDisplay.Size = new System.Drawing.Size(41, 13);
this.labelDisplay.TabIndex = 8;
@@ -89,8 +90,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.comboBoxDisplay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxDisplay.FormattingEnabled = true;
this.comboBoxDisplay.Location = new System.Drawing.Point(9, 170);
this.comboBoxDisplay.Margin = new System.Windows.Forms.Padding(3, 3, 3, 12);
this.comboBoxDisplay.Location = new System.Drawing.Point(9, 164);
this.comboBoxDisplay.Name = "comboBoxDisplay";
this.comboBoxDisplay.Size = new System.Drawing.Size(168, 21);
this.comboBoxDisplay.TabIndex = 7;
@@ -98,9 +98,9 @@
//
// labelEdgeDistance
//
this.labelEdgeDistance.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelEdgeDistance.AutoSize = true;
this.labelEdgeDistance.Location = new System.Drawing.Point(6, 203);
this.labelEdgeDistance.Location = new System.Drawing.Point(6, 197);
this.labelEdgeDistance.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
this.labelEdgeDistance.Name = "labelEdgeDistance";
this.labelEdgeDistance.Size = new System.Drawing.Size(103, 13);
this.labelEdgeDistance.TabIndex = 6;
@@ -108,10 +108,10 @@
//
// trackBarEdgeDistance
//
this.trackBarEdgeDistance.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.trackBarEdgeDistance.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.trackBarEdgeDistance.LargeChange = 8;
this.trackBarEdgeDistance.Location = new System.Drawing.Point(6, 219);
this.trackBarEdgeDistance.Location = new System.Drawing.Point(6, 213);
this.trackBarEdgeDistance.Maximum = 40;
this.trackBarEdgeDistance.Minimum = 8;
this.trackBarEdgeDistance.Name = "trackBarEdgeDistance";
@@ -219,9 +219,10 @@
//
this.groupUserInterface.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupUserInterface.Controls.Add(this.comboBoxTrayType);
this.groupUserInterface.Controls.Add(this.labelTrayType);
this.groupUserInterface.Controls.Add(this.checkUpdateNotifications);
this.groupUserInterface.Controls.Add(this.checkNotificationTimer);
this.groupUserInterface.Controls.Add(this.checkMinimizeTray);
this.groupUserInterface.Location = new System.Drawing.Point(3, 128);
this.groupUserInterface.Name = "groupUserInterface";
this.groupUserInterface.Size = new System.Drawing.Size(183, 145);
@@ -229,10 +230,47 @@
this.groupUserInterface.TabStop = false;
this.groupUserInterface.Text = "User Interface";
//
// comboBoxTrayType
//
this.comboBoxTrayType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboBoxTrayType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTrayType.FormattingEnabled = true;
this.comboBoxTrayType.Location = new System.Drawing.Point(9, 93);
this.comboBoxTrayType.Margin = new System.Windows.Forms.Padding(3, 3, 3, 12);
this.comboBoxTrayType.Name = "comboBoxTrayType";
this.comboBoxTrayType.Size = new System.Drawing.Size(168, 21);
this.comboBoxTrayType.TabIndex = 10;
this.comboBoxTrayType.SelectedIndexChanged += new System.EventHandler(this.comboBoxTrayType_SelectedIndexChanged);
//
// labelTrayType
//
this.labelTrayType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelTrayType.AutoSize = true;
this.labelTrayType.Location = new System.Drawing.Point(6, 77);
this.labelTrayType.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelTrayType.Name = "labelTrayType";
this.labelTrayType.Size = new System.Drawing.Size(52, 13);
this.labelTrayType.TabIndex = 9;
this.labelTrayType.Text = "Tray Icon";
//
// checkUpdateNotifications
//
this.checkUpdateNotifications.AutoSize = true;
this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 45);
this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(3, 4, 3, 3);
this.checkUpdateNotifications.Name = "checkUpdateNotifications";
this.checkUpdateNotifications.Size = new System.Drawing.Size(115, 17);
this.checkUpdateNotifications.TabIndex = 5;
this.checkUpdateNotifications.Text = "Check for Updates";
this.checkUpdateNotifications.UseVisualStyleBackColor = true;
this.checkUpdateNotifications.CheckedChanged += new System.EventHandler(this.checkUpdateNotifications_CheckedChanged);
//
// checkNotificationTimer
//
this.checkNotificationTimer.AutoSize = true;
this.checkNotificationTimer.Location = new System.Drawing.Point(6, 43);
this.checkNotificationTimer.Location = new System.Drawing.Point(6, 21);
this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
this.checkNotificationTimer.Name = "checkNotificationTimer";
this.checkNotificationTimer.Size = new System.Drawing.Size(145, 17);
this.checkNotificationTimer.TabIndex = 4;
@@ -240,17 +278,6 @@
this.checkNotificationTimer.UseVisualStyleBackColor = true;
this.checkNotificationTimer.CheckedChanged += new System.EventHandler(this.checkNotificationTimer_CheckedChanged);
//
// checkMinimizeTray
//
this.checkMinimizeTray.AutoSize = true;
this.checkMinimizeTray.Location = new System.Drawing.Point(6, 20);
this.checkMinimizeTray.Name = "checkMinimizeTray";
this.checkMinimizeTray.Size = new System.Drawing.Size(102, 17);
this.checkMinimizeTray.TabIndex = 0;
this.checkMinimizeTray.Text = "Minimize to Tray";
this.checkMinimizeTray.UseVisualStyleBackColor = true;
this.checkMinimizeTray.CheckedChanged += new System.EventHandler(this.checkMinimizeTray_CheckedChanged);
//
// groupNotificationDuration
//
this.groupNotificationDuration.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -318,17 +345,6 @@
this.radioDurShort.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
this.radioDurShort.Click += new System.EventHandler(this.radioDur_Click);
//
// checkUpdateNotifications
//
this.checkUpdateNotifications.AutoSize = true;
this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 67);
this.checkUpdateNotifications.Name = "checkUpdateNotifications";
this.checkUpdateNotifications.Size = new System.Drawing.Size(122, 17);
this.checkUpdateNotifications.TabIndex = 5;
this.checkUpdateNotifications.Text = "Update Notifications";
this.checkUpdateNotifications.UseVisualStyleBackColor = true;
this.checkUpdateNotifications.CheckedChanged += new System.EventHandler(this.checkUpdateNotifications_CheckedChanged);
//
// FormSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -336,7 +352,7 @@
this.ClientSize = new System.Drawing.Size(384, 282);
this.Controls.Add(this.tableLayout);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::TweetDck.Properties.Resources.icon;
this.Icon = ((System.Drawing.Icon)(TweetDck.Properties.Resources.ResourceManager.GetObject("icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormSettings";
@@ -375,8 +391,9 @@
private System.Windows.Forms.RadioButton radioDurLong;
private System.Windows.Forms.RadioButton radioDurMedium;
private System.Windows.Forms.RadioButton radioDurShort;
private System.Windows.Forms.CheckBox checkMinimizeTray;
private System.Windows.Forms.CheckBox checkNotificationTimer;
private System.Windows.Forms.CheckBox checkUpdateNotifications;
private System.Windows.Forms.ComboBox comboBoxTrayType;
private System.Windows.Forms.Label labelTrayType;
}
}

View File

@@ -53,8 +53,13 @@ namespace TweetDck.Core.Other{
comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1,Config.NotificationDisplay);
comboBoxTrayType.Items.Add("Disabled");
comboBoxTrayType.Items.Add("Display Icon Only");
comboBoxTrayType.Items.Add("Minimize to Tray");
comboBoxTrayType.Items.Add("Close to Tray");
comboBoxTrayType.SelectedIndex = Math.Min(Math.Max((int)Config.TrayBehavior,0),comboBoxTrayType.Items.Count-1);
trackBarEdgeDistance.Value = Config.NotificationEdgeDistance;
checkMinimizeTray.Checked = Config.MinimizeToTray;
checkNotificationTimer.Checked = Config.DisplayNotificationTimer;
checkUpdateNotifications.Checked = Config.EnableUpdateCheck;
}
@@ -119,10 +124,10 @@ namespace TweetDck.Core.Other{
notification.ShowNotificationForSettings(true);
}
private void checkMinimizeTray_CheckedChanged(object sender, EventArgs e){
private void comboBoxTrayType_SelectedIndexChanged(object sender, EventArgs e){
if (!isLoaded)return;
Config.MinimizeToTray = checkMinimizeTray.Checked;
Config.TrayBehavior = (TrayIcon.Behavior)comboBoxTrayType.SelectedIndex;
}
private void checkNotificationTimer_CheckedChanged(object sender, EventArgs e){

View File

@@ -82,7 +82,7 @@
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.progressDownload);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = global::TweetDck.Properties.Resources.icon;
this.Icon = ((System.Drawing.Icon)(TweetDck.Properties.Resources.ResourceManager.GetObject("icon")));
this.MaximizeBox = false;
this.Name = "FormUpdateDownload";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

89
Core/TrayIcon.Designer.cs generated Normal file
View File

@@ -0,0 +1,89 @@
namespace TweetDck.Core {
partial class TrayIcon {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.muteNotificationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenu.SuspendLayout();
//
// trayIcon
//
this.notifyIcon.ContextMenuStrip = this.contextMenu;
this.notifyIcon.Icon = global::TweetDck.Properties.Resources.icon;
this.notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(this.trayIcon_MouseClick);
//
// contextMenuTray
//
this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.restoreToolStripMenuItem,
this.muteNotificationsToolStripMenuItem,
this.closeToolStripMenuItem});
this.contextMenu.Name = "contextMenuTray";
this.contextMenu.ShowCheckMargin = true;
this.contextMenu.ShowImageMargin = false;
this.contextMenu.ShowItemToolTips = false;
this.contextMenu.Size = new System.Drawing.Size(174, 92);
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuTray_Opening);
this.contextMenu.Opened += new System.EventHandler(this.contextMenuTray_Opened);
//
// restoreToolStripMenuItem
//
this.restoreToolStripMenuItem.Name = "restoreToolStripMenuItem";
this.restoreToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.restoreToolStripMenuItem.Text = "Restore";
this.restoreToolStripMenuItem.Click += new System.EventHandler(this.restoreToolStripMenuItem_Click);
//
// muteNotificationsToolStripMenuItem
//
this.muteNotificationsToolStripMenuItem.CheckOnClick = true;
this.muteNotificationsToolStripMenuItem.Name = "muteNotificationsToolStripMenuItem";
this.muteNotificationsToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.muteNotificationsToolStripMenuItem.Text = "Mute Notifications";
this.muteNotificationsToolStripMenuItem.CheckedChanged += new System.EventHandler(this.muteNotificationsToolStripMenuItem_CheckedChanged);
//
// closeToolStripMenuItem
//
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
this.closeToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
this.closeToolStripMenuItem.Text = "Close";
this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
//
// TrayIcon
//
this.contextMenu.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.NotifyIcon notifyIcon;
private System.Windows.Forms.ContextMenuStrip contextMenu;
private System.Windows.Forms.ToolStripMenuItem restoreToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem muteNotificationsToolStripMenuItem;
}
}

63
Core/TrayIcon.cs Normal file
View File

@@ -0,0 +1,63 @@
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace TweetDck.Core{
partial class TrayIcon : Component{
public enum Behavior{ // keep order
Disabled, DisplayOnly, MinimizeToTray, CloseToTray
}
public event EventHandler ClickRestore;
public event EventHandler ClickClose;
public bool Visible{
get{
return notifyIcon.Visible;
}
set{
notifyIcon.Visible = value;
}
}
public TrayIcon(){
InitializeComponent();
notifyIcon.Text = Program.BrandName;
}
// event handlers
private void trayIcon_MouseClick(object sender, MouseEventArgs e){
if (e.Button == MouseButtons.Left){
restoreToolStripMenuItem_Click(sender,e);
}
}
private void contextMenuTray_Opening(object sender, CancelEventArgs e){
muteNotificationsToolStripMenuItem.CheckedChanged -= muteNotificationsToolStripMenuItem_CheckedChanged;
muteNotificationsToolStripMenuItem.Checked = Program.UserConfig.MuteNotifications;
}
private void contextMenuTray_Opened(object sender, EventArgs e){
muteNotificationsToolStripMenuItem.CheckedChanged += muteNotificationsToolStripMenuItem_CheckedChanged;
}
private void restoreToolStripMenuItem_Click(object sender, EventArgs e){
if (ClickRestore != null){
ClickRestore(this,e);
}
}
private void muteNotificationsToolStripMenuItem_CheckedChanged(object sender, EventArgs e){
Program.UserConfig.MuteNotifications = muteNotificationsToolStripMenuItem.Checked;
Program.UserConfig.Save();
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e){
if (ClickClose != null){
ClickClose(this,e);
}
}
}
}

View File

@@ -22,7 +22,8 @@ namespace TweetDck{
public const string Website = "http://tweetdick.chylex.com";
#endif
public const string VersionTag = "1.1";
public const string VersionTag = "1.2";
public const string VersionFull = "1.2.0.0";
public static readonly string StoragePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),BrandName);
private static readonly LockManager LockManager = new LockManager(Path.Combine(StoragePath,".lock"));
@@ -41,6 +42,9 @@ namespace TweetDck{
[DllImport("Shell32.dll")]
public static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern bool SetWindowPos(int hWnd, int hWndOrder, int x, int y, int width, int height, uint flags);
[STAThread]
private static void Main(){
Application.EnableVisualStyles();

View File

@@ -33,7 +33,7 @@ using TweetDck;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion(Program.VersionFull)]
[assembly: AssemblyFileVersion(Program.VersionFull)]
[assembly: NeutralResourcesLanguageAttribute("en")]

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Linq;
namespace TweetDck.Resources{
static class ScriptLoader{
@@ -13,5 +15,9 @@ namespace TweetDck.Resources{
return null;
}
}
public static IList<string> LoadResources(params string[] names){
return names.Select(LoadResource).ToList();
}
}
}

View File

@@ -1,24 +1,9 @@
(function($,$TD){
//
// Constant: List of valid font size classes.
//
var fontSizeClasses = [ "txt-base-smallest", "txt-base-small", "txt-base-medium", "txt-base-large", "txt-base-largest" ];
(function($,$TD,TD){
//
// Variable: Says whether TweetD*ck events was initialized.
//
var isInitialized = false;
//
// Variable: Previous font size class in the <html> tag.
//
var prevFontSizeClass;
//
// Variable: Current timeout ID for update checking.
//
var updateCheckTimeoutID;
//
// Function: Initializes TweetD*ck events. Called after the website app is loaded.
//
@@ -29,7 +14,7 @@
var menu = $(".js-dropdown-content").children("ul").first();
if (menu.length === 0)return;
menu.children(".drp-h-divider").last().after('<li class="is-selectable" data-std><a href="#" data-action>'+$TD.brandName+'</a></li><li class="drp-h-divider"></li>');
menu.children(".drp-h-divider").last().after('<li class="is-selectable" data-std><a href="#" data-action>'+$TD.brandName+' settings</a></li><li class="drp-h-divider"></li>');
var tweetDckBtn = menu.children("[data-std]").first();
@@ -45,115 +30,68 @@
},0);
});
// Tweet notifications
(function(){
var columns = $(".js-app-columns").first();
var refreshColumnObservers = function(){
columns.children().each(function(){
registerTweetObserverForColumn($(this));
});
};
new MutationObserver(refreshColumnObservers).observe(columns[0],{
childList: true
});
refreshColumnObservers();
})();
// Force popup notification settings
window.TD.controller.notifications.hasNotifications = function(){
return true;
};
window.TD.controller.notifications.isPermissionGranted = function(){
return true;
};
// Run update check
runUpdateCheck();
// Notification handling
$.subscribe("/notifications/new",function(obj){
for(var item of obj.items){
onNewTweet(obj.column,item);
}
});
// Finish init
$TD.loadFontSizeClass(TD.settings.getFontSize());
$TD.loadNotificationHeadContents(getNotificationHeadContents());
isInitialized = true;
};
//
// Function: Registers an observer to a TweetDeck column, which reports new tweets.
// Function: Prepends code at the beginning of a function. If the prepended function returns true, execution of the original function is cancelled.
//
var registerTweetObserverForColumn = function(column){
if (column[0].hasAttribute("data-std-observed"))return;
var prependToFunction = function(func, extension){
return function(){
return extension.apply(this,arguments) === true ? undefined : func.apply(this,arguments);
};
};
var mid = column;
mid = mid.children().first();
mid = mid.children().first();
mid = mid.children(".js-column-content").first();
mid = mid.children(".js-column-scroller").first();
var container = mid.children(".js-chirp-container").first();
if (container.length === 0)return;
var scroller = container.parent();
new MutationObserver(function(mutations){
if (!container[0].hasAttribute("data-std-loaded")){
container[0].setAttribute("data-std-loaded","");
return;
}
var data = TD.controller.columnManager.get(column.attr("data-column"));
if (!data.model.getHasNotification())return;
if (scroller.scrollTop() != 0)return;
Array.prototype.forEach.call(mutations,function(mutation){
Array.prototype.forEach.call(mutation.addedNodes,function(node){
if (node.tagName !== "ARTICLE")return;
onNewTweet(column,node);
});
});
}).observe(container[0],{
childList: true
});
column[0].setAttribute("data-std-observed","");
//
// Function: Appends code at the end of a function.
//
var appendToFunction = function(func, extension){
return function(){
var res = func.apply(this,arguments);
extension.apply(this,arguments);
return res;
};
};
//
// Function: Event callback for a new tweet.
//
var onNewTweet = function(column, tweet){
var html = $(tweet.outerHTML);
var body = html.find(".tweet-body").first();
if (column.model.getHasNotification()){
var html = $(tweet.render({
withFooter: false,
withTweetActions: false,
withMediaPreview: false
}));
if (html.find(".icon-reply").length > 0){
return; // ignore sent messages
html.css("border","0");
var body = html.find(".tweet-body").first();
body.children("div.js-quote-detail").each(function(){
$(this).html("(quoted tweet)");
$(this).removeClass("padding-al");
$(this).css("padding","6px");
});
body.children("footer").remove();
$TD.onTweetPopup(html.html(),tweet.fullLength); // TODO column
}
body.children("div.js-quote-detail").each(function(){
$(this).html("(quoted tweet)");
});
body.children().not("p,span,div.js-quote-detail").remove();
var characters = html.find(".js-tweet-text:first").text().length;
if (characters == 0)return;
$TD.onTweetPopup(html.html(),characters); // TODO column & remove pic links from text()
};
//
// Function: Retrieves the font size using <html> class attribute.
//
var getFontSizeClass = function(){
for(var index = 0; index < fontSizeClasses.length; index++){
if (document.documentElement.classList.contains(fontSizeClasses[index])){
return fontSizeClasses[index];
}
else if (column.model.getHasSound()){
$TD.onTweetSound(); // TODO disable original
}
return fontSizeClasses[0];
};
//
@@ -169,114 +107,6 @@
return tags.join("");
};
//
// Function: Creates the update notification element. Removes the old one if already exists.
//
var createUpdateNotificationElement = function(version, download){
var ele = $("#tweetdck-update");
var existed = ele.length > 0;
if (existed > 0){
ele.remove();
}
var html = [
"<div id='tweetdck-update'>",
"<p class='tdu-title'>"+$TD.brandName+" Update</p>",
"<p class='tdu-info'>Version "+version+" is now available.</p>",
"<div class='tdu-buttons'>",
"<button class='btn btn-positive tdu-btn-download'><span class='label'>Download</button>",
"<button class='btn btn-negative tdu-btn-dismiss'><span class='label'>Dismiss</button>",
"</div>",
"</div>"
];
$("h1.app-title").after(html.join(""));
ele = $("#tweetdck-update");
var buttonDiv = ele.children("div.tdu-buttons").first();
ele.css({
color: "#fff",
backgroundColor: "rgb(32,94,138)",
position: "absolute",
left: "4px",
bottom: "4px",
width: "192px",
height: "86px",
display: existed ? "block" : "none",
borderRadius: "2px"
});
ele.children("p.tdu-title").first().css({
fontSize: "17px",
fontWeight: "bold",
textAlign: "center",
letterSpacing: "0.2px",
margin: "4px auto 2px"
});
ele.children("p.tdu-info").first().css({
fontSize: "12px",
textAlign: "center",
margin: "2px auto 6px"
});
buttonDiv.css({
textAlign: "center"
});
buttonDiv.children().css({
margin: "0 4px",
minHeight: "25px",
boxShadow: "1px 1px 1px rgba(17,17,17,0.5)"
});
buttonDiv.find("span").css({
verticalAlign: "baseline"
});
ele.find("span.tdu-data-tag").first().css({
cursor: "pointer",
textDecoration: "underline"
});
buttonDiv.children(".tdu-btn-download").click(function(){
ele.remove();
$TD.onUpdateAccepted(version,download);
});
buttonDiv.children(".tdu-btn-dismiss").click(function(){
$TD.onUpdateDismissed(version);
ele.slideUp(function(){ ele.remove(); });
});
if (!existed){
ele.slideDown();
}
return ele;
};
//
// Function: Runs an update check and updates all DOM elements appropriately
//
var runUpdateCheck = function(){
clearTimeout(updateCheckTimeoutID);
updateCheckTimeoutID = setTimeout(runUpdateCheck,1000*60*60); // 1 hour
if (!$TD.updateCheckEnabled)return;
$.getJSON("https://api.github.com/repos/chylex/"+$TD.brandName+"/releases/latest",function(response){
var tagName = response.tag_name;
if (tagName != $TD.versionTag && tagName != $TD.dismissedVersionTag && response.assets.length > 0){
createUpdateNotificationElement(tagName,response.assets[0].browser_download_url);
}
});
};
//
// Block: Observe the app <div> element and initialize TweetD*ck whenever possible.
//
@@ -295,31 +125,28 @@
});
//
// Block: Observe changes in <html> class to update font size.
// Block: Hook into settings object to detect when the settings change.
//
new MutationObserver(function(mutations){
var fsClass = getFontSizeClass();
TD.settings.setFontSize = appendToFunction(TD.settings.setFontSize,function(name){
$TD.loadFontSizeClass(name);
});
if (fsClass != prevFontSizeClass){
prevFontSizeClass = fsClass;
$TD.loadFontSizeClass(fsClass);
}
}).observe(document.documentElement,{
attributes: true,
attributeFilter: [ "class" ]
TD.settings.setTheme = appendToFunction(TD.settings.setTheme,function(){
setTimeout(function(){
$TD.loadNotificationHeadContents(getNotificationHeadContents());
},0);
});
//
// Block: Observe stylesheet swapping.
// Block: Force popup notification settings
//
new MutationObserver(function(mutations){
$TD.loadNotificationHeadContents(getNotificationHeadContents());
}).observe(document.head.querySelector("[http-equiv='Default-Style']"),{
attributes: true,
attributeFilter: [ "content" ]
});
TD.controller.notifications.hasNotifications = function(){
return true;
};
$TD.loadNotificationHeadContents(getNotificationHeadContents());
TD.controller.notifications.isPermissionGranted = function(){
return true;
};
//
// Block: Hook into links to bypass default open function
@@ -338,7 +165,7 @@
var me = $(this);
var rel = me.attr("rel");
if (!me.is(".link-complex") && !(rel === "mediaPreview" && me.closest("#open-modal").length === 0) && rel !== "list"){
if (!me.is(".link-complex") && !(rel === "mediaPreview" && me.closest("#open-modal").length === 0) && rel !== "list" && rel !== "user"){
$TD.openBrowser(me.attr("href"));
}
@@ -354,6 +181,75 @@
};
})();
TD.util.maybeOpenClickExternally = prependToFunction(TD.util.maybeOpenClickExternally,function(e){
if (e.ctrlKey){
$TD.openBrowser(e.currentTarget.getAttribute("href"));
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return true;
}
});
//
// Block: Expand shortened links on hover.
//
(function(){
var cutStart = function(str, search){
return _.startsWith(str,search) ? str.substr(search.length) : str;
};
$(document.body).delegate("a[data-full-url]","mouseenter mouseleave",function(e){
var me = $(this);
if (e.type === "mouseenter"){
var text = me.text();
if (text.charCodeAt(text.length-1) !== 8230){ // horizontal ellipsis
return;
}
var expanded = me.attr("data-full-url");
expanded = cutStart(expanded,"https://");
expanded = cutStart(expanded,"http://");
expanded = cutStart(expanded,"www.");
me.css("word-break","break-all");
me.attr("td-prev-text",text);
me.text(expanded);
}
else if (e.type === "mouseleave"){
var prevText = me.attr("td-prev-text");
if (prevText){
me.text(prevText);
}
}
});
})();
//
// Block: Allow bypassing of t.co in context menus.
//
$(document.body).delegate("a","contextmenu",function(){
$TD.setLastRightClickedLink($(this).attr("data-full-url") || "");
});
//
// Block: Hook into the notification sound effect.
//
(function(){
var soundEle = document.getElementById("update-sound");
soundEle.play = prependToFunction(soundEle.play,function(){
return $TD.muteNotifications;
});
})();
/* TODO document.getElementById("update-sound").play = function(){
$TD.onTweetSound();
};*/
//
// Block: Hook into mp4 video element clicking
//
@@ -365,9 +261,4 @@
e.preventDefault();
}
});
//
// Block: Setup global functions.
//
window.TDGF_runUpdateCheck = runUpdateCheck;
})($,$TD);
})($,$TD,TD);

View File

@@ -1,11 +1,35 @@
(function($TD){
//
// Block: Hook into links to bypass default open function
// Function: Bubbles up the parents until it hits an element with the specified tag (includes the first element), and returns true if the search was successful.
//
var bubbleParents = function(element, tag, callback){
do{
if (element.tagName == "A"){
callback(element);
return true;
}
}while((element = element.parentElement) != null);
return false;
};
//
// Block: Hook into links to bypass default open function.
//
document.body.addEventListener("click",function(e){
if (e.target.tagName == "A"){
$TD.openBrowser(e.target.getAttribute("href"));
if (bubbleParents(e.target,"A",function(ele){
$TD.openBrowser(ele.getAttribute("href"));
})){
e.preventDefault();
}
});
//
// Block: Allow bypassing of t.co in context menus.
//
document.body.addEventListener("contextmenu",function(e){
bubbleParents(e.target,"A",function(ele){
$TD.setLastRightClickedLink(element.getAttribute("data-full-url") || "");
});
});
})($TD);

121
Resources/update.js Normal file
View File

@@ -0,0 +1,121 @@
(function($,$TD){
//
// Variable: Current timeout ID for update checking.
//
var updateCheckTimeoutID;
//
// Function: Creates the update notification element. Removes the old one if already exists.
//
var createUpdateNotificationElement = function(version, download){
var ele = $("#tweetdck-update");
var existed = ele.length > 0;
if (existed > 0){
ele.remove();
}
var html = [
"<div id='tweetdck-update'>",
"<p class='tdu-title'>"+$TD.brandName+" Update</p>",
"<p class='tdu-info'>Version "+version+" is now available.</p>",
"<div class='tdu-buttons'>",
"<button class='btn btn-positive tdu-btn-download'><span class='label'>Download</button>",
"<button class='btn btn-negative tdu-btn-dismiss'><span class='label'>Dismiss</button>",
"</div>",
"</div>"
];
$(document.body).append(html.join(""));
ele = $("#tweetdck-update");
var buttonDiv = ele.children("div.tdu-buttons").first();
ele.css({
color: "#fff",
backgroundColor: "rgb(32,94,138)",
position: "absolute",
left: "4px",
bottom: "4px",
width: "192px",
height: "86px",
display: existed ? "block" : "none",
borderRadius: "2px",
zIndex: 9999
});
ele.children("p.tdu-title").first().css({
fontSize: "17px",
fontWeight: "bold",
textAlign: "center",
letterSpacing: "0.2px",
margin: "4px auto 2px"
});
ele.children("p.tdu-info").first().css({
fontSize: "12px",
textAlign: "center",
margin: "2px auto 6px"
});
buttonDiv.css({
textAlign: "center"
});
buttonDiv.children().css({
margin: "0 4px",
minHeight: "25px",
boxShadow: "1px 1px 1px rgba(17,17,17,0.5)"
});
buttonDiv.find("span").css({
verticalAlign: "baseline"
});
ele.find("span.tdu-data-tag").first().css({
cursor: "pointer",
textDecoration: "underline"
});
buttonDiv.children(".tdu-btn-download").click(function(){
ele.remove();
$TD.onUpdateAccepted(version,download);
});
buttonDiv.children(".tdu-btn-dismiss").click(function(){
$TD.onUpdateDismissed(version);
ele.slideUp(function(){ ele.remove(); });
});
if (!existed){
ele.slideDown();
}
return ele;
};
//
// Function: Runs an update check and updates all DOM elements appropriately
//
var runUpdateCheck = function(){
clearTimeout(updateCheckTimeoutID);
updateCheckTimeoutID = setTimeout(runUpdateCheck,1000*60*60); // 1 hour
if (!$TD.updateCheckEnabled)return;
$.getJSON("https://api.github.com/repos/chylex/"+$TD.brandName+"/releases/latest",function(response){
var tagName = response.tag_name;
if (tagName != $TD.versionTag && tagName != $TD.dismissedVersionTag && response.assets.length > 0){
createUpdateNotificationElement(tagName,response.assets[0].browser_download_url);
}
});
};
//
// Block: Setup global functions.
//
window.TDGF_runUpdateCheck = runUpdateCheck;
runUpdateCheck();
})($,$TD);

View File

@@ -131,6 +131,12 @@
<Compile Include="Core\Other\FormUpdateDownload.Designer.cs">
<DependentUpon>FormUpdateDownload.cs</DependentUpon>
</Compile>
<Compile Include="Core\TrayIcon.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Core\TrayIcon.Designer.cs">
<DependentUpon>TrayIcon.cs</DependentUpon>
</Compile>
<Compile Include="Core\Utils\BrowserUtils.cs" />
<Compile Include="Core\Utils\UpdateInfo.cs" />
<Compile Include="Migration\FormMigrationQuestion.cs">
@@ -212,6 +218,12 @@
<TargetPath>notification.js</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="Resources\update.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>update.js</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@@ -228,9 +240,9 @@
<Import Project="packages\CefSharp.Common.49.0.0-pre02\build\CefSharp.Common.targets" Condition="Exists('packages\CefSharp.Common.49.0.0-pre02\build\CefSharp.Common.targets')" />
<PropertyGroup>
<PostBuildEvent>del "$(TargetPath).config"
xcopy "$(ProjectDir)LICENSE" "$(TargetDir)" /Y
xcopy "$(ProjectDir)LICENSE.md" "$(TargetDir)" /Y
del "$(TargetDir)LICENSE.txt"
ren "$(TargetDir)LICENSE" "LICENSE.txt"
ren "$(TargetDir)LICENSE.md" "LICENSE.txt"
xcopy "$(ProjectDir)Libraries\CEFSHARP-LICENSE.txt" "$(TargetDir)" /Y
xcopy "$(ProjectDir)packages\Microsoft.VC120.CRT.JetBrains.12.0.21005.2\DotFiles\msvcp120.dll" "$(TargetDir)" /Y
xcopy "$(ProjectDir)packages\Microsoft.VC120.CRT.JetBrains.12.0.21005.2\DotFiles\msvcr120.dll" "$(TargetDir)" /Y</PostBuildEvent>