Skip to content

Commit 4340ccf

Browse files
authored
ImageSource and ImageSourceServices (#759)
1 parent cacabd6 commit 4340ccf

File tree

242 files changed

+5883
-1087
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+5883
-1087
lines changed

.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net6.0-ios')) != true AND $(TargetFramework.StartsWith('net6.0-maccatalyst')) != true ">
33
<Compile Remove="**\*.iOS.cs" />
44
<None Include="**\*.iOS.cs" />
5-
<Compile Remove="**\iOS\*.cs" />
6-
<None Include="**\iOS\*.cs" />
5+
<Compile Remove="**\iOS\**\*.cs" />
6+
<None Include="**\iOS\**\*.cs" />
77
</ItemGroup>
88
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true ">
99
<Compile Remove="**\*.Mac.cs" />
1010
<None Include="**\*.Mac.cs" />
11-
<Compile Remove="**\Mac\*.cs" />
12-
<None Include="**\Mac\*.cs" />
11+
<Compile Remove="**\Mac\**\*.cs" />
12+
<None Include="**\Mac\**\*.cs" />
1313
</ItemGroup>
1414
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net6.0-ios')) != true AND $(TargetFramework.StartsWith('net6.0-maccatalyst')) != true">
1515
<Compile Remove="**\*.MaciOS.cs" />
1616
<None Include="**\*.MaciOS.cs" />
17-
<Compile Remove="**\MaciOS\*.cs" />
18-
<None Include="**\MaciOS\*.cs" />
17+
<Compile Remove="**\MaciOS\**\*.cs" />
18+
<None Include="**\MaciOS\**\*.cs" />
1919
</ItemGroup>
2020
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid')) != true AND $(TargetFramework.StartsWith('net6.0-android')) != true ">
2121
<Compile Remove="**\*.Android.cs" />
2222
<None Include="**\*.Android.cs" />
23-
<Compile Remove="**\Android\*.cs" />
24-
<None Include="**\Android\*.cs" />
23+
<Compile Remove="**\Android\**\*.cs" />
24+
<None Include="**\Android\**\*.cs" />
2525
</ItemGroup>
2626
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard')) != true ">
2727
<Compile Remove="**\*.Standard.cs" />
2828
<None Include="**\*.Standard.cs" />
29-
<Compile Remove="**\Standard\*.cs" />
30-
<None Include="**\Standard\*.cs" />
29+
<Compile Remove="**\Standard\**\*.cs" />
30+
<None Include="**\Standard\**\*.cs" />
3131
</ItemGroup>
3232
<ItemGroup Condition="$(TargetFramework.Contains('-windows')) != true ">
3333
<Compile Remove="**\*.Windows.cs" />

.nuspec/Microsoft.Maui.Resizetizer.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
_CleanResizetizer;
3939
</CleanDependsOn>
4040

41-
<_ResizetizerInputsFile>$(IntermediateOutputPath)resizetizer.inputs</_ResizetizerInputsFile>
42-
<_ResizetizerStampFile>$(IntermediateOutputPath)resizetizer.stamp</_ResizetizerStampFile>
41+
<_ResizetizerInputsFile>$(IntermediateOutputPath)mauiimage.inputs</_ResizetizerInputsFile>
42+
<_ResizetizerStampFile>$(IntermediateOutputPath)mauiimage.stamp</_ResizetizerStampFile>
4343
<_MauiFontInputsFile>$(IntermediateOutputPath)mauifont.inputs</_MauiFontInputsFile>
4444
<_MauiFontStampFile>$(IntermediateOutputPath)mauifont.stamp</_MauiFontStampFile>
4545
<_MauiSplashInputsFile>$(IntermediateOutputPath)mauisplash.inputs</_MauiSplashInputsFile>

eng/Microsoft.Extensions.targets

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<_MicrosoftProjectReunionVersion>0.5.0</_MicrosoftProjectReunionVersion>
1212
<_MicrosoftGraphicsWin2DVersion>0.5.0.13</_MicrosoftGraphicsWin2DVersion>
1313
<_MicrosoftMauiGraphics>6.0.100-preview.3.61</_MicrosoftMauiGraphics>
14+
<_XamarinAndroidGlideVersion>4.11.0.1</_XamarinAndroidGlideVersion>
1415
</PropertyGroup>
1516
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0-ios' Or '$(TargetFramework)' == 'net6.0-maccatalyst'">
1617
<!-- Debugger workaround -->
@@ -40,6 +41,14 @@
4041
Update="Microsoft.Extensions.Logging"
4142
Version="$(_MicrosoftHostingVersion)"
4243
/>
44+
<PackageReference
45+
Update="Microsoft.Extensions.Logging.Console"
46+
Version="$(_MicrosoftHostingVersion)"
47+
/>
48+
<PackageReference
49+
Update="Microsoft.Extensions.Logging.Debug"
50+
Version="$(_MicrosoftHostingVersion)"
51+
/>
4352
<PackageReference
4453
Update="Microsoft.ProjectReunion"
4554
Version="$(_MicrosoftProjectReunionVersion)"
@@ -56,5 +65,9 @@
5665
Update="Microsoft.Graphics.Win2D"
5766
Version="$(_MicrosoftGraphicsWin2DVersion)"
5867
/>
68+
<PackageReference
69+
Update="Xamarin.Android.Glide"
70+
Version="$(_XamarinAndroidGlideVersion)"
71+
/>
5972
</ItemGroup>
6073
</Project>

src/Compatibility/ControlGallery/src/WinUI/BrokenImageSourceHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
88
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
9+
using Microsoft.Maui.Controls.Platform;
910

1011
[assembly: ExportRenderer(typeof(_51173Image), typeof(_51173CustomImageRenderer))]
1112
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI

src/Compatibility/ControlGallery/src/WinUI/_13109IssueHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
44
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues;
55
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
6+
using Microsoft.Maui.Controls.Platform;
67
using Bitmap = Microsoft.UI.Xaml.Media.ImageSource;
78

89
[assembly: Dependency(typeof(_13109IssueHelper))]

src/Compatibility/Core/src/Android/Compatibility.Android.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
<AndroidResource Include="Resources\layout\toolbar.axml" />
3333
</ItemGroup>
3434
<ItemGroup>
35-
<Compile Include="..\..\..\..\Controls\src\Core\Crc64.cs" Link="Crc64.cs" />
36-
<Compile Include="..\..\..\..\Controls\src\Core\StreamWrapper.cs" Link="StreamWrapper.cs" />
3735
<Compile Include="..\AppHostBuilderExtensions.cs" Link="AppHostBuilderExtensions.cs" />
3836
<Compile Include="..\MauiHandlersCollectionExtensions.cs" Link="MauiHandlersCollectionExtensions.cs" />
3937
</ItemGroup>

src/Compatibility/Core/src/Android/Extensions/JavaObjectExtensions.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Compatibility/Core/src/Android/Forms.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public static class Forms
6262
static bool? s_isNougatOrNewer;
6363
static bool? s_isOreoOrNewer;
6464
static bool? s_isPieOrNewer;
65-
static FontManager s_fontManager;
6665

6766
// One per process; does not change, suitable for loading resources (e.g., ResourceProvider)
6867
internal static Context ApplicationContext { get; private set; } = global::Android.App.Application.Context;
@@ -155,9 +154,6 @@ internal static bool IsPieOrNewer
155154
}
156155
}
157156

158-
internal static IFontManager FontManager =>
159-
s_fontManager ??= new FontManager(Registrar.FontRegistrar);
160-
161157
public static float GetFontSizeNormal(Context context)
162158
{
163159
float size = 50;

src/Compatibility/Core/src/Android/Renderers/AndroidGIFImageParser.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,18 @@ public override bool SelectDrawable(int index)
218218

219219
public static async Task<IFormsAnimationDrawable> LoadImageAnimationAsync(UriImageSource imagesource, Context context, CancellationToken cancelationToken = default(CancellationToken))
220220
{
221-
Uri uri = imagesource?.Uri;
222221
FormsAnimationDrawable animation = null;
223222

224-
if (uri != null)
223+
if (imagesource is IStreamImageSource streamImageSource)
225224
{
226-
var options = new BitmapFactory.Options
225+
using var stream = await streamImageSource.GetStreamAsync(cancelationToken).ConfigureAwait(false);
226+
if (stream != null)
227227
{
228-
InJustDecodeBounds = true
229-
};
228+
var options = new BitmapFactory.Options
229+
{
230+
InJustDecodeBounds = true
231+
};
230232

231-
using (Stream stream = await imagesource.GetStreamAsync(cancelationToken).ConfigureAwait(false))
232-
{
233233
using (var decoder = new AndroidGIFImageParser(context, options.InDensity, options.InTargetDensity))
234234
{
235235
try
@@ -247,11 +247,11 @@ public override bool SelectDrawable(int index)
247247
animation = null;
248248
}
249249
}
250-
}
251250

252-
if (animation == null)
253-
{
254-
Log.Warning(nameof(FileImageSourceHandler), "Could not retrieve image or image data was invalid: {0}", imagesource);
251+
if (animation == null)
252+
{
253+
Log.Warning(nameof(FileImageSourceHandler), "Could not retrieve image or image data was invalid: {0}", imagesource);
254+
}
255255
}
256256
}
257257

src/Compatibility/Core/src/Android/Renderers/FontExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.Android
66
public static class FontExtensions
77
{
88
public static float ToScaledPixel(this Font self)
9-
=> Forms.FontManager.GetScaledPixel(self);
9+
=> CompatServiceProvider.FontManager.GetScaledPixel(self);
1010

1111
public static Typeface ToTypeface(this Font self)
12-
=> Forms.FontManager.GetTypeface(self);
12+
=> CompatServiceProvider.FontManager.GetTypeface(self);
1313

1414
internal static Typeface ToTypeface(this string fontfamily, FontAttributes attr = FontAttributes.None)
15-
=> Forms.FontManager.GetTypeface(Font.OfSize(fontfamily, 0.0).WithAttributes(attr));
15+
=> CompatServiceProvider.FontManager.GetTypeface(Font.OfSize(fontfamily, 0.0).WithAttributes(attr));
1616

1717
internal static bool IsDefault(this IFontElement self)
1818
=> self.FontFamily == null && self.FontSize == Device.GetNamedSize(NamedSize.Default, typeof(Label), true) && self.FontAttributes == FontAttributes.None;
1919

2020
internal static Typeface ToTypeface(this IFontElement self)
2121
{
2222
if (self.IsDefault())
23-
return Forms.FontManager.DefaultTypeface;
23+
return CompatServiceProvider.FontManager.DefaultTypeface;
2424

2525
var font = Font.OfSize(self.FontFamily, self.FontSize).WithAttributes(self.FontAttributes);
2626

27-
return Forms.FontManager.GetTypeface(font);
27+
return CompatServiceProvider.FontManager.GetTypeface(font);
2828
}
2929
}
3030
}

0 commit comments

Comments
 (0)