Skip to content

Commit

Permalink
[WIP] Remove "Enable BYOAPI" Key buttons from recognition view. Simpl…
Browse files Browse the repository at this point in the history
…ify workflow and imply users always need to use their own api key.
  • Loading branch information
Soapwood committed Jul 27, 2024
1 parent 299a554 commit fb9c5b9
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 54 deletions.
4 changes: 2 additions & 2 deletions VXMusicDesktop/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
<value />
</setting>
<setting name="IsShazamByoApiEnabled" serializeAs="String">
<value>False</value>
<value>True</value>
</setting>
<setting name="IsAudDByoApiEnabled" serializeAs="String">
<value>False</value>
<value>True</value>
</setting>
<setting name="LastfmUsername" serializeAs="String">
<value />
Expand Down
4 changes: 2 additions & 2 deletions VXMusicDesktop/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public App() : base()
ClientSecret = configuration["Recognition:Shazam:ClientSecret"],
X_RapidAPI_Key = configuration["Recognition:Shazam:X-RapidAPI-Key"],
X_RapidAPI_Host = configuration["Recognition:Shazam:X-RapidAPI-Host"],
IsByoApiEnabled = VXUserSettings.Recognition.GetIsShazamByoApiEnabled(),
IsByoApiEnabled = true, //VXUserSettings.Recognition.GetIsShazamByoApiEnabled(),
ByoApiKey = VXUserSettings.Recognition.GetIsShazamByoApiEnabled() ?
VXUserSettings.Recognition.GetShazamByoApiKey() : null
},

AudDSettings = new AudDSettings()
{
ClientId = configuration["Recognition:Shazam:ClientId"],
IsByoApiEnabled = VXUserSettings.Recognition.GetIsAudDByoApiEnabled(),
IsByoApiEnabled = true, //VXUserSettings.Recognition.GetIsAudDByoApiEnabled(),
ByoApiKey = VXUserSettings.Recognition.GetIsAudDByoApiEnabled() ?
VXUserSettings.Recognition.GetAudDByoApiKey() : null
}
Expand Down
57 changes: 29 additions & 28 deletions VXMusicDesktop/MVVM/View/RecognitionView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,24 @@

<!-- BYOAPI -->
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<CheckBox x:Name="ShazamByoApiCheckBox"
Content="Enable BYOAPI"
Cursor="Hand"
IsChecked="{Binding IsShazamByoApiEnabled}"
IsEnabled="{Binding IsShazamApiEnabled}"
VerticalAlignment="Center" HorizontalAlignment="Left"
Margin="20,0,0,0"
Height="30"
Style="{StaticResource CustomCheckBoxStyle}"
Checked="ShazamByoApiCheckButtonChecked" Unchecked="ShazamByoApiCheckButtonUnchecked" />
<!-- <CheckBox x:Name="ShazamByoApiCheckBox" -->
<!-- Content="Enable BYOAPI" -->
<!-- Cursor="Hand" -->
<!-- IsChecked="{Binding IsShazamByoApiEnabled}" -->
<!-- IsEnabled="{Binding IsShazamApiEnabled}" -->
<!-- VerticalAlignment="Center" HorizontalAlignment="Left" -->
<!-- Margin="20,0,0,0" -->
<!-- Height="30" -->
<!-- Style="{StaticResource CustomCheckBoxStyle}" -->
<!-- Checked="ShazamByoApiCheckButtonChecked" Unchecked="ShazamByoApiCheckButtonUnchecked" /> -->
<StackPanel Orientation="Horizontal">
<Grid>
<PasswordBox x:Name="ShazamByoApiPasswordBox"
Visibility="{Binding IsShazamByoApiEnabled, Converter={StaticResource BoolToVis}}"
Visibility="{Binding IsShazamApiEnabled, Converter={StaticResource BoolToVis}}"
Style="{StaticResource ModernApiBox}"
IsEnabled="{Binding IsShazamByoApiEnabled}"
Margin="10,0,0,0"

IsEnabled="{Binding IsShazamApiEnabled}"
Margin="20,0,0,0"
PasswordChanged="ShazamByoApiPasswordBoxChanged"
GotFocus="ShazamByoApiPasswordBoxGotFocus"
LostFocus="ShazamByoApiPasswordBoxLostFocus" />
Expand All @@ -186,7 +187,7 @@
Width="260"
Height="30"
Panel.ZIndex="6"
Margin="17,0,0,0" />
Margin="27,0,0,0" />
</Canvas>
</Grid>
</StackPanel>
Expand Down Expand Up @@ -288,22 +289,22 @@

<!-- BYOAPI -->
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<CheckBox x:Name="AudDByoApiCheckBox"
Content="Enable BYOAPI"
Cursor="Hand"
IsChecked="{Binding IsAudDByoApiEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsAudDApiEnabled, Mode=TwoWay}"
Margin="20,0,0,0"
Height="30"
VerticalAlignment="Center" HorizontalAlignment="Left"
Style="{StaticResource CustomCheckBoxStyle}"
Checked="AudDByoApiCheckButtonChecked" Unchecked="AudDByoApiCheckButtonUnchecked" />
<!-- <CheckBox x:Name="AudDByoApiCheckBox" -->
<!-- Content="Enable BYOAPI" -->
<!-- Cursor="Hand" -->
<!-- IsChecked="{Binding IsAudDByoApiEnabled, Mode=TwoWay}" -->
<!-- IsEnabled="{Binding IsAudDApiEnabled, Mode=TwoWay}" -->
<!-- Margin="20,0,0,0" -->
<!-- Height="30" -->
<!-- VerticalAlignment="Center" HorizontalAlignment="Left" -->
<!-- Style="{StaticResource CustomCheckBoxStyle}" -->
<!-- Checked="AudDByoApiCheckButtonChecked" Unchecked="AudDByoApiCheckButtonUnchecked" /> -->
<StackPanel Orientation="Horizontal">
<Grid>
<PasswordBox x:Name="AudDByoApiPasswordBox"
Visibility="{Binding IsAudDByoApiEnabled, Converter={StaticResource BoolToVis}}"
IsEnabled="{Binding IsAudDByoApiEnabled}"
Margin="10,0,0,0"
Visibility="{Binding IsAudDApiEnabled, Converter={StaticResource BoolToVis}}"
IsEnabled="{Binding IsAudDApiEnabled}"
Margin="20,0,0,0"
Style="{StaticResource ModernApiBox}"
VerticalAlignment="Center" HorizontalAlignment="Center"
GotFocus="AudDByoApiPasswordBoxGotFocus"
Expand All @@ -321,7 +322,7 @@
Width="260"
Height="30"
Panel.ZIndex="6"
Margin="17,0,0,0" />
Margin="27,0,0,0" />
</Canvas>
</Grid>
</StackPanel>
Expand Down
16 changes: 8 additions & 8 deletions VXMusicDesktop/MVVM/View/RecognitionView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ private void OnThemeChanged(object sender, EventArgs e)
RunRecognitionButton.Background = ColourSchemeManager.SecondaryColour;
RunRecognitionButton.Foreground = ColourSchemeManager.TextBasic;

ShazamByoApiCheckBox.Background = ColourSchemeManager.Accent1Colour;
ShazamByoApiCheckBox.Foreground = ColourSchemeManager.TextBasic;
//ShazamByoApiCheckBox.Background = ColourSchemeManager.Accent1Colour;
//ShazamByoApiCheckBox.Foreground = ColourSchemeManager.TextBasic;
ShazamByoApiPasswordBox.Background = ColourSchemeManager.SecondaryColour;

AudDByoApiCheckBox.Background = ColourSchemeManager.Accent1Colour;
AudDByoApiCheckBox.Foreground = ColourSchemeManager.TextBasic;
//AudDByoApiCheckBox.Background = ColourSchemeManager.Accent1Colour;
//AudDByoApiCheckBox.Foreground = ColourSchemeManager.TextBasic;
AudDByoApiPasswordBox.Background = ColourSchemeManager.SecondaryColour;

// if (RecognitionIntegrationEnableShazamApiButton.DataContext as RecognitionViewModel)
Expand All @@ -82,7 +82,7 @@ private void ShazamByoApiCheckButtonChecked(object sender, RoutedEventArgs e)
recognitionViewModel.IsShazamByoApiEnabled = true;

//ShazamByoApiCheckBox.Content = "Disable BYOAPI";
ShazamByoApiCheckBox.Content = "";
//ShazamByoApiCheckBox.Content = "";
if(!string.IsNullOrEmpty(recognitionViewModel.ShazamByoApiToken))
ShazamByoApiPasswordBoxHintText.Text = ShazamApiKeyPlaceholder;

Expand All @@ -98,7 +98,7 @@ private void ShazamByoApiCheckButtonUnchecked(object sender, RoutedEventArgs e)
recognitionViewModel.SharedViewModel.IsShazamApiConnected = false;
recognitionViewModel.IsShazamByoApiEnabled = false;

ShazamByoApiCheckBox.Content = "Enable BYOAPI";
//ShazamByoApiCheckBox.Content = "Enable BYOAPI";
ShazamByoApiPasswordBoxHintText.Text = "";

if(recognitionViewModel.IsShazamApiEnabled)
Expand Down Expand Up @@ -180,7 +180,7 @@ private void AudDByoApiCheckButtonChecked(object sender, RoutedEventArgs e)
recognitionViewModel.IsAudDByoApiEnabled = true;

//AudDByoApiCheckBox.Content = "Disable BYOAPI";
AudDByoApiCheckBox.Content = "";
//AudDByoApiCheckBox.Content = "";

recognitionViewModel.PerformSaveAndTestAudDByoApi();
}
Expand All @@ -195,7 +195,7 @@ private void AudDByoApiCheckButtonUnchecked(object sender, RoutedEventArgs e)
recognitionViewModel.SharedViewModel.IsAudDApiConnected = false;
recognitionViewModel.IsAudDByoApiEnabled = false;

AudDByoApiCheckBox.Content = "Enable BYOAPI";
//AudDByoApiCheckBox.Content = "Enable BYOAPI";

if(recognitionViewModel.IsAudDApiEnabled)
recognitionViewModel.SetAudDApiKeyToDefaultAndTest();
Expand Down
16 changes: 8 additions & 8 deletions VXMusicDesktop/MVVM/ViewModel/RecognitionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,19 @@ private void ProcessRecognitionApiState()
{
case RecognitionApi.Shazam:
IsShazamApiEnabled = true;
IsShazamByoApiEnabled = App.VXMusicSession.RecognitionSettings.ShazamSettings.IsByoApiEnabled &&
!String.IsNullOrEmpty(App.VXMusicSession.RecognitionSettings.ShazamSettings.ByoApiKey);
IsShazamByoApiEnabled = App.VXMusicSession.RecognitionSettings.ShazamSettings.IsByoApiEnabled;
//&& !String.IsNullOrEmpty(App.VXMusicSession.RecognitionSettings.ShazamSettings.ByoApiKey);

IsAudDApiEnabled = false;
IsAudDByoApiEnabled = false;
//IsAudDByoApiEnabled = false;
break;
case RecognitionApi.AudD:
IsAudDApiEnabled = true;
IsAudDByoApiEnabled = App.VXMusicSession.RecognitionSettings.AudDSettings.IsByoApiEnabled &&
!String.IsNullOrEmpty(App.VXMusicSession.RecognitionSettings.AudDSettings.ByoApiKey);
IsAudDByoApiEnabled = App.VXMusicSession.RecognitionSettings.AudDSettings.IsByoApiEnabled;
//&& !String.IsNullOrEmpty(App.VXMusicSession.RecognitionSettings.AudDSettings.ByoApiKey);

IsShazamApiEnabled = false;
IsShazamByoApiEnabled = false;
//IsShazamByoApiEnabled = false;
break;
default:
IsShazamApiEnabled = false;
Expand Down Expand Up @@ -315,7 +315,7 @@ private void PerformShazamButtonClick(object commandParameter)

SharedViewModel.IsAudDApiConnected = false;
IsAudDApiEnabled = false;
IsAudDByoApiEnabled = false;
//IsAudDByoApiEnabled = false;

ProcessRecognitionApiState();
}
Expand All @@ -327,7 +327,7 @@ private void PerformAudDButtonClick(object commandParameter)

SharedViewModel.IsShazamApiConnected = false;
IsShazamApiEnabled = false;
IsShazamByoApiEnabled = false;
//IsShazamByoApiEnabled = false;

ProcessRecognitionApiState();
}
Expand Down
4 changes: 2 additions & 2 deletions VXMusicDesktop/Properties/Settings.Designer.cs

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

4 changes: 2 additions & 2 deletions VXMusicDesktop/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<Value Profile="(Default)" />
</Setting>
<Setting Name="IsShazamByoApiEnabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="IsAudDByoApiEnabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="LastfmUsername" Type="System.String" Scope="User">
<Value Profile="(Default)" />
Expand Down
2 changes: 1 addition & 1 deletion VXMusicDesktop/Theme/TextBoxTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
<ControlTemplate TargetType="{x:Type PasswordBox}">
<Border CornerRadius="5"
Background="{StaticResource SecondaryColor}"
Width="260" Height="30">
Width="300" Height="30">

<Grid>
<Rectangle StrokeThickness="1"/>
Expand Down
2 changes: 1 addition & 1 deletion VXMusicDesktop/VXMusicDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageIcon>VXLogo.png</PackageIcon>
<ApplicationIcon>Images\VXLogoIcon.ico</ApplicationIcon>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<Version>0.6.4.16</Version>
<Version>0.6.4.17</Version>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<Title>VXMusicDesktop</Title>
<Authors>VirtualXtensions</Authors>
Expand Down

0 comments on commit fb9c5b9

Please sign in to comment.