Skip to content

Commit

Permalink
Added the ability to make the app say Apple Music instead of iTunes
Browse files Browse the repository at this point in the history
  • Loading branch information
nint8835 committed Dec 31, 2018
1 parent 06cfd81 commit a49c191
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
3 changes: 3 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<setting name="ExperimentsEnabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="AppName" serializeAs="String">
<value>iTunes</value>
</setting>
</iTunesRichPresence_Rewrite.Properties.Settings>
</userSettings>
</configuration>
11 changes: 10 additions & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<CheckBox x:Name="RunOnStartupCheckBox" Content="Run on startup" HorizontalAlignment="Left" Click="RunOnStartupCheckBox_OnClick" Grid.Row="0" Margin="0,0,0,15"/>
<Grid Grid.Row="1" Margin="0,0,0,15">
Expand All @@ -62,7 +63,15 @@
<Label Content="Accent colour:" Grid.Column="0"/>
<ComboBox Name="ThemeComboBox" SelectionChanged="ThemeComboBox_OnSelectionChanged" Grid.Column="1"/>
</Grid>
<CheckBox x:Name="ExperimentsCheckBox" Content="Enable experiments" HorizontalAlignment="Left" Click="ExperimentsCheckBox_OnClick" Grid.Row="2" Margin="0,0,0,15"/>
<Grid Grid.Row="2" Margin="0,0,0,15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Label Content="App name:" Grid.Column="0"/>
<ComboBox Name="AppNameComboBox" SelectionChanged="AppNameComboBox_OnSelectionChanged" Grid.Column="1"/>
</Grid>
<CheckBox x:Name="ExperimentsCheckBox" Content="Enable experiments" HorizontalAlignment="Left" Click="ExperimentsCheckBox_OnClick" Grid.Row="3" Margin="0,0,0,15"/>

</Grid>
</controls:Flyout>
Expand Down
21 changes: 18 additions & 3 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace iTunesRichPresence_Rewrite {
public partial class MainWindow {

private readonly NotifyIcon _notifyIcon;
private readonly DiscordBridge _bridge;
private DiscordBridge _bridge;

private readonly Release _latestRelease;

Expand All @@ -36,8 +36,6 @@ public MainWindow() {

_lastFocusedTextBox = PlayingTopLineFormatTextBox;

_bridge = new DiscordBridge("383816327850360843");

_notifyIcon = new NotifyIcon {Text = "iTunesRichPresence", Visible = false, Icon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)};
_notifyIcon.MouseDoubleClick += (sender, args) => { WindowState = WindowState.Normal; };

Expand All @@ -58,6 +56,12 @@ public MainWindow() {
ExperimentsButton.Visibility =
Settings.Default.ExperimentsEnabled ? Visibility.Visible : Visibility.Collapsed;

AppNameComboBox.Items.Add("iTunes");
AppNameComboBox.Items.Add("Apple Music");
CreateBridge();

AppNameComboBox.SelectedItem = Settings.Default.AppName;

var gitHubClient = new GitHubClient(new ProductHeaderValue("iTunesRichPresence"));
_latestRelease = gitHubClient.Repository.Release.GetLatest("nint8835", "iTunesRichPresence").Result;
if (!Assembly.GetExecutingAssembly().GetName().Version.ToString().StartsWith(_latestRelease.Name.Substring(1))) {
Expand All @@ -68,6 +72,11 @@ public MainWindow() {

}

private void CreateBridge() {
_bridge?.Shutdown();
_bridge = (string)AppNameComboBox.SelectedItem == "iTunes" ? new DiscordBridge("383816327850360843") : new DiscordBridge("529435150472183819");
}

private void PopulateToolbox() {
var currentToken = 0;
foreach (var token in _bridge.tokens) {
Expand Down Expand Up @@ -192,5 +201,11 @@ private void Experiment_PlayButton_OnClick(object sender, RoutedEventArgs e) {
Globals.Log($"Playing {track.Name} by {track.Artist}");
track.Play();
}

private void AppNameComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) {
Settings.Default.AppName = (string) AppNameComboBox.SelectedItem;
CreateBridge();
Settings.Default.Save();
}
}
}
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// 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("2.2.0.0")]
[assembly: AssemblyVersion("2.3.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
14 changes: 13 additions & 1 deletion Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
<Setting Name="ExperimentsEnabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="AppName" Type="System.String" Scope="User">
<Value Profile="(Default)">iTunes</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit a49c191

Please sign in to comment.