mirror of
https://github.com/bitwarden/mobile
synced 2026-01-03 17:13:50 +00:00
[Auto Logout] Final review of feature (#932)
* Initial commit of LockService name refactor (#831) * [Auto-Logout] Update Service layer logic (#835) * Initial commit of service logic update * Added default value for action * Updated ToggleTokensAsync conditional * Removed unused variables, updated action conditional * Initial commit: lockOption/lock refactor app layer (#840) * [Auto-Logout] Settings Refactor - Application Layer Part 2 (#844) * Initial commit of app layer part 2 * Updated biometrics position * Reverted resource name refactor * LockOptions refactor revert * Updated method casing :: Removed VaultTimeout prefix for timeouts * Fixed dupe string resource (#854) * Updated dependency to use VaultTimeoutService (#896) * [Auto Logout] Xamarin Forms in AutoFill flow (iOS) (#902) * fix typo in PINRequireMasterPasswordRestart (#900) * initial commit for xf usage in autofill * Fixed databinding for hint button * Updated Two Factor page launch - removed unused imports * First pass at broadcast/messenger implentation for autofill * setting theme in extension using theme manager * extension app resources * App resources from main app * fix ref to twoFactorPage * apply resources to page * load empty app for sytling in extension * move ios renderers to ios core * static ref to resources and GetResourceColor helper * fix method ref * move application.current.resources refs to helper * switch login page alerts to device action dialogs * run on main thread * showDialog with device action service * abstract action sheet to device action service * add support for yubikey * add yubikey iimages to extension * support close button action * add support to action extension * remove empty lines Co-authored-by: Jonas Kittner <54631600+theendlessriver13@users.noreply.github.com> Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com> * [Auto Logout] Update lock option to be default value (#929) * Initial commit - make lock action default * Removed extra whitespace Co-authored-by: Jonas Kittner <54631600+theendlessriver13@users.noreply.github.com> Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com> Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
This commit is contained in:
@@ -15,8 +15,8 @@ namespace Bit.iOS.Core.Utilities
|
||||
if (await AutofillEnabled())
|
||||
{
|
||||
var storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
var lockService = ServiceContainer.Resolve<ILockService>("lockService");
|
||||
if (await lockService.IsLockedAsync())
|
||||
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||
if (await vaultTimeoutService.IsLockedAsync())
|
||||
{
|
||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, true);
|
||||
return;
|
||||
|
||||
@@ -27,12 +27,18 @@ namespace Bit.iOS.Core.Utilities
|
||||
return alert;
|
||||
}
|
||||
|
||||
public static UIAlertController CreateAlert(string title, string message, string accept, Action<UIAlertAction> acceptHandle = null)
|
||||
public static UIAlertController CreateAlert(string title, string message, string accept,
|
||||
Action<UIAlertAction> acceptHandle = null, string cancel = null, Action<UIAlertAction> cancelHandle = null)
|
||||
{
|
||||
var alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);
|
||||
var oldFrame = alert.View.Frame;
|
||||
alert.View.Frame = new RectangleF((float)oldFrame.X, (float)oldFrame.Y, (float)oldFrame.Width, (float)oldFrame.Height - 20);
|
||||
alert.View.Frame = new RectangleF((float)oldFrame.X, (float)oldFrame.Y, (float)oldFrame.Width,
|
||||
(float)oldFrame.Height - 20);
|
||||
alert.AddAction(UIAlertAction.Create(accept, UIAlertActionStyle.Default, acceptHandle));
|
||||
if (!string.IsNullOrWhiteSpace(cancel))
|
||||
{
|
||||
alert.AddAction(UIAlertAction.Create(cancel, UIAlertActionStyle.Default, cancelHandle));
|
||||
}
|
||||
return alert;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Bit.App.Resources;
|
||||
using Bit.App.Services;
|
||||
using Bit.App.Utilities;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.iOS.Core.Services;
|
||||
using CoreNFC;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
@@ -68,6 +71,8 @@ namespace Bit.iOS.Core.Utilities
|
||||
{
|
||||
(ServiceContainer.Resolve<II18nService>("i18nService") as MobileI18nService).Init();
|
||||
ServiceContainer.Resolve<IAuthService>("authService").Init();
|
||||
(ServiceContainer.
|
||||
Resolve<IPlatformUtilsService>("platformUtilsService") as MobilePlatformUtilsService).Init();
|
||||
// Note: This is not awaited
|
||||
var bootstrapTask = BootstrapAsync(postBootstrapFunc);
|
||||
}
|
||||
@@ -79,6 +84,54 @@ namespace Bit.iOS.Core.Utilities
|
||||
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
|
||||
}
|
||||
|
||||
public static void SubscribeBroadcastReceiver(UIViewController controller, NFCNdefReaderSession nfcSession,
|
||||
NFCReaderDelegate nfcDelegate)
|
||||
{
|
||||
var broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
||||
var messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
broadcasterService.Subscribe(nameof(controller), (message) =>
|
||||
{
|
||||
if (message.Command == "showDialog")
|
||||
{
|
||||
var details = message.Data as DialogDetails;
|
||||
var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ?
|
||||
AppResources.Ok : details.ConfirmText;
|
||||
|
||||
NSRunLoop.Main.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
var result = await deviceActionService.DisplayAlertAsync(details.Title, details.Text,
|
||||
details.CancelText, details.ConfirmText);
|
||||
var confirmed = result == details.ConfirmText;
|
||||
messagingService.Send("showDialogResolve", new Tuple<int, bool>(details.DialogId, confirmed));
|
||||
});
|
||||
}
|
||||
else if (message.Command == "listenYubiKeyOTP")
|
||||
{
|
||||
ListenYubiKey((bool)message.Data, deviceActionService, nfcSession, nfcDelegate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void ListenYubiKey(bool listen, IDeviceActionService deviceActionService,
|
||||
NFCNdefReaderSession nfcSession, NFCReaderDelegate nfcDelegate)
|
||||
{
|
||||
if (deviceActionService.SupportsNfc())
|
||||
{
|
||||
nfcSession?.InvalidateSession();
|
||||
nfcSession?.Dispose();
|
||||
nfcSession = null;
|
||||
if (listen)
|
||||
{
|
||||
nfcSession = new NFCNdefReaderSession(nfcDelegate, null, true)
|
||||
{
|
||||
AlertMessage = AppResources.HoldYubikeyNearTop
|
||||
};
|
||||
nfcSession.BeginSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task BootstrapAsync(Func<Task> postBootstrapFunc = null)
|
||||
{
|
||||
var disableFavicon = await ServiceContainer.Resolve<IStorageService>("storageService").GetAsync<bool?>(
|
||||
|
||||
64
src/iOS.Core/Utilities/iOSHelpers.cs
Normal file
64
src/iOS.Core/Utilities/iOSHelpers.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Bit.App.Utilities;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
namespace Bit.iOS.Core.Utilities
|
||||
{
|
||||
public static class iOSHelpers
|
||||
{
|
||||
public static System.nfloat? GetAccessibleFont<T>(double size)
|
||||
{
|
||||
var pointSize = UIFontDescriptor.PreferredBody.PointSize;
|
||||
if (size == Device.GetNamedSize(NamedSize.Large, typeof(T)))
|
||||
{
|
||||
pointSize *= 1.3f;
|
||||
}
|
||||
else if (size == Device.GetNamedSize(NamedSize.Small, typeof(T)))
|
||||
{
|
||||
pointSize *= .8f;
|
||||
}
|
||||
else if (size == Device.GetNamedSize(NamedSize.Micro, typeof(T)))
|
||||
{
|
||||
pointSize *= .6f;
|
||||
}
|
||||
else if (size != Device.GetNamedSize(NamedSize.Default, typeof(T)))
|
||||
{
|
||||
// not using dynamic font sizes, return
|
||||
return null;
|
||||
}
|
||||
return pointSize;
|
||||
}
|
||||
|
||||
public static void SetBottomBorder(UITextField control)
|
||||
{
|
||||
control.BorderStyle = UITextBorderStyle.None;
|
||||
SetBottomBorder(control as UIView);
|
||||
}
|
||||
|
||||
public static void SetBottomBorder(UITextView control)
|
||||
{
|
||||
SetBottomBorder(control as UIView);
|
||||
}
|
||||
|
||||
private static void SetBottomBorder(UIView control)
|
||||
{
|
||||
var borderLine = new UIView
|
||||
{
|
||||
BackgroundColor = ThemeManager.GetResourceColor("BoxBorderColor").ToUIColor(),
|
||||
TranslatesAutoresizingMaskIntoConstraints = false
|
||||
};
|
||||
control.AddSubview(borderLine);
|
||||
control.AddConstraints(new NSLayoutConstraint[]
|
||||
{
|
||||
NSLayoutConstraint.Create(borderLine, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 1f),
|
||||
NSLayoutConstraint.Create(borderLine, NSLayoutAttribute.Leading, NSLayoutRelation.Equal,
|
||||
control, NSLayoutAttribute.Leading, 1, 0),
|
||||
NSLayoutConstraint.Create(borderLine, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal,
|
||||
control, NSLayoutAttribute.Trailing, 1, 0),
|
||||
NSLayoutConstraint.Create(borderLine, NSLayoutAttribute.Top, NSLayoutRelation.Equal,
|
||||
control, NSLayoutAttribute.Bottom, 1, 10f),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user