Skip to content

Commit

Permalink
Squashed commit of the following: (#22874)
Browse files Browse the repository at this point in the history
commit db8a3bd
Author: Matthew Leibowitz <[email protected]>
Date:   Mon Jun 10 13:46:16 2024 +0800

    Add android

commit 0bd2d65
Author: Matthew Leibowitz <[email protected]>
Date:   Mon Jun 10 12:16:34 2024 +0800

    oops!

commit 647e5f5
Author: Matthew Leibowitz <[email protected]>
Date:   Sat Jun 8 18:15:40 2024 +0800

    Almost

commit c3ea650
Author: Matthew Leibowitz <[email protected]>
Date:   Sat Jun 8 16:17:58 2024 +0800

    sadfasdf

commit d9a398f
Author: Matthew Leibowitz <[email protected]>
Date:   Sat Jun 8 13:56:34 2024 +0800

    screenshots

commit 4b3c01f
Merge: 595ff03 e94b364
Author: Matthew Leibowitz <[email protected]>
Date:   Sat Jun 8 13:54:52 2024 +0800

    Merge branch 'main' into dev/gif-in-release

commit 595ff03
Author: Matthew Leibowitz <[email protected]>
Date:   Thu Jun 6 21:00:52 2024 +0800

    Update ImageUITests.cs

commit 2c20fe0
Author: Matthew Leibowitz <[email protected]>
Date:   Thu Jun 6 19:05:23 2024 +0800

    Make some tests

commit 1e82e8b
Author: Matthew Leibowitz <[email protected]>
Date:   Thu Jun 6 18:44:18 2024 +0800

    Take 2?

commit d576c82
Author: Matthew Leibowitz <[email protected]>
Date:   Thu Jun 6 07:11:17 2024 +0800

    Fix animated gifs in Release builds
  • Loading branch information
mattleibow authored Jun 18, 2024
1 parent 7fad926 commit a8367fc
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Controls/tests/CustomAttributes/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ public enum Image
{
Source,
Source_FontImageSource,
IsAnimationPlaying,
Aspect,
IsOpaque,
IsLoading,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/Controls/tests/TestCases.Shared.Tests/Tests/ImageUITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,16 @@ public void Source_FontImageSource()
remote.TapStateButton();
VerifyScreenshot("ImageUITests_Source_FontImageSource_FontAwesome");
}

[Test]
public async Task IsAnimationPlaying()
{
var remote = GoToStateRemote();
await Task.Delay(500); // make sure the gif is NOT playing
VerifyScreenshot("ImageUITests_IsAnimationPlaying_No");

remote.TapStateButton();
await Task.Delay(500); // make sure the gif IS playing
VerifyScreenshot("ImageUITests_IsAnimationPlaying_Yes");
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/Controls/tests/TestCases/Controls.TestCases.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<OutputType>Exe</OutputType>
<SingleProject>true</SingleProject>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Disable multi-RID builds to workaround a parallel build issue -->
<RuntimeIdentifier Condition="$(TargetFramework.Contains('-maccatalyst'))">maccatalyst-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$(TargetFramework.Contains('-maccatalyst')) and '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'arm64'">maccatalyst-arm64</RuntimeIdentifier>
Expand Down
15 changes: 15 additions & 0 deletions src/Controls/tests/TestCases/Elements/ImageCoreGalleryPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,20 @@ protected override void Build()
};
Add(familyContainer);
}

{
var image = new Image
{
Source = "red_is_good.gif",
WidthRequest = 100,
HeightRequest = 100,
};
var container = new StateViewContainer<Image>(Test.Image.IsAnimationPlaying, image);
container.StateChangeButton.Clicked += (s, a) =>
{
image.IsAnimationPlaying = !image.IsAnimationPlaying;
};
Add(container);
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/Core/src/Platform/Android/ImageViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Android.Graphics.Drawables;
using Android.Views;
using Android.Widget;
using Bumptech.Glide.Load.Resource.Gif;

namespace Microsoft.Maui.Platform
{
Expand All @@ -29,7 +30,8 @@ public static void UpdateIsAnimationPlaying(this ImageView imageView, IImageSour

public static void UpdateIsAnimationPlaying(this Drawable? drawable, IImageSourcePart image)
{
if (drawable is IAnimatable animatable)
var animatable = drawable.TryJavaCast<IAnimatable>();
if (animatable is not null)
{
if (image.IsAnimationPlaying)
{
Expand Down
16 changes: 16 additions & 0 deletions src/Core/src/Platform/Android/JavaObjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Android.Runtime;

namespace Microsoft.Maui
{
static class JavaObjectExtensions
{
const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors;

public static bool IsDisposed(this Java.Lang.Object obj)
{
return obj.Handle == IntPtr.Zero;
Expand All @@ -30,5 +33,18 @@ public static bool IsAlive([NotNullWhen(true)] this global::Android.Runtime.IJav

return !obj.IsDisposed();
}

public static TResult? TryJavaCast<[DynamicallyAccessedMembers (Constructors)] TResult>(this IJavaObject? instance)
where TResult : class, IJavaObject
{
try
{
return instance.JavaCast<TResult>();
}
catch
{
return null;
}
}
}
}

0 comments on commit a8367fc

Please sign in to comment.