Browse Source

Resolve #36 - User setting to make user controls always visible in the mini player

pull/52/head
Samuel Attard 7 years ago
parent
commit
49103c98ba
  1. 3
      Google Play Music/App.config
  2. 12
      Google Play Music/Properties/Settings.Designer.cs
  3. 3
      Google Play Music/Properties/Settings.settings
  4. 6
      Google Play Music/ResourceHandlerFactory.cs
  5. 11
      Google Play Music/Resources/mini-player.js
  6. 19
      Google Play Music/SettingsDialog.Designer.cs
  7. 10
      Google Play Music/SettingsDialog.cs

3
Google Play Music/App.config

@ -31,6 +31,9 @@
<setting name="DesktopNotifications" serializeAs="String">
<value>True</value>
</setting>
<setting name="HoverControls" serializeAs="String">
<value>True</value>
</setting>
</Google_Play_Music.Properties.Settings>
</userSettings>
<runtime>

12
Google Play Music/Properties/Settings.Designer.cs

@ -106,5 +106,17 @@ namespace Google_Play_Music.Properties {
this["DesktopNotifications"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool HoverControls {
get {
return ((bool)(this["HoverControls"]));
}
set {
this["HoverControls"] = value;
}
}
}
}

3
Google Play Music/Properties/Settings.settings

@ -23,5 +23,8 @@
<Setting Name="DesktopNotifications" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="HoverControls" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

6
Google Play Music/ResourceHandlerFactory.cs

@ -25,7 +25,11 @@ namespace Google_Play_Music
Color c = Properties.Settings.Default.CustomColor;
string RGB = "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
string custom_color = ";(function() {window.CustomColor = '" + RGB + "';})();";
return ResourceHandler.FromStream(new MemoryStream(Encoding.UTF8.GetBytes(webClient.DownloadString(request.Url) + ";" + custom_color + dark_theme + custom_interface + mini_player)), webClient.ResponseHeaders["Content-Type"]);
bool controlsOnHover = Properties.Settings.Default.HoverControls;
string controlsOnHoverJS = ";(function() {window.hoverControls = " + controlsOnHover.ToString().ToLower() + ";})();";
return ResourceHandler.FromStream(new MemoryStream(Encoding.UTF8.GetBytes(webClient.DownloadString(request.Url) + ";" + custom_color + controlsOnHoverJS + dark_theme + custom_interface + mini_player)), webClient.ResponseHeaders["Content-Type"]);
}
}
return null;

11
Google Play Music/Resources/mini-player.js

@ -20,8 +20,8 @@ document.addEventListener("DOMContentLoaded", function () {
setStyle('#player', ['transition: bottom 0.3s', 'bottom: -100px', 'transition-timing-function: ease-in-out', 'width: 280px', 'left: 10px', 'right: 10px',
'border-bottom-left-radius: 8px', 'border-bottom-right-radius: 8px'
]);
setStyle('body[ready]:hover #player', ['bottom: 10px']);
setStyle('body[ready]:hover #mini-info', ['opacity: 1']);
setStyle('body[ready]:hover #player, body[controls] #player', ['bottom: 10px']);
setStyle('body[ready]:hover #mini-info, body[controls] #mini-info', ['opacity: 1']);
setStyle('#material-player-left-wrapper, #material-player-right-wrapper', ['display: none']);
setStyle('#mini-album', ['position: fixed', 'top: 0', 'left: 0', 'display: block', 'width: 100%', 'height: 100%', 'z-index: 9999998']);
setStyle('.player-progress-wrapper', ['left: 0']);
@ -102,6 +102,13 @@ document.addEventListener("DOMContentLoaded", function () {
targetSpan.innerHTML = maxTime.innerHTML;
}
}
// Also check the controls setting
if (window.hoverControls && document.body.getAttribute('controls') != null) {
document.body.removeAttribute('controls');
}
if (!window.hoverControls && document.body.getAttribute('controls') == null) {
document.body.setAttribute('controls', 'controls');
}
}, 10);
window.addEventListener('song-change', function (e) {

19
Google Play Music/SettingsDialog.Designer.cs

@ -35,6 +35,7 @@
this.colorWheel1 = new Google_Play_Music.ColorWheel();
this.materialRaisedButton1 = new MaterialSkin.Controls.MaterialRaisedButton();
this.materialCheckBox2 = new MaterialSkin.Controls.MaterialCheckBox();
this.materialCheckBox3 = new MaterialSkin.Controls.MaterialCheckBox();
this.SuspendLayout();
//
// materialLabel1
@ -119,11 +120,28 @@
this.materialCheckBox2.Text = "Desktop Notifications";
this.materialCheckBox2.UseVisualStyleBackColor = true;
//
// materialCheckBox3
//
this.materialCheckBox3.AutoSize = true;
this.materialCheckBox3.Depth = 0;
this.materialCheckBox3.Font = new System.Drawing.Font("Roboto", 10F);
this.materialCheckBox3.Location = new System.Drawing.Point(13, 177);
this.materialCheckBox3.Margin = new System.Windows.Forms.Padding(0);
this.materialCheckBox3.MouseLocation = new System.Drawing.Point(-1, -1);
this.materialCheckBox3.MouseState = MaterialSkin.MouseState.HOVER;
this.materialCheckBox3.Name = "materialCheckBox3";
this.materialCheckBox3.Ripple = true;
this.materialCheckBox3.Size = new System.Drawing.Size(261, 30);
this.materialCheckBox3.TabIndex = 6;
this.materialCheckBox3.Text = "Controls Always Visible in Mini Player";
this.materialCheckBox3.UseVisualStyleBackColor = true;
//
// SettingsDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(600, 300);
this.Controls.Add(this.materialCheckBox3);
this.Controls.Add(this.materialCheckBox2);
this.Controls.Add(this.materialRaisedButton1);
this.Controls.Add(this.materialLabel2);
@ -148,5 +166,6 @@
private MaterialSkin.Controls.MaterialLabel materialLabel2;
private MaterialSkin.Controls.MaterialRaisedButton materialRaisedButton1;
private MaterialSkin.Controls.MaterialCheckBox materialCheckBox2;
private MaterialSkin.Controls.MaterialCheckBox materialCheckBox3;
}
}

10
Google Play Music/SettingsDialog.cs

@ -65,6 +65,16 @@ namespace Google_Play_Music
Properties.Settings.Default.Save();
};
materialCheckBox3.Checked = !Properties.Settings.Default.HoverControls;
materialCheckBox3.CheckStateChanged += (res, send) =>
{
Properties.Settings.Default.HoverControls = !materialCheckBox3.Checked;
app.Invoke((MethodInvoker)delegate
{
app.GPMBrowser.EvaluateScriptAsync("(function() {window.hoverControls = " + (!materialCheckBox3.Checked).ToString().ToLower() + "})();");
});
};
materialRaisedButton1.Click += (res, send) =>
{
Properties.Settings.Default.Reset();

Loading…
Cancel
Save