Skip to content

Commit 45f9d47

Browse files
mattleibowPureWeen
andauthored
Update Resizetizer Dependencies and Support Different Cultures (#464)
* Fix it all * Try using old school powershell * Store window to local variable so GC doesn't collect it (#465) Co-authored-by: Shane Neuville <[email protected]>
1 parent 6e036fd commit 45f9d47

File tree

9 files changed

+24
-28
lines changed

9 files changed

+24
-28
lines changed

eng/pipelines/common/build-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ steps:
1616
provisioning_script: $(provisionator.path)
1717
provisioning_extra_args: $(provisionator.extraArguments)
1818

19-
- pwsh: |
19+
- powershell: |
2020
$(System.DefaultWorkingDirectory)/build.ps1 --target provision --TeamProject="$(System.TeamProject)"
2121
displayName: 'Cake Provision'
2222
condition: eq(variables['provisioningCake'], 'true')

src/Controls/src/Build.Tasks/Controls.Build.Tasks.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111

112112
<Target Name="_CopyToNuspecDir" AfterTargets="Build">
113113
<ItemGroup>
114-
<_CopyItems Include="$(TargetDir)*.dll" />
114+
<_CopyItems Include="$(TargetDir)*.dll" Exclude="$(TargetDir)System.*.dll" />
115+
<_CopyItems Include="$(TargetDir)System.CodeDom.dll" />
115116
</ItemGroup>
116117
<Copy SourceFiles="@(_CopyItems)" DestinationFolder="..\..\..\..\.nuspec\" ContinueOnError="true" Retries="0" />
117118
</Target>

src/Core/src/Platform/iOS/MauiUIApplicationDelegate.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ namespace Microsoft.Maui
1111
{
1212
public class MauiUIApplicationDelegate<TApplication> : UIApplicationDelegate, IUIApplicationDelegate where TApplication : MauiApp
1313
{
14+
public override UIWindow? Window
15+
{
16+
get;
17+
set;
18+
}
19+
1420
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
1521
{
1622
if (!(Activator.CreateInstance(typeof(TApplication)) is TApplication app))
@@ -32,15 +38,15 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l
3238

3339
var content = (window.Page as IView) ?? window.Page.View;
3440

35-
var uiWindow = new UIWindow
41+
Window = new UIWindow
3642
{
3743
RootViewController = new UIViewController
3844
{
3945
View = content.ToNative(window.MauiContext)
4046
}
4147
};
4248

43-
uiWindow.MakeKeyAndVisible();
49+
Window.MakeKeyAndVisible();
4450

4551
return true;
4652
}

src/SingleProject/Resizetizer/src/AndroidAdaptiveIconGenerator.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public IEnumerable<ResizedImageInfo> Generate()
5959
fileInfo.Directory.Create();
6060

6161
Logger.Log("Converting Background SVG to Android Drawable Vector: " + backgroundFile);
62-
var bgConvertErr = Svg2VectorDrawable.Svg2Vector.Convert(backgroundFile, backgroundDestination);
63-
if (!string.IsNullOrEmpty(bgConvertErr))
64-
throw new Svg2AndroidDrawableConversionException(bgConvertErr, backgroundFile);
62+
Svg2VectorDrawable.Svg2Vector.Convert(backgroundFile, backgroundDestination);
6563

6664
var foregroundDestination = Path.Combine(fullIntermediateOutputPath.FullName, "drawable", AppIconName + "_foreground.xml");
6765
fileInfo = new FileInfo(foregroundDestination);
@@ -72,9 +70,7 @@ public IEnumerable<ResizedImageInfo> Generate()
7270
if (foregroundExists)
7371
{
7472
Logger.Log("Converting Foreground SVG to Android Drawable Vector: " + foregroundFile);
75-
var fgConvertErr = Svg2VectorDrawable.Svg2Vector.Convert(foregroundFile, foregroundDestination);
76-
if (!string.IsNullOrEmpty(fgConvertErr))
77-
throw new Svg2AndroidDrawableConversionException(fgConvertErr, foregroundFile);
73+
Svg2VectorDrawable.Svg2Vector.Convert(foregroundFile, foregroundDestination);
7874
}
7975
else
8076
{

src/SingleProject/Resizetizer/src/AppleIconAssetsGenerator.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Drawing;
5+
using System.Globalization;
56
using System.IO;
67

78
namespace Microsoft.Maui.Resizetizer
@@ -48,10 +49,14 @@ public IEnumerable<ResizedImageInfo> Generate()
4849
{
4950
foreach (var idiom in dpi.Idioms)
5051
{
52+
var w = dpi.Size.Value.Width.ToString("0.#", CultureInfo.InvariantCulture);
53+
var h = dpi.Size.Value.Height.ToString("0.#", CultureInfo.InvariantCulture);
54+
var s = dpi.Scale.ToString("0", CultureInfo.InvariantCulture);
55+
5156
appIconImagesJson.Add(new JObject(
5257
new JProperty("idiom", idiom),
53-
new JProperty("size", $"{dpi.Size.Value.Width}x{dpi.Size.Value.Height}"),
54-
new JProperty("scale", dpi.Scale.ToString("0") + "x"),
58+
new JProperty("size", $"{w}x{h}"),
59+
new JProperty("scale", $"{s}x"),
5560
new JProperty("filename", AppIconName + dpi.FileSuffix + ".png")));
5661
}
5762
}

src/SingleProject/Resizetizer/src/Resizer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public ResizedImageInfo CopyFile(DpiPath dpi, string inputsFile, bool isAndroid
5555
Logger.Log("Converting SVG to Android Drawable Vector: " + Info.Filename);
5656

5757
// Transform into an android vector drawable
58-
var convertErr = Svg2VectorDrawable.Svg2Vector.Convert(Info.Filename, destination);
59-
if (!string.IsNullOrEmpty(convertErr))
60-
throw new Svg2AndroidDrawableConversionException(convertErr, Info.Filename);
58+
Svg2VectorDrawable.Svg2Vector.Convert(Info.Filename, destination);
6159
}
6260
else
6361
{

src/SingleProject/Resizetizer/src/ResizetizeSharedImages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ System.Threading.Tasks.Task DoExecute()
106106
}
107107
catch (Exception ex)
108108
{
109-
Log.LogErrorFromException(ex);
109+
Log.LogWarningFromException(ex, true);
110110

111111
throw;
112112
}

src/SingleProject/Resizetizer/src/Resizetizer.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@
6363
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" GeneratePathProperty="true" PrivateAssets="all" />
6464
<PackageReference Include="System.Drawing.Common" Version="4.7.0" GeneratePathProperty="true" PrivateAssets="all" />
6565
<PackageReference Include="System.ObjectModel" Version="4.3.0" GeneratePathProperty="true" PrivateAssets="all" />
66-
<PackageReference Include="Svg2VectorDrawable.Net" Version="0.1.0" GeneratePathProperty="true" PrivateAssets="all" />
66+
<PackageReference Include="Svg2VectorDrawable.Net" Version="0.3.0" GeneratePathProperty="true" PrivateAssets="all" />
6767
</ItemGroup>
6868

6969
<Target Name="_CopyToNuspecDir" AfterTargets="Build">
7070
<ItemGroup>
71-
<_CopyItems Include="$(TargetDir)**\*.dll" />
71+
<_CopyItems Include="$(TargetDir)**\*.dll" Exclude="$(TargetDir)System.*.dll" />
7272
<_CopyItems Include="$(TargetDir)**\*.dylib" />
7373
</ItemGroup>
7474
<Copy SourceFiles="@(_CopyItems)" DestinationFolder="..\..\..\..\.nuspec\%(RecursiveDir)" ContinueOnError="true" Retries="0" />

src/SingleProject/Resizetizer/src/SkiaSharpSvgTools.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66

77
namespace Microsoft.Maui.Resizetizer
88
{
9-
public class Svg2AndroidDrawableConversionException : Exception
10-
{
11-
public Svg2AndroidDrawableConversionException(string message, string file) : base ("Failed to Convert SVG to Android Drawable: " + message + " in [" + file + "]")
12-
{
13-
Filename = file;
14-
}
15-
16-
public string Filename { get; }
17-
}
18-
199
internal class SkiaSharpSvgTools : SkiaSharpTools, IDisposable
2010
{
2111
SKSvg svg;

0 commit comments

Comments
 (0)