Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
UserSettings Pirvacy page
Browse files Browse the repository at this point in the history
  • Loading branch information
Avid29 committed Apr 25, 2022
1 parent 9615973 commit 0efe74d
Show file tree
Hide file tree
Showing 15 changed files with 210 additions and 58 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Quarrel © 2022

namespace Discord.API.Models.Enums.Settings
{
/// <summary>
/// The content filter level.
/// </summary>
public enum ExplicitContentFilterLevel : int
{
/// <summary>
/// Filter content from nobody.
/// </summary>
None,

/// <summary>
/// Filter content not from my friends
/// </summary>
Public,

/// <summary>
/// Filter content from everyone.
/// </summary>
All,
}
}
1 change: 1 addition & 0 deletions src/API/Discord.API/Models/Json/Guilds/JsonGuild.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Guilds;
using Discord.API.Models.Enums.Settings;
using Discord.API.Models.Json.Channels;
using Discord.API.Models.Json.Emojis;
using Discord.API.Models.Json.Roles;
Expand Down
3 changes: 3 additions & 0 deletions src/API/Discord.API/Models/Json/Settings/JsonUserSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Settings;
using System.Text.Json.Serialization;

// JSON models don't need to respect standard nullable rules.
Expand Down Expand Up @@ -48,5 +49,7 @@ internal class JsonUserSettings
[JsonPropertyName("guild_folders")]
public JsonGuildFolder[] GuildFolders { get; set; }

[JsonPropertyName("explicit_content_filter")]
public ExplicitContentFilterLevel ExplicitContentFilter { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Quarrel.Client/Models/Guilds/Guild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using CommunityToolkit.Diagnostics;
using Discord.API.Models.Enums.Guilds;
using Discord.API.Models.Enums.Settings;
using Discord.API.Models.Json.Guilds;
using Quarrel.Client.Models.Base;
using Quarrel.Client.Models.Channels.Abstract;
Expand Down
1 change: 1 addition & 0 deletions src/Quarrel.Client/Models/Guilds/Interfaces/IGuild.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Guilds;
using Discord.API.Models.Enums.Settings;
using Quarrel.Client.Models.Base.Interfaces;

namespace Quarrel.Client.Models.Guilds.Interfaces
Expand Down
6 changes: 6 additions & 0 deletions src/Quarrel.Client/Models/Settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal Settings(JsonUserSettings jsonUserSettings, QuarrelClient context) :
InlineAttachementMedia = jsonUserSettings.InlineAttachementMedia;
Locale = jsonUserSettings.Locale;
ShowCurrentGame = jsonUserSettings.ShowCurrentGame;
ContentFilterLevel = jsonUserSettings.ExplicitContentFilter;

switch (jsonUserSettings.Theme)
{
Expand Down Expand Up @@ -85,6 +86,11 @@ internal Settings(JsonUserSettings jsonUserSettings, QuarrelClient context) :
/// </summary>
public bool ShowCurrentGame { get; private set; }

/// <summary>
/// Gets if the user's presence includes the current game.
/// </summary>
public ExplicitContentFilterLevel ContentFilterLevel { get; private set; }

/// <summary>
/// Gets the Discord theme for the user.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Quarrel.Client/QuarrelClient.Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public partial class QuarrelClient
return user;
}

public Settings GetSettings()
{
return _settings;
}

/// <summary>
/// Gets messages in a channel.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Quarrel © 2022

using Discord.API.Models.Enums.Settings;
using Quarrel.Services.Discord;
using Quarrel.Services.Localization;
using Quarrel.Services.Storage;
using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract;
Expand All @@ -9,14 +11,61 @@ namespace Quarrel.ViewModels.SubPages.UserSettings.Pages
public class PrivacyPageViewModel : UserSettingsSubPageViewModel
{
private const string PrivacyResource = "UserSettings/Privacy";
private readonly IDiscordService _discordService;
private ExplicitContentFilterLevel _contentFilterLevel;

internal PrivacyPageViewModel(ILocalizationService localizationService, IStorageService storageService) :
internal PrivacyPageViewModel(ILocalizationService localizationService, IStorageService storageService, IDiscordService discordService) :
base(localizationService, storageService)
{
_discordService = discordService;
}

public override string Glyph => "";

public override string Title => _localizationService[PrivacyResource];

private ExplicitContentFilterLevel ContentFilterLevel
{
get => _contentFilterLevel;
set
{
if (SetProperty(ref _contentFilterLevel, value))
{
OnPropertyChanged(nameof(FilterNone));
OnPropertyChanged(nameof(FilterPublic));
OnPropertyChanged(nameof(FilterAll));
}
}
}

public bool FilterAll
{
get => _contentFilterLevel == ExplicitContentFilterLevel.All;
set
{
if (!value) return;
ContentFilterLevel = ExplicitContentFilterLevel.All;
}
}

public bool FilterPublic
{
get => _contentFilterLevel == ExplicitContentFilterLevel.Public;
set
{
if (!value) return;
ContentFilterLevel = ExplicitContentFilterLevel.Public;
}
}

public bool FilterNone
{
get => _contentFilterLevel == ExplicitContentFilterLevel.None;
set
{
if (!value) return;
ContentFilterLevel = ExplicitContentFilterLevel.None;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public UserSettingsPageViewModel(ILocalizationService localizationService, IStor
Pages = new ObservableCollection<UserSettingsSubPageViewModel>();

Pages.Add(new MyAccountPageViewModel(localizationService, storageService, discordService));
Pages.Add(new PrivacyPageViewModel(_localizationService, storageService));
Pages.Add(new PrivacyPageViewModel(_localizationService, storageService, discordService));
Pages.Add(new ConnectionsPageViewModel(_localizationService, storageService));

Pages.Add(new DisplayPageViewModel(_localizationService, storageService));
Expand Down
7 changes: 7 additions & 0 deletions src/Quarrel/Quarrel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
<Compile Include="SubPages\UserSettings\Pages\MyAccountPage.xaml.cs">
<DependentUpon>MyAccountPage.xaml</DependentUpon>
</Compile>
<Compile Include="SubPages\UserSettings\Pages\PrivacyPage.xaml.cs">
<DependentUpon>PrivacyPage.xaml</DependentUpon>
</Compile>
<Compile Include="SubPages\UserSettings\UserSettingsPage.xaml.cs">
<DependentUpon>UserSettingsPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -565,6 +568,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SubPages\UserSettings\Pages\PrivacyPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SubPages\UserSettings\UserSettingsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
62 changes: 32 additions & 30 deletions src/Quarrel/SubPages/UserSettings/Pages/MyAccountPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,41 @@
<ColumnDefinition Width="256"/>
</Grid.ColumnDefinitions>

<StackPanel Padding="16">
<TextBox x:Uid="UserSettings/EmailTB"
Header="Email"
Text="{x:Bind ViewModel.Email, Mode=TwoWay}"
IsReadOnly="True"
Style="{StaticResource DiscordTextBox}"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="128"/>
</Grid.ColumnDefinitions>
<TextBox x:Uid="UserSettings/UsernameTB"
Header="Username"
Text="{x:Bind ViewModel.Username, Mode=TwoWay}"
<ScrollViewer>
<StackPanel Padding="16">
<TextBox x:Uid="UserSettings/EmailTB"
Header="Email"
Text="{x:Bind ViewModel.Email, Mode=TwoWay}"
IsReadOnly="True"
Margin="0,0,8,0"
Style="{StaticResource DiscordTextBox}"/>
<TextBox x:Uid="UserSettings/DiscriminatorTB"
Header="Discriminator"
Text="{x:Bind ViewModel.Discriminator, Mode=TwoWay}"
Grid.Column="1"
IsReadOnly="True"
Style="{StaticResource DiscordTextBox}"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="128"/>
</Grid.ColumnDefinitions>
<TextBox x:Uid="UserSettings/UsernameTB"
Header="Username"
Text="{x:Bind ViewModel.Username, Mode=TwoWay}"
IsReadOnly="True"
Margin="0,0,8,0"
Style="{StaticResource DiscordTextBox}"/>
<TextBox x:Uid="UserSettings/DiscriminatorTB"
Header="Discriminator"
Text="{x:Bind ViewModel.Discriminator, Mode=TwoWay}"
Grid.Column="1"
IsReadOnly="True"
Style="{StaticResource DiscordTextBox}"/>
</Grid>

<TextBox x:Uid="UserSettings/AboutMeTB"
Header="About Me"
Text="{x:Bind ViewModel.AboutMe, Mode=TwoWay}"
Style="{StaticResource DiscordTextBox}"
TextWrapping="Wrap"
IsReadOnly="True"
MinHeight="96"/>
</StackPanel>
<TextBox x:Uid="UserSettings/AboutMeTB"
Header="About Me"
Text="{x:Bind ViewModel.AboutMe, Mode=TwoWay}"
Style="{StaticResource DiscordTextBox}"
TextWrapping="Wrap"
IsReadOnly="True"
MinHeight="96"/>
</StackPanel>
</ScrollViewer>

<Grid Grid.Column="1">

Expand Down
55 changes: 55 additions & 0 deletions src/Quarrel/SubPages/UserSettings/Pages/PrivacyPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<UserControl
x:Class="Quarrel.SubPages.UserSettings.Pages.PrivacyPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Quarrel.SubPages.UserSettings.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="800">

<ScrollViewer>
<StackPanel Padding="16">
<TextBlock x:Uid="UserSettings/DMFilterTB"
Text="DIRECT MESSAGE FILTERING"
FontSize="18"
FontWeight="Bold"
Foreground="{ThemeResource SystemControlBackgroundAccentBrush}"
TextWrapping="Wrap"/>
<TextBlock x:Uid="UserSettings/DMFilterDescTB"
Text="Analyze and automatically delete direct messages containing explicit content"
TextWrapping="Wrap" FontSize="12" Opacity="0.75"
Foreground="{ThemeResource SystemControlBackgroundAccentBrush}"/>

<RadioButton IsChecked="{x:Bind ViewModel.FilterAll, Mode=TwoWay}"
Style="{StaticResource QuarrelRadioButton}"
Foreground="{StaticResource DiscordGreenBrush}"
Margin="0,6,0,0"
GroupName="Filtering">
<StackPanel>
<TextBlock x:Uid="UserSettings/ProtectMeTB" Text="Protect me"/>
<TextBlock x:Uid="UserSettings/ProtectMeDescTB" FontSize="11" Foreground="{ThemeResource InvertedBackground}" Opacity="0.5" TextWrapping="Wrap" Text="Analyze all DMs" />
</StackPanel>
</RadioButton>
<RadioButton IsChecked="{x:Bind ViewModel.FilterPublic, Mode=TwoWay}"
Style="{StaticResource QuarrelRadioButton}"
Foreground="{StaticResource DiscordYellowBrush}"
GroupName="Filtering">
<StackPanel>
<TextBlock x:Uid="UserSettings/NiceFriendsTB" Text="My friends are nice"/>
<TextBlock x:Uid="UserSettings/NiceFriendsDescTB" FontSize="11" Foreground="{ThemeResource InvertedBackground}" Opacity="0.5" TextWrapping="Wrap" Text="Analyze all DMs, except from my friends"/>
</StackPanel>
</RadioButton>
<RadioButton IsChecked="{x:Bind ViewModel.FilterNone, Mode=TwoWay}"
Style="{StaticResource QuarrelRadioButton}"
Foreground="{StaticResource DiscordRedBrush}"
GroupName="Filtering">
<StackPanel>
<TextBlock x:Uid="UserSettings/DangerZoneTB" Text="I live dangerously"/>
<TextBlock x:Uid="UserSettings/DangerZoneDescTB" FontSize="11" Foreground="{ThemeResource InvertedBackground}" Opacity="0.5" TextWrapping="Wrap" Text="Don't analyze any DMs"/>
</StackPanel>
</RadioButton>
</StackPanel>
</ScrollViewer>
</UserControl>
17 changes: 17 additions & 0 deletions src/Quarrel/SubPages/UserSettings/Pages/PrivacyPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Quarrel © 2022

using Quarrel.ViewModels.SubPages.UserSettings.Pages;
using Windows.UI.Xaml.Controls;

namespace Quarrel.SubPages.UserSettings.Pages
{
public sealed partial class PrivacyPage : UserControl
{
public PrivacyPage()
{
this.InitializeComponent();
}

public PrivacyPageViewModel ViewModel => (PrivacyPageViewModel)DataContext;
}
}
7 changes: 6 additions & 1 deletion src/Quarrel/SubPages/UserSettings/UserSettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
<pages:MyAccountPage/>
</DataTemplate>

<DataTemplate x:Key="PrivacyPageTemplate" x:DataType="ssub:PrivacyPageViewModel">
<pages:PrivacyPage/>
</DataTemplate>

<usselector:UserSettingsPageSelector x:Key="UserPageSelector"
MyAccountTemplate="{StaticResource MyAccountPageTemplate}"/>
MyAccountTemplate="{StaticResource MyAccountPageTemplate}"
PrivacyTemplate="{StaticResource PrivacyPageTemplate}"/>
</UserControl.Resources>

<Grid Width="800" Height="620">
Expand Down

0 comments on commit 0efe74d

Please sign in to comment.