Skip to content

Commit

Permalink
lots of new stuff and lots of small changes under the hood
Browse files Browse the repository at this point in the history
add notifications bottom right corner
add undo action for hiding episode in home
add undo action for deleting a tracked anime
add you can now track anime in all animebytes views
fix lots of small style stuff
rearranged animebytes settings
add setup wizard (WIP)
lots of other small stuff
  • Loading branch information
Tensei committed Jun 9, 2021
1 parent 7eb9e9a commit 8c1baca
Show file tree
Hide file tree
Showing 74 changed files with 2,647 additions and 918 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
name: .NET
name: .NET 5 Build

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
24 changes: 22 additions & 2 deletions anidow/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ResourceDictionary Source="pack://application:,,,/Styles/ListViewItem.xaml" />
<ResourceDictionary Source="pack://application:,,,/Styles/Button.xaml" />
<ResourceDictionary Source="pack://application:,,,/Styles/ListBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/Styles/Notification.xaml" />
</s:ApplicationLoader.MergedDictionaries>

<!-- Override colors -->
Expand Down Expand Up @@ -49,7 +50,27 @@
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="2" />
<Setter Property="Margin" Value="2,0,2,2" />
</Style>

<Style
x:Key="GridViewFirstCenteredContainerStyle"
BasedOn="{StaticResource {x:Type GridViewColumnHeader}}"
TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="0,0,2,2" />
</Style>

<Style
x:Key="GridViewLastCenteredContainerStyle"
BasedOn="{StaticResource {x:Type GridViewColumnHeader}}"
TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Margin" Value="2,0,0,2" />
</Style>

<Style
Expand Down Expand Up @@ -102,7 +123,6 @@
</Setter.Value>
</Setter>
</Style>

</s:ApplicationLoader>
</Application.Resources>
</Application>
6 changes: 2 additions & 4 deletions anidow/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Windows;

namespace Anidow
namespace Anidow
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
public partial class App
{
}
}
94 changes: 41 additions & 53 deletions anidow/Bootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using System.Windows;
using System.Windows.Markup;
using AdonisUI.Controls;
using Anidow.Database;
using Anidow.Database.Models;
using Anidow.Factories;
using Anidow.Helpers;
using Anidow.Pages;
Expand All @@ -22,19 +22,24 @@
using Jot;
using Jot.Storage;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using Microsoft.EntityFrameworkCore;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using Stylet;
using StyletIoC;
using ILogger = Serilog.ILogger;

#if RELEASE
using AdonisUI.Controls;
using System.IO;
using System.Windows.Threading;
using System.Diagnostics;

using MessageBox = AdonisUI.Controls.MessageBox;
using MessageBoxButton = AdonisUI.Controls.MessageBoxButton;
using MessageBoxImage = AdonisUI.Controls.MessageBoxImage;
using MessageBoxResult = AdonisUI.Controls.MessageBoxResult;
#endif
Expand All @@ -52,11 +57,11 @@ public class Bootstrapper : Bootstrapper<ShellViewModel>
// Configure the IoC container in here
protected override void ConfigureIoC(IStyletIoCBuilder builder)
{
builder.Bind<Assembly>().ToInstance(Assembly.GetExecutingAssembly());
var assembly = Assembly.GetExecutingAssembly();
builder.Bind<Assembly>().ToInstance(assembly);
var tracker = InitTracker();
builder.Bind<Tracker>().ToInstance(tracker);


var logViewModel = new LogViewModel();
InitLogger(logViewModel);

Expand Down Expand Up @@ -153,53 +158,43 @@ private void InitLogger(ILogEventSink logViewModel)
.WriteTo.Console()
.WriteTo.Sink(logViewModel, logLevel)
.WriteTo.File(
"./logs/log-.txt", rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 7);
"./logs/log-.txt",
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 7,
restrictedToMinimumLevel: LogEventLevel.Error);

_logger = logConfiguration.CreateLogger();
}

public override void Start(string[] args)
{
base.Start(args);
}

protected override void OnExit(ExitEventArgs e)
{
_taskBarIcon?.Dispose();
JobManager.Stop();
base.OnExit(e);
}

protected override async void Configure()
protected override void Configure()
{
#if RELEASE
var processes = Process.GetProcessesByName(
Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly()?.Location));
if (processes.Length > 1)
{
MessageBox.Show("Anidow is already running!", "Already running");
MessageBox.Show("Already running!", "Anidow");
Environment.Exit(0);
}
#endif

var secret = Resources.AppCenter_Secret;
if (!AppCenter.Configured && !string.IsNullOrWhiteSpace(secret))
if (!string.IsNullOrWhiteSpace(secret) && !AppCenter.Configured)
{
AppCenter.Start(secret, typeof(Crashes));
AppCenter.Start(secret, typeof(Crashes), typeof(Analytics));
}

if (string.IsNullOrWhiteSpace(secret))
else
{
_logger.Warning("AppCenter not configured, secret is empty");
}

// Perform any other configuration before the application starts
{
await using var db = new TrackContext();
await db.Database.MigrateAsync();
}

if (Application.Current.MainWindow != null)
{
Application.Current.MainWindow.Language =
Expand All @@ -211,48 +206,41 @@ protected override async void Configure()
JobManager.JobException += info =>
_logger.Error(info.Exception, "An error just happened with a scheduled job");

var selfContained = false;
#if SELF_CONTAINED && RELEASE
selfContained = true;
var selfContained = true;
#else
var selfContained = false;
#endif
_logger.Information(
$"Anidow v{Assembly.GetExecutingAssembly().GetName().Version} selfcontained: {selfContained}");

#if RELEASE
try
{
var (check, hasUpdate) = await _updateManager.HasUpdate();
if (hasUpdate && check != null)
{
await _updateManager.Update(check);
}
}
catch (Exception e)
{
_logger.Error(e, "failed updating anidow");
}
#endif
}
#if RELEASE
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
{
_logger.Fatal(e.Exception, e.Exception.Message);
var messageBox = new MessageBoxModel
if (AppCenter.Configured)
{
Text = $"Would you like to report this crash?\n\nCrash message: '{e.Exception.Message}'",
Caption = "Anidow crashed!",
Icon = MessageBoxImage.Error,
Buttons = new[]
var messageBox = new MessageBoxModel
{
MessageBoxButtons.Yes("Yes!"),
MessageBoxButtons.No("No!"),
},
IsSoundEnabled = true,
};
var result = MessageBox.Show(messageBox);
if (result == MessageBoxResult.Yes)
Text = $"Would you like to report this crash?\n\nCrash message: '{e.Exception.Message}'",
Caption = "Anidow crashed!",
Icon = MessageBoxImage.Error,
Buttons = new[]
{
MessageBoxButtons.Yes("Yes!"),
MessageBoxButtons.No("No!"),
},
IsSoundEnabled = true,
};
var result = MessageBox.Show(messageBox);
if (result == MessageBoxResult.Yes)
{
Crashes.TrackError(e.Exception);
}
}
else
{
Crashes.TrackError(e.Exception);
MessageBox.Show(e.Exception.Message, "Anidow crashed!", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using System.Windows.Data;
using Serilog.Events;

namespace Anidow.Utils
namespace Anidow.Converters
{
public class LogEventRender : IValueConverter
public class LogEventRenderConverter : IValueConverter
{
public static readonly LogEventRender Instance = new();
public static readonly LogEventRenderConverter Instance = new();

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Expand Down
2 changes: 0 additions & 2 deletions anidow/Database/Models/Anime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Windows.Documents;
using Anidow.Enums;
using Anidow.Model;
using Humanizer;
using Newtonsoft.Json;

namespace Anidow.Database.Models
{
Expand Down
14 changes: 14 additions & 0 deletions anidow/Database/Models/AppState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// // Created: 06-06-2021 21:45

using System;
using Anidow.Model;

namespace Anidow.Database.Models
{
public class AppState : ObservableObject
{
public int Id { get; set; }
public DateTime Created { get; set; }
public bool FirstStart { get; set; } = true;
}
}
9 changes: 8 additions & 1 deletion anidow/Database/TrackContext.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Anidow.Database.Models;
using System;
using Anidow.Database.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Anidow.Database
{
public class TrackContext : DbContext
{
public DbSet<AppState> AppStates { get; set; }
public DbSet<Anime> Anime { get; set; }
public DbSet<Episode> Episodes { get; set; }
public DbSet<Cover> Covers { get; set; }
Expand All @@ -18,6 +21,10 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<AppState>()
.Property(b => b.Created)
.HasDefaultValue(DateTime.UtcNow);

}
}
}
9 changes: 9 additions & 0 deletions anidow/Events/AddToHomeEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Anidow.Database.Models;

namespace Anidow.Events
{
public class AddToHomeEvent
{
public Episode Episode { get; init; }
}
}
7 changes: 1 addition & 6 deletions anidow/Events/OpenAnimeEditEvent.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Anidow.Database.Models;
using Anidow.Database.Models;

namespace Anidow.Events
{
Expand Down
9 changes: 9 additions & 0 deletions anidow/Events/TrackedDeleteAnimeEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Anidow.Database.Models;

namespace Anidow.Events
{
public class TrackedDeleteAnimeEvent
{
public Anime Anime { get; set; }
}
}
6 changes: 6 additions & 0 deletions anidow/Events/TrackedRefreshEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Anidow.Events
{
public class TrackedRefreshEvent
{
}
}

0 comments on commit 8c1baca

Please sign in to comment.