mirror of
https://github.com/bitwarden/android.git
synced 2024-12-27 11:28:28 +03:00
PM-3350 Fixed/Updated all MAUI-Migration TODOs
This commit is contained in:
parent
16ada4993c
commit
1a0b52d644
15 changed files with 51 additions and 127 deletions
|
@ -11,10 +11,10 @@
|
|||
<Grid RowSpacing="0"
|
||||
ColumnSpacing="0">
|
||||
<Grid.Behaviors>
|
||||
<!--TODO: [MAUI-Migration] Currently using a "copied" implementation from the github issue in the link until they add this to the Community Toolkit ( https://github.com/CommunityToolkit/Maui/issues/86 ) -->
|
||||
<!--TODO: [TouchEffect] Currently using a "copied" implementation from the github issue in the link until they add this to the Community Toolkit ( https://github.com/CommunityToolkit/Maui/issues/86 ) -->
|
||||
<behaviors:TouchBehavior NativeAnimation="True"
|
||||
LongPressCommand="{Binding LongPressAccountCommand, Source={x:Reference _accountView}}"
|
||||
LongPressCommandParameter="{Binding .BindingContext, Source={x:Reference _accountView}}" />
|
||||
LongPressCommandParameter="{Binding BindingContext, Source={x:Reference _accountView}}" />
|
||||
</Grid.Behaviors>
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding SelectAccountCommand, Source={x:Reference _accountView}}" CommandParameter="{Binding .}" />
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Bit.App.Controls
|
|||
|
||||
private Task<Stream> GetStreamAsync(CancellationToken userToken = new CancellationToken())
|
||||
{
|
||||
// TODO: [MAUI-Migration] [Critical] now methods are private protected so cannot be used here, figure out workaround
|
||||
// TODO: [MAUI-Avatar] now methods are private protected so cannot be used here, figure out workaround
|
||||
//OnLoadingStarted();
|
||||
//userToken.Register(CancellationTokenSource.Cancel);
|
||||
var result = Draw();
|
||||
|
|
|
@ -6,16 +6,15 @@ namespace Bit.App.Controls
|
|||
{
|
||||
public ExtendedGrid()
|
||||
{
|
||||
#if ANDROID
|
||||
// Add Android Ripple effect. Eventually we should be able to replace this with the Maui Community Toolkit implementation. (https://github.com/CommunityToolkit/Maui/issues/86)
|
||||
// [MAUI-Migration] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*")
|
||||
if (DeviceInfo.Platform == DevicePlatform.Android)
|
||||
// TODO: [TouchEffect] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*")
|
||||
var touchBehavior = new TouchBehavior()
|
||||
{
|
||||
var touchBehavior = new TouchBehavior()
|
||||
{
|
||||
NativeAnimation = true
|
||||
};
|
||||
Behaviors.Add(touchBehavior);
|
||||
}
|
||||
NativeAnimation = true
|
||||
};
|
||||
Behaviors.Add(touchBehavior);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,16 +6,15 @@ namespace Bit.App.Controls
|
|||
{
|
||||
public ExtendedStackLayout()
|
||||
{
|
||||
#if ANDROID
|
||||
// Add Android Ripple effect. Eventually we should be able to replace this with the Maui Community Toolkit implementation. (https://github.com/CommunityToolkit/Maui/issues/86)
|
||||
// [MAUI-Migration] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*")
|
||||
if (DeviceInfo.Platform == DevicePlatform.Android)
|
||||
// TODO: [TouchEffect] When this TouchBehavior is replaced we can delete the existing TouchBehavior support files (which is all the files and folders inside "Core.Behaviors.PlatformBehaviors.MCTTouch.*")
|
||||
var touchBehavior = new TouchBehavior()
|
||||
{
|
||||
var touchBehavior = new TouchBehavior()
|
||||
{
|
||||
NativeAnimation = true
|
||||
};
|
||||
Behaviors.Add(touchBehavior);
|
||||
}
|
||||
NativeAnimation = true
|
||||
};
|
||||
Behaviors.Add(touchBehavior);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,6 @@
|
|||
AutomationId="SendHideTextByDefaultToggle" />
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
<!--TODO: [MAUI-Migration] xct:TouchEffect.Command="{Binding ToggleOptionsCommand}" for below ( https://github.com/CommunityToolkit/Maui/issues/86 ) -->
|
||||
<StackLayout
|
||||
Orientation="Horizontal"
|
||||
Spacing="0"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Bit.App.Styles.Light">
|
||||
|
@ -35,7 +35,6 @@
|
|||
<Color x:Key="ListHeaderTextColor">#175DDC</Color>
|
||||
<Color x:Key="ListHeaderBackgroundColor">#efeff4</Color>
|
||||
|
||||
<!--[MAUI-Migration][Color-default]-->
|
||||
<Color x:Key="SliderThumbColor">#ffffff</Color>
|
||||
<Color x:Key="SliderThumbBorderColor">#b5b5b5</Color>
|
||||
<Color x:Key="SliderTrackMinColor">#175DDC</Color>
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace Bit.Core.Services
|
|||
_userId = await ServiceContainer.Resolve<IStateService>("stateService").GetActiveUserIdAsync();
|
||||
_appId = await ServiceContainer.Resolve<IAppIdService>("appIdService").GetAppIdAsync();
|
||||
|
||||
// TODO: [MAUI-Migration] [Critical]
|
||||
// TODO: [Error-Reporting]
|
||||
//switch (device)
|
||||
//{
|
||||
// case Enums.DeviceType.Android:
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Bit.Core.Services
|
|||
#if !FDROID
|
||||
// just in case the caller throws the exception in a moment where the logger can't be resolved
|
||||
// we need to track the error as well
|
||||
// [MAUI-Migration] [Critical]
|
||||
// TODO: [Error-Reporting]
|
||||
//Microsoft.AppCenter.Crashes.Crashes.TrackError(ex);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Bit.Core.Resources.Localization;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Domain;
|
||||
using Bit.Core.Resources.Localization;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui;
|
||||
|
||||
namespace Bit.App.Utilities.AccountManagement
|
||||
{
|
||||
|
@ -145,7 +141,7 @@ namespace Bit.App.Utilities.AccountManagement
|
|||
switch (message.Command)
|
||||
{
|
||||
case AccountsManagerMessageCommands.LOCKED:
|
||||
await Device.InvokeOnMainThreadAsync(() => LockedAsync(message.Data as Tuple<string, bool>));
|
||||
await MainThread.InvokeOnMainThreadAsync(() => LockedAsync(message.Data as Tuple<string, bool>));
|
||||
break;
|
||||
case AccountsManagerMessageCommands.LOCK_VAULT:
|
||||
await _vaultTimeoutService.LockAsync(true);
|
||||
|
@ -155,7 +151,7 @@ namespace Bit.App.Utilities.AccountManagement
|
|||
var userId = extras?.Item1;
|
||||
var userInitiated = extras?.Item2 ?? true;
|
||||
var expired = extras?.Item3 ?? false;
|
||||
await Device.InvokeOnMainThreadAsync(() => LogOutAsync(userId, userInitiated, expired));
|
||||
await MainThread.InvokeOnMainThreadAsync(() => LogOutAsync(userId, userInitiated, expired));
|
||||
break;
|
||||
case AccountsManagerMessageCommands.LOGGED_OUT:
|
||||
// Clean up old migrated key if they ever log out.
|
||||
|
@ -192,7 +188,7 @@ namespace Bit.App.Utilities.AccountManagement
|
|||
|
||||
var autoPromptBiometric = !userInitiated;
|
||||
// TODO Xamarin.Forms.Device.RuntimePlatform is no longer supported. Use Microsoft.Maui.Devices.DeviceInfo.Platform instead. For more details see https://learn.microsoft.com/en-us/dotnet/maui/migration/forms-projects#device-changes
|
||||
if (autoPromptBiometric && Device.RuntimePlatform == Device.iOS)
|
||||
if (autoPromptBiometric && DeviceInfo.Platform == DevicePlatform.iOS)
|
||||
{
|
||||
var vaultTimeout = await _stateService.GetVaultTimeoutAsync();
|
||||
if (vaultTimeout == 0)
|
||||
|
@ -203,13 +199,13 @@ namespace Bit.App.Utilities.AccountManagement
|
|||
|
||||
await _accountsManagerHost.SetPreviousPageInfoAsync();
|
||||
|
||||
await Device.InvokeOnMainThreadAsync(() => _accountsManagerHost.Navigate(NavigationTarget.Lock, new LockNavigationParams(autoPromptBiometric)));
|
||||
await MainThread.InvokeOnMainThreadAsync(() => _accountsManagerHost.Navigate(NavigationTarget.Lock, new LockNavigationParams(autoPromptBiometric)));
|
||||
}
|
||||
|
||||
private async Task AddAccountAsync()
|
||||
{
|
||||
await AppHelpers.ClearServiceCacheAsync();
|
||||
await Device.InvokeOnMainThreadAsync(() =>
|
||||
await MainThread.InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
Options.HideAccountSwitcher = false;
|
||||
_accountsManagerHost.Navigate(NavigationTarget.HomeLogin);
|
||||
|
@ -234,7 +230,7 @@ namespace Bit.App.Utilities.AccountManagement
|
|||
private async Task SwitchedAccountAsync()
|
||||
{
|
||||
await AppHelpers.OnAccountSwitchAsync();
|
||||
await Device.InvokeOnMainThreadAsync(async () =>
|
||||
await MainThread.InvokeOnMainThreadAsync(async () =>
|
||||
{
|
||||
if (await _vaultTimeoutService.ShouldTimeoutAsync())
|
||||
{
|
||||
|
|
|
@ -8,7 +8,8 @@ using System.ComponentModel;
|
|||
|
||||
namespace Bit.Core.Utilities
|
||||
{
|
||||
// TODO: [MAUI-Migration] CHECK WHEN MIGRATION IS DONE
|
||||
// TODO: Review this from time to time in case this gets added to MAUI or some toolkit, for now the api/feature
|
||||
// has been rejected: https://github.com/CommunityToolkit/dotnet/issues/256
|
||||
|
||||
/// <summary>
|
||||
/// Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
// TODO: [MAUI-Migration] Check if moving this to the main project works for extensions.
|
||||
|
||||
//using Bit.iOS.Core.Effects;
|
||||
//using UIKit;
|
||||
//using Xamarin.Forms;
|
||||
//using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
//[assembly: ResolutionGroupName("Bitwarden")]
|
||||
//[assembly: ExportEffect(typeof(ScrollEnabledEffect), "ScrollEnabledEffect")]
|
||||
//namespace Bit.iOS.Core.Effects
|
||||
//{
|
||||
// public class ScrollEnabledEffect : PlatformEffect
|
||||
// {
|
||||
// protected override void OnAttached()
|
||||
// {
|
||||
// // this can be for any view that inherits from UIScrollView like UITextView.
|
||||
// if (Element != null && Control is UIScrollView scrollView)
|
||||
// {
|
||||
// scrollView.ScrollEnabled = App.Effects.ScrollEnabledEffect.GetIsScrollEnabled(Element);
|
||||
// }
|
||||
// }
|
||||
|
||||
// protected override void OnDetached()
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -1,39 +0,0 @@
|
|||
// TODO: [MAUI-Migration] Check if moving this to the main project works for extensions.
|
||||
|
||||
//using Bit.iOS.Core.Effects;
|
||||
//using UIKit;
|
||||
//using Xamarin.Forms;
|
||||
//using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
//[assembly: ExportEffect(typeof(ScrollViewContentInsetAdjustmentBehaviorEffect), nameof(ScrollViewContentInsetAdjustmentBehaviorEffect))]
|
||||
//namespace Bit.iOS.Core.Effects
|
||||
//{
|
||||
// public class ScrollViewContentInsetAdjustmentBehaviorEffect : PlatformEffect
|
||||
// {
|
||||
// protected override void OnAttached()
|
||||
// {
|
||||
// if (Element != null && Control is UIScrollView scrollView)
|
||||
// {
|
||||
// switch (App.Effects.ScrollViewContentInsetAdjustmentBehaviorEffect.GetContentInsetAdjustmentBehavior(Element))
|
||||
// {
|
||||
// case App.Effects.ScrollContentInsetAdjustmentBehavior.Automatic:
|
||||
// scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Automatic;
|
||||
// break;
|
||||
// case App.Effects.ScrollContentInsetAdjustmentBehavior.ScrollableAxes:
|
||||
// scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.ScrollableAxes;
|
||||
// break;
|
||||
// case App.Effects.ScrollContentInsetAdjustmentBehavior.Never:
|
||||
// scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never;
|
||||
// break;
|
||||
// case App.Effects.ScrollContentInsetAdjustmentBehavior.Always:
|
||||
// scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Always;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// protected override void OnDetached()
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -21,7 +21,7 @@ namespace Bit.iOS.Core.Utilities
|
|||
_logger = ServiceContainer.Resolve<ILogger>("logger");
|
||||
}
|
||||
|
||||
public async Task<UIImage> CreateAvatarImageAsync()
|
||||
public async Task<UIImage?> CreateAvatarImageAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -66,11 +66,11 @@ namespace Bit.iOS.Core.Utilities
|
|||
overlay.BindingContext = vm;
|
||||
overlay.IsVisible = false;
|
||||
|
||||
// TODO: [MAUI-Migration] [Critical] check how to create a native view here.
|
||||
//var renderer = Platform.CreateRenderer(overlay.Content);
|
||||
//renderer.SetElementSize(new Size(containerView.Frame.Size.Width, containerView.Frame.Size.Height));
|
||||
if (MauiContextSingleton.Instance.MauiContext is null)
|
||||
{
|
||||
throw new ArgumentNullException("Maui context should be set to create the account switching overlay view");
|
||||
}
|
||||
|
||||
//var view = renderer.NativeView;
|
||||
var view = overlay.ToPlatform(MauiContextSingleton.Instance.MauiContext);
|
||||
view.TranslatesAutoresizingMaskIntoConstraints = false;
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ namespace Bit.iOS.Core.Utilities
|
|||
{
|
||||
public static class FontElementExtensions
|
||||
{
|
||||
// TODO: [MAUI-Migration] [Critical] Compiling but big untested change
|
||||
|
||||
public static UIFont ToUIFont(this Microsoft.Maui.Font font)
|
||||
{
|
||||
var fontSize = font.Size;
|
||||
|
|
|
@ -1,64 +1,64 @@
|
|||
using Bit.App.Utilities;
|
||||
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
|
||||
using Microsoft.Maui.Platform;
|
||||
using UIKit;
|
||||
|
||||
namespace Bit.iOS.Core.Utilities
|
||||
{
|
||||
public static class ThemeHelpers
|
||||
{
|
||||
public static bool LightTheme = true;
|
||||
public static bool LightTheme { get; private set; } = true;
|
||||
|
||||
public static UIColor SplashBackgroundColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("SplashBackgroundColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("SplashBackgroundColor").ToPlatform();
|
||||
}
|
||||
public static UIColor BackgroundColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("BackgroundColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("BackgroundColor").ToPlatform();
|
||||
}
|
||||
public static UIColor MutedColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("MutedColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("MutedColor").ToPlatform();
|
||||
}
|
||||
public static UIColor SuccessColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("SuccessColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("SuccessColor").ToPlatform();
|
||||
}
|
||||
public static UIColor DangerColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("DangerColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("DangerColor").ToPlatform();
|
||||
}
|
||||
public static UIColor PrimaryColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("PrimaryColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("PrimaryColor").ToPlatform();
|
||||
}
|
||||
public static UIColor TextColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("TextColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("TextColor").ToPlatform();
|
||||
}
|
||||
public static UIColor SeparatorColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("SeparatorColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("SeparatorColor").ToPlatform();
|
||||
}
|
||||
public static UIColor ListHeaderBackgroundColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("ListHeaderBackgroundColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("ListHeaderBackgroundColor").ToPlatform();
|
||||
}
|
||||
public static UIColor NavBarBackgroundColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("NavigationBarBackgroundColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("NavigationBarBackgroundColor").ToPlatform();
|
||||
}
|
||||
public static UIColor NavBarTextColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("NavigationBarTextColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("NavigationBarTextColor").ToPlatform();
|
||||
}
|
||||
public static UIColor TabBarBackgroundColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("TabBarBackgroundColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("TabBarBackgroundColor").ToPlatform();
|
||||
}
|
||||
public static UIColor TabBarItemColor
|
||||
{
|
||||
get => ThemeManager.GetResourceColor("TabBarItemColor").ToUIColor();
|
||||
get => ThemeManager.GetResourceColor("TabBarItemColor").ToPlatform();
|
||||
}
|
||||
|
||||
public static void SetAppearance(string theme, bool osDarkModeEnabled)
|
||||
|
@ -75,8 +75,7 @@ namespace Bit.iOS.Core.Utilities
|
|||
|
||||
public static UIFont GetDangerFont()
|
||||
{
|
||||
// TODO: [MAUI-Migration] [Deprecated] NamedSizes are deprecated on MAUI
|
||||
return Microsoft.Maui.Font.SystemFontOfSize(Device.GetNamedSize(NamedSize.Small, typeof(UILabel)), FontWeight.Bold).ToUIFont();
|
||||
return Microsoft.Maui.Font.SystemFontOfSize(14, FontWeight.Bold).ToUIFont();
|
||||
}
|
||||
|
||||
private static void SetThemeVariables(string theme, bool osDarkModeEnabled)
|
||||
|
|
Loading…
Reference in a new issue