From 759627b3c7a716aebedd6dae87e121975c72c998 Mon Sep 17 00:00:00 2001 From: Dinis Vieira Date: Wed, 7 Feb 2024 17:50:07 +0000 Subject: [PATCH 1/5] PM-6077 Separated Android and iOS HybridWebViewHandler so that it can be used on iOS.Core (#2983) --- src/App/Handlers/HybridWebViewHandler.cs | 25 ------------------- src/App/MauiProgram.cs | 2 +- .../Android/Handlers/HybridWebViewHandler.cs | 11 +++++++- .../Handlers/HybridWebViewHandler.cs | 13 ++++++++-- src/iOS.Core/Utilities/iOSCoreHelpers.cs | 1 + 5 files changed, 23 insertions(+), 29 deletions(-) delete mode 100644 src/App/Handlers/HybridWebViewHandler.cs rename src/{App/Platforms/iOS => iOS.Core}/Handlers/HybridWebViewHandler.cs (86%) diff --git a/src/App/Handlers/HybridWebViewHandler.cs b/src/App/Handlers/HybridWebViewHandler.cs deleted file mode 100644 index eb8acc495..000000000 --- a/src/App/Handlers/HybridWebViewHandler.cs +++ /dev/null @@ -1,25 +0,0 @@ -#if IOS || MACCATALYST -using PlatformView = WebKit.WKWebView; -#elif ANDROID -using PlatformView = Android.Webkit.WebView; -#elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID) -using PlatformView = System.Object; -#endif - -using Bit.App.Controls; -using Microsoft.Maui.Handlers; - -namespace Bit.App.Handlers -{ - public partial class HybridWebViewHandler - { - public static PropertyMapper PropertyMapper = new PropertyMapper(ViewHandler.ViewMapper) - { - [nameof(HybridWebView.Uri)] = MapUri - }; - - public HybridWebViewHandler() : base(PropertyMapper) - { - } - } -} diff --git a/src/App/MauiProgram.cs b/src/App/MauiProgram.cs index 0822e59a7..1157399e5 100644 --- a/src/App/MauiProgram.cs +++ b/src/App/MauiProgram.cs @@ -13,7 +13,6 @@ }, handlers => { - handlers.AddHandler(typeof(Bit.App.Controls.HybridWebView), typeof(Bit.App.Handlers.HybridWebViewHandler)); #if ANDROID Bit.App.Handlers.EntryHandlerMappings.Setup(); Bit.App.Handlers.EditorHandlerMappings.Setup(); @@ -28,6 +27,7 @@ Bit.App.Handlers.ButtonHandlerMappings.Setup(); Bit.App.Handlers.ToolbarHandlerMappings.Setup(); + handlers.AddHandler(typeof(Bit.App.Controls.HybridWebView), typeof(Bit.App.Handlers.HybridWebViewHandler)); handlers.AddHandler(typeof(Bit.App.Pages.TabsPage), typeof(Bit.App.Handlers.CustomTabbedPageHandler)); handlers.AddHandler(typeof(Bit.App.Controls.ExtendedDatePicker), typeof(Bit.App.Handlers.ExtendedDatePickerHandler)); #else diff --git a/src/App/Platforms/Android/Handlers/HybridWebViewHandler.cs b/src/App/Platforms/Android/Handlers/HybridWebViewHandler.cs index 7c7bcfbd5..708b72743 100644 --- a/src/App/Platforms/Android/Handlers/HybridWebViewHandler.cs +++ b/src/App/Platforms/Android/Handlers/HybridWebViewHandler.cs @@ -6,10 +6,19 @@ using AWebkit = Android.Webkit; namespace Bit.App.Handlers { - public partial class HybridWebViewHandler : ViewHandler + public class HybridWebViewHandler : ViewHandler { private const string JSFunction = "function invokeCSharpAction(data){jsBridge.invokeAction(data);}"; + public static PropertyMapper PropertyMapper = new PropertyMapper(ViewHandler.ViewMapper) + { + [nameof(HybridWebView.Uri)] = MapUri + }; + + public HybridWebViewHandler() : base(PropertyMapper) + { + } + public HybridWebViewHandler([NotNull] IPropertyMapper mapper, CommandMapper commandMapper = null) : base(mapper, commandMapper) { } diff --git a/src/App/Platforms/iOS/Handlers/HybridWebViewHandler.cs b/src/iOS.Core/Handlers/HybridWebViewHandler.cs similarity index 86% rename from src/App/Platforms/iOS/Handlers/HybridWebViewHandler.cs rename to src/iOS.Core/Handlers/HybridWebViewHandler.cs index 694128f42..537555dec 100644 --- a/src/App/Platforms/iOS/Handlers/HybridWebViewHandler.cs +++ b/src/iOS.Core/Handlers/HybridWebViewHandler.cs @@ -5,15 +5,24 @@ using Foundation; using Microsoft.Maui.Handlers; using WebKit; -namespace Bit.App.Handlers +namespace Bit.iOS.Core.Handlers { - public partial class HybridWebViewHandler : ViewHandler + public class HybridWebViewHandler : ViewHandler { private const string JSFunction = "function invokeCSharpAction(data){window.webkit.messageHandlers.invokeAction.postMessage(data);}"; private WKUserContentController _userController; + public static PropertyMapper PropertyMapper = new PropertyMapper(ViewHandler.ViewMapper) + { + [nameof(HybridWebView.Uri)] = MapUri + }; + + public HybridWebViewHandler() : base(PropertyMapper) + { + } + public HybridWebViewHandler([NotNull] IPropertyMapper mapper, CommandMapper commandMapper = null) : base(mapper, commandMapper) { } diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index cf679e9ab..8e55434f1 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -48,6 +48,7 @@ namespace Bit.iOS.Core.Utilities public static void ConfigureMAUIHandlers(IMauiHandlersCollection handlers) { + handlers.AddHandler(typeof(HybridWebView), typeof(Handlers.HybridWebViewHandler)); handlers.AddHandler(typeof(TabsPage), typeof(Handlers.CustomTabbedHandler)); handlers.AddHandler(typeof(NavigationPage), typeof(Handlers.CustomNavigationHandler)); handlers.AddHandler(typeof(ViewCell), typeof(Handlers.CustomViewCellHandler)); From 37208571fe4dcdbf906ddabb10ae44e85831f400 Mon Sep 17 00:00:00 2001 From: Dinis Vieira Date: Wed, 7 Feb 2024 19:08:51 +0000 Subject: [PATCH 2/5] [PM-5907] Fix for incorrect TOTP white text color on label when using light theme on iOS (#2982) * PM-5907 workaround for incorrect textcolor when programmatically changing text on Entry * Update src/Core/Pages/Vault/CipherAddEditPage.xaml.cs Co-authored-by: Federico Maccaroni --------- Co-authored-by: Federico Maccaroni --- src/Core/Pages/Vault/CipherAddEditPage.xaml.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Core/Pages/Vault/CipherAddEditPage.xaml.cs b/src/Core/Pages/Vault/CipherAddEditPage.xaml.cs index 1ff0be66c..2aa659d1b 100644 --- a/src/Core/Pages/Vault/CipherAddEditPage.xaml.cs +++ b/src/Core/Pages/Vault/CipherAddEditPage.xaml.cs @@ -268,6 +268,14 @@ namespace Bit.App.Pages { await Navigation.PopModalAsync(); await _vm.UpdateTotpKeyAsync(key); + +#if IOS + // HACK: To avoid a bug that incorrectly sets the TextColor when changing text + // programatically we need to set it to null and back to the correct color + // MAUI issue https://github.com/dotnet/maui/pull/20100 + _loginTotpEntry.TextColor = null; + _loginTotpEntry.TextColor = ThemeManager.GetResourceColor("TextColor"); +#endif } catch (Exception ex) { From 8d5006c0bdfc226c33739424b383c0bafe4ad432 Mon Sep 17 00:00:00 2001 From: Dinis Vieira Date: Wed, 7 Feb 2024 19:09:18 +0000 Subject: [PATCH 3/5] [PM-5906] Fix for incorrect Send MaxAccess white text color on label when using light theme on iOS (#2981) * PM-5906 workaround for incorrect textcolor when programmatically changing text on Entry * Update src/Core/Pages/Send/SendAddEditPage.xaml.cs Co-authored-by: Federico Maccaroni --------- Co-authored-by: Federico Maccaroni --- src/Core/Pages/Send/SendAddEditPage.xaml.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Core/Pages/Send/SendAddEditPage.xaml.cs b/src/Core/Pages/Send/SendAddEditPage.xaml.cs index a41efe58c..134d4608a 100644 --- a/src/Core/Pages/Send/SendAddEditPage.xaml.cs +++ b/src/Core/Pages/Send/SendAddEditPage.xaml.cs @@ -181,6 +181,16 @@ namespace Bit.App.Pages private void OnMaxAccessCountTextChanged(object sender, TextChangedEventArgs e) { + var maxAccessEntry = (Microsoft.Maui.Controls.Entry)sender; + +#if IOS + // HACK: To avoid a bug that incorrectly sets the TextColor when changing text + // programatically we need to set it to null and back to the correct color + // MAUI issue https://github.com/dotnet/maui/pull/20100 + maxAccessEntry.TextColor = null; + maxAccessEntry.TextColor = ThemeManager.GetResourceColor("TextColor"); +#endif + if (string.IsNullOrWhiteSpace(e.NewTextValue)) { _vm.MaxAccessCount = null; @@ -190,7 +200,7 @@ namespace Bit.App.Pages // accept only digits if (!int.TryParse(e.NewTextValue, out int _)) { - ((Microsoft.Maui.Controls.Entry)sender).Text = e.OldTextValue; + maxAccessEntry.Text = e.OldTextValue; } } From f30158adf59cab1eed0f810a571692d34f4da4c6 Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:25:16 -0500 Subject: [PATCH 4/5] Bumped version to 2024.2.1 (#2985) --- src/Android/Properties/AndroidManifest.xml | 2 +- src/iOS.Autofill/Info.plist | 2 +- src/iOS.Extension/Info.plist | 2 +- src/iOS.ShareExtension/Info.plist | 2 +- src/iOS/Info.plist | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Android/Properties/AndroidManifest.xml b/src/Android/Properties/AndroidManifest.xml index 7d73bc47c..4a38955a6 100644 --- a/src/Android/Properties/AndroidManifest.xml +++ b/src/Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/src/iOS.Autofill/Info.plist b/src/iOS.Autofill/Info.plist index 072e2547b..ff96f15aa 100644 --- a/src/iOS.Autofill/Info.plist +++ b/src/iOS.Autofill/Info.plist @@ -11,7 +11,7 @@ CFBundleIdentifier com.8bit.bitwarden.autofill CFBundleShortVersionString - 2024.2.0 + 2024.2.1 CFBundleVersion 1 CFBundleLocalizations diff --git a/src/iOS.Extension/Info.plist b/src/iOS.Extension/Info.plist index 10b2611be..24289c18e 100644 --- a/src/iOS.Extension/Info.plist +++ b/src/iOS.Extension/Info.plist @@ -11,7 +11,7 @@ CFBundleIdentifier com.8bit.bitwarden.find-login-action-extension CFBundleShortVersionString - 2024.2.0 + 2024.2.1 CFBundleLocalizations en diff --git a/src/iOS.ShareExtension/Info.plist b/src/iOS.ShareExtension/Info.plist index 2b274c146..ba68616b6 100644 --- a/src/iOS.ShareExtension/Info.plist +++ b/src/iOS.ShareExtension/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 2024.2.0 + 2024.2.1 CFBundleVersion 1 MinimumOSVersion diff --git a/src/iOS/Info.plist b/src/iOS/Info.plist index 7fcff1107..d82c64a97 100644 --- a/src/iOS/Info.plist +++ b/src/iOS/Info.plist @@ -11,7 +11,7 @@ CFBundleIdentifier com.8bit.bitwarden CFBundleShortVersionString - 2024.2.0 + 2024.2.1 CFBundleVersion 1 CFBundleIconName From 4631a9e62c7e7557c0ff3562675afd523698d60d Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Thu, 8 Feb 2024 12:31:52 -0300 Subject: [PATCH 5/5] PM-3349 PM-3350 Fixed Unit tests because of referencing FFImageLoading when it's not possible --- src/Core/Controls/CachedImage.cs | 5 +++++ src/Core/Controls/CipherViewCell/BaseCipherViewCell.cs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/Core/Controls/CachedImage.cs b/src/Core/Controls/CachedImage.cs index da4917d81..3f95dc1bf 100644 --- a/src/Core/Controls/CachedImage.cs +++ b/src/Core/Controls/CachedImage.cs @@ -32,6 +32,11 @@ get { return (Aspect)GetValue(AspectProperty); } set { SetValue(AspectProperty, value); } } + + public bool IsLoading { get; set; } + + public event EventHandler Success; + public event EventHandler Error; } #endif } diff --git a/src/Core/Controls/CipherViewCell/BaseCipherViewCell.cs b/src/Core/Controls/CipherViewCell/BaseCipherViewCell.cs index 15bd0dd7f..69fbd75f5 100644 --- a/src/Core/Controls/CipherViewCell/BaseCipherViewCell.cs +++ b/src/Core/Controls/CipherViewCell/BaseCipherViewCell.cs @@ -47,6 +47,7 @@ namespace Bit.App.Controls }); } +#if !UT public void Icon_Success(object sender, FFImageLoading.Maui.CachedImageEvents.SuccessEventArgs e) { if (BindingContext is CipherItemViewModel cipherItemVM) @@ -72,6 +73,10 @@ namespace Bit.App.Controls IconPlaceholder.IsVisible = true; }); } +#else + private void Icon_Success(object sender, EventArgs e) {} + private void Icon_Error(object sender, EventArgs e) {} +#endif } public class StubBaseCipherViewCellSoLinkerDoesntRemoveMethods : BaseCipherViewCell @@ -81,6 +86,7 @@ namespace Bit.App.Controls public static void CallThisSoLinkerDoesntRemoveMethods() { +#if !UT var stub = new StubBaseCipherViewCellSoLinkerDoesntRemoveMethods(); try @@ -98,6 +104,7 @@ namespace Bit.App.Controls catch (Exception) { } +#endif } } }