Skip to content

Commit

Permalink
Themes 2.0 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
WamWooWam authored Sep 30, 2024
1 parent 89f501e commit eb525c5
Show file tree
Hide file tree
Showing 125 changed files with 4,459 additions and 1,765 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ publish/
PublishScripts/

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
url = https://github.com/WamWooWam/MomentSharp
[submodule "Libraries/DSharpPlus"]
path = Libraries/DSharpPlus
url = https://github.com/WamWooWam/DSharpPlus/
url = https://github.com/UnicordDev/DSharpPlus-Unicord/
[submodule "Libraries/unicode.net"]
path = Libraries/unicode.net
url = https://github.com/wamwoowam/unicode.net
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 2,
"contentHash": "9P9b9/H315ficqW9u01EJCjKD3QYfxzGXscGHT6lndyrAzkW5iNho28ILC6bYMpgE+G/GNzTij/OVZL9Jxq5mw==",
"source": null
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9P9b9/H315ficqW9u01EJCjKD3QYfxzGXscGHT6lndyrAzkW5iNho28ILC6bYMpgE+G/GNzTij/OVZL9Jxq5mw==
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>Microsoft.Web.WebView2.Undocked</id>
<version>1.0.2739.170</version>
<title>Undocked WebView2 Library</title>
<authors>Microsoft, Kimbra</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<projectUrl>https://github.com/microsoft/microsoft-ui-xaml</projectUrl>
<iconUrl>https://aka.ms/winui_icon</iconUrl>
<description>This package provides the WebView2 control, undocked from WinUI 2.8.</description>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<tags>Windows WinUI UWP XAML Fluent Controls Downlevel Compatibility TreeView ColorPicker NavigationView MenuBar</tags>
<dependencies>
<group targetFramework="UAP10.0">
<dependency id="Microsoft.Web.WebView2" version="1.0.2739.15" />
</group>
</dependencies>
</metadata>
</package>
65 changes: 65 additions & 0 deletions Unicord.Universal.Background.Tasks/PeriodicNotificationsTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus;
using Unicord.Universal.Shared;
using Windows.ApplicationModel.Background;
using Windows.Security.Credentials;
using Windows.UI.Notifications;

namespace Unicord.Universal.Background.Tasks
{
public sealed class PeriodicNotificationsTask : IBackgroundTask
{
public async void Run(IBackgroundTaskInstance taskInstance)
{
var deferral = taskInstance.GetDeferral();
try
{
if (!TryGetToken(out string token))
return;

var tileUpdateManager = TileUpdateManager.CreateTileUpdaterForApplication();
var toastNotifier = ToastNotificationManager.CreateToastNotifier();

var restClient = new DiscordRestClient(new DiscordConfiguration() { Token = token, TokenType = TokenType.User });
var mentions = await restClient.GetUserMentionsAsync(25, true, true);

foreach (var mention in mentions)
{
if (!NotificationUtils.WillShowToast(restClient, mention))
continue;

var tileNotification = NotificationUtils.CreateTileNotificationForMessage(restClient, mention);
var toastNotification = NotificationUtils.CreateToastNotificationForMessage(restClient, mention);

tileUpdateManager.Update(tileNotification);
toastNotifier.Show(toastNotification);
}
}
finally
{
deferral.Complete();
}
}

internal static bool TryGetToken(out string token)
{
try
{
var passwordVault = new PasswordVault();
var credential = passwordVault.Retrieve(Constants.TOKEN_IDENTIFIER, "Default");
credential.RetrievePassword();

token = credential.Password;
return true;
}
catch { }

token = null;
return false;
}
}
}
26 changes: 26 additions & 0 deletions Unicord.Universal.Background.Tasks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Unicord.Universal.Background.Tasks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Unicord.Universal.Background.Tasks")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{69F44648-37CD-4B20-8814-2BAF85B4F624}</ProjectGuid>
<OutputType>winmdobj</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Unicord.Universal.Background.Tasks</RootNamespace>
<AssemblyName>Unicord.Universal.Background.Tasks</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22000.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting>
<LangVersion>9</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<PlatformTarget>ARM64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
<PlatformTarget>ARM64</PlatformTarget>
<OutputPath>bin\ARM64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="PeriodicNotificationsTask.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.14</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Libraries\DSharpPlus\DSharpPlus.Rest\DSharpPlus.Rest.csproj">
<Project>{c01b8589-13fe-4a6d-b159-6644977f58de}</Project>
<Name>DSharpPlus.Rest</Name>
</ProjectReference>
<ProjectReference Include="..\Libraries\DSharpPlus\DSharpPlus\DSharpPlus.csproj">
<Project>{0f4b3af7-9320-41ae-82d0-3737949499c7}</Project>
<Name>DSharpPlus</Name>
</ProjectReference>
<ProjectReference Include="..\Libraries\MomentSharp\MomentSharp\MomentSharp.csproj">
<Project>{8a4a933c-c579-4c36-9133-7d6721f99aec}</Project>
<Name>MomentSharp</Name>
</ProjectReference>
<ProjectReference Include="..\Libraries\WamWooWam.Core\WamWooWam.Core\WamWooWam.Core.csproj">
<Project>{6e8e3c2c-a7d2-4971-a97d-fa831e3ecf15}</Project>
<Name>WamWooWam.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Libraries\WindowsCommunityToolkit\Microsoft.Toolkit.Uwp.Notifications\Microsoft.Toolkit.Uwp.Notifications.csproj">
<Project>{921c4ba1-7a60-43a5-950f-0d72d5ed64e3}</Project>
<Name>Microsoft.Toolkit.Uwp.Notifications</Name>
</ProjectReference>
</ItemGroup>
<Import Project="..\Unicord.Universal.Shared\Unicord.Universal.Shared.projitems" Label="Shared" />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
3 changes: 3 additions & 0 deletions Unicord.Universal.Background/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<runtime>
<GCConserveMemory enabled="5"/>
</runtime>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2" />
</System.Windows.Forms.ApplicationConfigurationSection>
</configuration>
17 changes: 10 additions & 7 deletions Unicord.Universal.Background/NotificationApplicationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ private async Task InitialiseAsync()
{
TokenType = TokenType.User,
Token = _token,
MessageCacheSize = 0
MessageCacheSize = 0,
ReconnectIndefinitely = true
});

_badgeManager = new BadgeManager(_discord);
Expand All @@ -96,8 +97,9 @@ private async Task InitialiseAsync()

await _discord.ConnectAsync(status: UserStatus.Invisible, idlesince: DateTimeOffset.Now);
}
catch (Exception)
catch (Exception ex)
{
Debug.WriteLine(ex);
this.ExitThread();
}
}
Expand Down Expand Up @@ -150,9 +152,9 @@ private async Task OnDiscordMessage(DiscordClient client, MessageCreateEventArgs
if (_secondaryTileManager != null)
await _secondaryTileManager.HandleMessageAsync(client, e.Message);
}
catch (Exception)
catch (Exception ex)
{
// TODO: log
Debug.WriteLine(ex);
}
}

Expand All @@ -165,9 +167,9 @@ private Task OnMessageUpdated(DiscordClient client, MessageUpdateEventArgs e)
_toastManager?.HandleMessageUpdated(client, e.Message);
}
}
catch (Exception)
catch (Exception ex)
{
// TODO: log
Debug.WriteLine(ex);
}

return Task.CompletedTask;
Expand All @@ -186,9 +188,10 @@ private async Task OnMessageAcknowledged(DiscordClient client, MessageAcknowledg
if (_secondaryTileManager != null)
await _secondaryTileManager.HandleAcknowledgeAsync(e.Channel);
}
catch (Exception)
catch (Exception ex)
{
// TODO: log
Debug.WriteLine(ex);
}
}

Expand Down
1 change: 0 additions & 1 deletion Unicord.Universal.Background/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
Application.Run(new NotificationApplicationContext());
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<ProjectReference Include="..\libraries\DSharpPlus\DSharpPlus\DSharpPlus.csproj" />
<ProjectReference Include="..\Libraries\MomentSharp\MomentSharp\MomentSharp.csproj" />
<ProjectReference Include="..\Libraries\WamWooWam.Core\WamWooWam.Core\WamWooWam.Core.csproj" />
<ProjectReference Include="..\Unicord\Unicord.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit eb525c5

Please sign in to comment.