Skip to content

Commit

Permalink
Merge pull request #3 from UnicordDev/master
Browse files Browse the repository at this point in the history
dfg
  • Loading branch information
Tarvey authored Dec 13, 2024
2 parents 721ef0c + 0d99277 commit 1eb697f
Show file tree
Hide file tree
Showing 138 changed files with 12,573 additions and 1,066 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,30 @@ jobs:
$certificatePath = "GitHubActionsWorkflow.pfx"
[IO.File]::WriteAllBytes("$env:Project_Name/$certificatePath", $pfx_cert_byte)
- name: Adjust Package Version
run: |
$epoch = (Get-Date) - ([System.DateTime]::new(2024, 11, 01))
$file = (Resolve-Path "UniSky/Package.appxmanifest")
$xml = [System.Xml.XmlDocument]::new()
$xml.Load($file)
$node = $xml.GetElementsByTagName("Identity", "http://schemas.microsoft.com/appx/manifest/foundation/windows10")[0]
$version = [System.Version]::Parse($node.GetAttribute("Version"))
$version = [System.Version]::new($version.Major, $version.Minor, $version.Build, $epoch.TotalMinutes);
$node.SetAttribute("Version", $version.ToString())
$xml.Save($file)
# Create the app package by building and packaging the project
- name: Build App Packages
run: msbuild $env:ProjectFile_Name /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:AppxBundlePlatforms="x86|x64|ARM|ARM64" /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:AppxPackageDir="$env:Appx_Package_Dir" /p:GenerateAppxPackageOnBuild=true
run: msbuild $env:ProjectFile_Name /p:Configuration=$env:Configuration /p:SourceRevisionBranch="$env:Head_Ref" /p:SourceRevisionCommit="$($env:Sha.Substring(0, 7))" /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:AppxBundlePlatforms="x86|x64|ARM|ARM64" /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:AppxPackageDir="$env:Appx_Package_Dir" /p:GenerateAppxPackageOnBuild=true
env:
Appx_Bundle: Always
Appx_Package_Build_Mode: SideloadOnly
Appx_Package_Dir: Packages\
Configuration: ${{ matrix.configuration }}
Head_Ref: ${{ github.head_ref }}
Sha: ${{ github.sha }}

# Remove the pfx
- name: Cleanup
Expand All @@ -67,7 +83,3 @@ jobs:
name: AppxPackage-${{ matrix.configuration }}
path: |
${{ env.Project_Name }}\\Packages
${{ env.Project_Name }}\\bin\\x86\\${{ matrix.configuration }}\\ilc\\${{ env.Project_Name }}.pdb
${{ env.Project_Name }}\\bin\\x64\\${{ matrix.configuration }}\\ilc\\${{ env.Project_Name }}.pdb
${{ env.Project_Name }}\\bin\\ARM\\${{ matrix.configuration }}\\ilc\\${{ env.Project_Name }}.pdb
${{ env.Project_Name }}\\bin\\ARM64\\${{ matrix.configuration }}\\ilc\\${{ env.Project_Name }}.pdb
18 changes: 16 additions & 2 deletions UniSky.Models/UniSky.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FishyFlip" Version="3.1.0-alpha.0" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="FishyFlip" Version="3.1.0-alpha.7" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
</ItemGroup>

<Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation">
<Exec Condition="'$(SourceRevisionCommit)' == ''" Command="git describe --long --always --dirty --exclude=* --abbrev=7" ConsoleToMSBuild="True" IgnoreExitCode="False">
<Output PropertyName="SourceRevisionCommit" TaskParameter="ConsoleOutput"/>
</Exec>
<Exec Condition="'$(SourceRevisionBranch)' == ''" Command="git branch --show-current" ConsoleToMSBuild="True" IgnoreExitCode="True">
<Output PropertyName="SourceRevisionBranch" TaskParameter="ConsoleOutput"/>
</Exec>

<PropertyGroup>
<SourceRevisionId Condition="'$(SourceRevisionBranch)' == 'master' Or '$(SourceRevisionBranch)' == 'main' Or '$(SourceRevisionBranch)' == ''">$(SourceRevisionCommit)</SourceRevisionId>
<SourceRevisionId Condition="'$(SourceRevisionBranch)' != 'master' And '$(SourceRevisionBranch)' != 'main' And '$(SourceRevisionBranch)' != ''">$(SourceRevisionCommit) ($(SourceRevisionBranch))</SourceRevisionId>
</PropertyGroup>
</Target>

</Project>
42 changes: 20 additions & 22 deletions UniSky/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,42 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniSky"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:media="using:Microsoft.UI.Xaml.Media">
xmlns:media="using:Microsoft.UI.Xaml.Media"
xmlns:sheets="using:UniSky.Controls.Sheet"
xmlns:themes="using:UniSky.Themes">

<Application.Resources>
<controls:XamlControlsResources ControlsResourcesVersion="Version1">
<controls:XamlControlsResources.MergedDictionaries>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ThemeResources xmlns="using:UniSky.Themes"/>

<!-- Styles -->
<ResourceDictionary Source="/Templates/Icons.xaml"/>
<ResourceDictionary Source="/Templates/NavigationViewStyles.xaml"/>
<ResourceDictionary Source="/Templates/ButtonStyles.xaml"/>
<ResourceDictionary Source="/Templates/TextBoxStyles.xaml"/>
<ResourceDictionary Source="/Templates/RichTextBlockStyles.xaml"/>
<ResourceDictionary Source="/Templates/MediaTransportControlsStyles.xaml"/>

<!-- Templates -->
<FeedTemplates xmlns="using:UniSky.Templates"/>
</ResourceDictionary.MergedDictionaries>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="#FF080808" />
<SolidColorBrush x:Key="SystemControlSeparatorBrush" Color="#FF404040"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="SystemControlSeparatorBrush" Color="#FFDEDEDE"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<x:String x:Key="BlueSkyLogoPath">M13.873 3.77C21.21 9.243 29.103 20.342 32 26.3v15.732c0-.335-.13.043-.41.858-1.512 4.414-7.418 21.642-20.923 7.87-7.111-7.252-3.819-14.503 9.125-16.692-7.405 1.252-15.73-.817-18.014-8.93C1.12 22.804 0 8.431 0 6.488 0-3.237 8.579-.18 13.873 3.77ZM50.127 3.77C42.79 9.243 34.897 20.342 32 26.3v15.732c0-.335.13.043.41.858 1.512 4.414 7.418 21.642 20.923 7.87 7.111-7.252 3.819-14.503-9.125-16.692 7.405 1.252 15.73-.817 18.014-8.93C62.88 22.804 64 8.431 64 6.488 64-3.237 55.422-.18 50.127 3.77Z</x:String>
<x:Int32 x:Key="BlueSkyLogoWidth">64</x:Int32>
<x:Int32 x:Key="BlueSkyLogoHeight">57</x:Int32>

<!--<x:String x:Key="BlueSkyLogoPath">m64.67 6.525c-1.74 2.61-4.06 4.93-6.525 6.815 0 .58 0 1.16 0 1.74 0 17.4-13.195 37.555-37.555 37.555-7.395 0-14.355-2.175-20.155-5.945 1.015.145 2.03.145 3.19.145 6.235 0 11.89-2.175 16.385-5.655-5.8-.145-10.585-3.915-12.325-9.135.87.145 1.595.29 2.465.29 1.16 0 2.32-.145 3.48-.435C7.54 30.595 2.9 25.23 2.9 18.85c0 0 0-.145 0-.145 1.74 1.015 3.77 1.595 5.945 1.595C5.365 17.98 3.045 13.92 3.045 9.425c0-2.465.58-4.64 1.74-6.67 6.525 7.975 16.24 13.195 27.115 13.775-.29-1.015-.29-2.03-.29-3.045 0-7.25 5.945-13.195 13.195-13.195 3.77 0 7.25 1.595 9.57 4.205 3.045-.58 5.8-1.74 8.41-3.19-1.015 3.045-3.045 5.655-5.8 7.25 2.61-.29 5.22-1.015 7.54-2.03z</x:String>
<x:Int32 x:Key="BlueSkyLogoWidth">64</x:Int32>
<x:Int32 x:Key="BlueSkyLogoHeight">38</x:Int32>-->
<!-- Controls -->
<ResourceDictionary Source="/Controls/Sheet/SheetControl.xaml"/>
<ResourceDictionary Source="/Controls/RadialProgressBar/RadialProgressBar.xaml"/>
</ResourceDictionary.MergedDictionaries>

<Thickness x:Key="HairlineThickness">0,1,0,0</Thickness>
<CornerRadius x:Key="ControlCornerRadius">0,0,0,0</CornerRadius>

<x:Double x:Key="ControlContentThemeFontSize">14</x:Double>
<x:Double x:Key="ContentControlFontSize">14</x:Double>
<x:Double x:Key="ContentControlFontSize">14</x:Double>

<SolidColorBrush x:Key="SystemControlBackgroundListExtraLowBrush"
Color="{ThemeResource SystemListExtraLowColor}"/>

<SolidColorBrush x:Key="SystemControlSeparatorBrush" Color="{ThemeResource SystemControlSeparatorColor}"/>

<Style TargetType="sheets:SheetControl" BasedOn="{StaticResource DefaultSheetControlStyle}"/>
</ResourceDictionary>
</controls:XamlControlsResources.MergedDictionaries>
</controls:XamlControlsResources>
Expand Down
75 changes: 56 additions & 19 deletions UniSky/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using CommunityToolkit.Mvvm.DependencyInjection;
using Humanizer.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using UniSky.Extensions;
using UniSky.Helpers.Localisation;
using UniSky.Services;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
using Windows.ApplicationModel.Resources.Core;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using UnhandledExceptionEventArgs = Windows.UI.Xaml.UnhandledExceptionEventArgs;

namespace UniSky;

Expand All @@ -29,34 +19,64 @@ namespace UniSky;
/// </summary>
sealed partial class App : Application
{
private ILogger<App> _logger;

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.ConfigureServices();

this.InitializeComponent();
this.Suspending += OnSuspending;
this.UnhandledException += OnUnhandledException;

this.ConfigureServices();
_logger = ServiceContainer.Default.GetRequiredService<ILoggerFactory>()
.CreateLogger<App>();

// ResourceContext.SetGlobalQualifierValue("Custom", "Twitter", ResourceQualifierPersistence.LocalMachine);
}

private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
_logger.LogError(e.Exception, "Unhandled exception!!");

// hate this
e.Handled = true;
}

private void ConfigureServices()
{
var collection = new ServiceCollection();
collection.AddLogging(c => c.AddDebug()
.SetMinimumLevel(LogLevel.Trace));

collection.AddSingleton<IProtocolService, ProtocolService>();
collection.AddSingleton<ISettingsService, SettingsService>();
collection.AddSingleton<ITypedSettings, SettingsService>();
collection.AddSingleton<IThemeService, ThemeService>();
collection.AddSingleton<INavigationServiceLocator, NavigationServiceLocator>();
collection.AddScoped<ISafeAreaService, CoreWindowSafeAreaService>();
collection.AddScoped<ISheetService, SheetService>();

collection.AddTransient<LoginService>();
collection.AddTransient<SessionService>();

collection.AddSingleton<INavigationServiceLocator, NavigationServiceLocator>();
collection.AddSingleton<IProtocolService, ProtocolService>();
collection.AddSingleton<ISafeAreaService, SafeAreaService>();
ServiceContainer.Default.ConfigureServices(collection.BuildServiceProvider());

Configurator.Formatters.Register("en", (locale) => new ShortTimespanFormatter("en"));
Configurator.Formatters.Register("en-GB", (locale) => new ShortTimespanFormatter("en"));
Configurator.Formatters.Register("en-US", (locale) => new ShortTimespanFormatter("en"));
}

Ioc.Default.ConfigureServices(collection.BuildServiceProvider());
protected override void OnActivated(IActivatedEventArgs args)
{
if (args is ProtocolActivatedEventArgs e)
{
this.OnProtocolActivated(e);
}
}

/// <summary>
Expand All @@ -66,6 +86,8 @@ private void ConfigureServices()
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Hairline.Initialize();

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (Window.Current.Content is not Frame rootFrame)
Expand Down Expand Up @@ -99,6 +121,21 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
}
}

private void OnProtocolActivated(ProtocolActivatedEventArgs e)
{
Hairline.Initialize();
if (Window.Current.Content is not Frame rootFrame)
{
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
rootFrame.Navigate(typeof(RootPage));
Window.Current.Content = rootFrame;
}

// Ensure the current window is active
Window.Current.Activate();
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
Expand Down
48 changes: 48 additions & 0 deletions UniSky/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UniSky.Models;
using Windows.ApplicationModel;
using Windows.UI.Xaml;

namespace UniSky;

public static class Constants
{
public static string Version
{
get
{
var gitSha = "";
var versionedAssembly = typeof(LoginModel).Assembly;
var attribute = versionedAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();

int idx;
if (attribute != null && (idx = attribute.InformationalVersion.IndexOf('+')) != -1)
{
gitSha = "-" + attribute.InformationalVersion.Substring(idx + 1);
}

var v = Package.Current.Id.Version;
return $"{v.Major}.{v.Minor}.{v.Build}.{v.Revision}{gitSha}";
}
}

public static string UserAgent
=> $"UniSky/{Version} (https://github.com/UnicordDev/UniSky)";

public static class Settings
{
public const string REQUESTED_COLOUR_SCHEME = "RequestedColourScheme_v1";
public const int REQUESTED_COLOUR_SCHEME_DEFAULT = (int)ElementTheme.Default;

public const string USE_MULTIPLE_WINDOWS = "UseMultipleWindows_v1";
// default: calculated

public const string AUTO_FEED_REFRESH = "AutoRefreshFeeds_v1";
public const bool AUTO_FEED_REFRESH_DEFAULT = true;
}
}
39 changes: 39 additions & 0 deletions UniSky/Controls/Compose/ComposeAddAltTextDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<ContentDialog
x:Class="UniSky.Controls.Compose.ComposeAddAltTextDialog"
x:Uid="ComposeAddAltTextDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniSky.Controls.Compose"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:compose="using:UniSky.ViewModels.Compose"
mc:Ignorable="d"
Title="ADD ALT TEXT"
PrimaryButtonText="OK"
SecondaryButtonText="Cancel"
PrimaryButtonStyle="{ThemeResource AccentButtonStyle}">
<d:ContentDialog.DataContext>
<d:DesignInstance Type="compose:ComposeViewAttachmentViewModel"/>
</d:ContentDialog.DataContext>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Image Source="{Binding Thumbnail}" MaxHeight="350" />

<TextBox x:Uid="ComposeAddAltTextTextBox"
Grid.Row="1"
Margin="0,16,0,0"
PlaceholderText="Describe this image! Be as detailed as you like."
TextWrapping="Wrap"
AcceptsReturn="True"
MaxLength="2000"
MaxHeight="200"
Text="{Binding AltText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">

</TextBox>
</Grid>
</ContentDialog>
13 changes: 13 additions & 0 deletions UniSky/Controls/Compose/ComposeAddAltTextDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using UniSky.ViewModels.Compose;
using Windows.UI.Xaml.Controls;

namespace UniSky.Controls.Compose;

public sealed partial class ComposeAddAltTextDialog : ContentDialog
{
public ComposeAddAltTextDialog(ComposeViewAttachmentViewModel viewModel)
{
this.InitializeComponent();
this.DataContext = viewModel;
}
}
Loading

0 comments on commit 1eb697f

Please sign in to comment.