Skip to content

Commit

Permalink
Application wallpaper launch options..
Browse files Browse the repository at this point in the history
- .. Resolved: #2054
- updated webview accent param code.
  • Loading branch information
rocksdanister committed May 5, 2024
1 parent aa5f294 commit 5c1492a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/Lively/Lively.Common/Extensions/WallpaperExtensions.cs
Expand Up @@ -15,6 +15,9 @@ public static class WallpaperExtensions
public static bool IsVideoWallpaper(this WallpaperType type) =>
type == WallpaperType.video || type == WallpaperType.videostream;

public static bool IsApplicationWallpaper(this WallpaperType type) =>
type == WallpaperType.unity || type == WallpaperType.unityaudio || type == WallpaperType.app || type == WallpaperType.godot || type == WallpaperType.bizhawk;

/// <summary>
/// Picture, gif and other non dynamic format
/// </summary>
Expand Down
10 changes: 8 additions & 2 deletions src/Lively/Lively.UI.WinUI/Services/DialogService.cs
Expand Up @@ -96,9 +96,15 @@ public async Task ShowDialogAsync(string message, string title, string primaryBt
};
}

public async Task<string> ShowTextInputDialogAsync(string title)
public async Task<string> ShowTextInputDialogAsync(string title, string placeholderText)
{
var tb = new TextBox();
var tb = new TextBox()
{
Height = 75,
Padding = new Thickness(10),
TextWrapping = TextWrapping.Wrap,
PlaceholderText = placeholderText
};
var dialog = new ContentDialog
{
Title = title,
Expand Down
2 changes: 1 addition & 1 deletion src/Lively/Lively.UI.WinUI/Services/IDialogService.cs
Expand Up @@ -19,7 +19,7 @@ public interface IDialogService
string primaryBtnText,
string secondaryBtnText,
bool isDefaultPrimary = true);
Task<string> ShowTextInputDialogAsync(string title);
Task<string> ShowTextInputDialogAsync(string title, string placeholderText);
Task ShowThemeDialogAsync();
Task ShowPatreonSupportersDialogAsync();
Task ShowShareWallpaperDialogAsync(LibraryModel obj);
Expand Down
4 changes: 2 additions & 2 deletions src/Lively/Lively.UI.WinUI/Strings/en-US/Resources.resw
Expand Up @@ -563,7 +563,7 @@ If still not working, close &amp; start Lively again/restart windows.
<value>Video</value>
</data>
<data name="TextWallpaperCommandlineArgs" xml:space="preserve">
<value>Enter optional commandline arguments</value>
<value>Launch Options</value>
</data>
<data name="WallpaperFitFill.Content" xml:space="preserve">
<value>Fill</value>
Expand Down Expand Up @@ -878,7 +878,7 @@ If still not working, close &amp; start Lively again/restart windows.
<data name="TitleWallpaper.Content" xml:space="preserve">
<value>Wallpaper</value>
</data>
<data name="TitleCustomise.Content" xml:space="preserve">
<data name="TitleCustomise.Content" xml:space="preserve">
<value>Customise</value>
</data>
<data name="WallpaperDir.Header" xml:space="preserve">
Expand Down
17 changes: 12 additions & 5 deletions src/Lively/Lively.UI.WinUI/ViewModels/LibraryViewModel.cs
Expand Up @@ -23,6 +23,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Lively.Helpers;
using CommunityToolkit.WinUI.Collections;
using Lively.Common.Extensions;

namespace Lively.UI.WinUI.ViewModels
{
Expand All @@ -47,6 +48,8 @@ public partial class LibraryViewModel : ObservableObject
private readonly IDialogService dialogService;
private readonly GalleryClient galleryClient;

private readonly ResourceLoader i18n;

public LibraryViewModel(IWallpaperLibraryFactory wallpaperLibraryFactory,
IDesktopCoreClient desktopCore,
IDisplayManagerClient displayManager,
Expand All @@ -63,6 +66,8 @@ public partial class LibraryViewModel : ObservableObject
this.dialogService = dialogService;
this.galleryClient = galleryClient;

i18n = ResourceLoader.GetForViewIndependentUse();

wallpaperScanFolders = new List<string>
{
Path.Combine(userSettings.Settings.WallpaperDir, Constants.CommonPartialPaths.WallpaperInstallDir),
Expand Down Expand Up @@ -570,11 +575,15 @@ public async Task<LibraryModel> AddWallpaperFile(string filePath)
}
else
{
throw new InvalidOperationException(ResourceLoader.GetForViewIndependentUse().GetString("LivelyExceptionNotLivelyZip"));
throw new InvalidOperationException(i18n.GetString("LivelyExceptionNotLivelyZip"));
}
}
else
{
var arguments = string.Empty;
if (type.IsApplicationWallpaper())
arguments = await dialogService.ShowTextInputDialogAsync(i18n.GetString("TextWallpaperCommandlineArgs"), "Examples: --myarguments1 -myargument2");

var dir = Path.Combine(userSettings.Settings.WallpaperDir, Constants.CommonPartialPaths.WallpaperInstallTempDir, Path.GetRandomFileName());
Directory.CreateDirectory(dir);
var data = new LivelyInfoModel()
Expand All @@ -586,15 +595,14 @@ public async Task<LibraryModel> AddWallpaperFile(string filePath)
Contact = string.Empty,
Preview = string.Empty,
Thumbnail = string.Empty,
Arguments = string.Empty,
Arguments = string.IsNullOrWhiteSpace(arguments) ? string.Empty : arguments,
};

//TODO generate livelyproperty for gif etc..
JsonStorage<LivelyInfoModel>.StoreData(Path.Combine(dir, "LivelyInfo.json"), data);
return AddWallpaper(dir, true);
}
}
throw new InvalidOperationException($"{ResourceLoader.GetForViewIndependentUse().GetString("TextUnsupportedFile")} ({Path.GetExtension(filePath)})");
throw new InvalidOperationException($"{i18n.GetString("TextUnsupportedFile")} ({Path.GetExtension(filePath)})");
}

public LibraryModel AddWallpaperLink(string url)
Expand All @@ -613,7 +621,6 @@ public LibraryModel AddWallpaperLink(string url)
Arguments = string.Empty,
};

//TODO generate livelyproperty for gif etc..
JsonStorage<LivelyInfoModel>.StoreData(Path.Combine(dir, "LivelyInfo.json"), data);
return AddWallpaper(dir, true);
}
Expand Down
7 changes: 4 additions & 3 deletions src/Lively/Lively.UI.WinUI/Views/Pages/AppUpdateView.xaml.cs
Expand Up @@ -35,11 +35,12 @@ public AppUpdateView()
_ => string.Empty,
};
// Set website accent color
var accentColor = ((Windows.UI.Color)App.Current.Resources["SystemAccentColor"]).ToHex().Substring(1);
var accentColorDark1 = ((Windows.UI.Color)App.Current.Resources["SystemAccentColorDark1"]).ToHex().Substring(1);
var accentColorLight1 = ((Windows.UI.Color)App.Current.Resources["SystemAccentColorLight1"]).ToHex().Substring(1);

var url = viewModel.IsBetaBuild ?
$"https://www.rocksdanister.com/lively-webpage/changelog/?source=app{pageTheme}&color={accentColor}" :
$"https://www.rocksdanister.com/lively/changelog/?source=app{pageTheme}&color={accentColor}";
$"https://www.rocksdanister.com/lively-webpage/changelog/?source=app{pageTheme}&colorLight={accentColorLight1}&colorDark={accentColorDark1}" :
$"https://www.rocksdanister.com/lively/changelog/?source=app{pageTheme}&colorLight={accentColorLight1}&colorDark={accentColorDark1}";
WebView.Source = LinkUtil.SanitizeUrl(url);
}

Expand Down
Expand Up @@ -38,11 +38,12 @@ public PatreonSupportersView()
_ => string.Empty,
};
// Set website accent color
var accentColor = ((Windows.UI.Color)App.Current.Resources["SystemAccentColor"]).ToHex().Substring(1);
var accentColorDark1 = ((Windows.UI.Color)App.Current.Resources["SystemAccentColorDark1"]).ToHex().Substring(1);
var accentColorLight1 = ((Windows.UI.Color)App.Current.Resources["SystemAccentColorLight1"]).ToHex().Substring(1);

var url = viewModel.IsBetaBuild ?
$"https://www.rocksdanister.com/lively-webpage/supporters/?{pageTheme}&color={accentColor}" :
$"https://www.rocksdanister.com/lively/supporters/?{pageTheme}&color={accentColor}";
$"https://www.rocksdanister.com/lively-webpage/supporters/?{pageTheme}&colorLight={accentColorLight1}&colorDark={accentColorDark1}" :
$"https://www.rocksdanister.com/lively/supporters/?{pageTheme}&colorLight={accentColorLight1}&colorDark={accentColorDark1}";
WebView.Source = LinkUtil.SanitizeUrl(url);
}

Expand Down

0 comments on commit 5c1492a

Please sign in to comment.