-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
15 changed files
with
912 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace EspionSpotify | ||
{ | ||
public class Analytics | ||
{ | ||
private const string url = "https://www.google-analytics.com/collect"; | ||
private const string tid = "UA-125662919-1"; | ||
|
||
private readonly HttpClient client = new HttpClient(); | ||
private readonly string cid; | ||
private readonly string cm; | ||
private readonly string ul; | ||
private readonly string cs; | ||
|
||
public DateTime LastRequest { get; set; } = new DateTime(); | ||
public string LastAction { get; set; } = string.Empty; | ||
|
||
public Analytics(string clientId, string version) | ||
{ | ||
cid = clientId; | ||
cm = version; | ||
ul = CultureInfo.CurrentCulture.Name; | ||
cs = Environment.OSVersion.ToString(); | ||
} | ||
|
||
public static string GenerateCID() | ||
{ | ||
return Guid.NewGuid().ToString(); | ||
} | ||
|
||
public async Task<bool> LogAction(string action) | ||
{ | ||
if (LastAction.Equals(action) && DateTime.Now - LastRequest < TimeSpan.FromMinutes(5)) return false; | ||
|
||
var data = new Dictionary<string, string> | ||
{ | ||
{ "v", "1" }, | ||
{ "tid", tid }, // App id | ||
{ "t", "pageview" }, // Analytics type | ||
{ "cid", cid }, // Client id | ||
{ "cm", cm }, // Campaign medium, App version | ||
{ "av", cm }, // App version | ||
{ "cn", "Spytify" }, // Campaign name | ||
{ "an", "Spytify" }, // App name | ||
{ "cs", cs}, // Campaign source, OS Version | ||
{ "ul", ul }, // User Language | ||
{ "dh", "jwallet.github.io/spy-spotify" }, // Document host | ||
{ "dl", $"/{action}" }, // Document link | ||
{ "dt", action }, // Document title | ||
{ "cd", action } // Screen name | ||
}; | ||
|
||
var content = new FormUrlEncodedContent(data); | ||
var resp = await client.PostAsync(url, content); | ||
|
||
LastAction = action; | ||
LastRequest = DateTime.Now; | ||
|
||
return resp.IsSuccessStatusCode; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace EspionSpotify.Controls | ||
{ | ||
public class MetroTile : MetroFramework.Controls.MetroTile | ||
{ | ||
private bool _isFocused = false; | ||
private bool _isHovered = false; | ||
|
||
protected override void OnPaintForeground(PaintEventArgs e) | ||
{ | ||
base.OnPaintForeground(e); | ||
|
||
Color color = Color.FromArgb(175, 240, 200); | ||
|
||
if (_isHovered || _isFocused) | ||
{ | ||
color = Color.FromArgb(30, 215, 96); | ||
} | ||
|
||
using (Pen p = new Pen(color)) | ||
{ | ||
p.Width = 3; | ||
Rectangle borderRect = new Rectangle(1, 1, Width - 3, Height - 3); | ||
e.Graphics.DrawRectangle(p, borderRect); | ||
} | ||
} | ||
protected override void OnGotFocus(EventArgs e) | ||
{ | ||
_isFocused = true; | ||
Invalidate(); | ||
|
||
base.OnGotFocus(e); | ||
} | ||
|
||
protected override void OnLostFocus(EventArgs e) | ||
{ | ||
_isFocused = false; | ||
_isHovered = false; | ||
|
||
Invalidate(); | ||
base.OnLostFocus(e); | ||
} | ||
|
||
protected override void OnLeave(EventArgs e) | ||
{ | ||
Task.Run(async () => | ||
{ | ||
await Task.Delay(150); | ||
base.OnLeave(e); | ||
}); | ||
} | ||
|
||
protected override void OnMouseEnter(EventArgs e) | ||
{ | ||
_isHovered = true; | ||
Invalidate(); | ||
|
||
base.OnMouseEnter(e); | ||
} | ||
|
||
protected override void OnMouseLeave(EventArgs e) | ||
{ | ||
_isHovered = false; | ||
Invalidate(); | ||
|
||
base.OnMouseLeave(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.