From a058637403a8d9d6a84f8a9327db623b4c5ab8fd Mon Sep 17 00:00:00 2001 From: "s.leushunou" Date: Fri, 27 Sep 2024 14:19:44 +0200 Subject: [PATCH 1/2] fix attributed string crash --- .../Extensions/NSStringExtensions.cs | 15 ++++++++++++++- .../Softeq.XToolkit.Common.iOS.csproj | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Softeq.XToolkit.Common.iOS/Extensions/NSStringExtensions.cs b/Softeq.XToolkit.Common.iOS/Extensions/NSStringExtensions.cs index 90f4fedd..e1211e82 100644 --- a/Softeq.XToolkit.Common.iOS/Extensions/NSStringExtensions.cs +++ b/Softeq.XToolkit.Common.iOS/Extensions/NSStringExtensions.cs @@ -66,9 +66,22 @@ public static NSMutableAttributedString BuildAttributedStringFromHtml( try { + NSAttributedString? attributedString; + + if (UIDevice.CurrentDevice.CheckSystemVersion(15, 0)) + { + var markdown = new Html2Markdown.Converter().Convert(html); #pragma warning disable CS8601 // Possible null reference assignment. - var attributedString = new NSAttributedString(html, importParams, ref error); + attributedString = new NSAttributedString(markdown, default, default, out error); #pragma warning restore CS8601 // Possible null reference assignment. + } + else + { +#pragma warning disable CS8601 // Possible null reference assignment. + attributedString = new NSAttributedString(html, importParams, ref error); +#pragma warning restore CS8601 // Possible null reference assignment. + } + return new NSMutableAttributedString(attributedString); } catch (Exception ex) diff --git a/Softeq.XToolkit.Common.iOS/Softeq.XToolkit.Common.iOS.csproj b/Softeq.XToolkit.Common.iOS/Softeq.XToolkit.Common.iOS.csproj index 5e128ed8..d30c71b8 100644 --- a/Softeq.XToolkit.Common.iOS/Softeq.XToolkit.Common.iOS.csproj +++ b/Softeq.XToolkit.Common.iOS/Softeq.XToolkit.Common.iOS.csproj @@ -19,4 +19,8 @@ + + + + \ No newline at end of file From 90e608f8d9d9587726f55ea47f5ecbc8cc95e5b1 Mon Sep 17 00:00:00 2001 From: Siarhei Leushunou Date: Thu, 3 Oct 2024 13:46:31 +0200 Subject: [PATCH 2/2] fix crash (#566) * fix attributed string crash * fix limited photo access --- .../Extensions/NSStringExtensions.cs | 11 +++++++++-- .../PluginPermissionStatusExtensions.cs | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Softeq.XToolkit.Common.iOS/Extensions/NSStringExtensions.cs b/Softeq.XToolkit.Common.iOS/Extensions/NSStringExtensions.cs index e1211e82..ffe03ac2 100644 --- a/Softeq.XToolkit.Common.iOS/Extensions/NSStringExtensions.cs +++ b/Softeq.XToolkit.Common.iOS/Extensions/NSStringExtensions.cs @@ -70,10 +70,17 @@ public static NSMutableAttributedString BuildAttributedStringFromHtml( if (UIDevice.CurrentDevice.CheckSystemVersion(15, 0)) { - var markdown = new Html2Markdown.Converter().Convert(html); + if (string.IsNullOrEmpty(html)) + { + attributedString = new NSAttributedString(); + } + else + { + var markdown = new Html2Markdown.Converter().Convert(html); #pragma warning disable CS8601 // Possible null reference assignment. - attributedString = new NSAttributedString(markdown, default, default, out error); + attributedString = new NSAttributedString(markdown, default, default, out error); #pragma warning restore CS8601 // Possible null reference assignment. + } } else { diff --git a/Softeq.XToolkit.Permissions/PluginPermissionStatusExtensions.cs b/Softeq.XToolkit.Permissions/PluginPermissionStatusExtensions.cs index e944f5a3..91fbea2f 100644 --- a/Softeq.XToolkit.Permissions/PluginPermissionStatusExtensions.cs +++ b/Softeq.XToolkit.Permissions/PluginPermissionStatusExtensions.cs @@ -14,6 +14,7 @@ public static PermissionStatus ToPermissionStatus(this PluginPermissionStatus pe { PluginPermissionStatus.Denied => PermissionStatus.Denied, PluginPermissionStatus.Disabled => PermissionStatus.Denied, + PluginPermissionStatus.Limited => PermissionStatus.Granted, PluginPermissionStatus.Granted => PermissionStatus.Granted, PluginPermissionStatus.Restricted => PermissionStatus.Restricted, PluginPermissionStatus.Unknown => PermissionStatus.Unknown,