mirror of
https://github.com/bitwarden/android.git
synced 2024-12-20 08:12:26 +03:00
Save newly added site in extension
This commit is contained in:
parent
066e48a721
commit
549ac1f996
5 changed files with 105 additions and 8 deletions
|
@ -167,7 +167,7 @@ namespace Bit.App.Models
|
||||||
{
|
{
|
||||||
ruleMatches.Add(result);
|
ruleMatches.Add(result);
|
||||||
}
|
}
|
||||||
Debug.WriteLine(string.Format("Domain part {0} matched {1} {2} rules", checkAgainst, result == null ? 0 : 1, rule));
|
//Debug.WriteLine(string.Format("Domain part {0} matched {1} {2} rules", checkAgainst, result == null ? 0 : 1, rule));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,11 +180,11 @@ namespace Bit.App.Models
|
||||||
TLDRule primaryMatch = results.Take(1).SingleOrDefault();
|
TLDRule primaryMatch = results.Take(1).SingleOrDefault();
|
||||||
if(primaryMatch != null)
|
if(primaryMatch != null)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(string.Format("Looks like our match is: {0}, which is a(n) {1} rule.", primaryMatch.Name, primaryMatch.Type));
|
//Debug.WriteLine(string.Format("Looks like our match is: {0}, which is a(n) {1} rule.", primaryMatch.Name, primaryMatch.Type));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.WriteLine(string.Format("No rules matched domain: {0}", domainString));
|
//Debug.WriteLine(string.Format("No rules matched domain: {0}", domainString));
|
||||||
}
|
}
|
||||||
|
|
||||||
return primaryMatch;
|
return primaryMatch;
|
||||||
|
|
|
@ -16,6 +16,8 @@ using Bit.iOS.Extension.Models;
|
||||||
using MobileCoreServices;
|
using MobileCoreServices;
|
||||||
using Plugin.Settings.Abstractions;
|
using Plugin.Settings.Abstractions;
|
||||||
using Plugin.Connectivity;
|
using Plugin.Connectivity;
|
||||||
|
using Acr.UserDialogs;
|
||||||
|
using Plugin.Fingerprint;
|
||||||
|
|
||||||
namespace Bit.iOS.Extension
|
namespace Bit.iOS.Extension
|
||||||
{
|
{
|
||||||
|
@ -96,6 +98,7 @@ namespace Bit.iOS.Extension
|
||||||
.RegisterType<ISiteService, SiteService>(new ContainerControlledLifetimeManager())
|
.RegisterType<ISiteService, SiteService>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<ISyncService, SyncService>(new ContainerControlledLifetimeManager())
|
.RegisterType<ISyncService, SyncService>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<IPasswordGenerationService, PasswordGenerationService>(new ContainerControlledLifetimeManager())
|
.RegisterType<IPasswordGenerationService, PasswordGenerationService>(new ContainerControlledLifetimeManager())
|
||||||
|
.RegisterType<IAppIdService, AppIdService>(new ContainerControlledLifetimeManager())
|
||||||
//.RegisterType<IClipboardService, ClipboardService>(new ContainerControlledLifetimeManager())
|
//.RegisterType<IClipboardService, ClipboardService>(new ContainerControlledLifetimeManager())
|
||||||
// Repositories
|
// Repositories
|
||||||
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
||||||
|
@ -104,9 +107,9 @@ namespace Bit.iOS.Extension
|
||||||
.RegisterType<ISiteApiRepository, SiteApiRepository>(new ContainerControlledLifetimeManager())
|
.RegisterType<ISiteApiRepository, SiteApiRepository>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<IAuthApiRepository, AuthApiRepository>(new ContainerControlledLifetimeManager())
|
.RegisterType<IAuthApiRepository, AuthApiRepository>(new ContainerControlledLifetimeManager())
|
||||||
// Other
|
// Other
|
||||||
.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager());
|
.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager())
|
||||||
//.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager())
|
.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager())
|
||||||
//.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager());
|
.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager());
|
||||||
|
|
||||||
ISettings settings = new Settings("group.com.8bit.bitwarden");
|
ISettings settings = new Settings("group.com.8bit.bitwarden");
|
||||||
container.RegisterInstance(settings, new ContainerControlledLifetimeManager());
|
container.RegisterInstance(settings, new ContainerControlledLifetimeManager());
|
||||||
|
|
|
@ -9,6 +9,11 @@ using Bit.iOS.Core.Views;
|
||||||
using Bit.iOS.Extension.Models;
|
using Bit.iOS.Extension.Models;
|
||||||
using Foundation;
|
using Foundation;
|
||||||
using UIKit;
|
using UIKit;
|
||||||
|
using XLabs.Ioc;
|
||||||
|
using Bit.App;
|
||||||
|
using Plugin.Connectivity.Abstractions;
|
||||||
|
using Acr.UserDialogs;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace Bit.iOS.Extension
|
namespace Bit.iOS.Extension
|
||||||
{
|
{
|
||||||
|
@ -83,14 +88,66 @@ namespace Bit.iOS.Extension
|
||||||
base.ViewDidLoad();
|
base.ViewDidLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void CancelBarButton_Activated(UIBarButtonItem sender)
|
async partial void CancelBarButton_Activated(UIBarButtonItem sender)
|
||||||
{
|
{
|
||||||
DismissViewController(true, null);
|
DismissViewController(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void SaveBarButton_Activated(UIBarButtonItem sender)
|
async partial void SaveBarButton_Activated(UIBarButtonItem sender)
|
||||||
{
|
{
|
||||||
|
var siteService = Resolver.Resolve<ISiteService>();
|
||||||
|
var connectivity = Resolver.Resolve<IConnectivity>();
|
||||||
|
var userDialogs = Resolver.Resolve<IUserDialogs>();
|
||||||
|
|
||||||
|
if(!connectivity.IsConnected)
|
||||||
|
{
|
||||||
|
AlertNoConnection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(string.IsNullOrWhiteSpace(PasswordCell.TextField.Text))
|
||||||
|
{
|
||||||
|
DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Password), AppResources.Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(string.IsNullOrWhiteSpace(NameCell.TextField.Text))
|
||||||
|
{
|
||||||
|
DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var site = new Site
|
||||||
|
{
|
||||||
|
Uri = UriCell.TextField.Text?.Encrypt(),
|
||||||
|
Name = NameCell.TextField.Text?.Encrypt(),
|
||||||
|
Username = UsernameCell.TextField.Text?.Encrypt(),
|
||||||
|
Password = PasswordCell.TextField.Text?.Encrypt(),
|
||||||
|
Notes = NotesCell.TextView.Text?.Encrypt(),
|
||||||
|
Favorite = FavoriteCell.Switch.On
|
||||||
|
};
|
||||||
|
|
||||||
|
var saveTask = siteService.SaveAsync(site);
|
||||||
|
userDialogs.ShowLoading("Saving...", MaskType.Black);
|
||||||
|
await saveTask;
|
||||||
|
|
||||||
|
userDialogs.HideLoading();
|
||||||
DismissViewController(true, null);
|
DismissViewController(true, null);
|
||||||
|
userDialogs.SuccessToast(NameCell.TextField.Text, "New site created.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayAlert(string title, string message, string accept)
|
||||||
|
{
|
||||||
|
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.AddAction(UIAlertAction.Create(accept, UIAlertActionStyle.Default, null));
|
||||||
|
PresentViewController(alert, true, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AlertNoConnection()
|
||||||
|
{
|
||||||
|
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TableSource : UITableViewSource
|
public class TableSource : UITableViewSource
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
<MtouchLink>None</MtouchLink>
|
<MtouchLink>None</MtouchLink>
|
||||||
<MtouchDebug>true</MtouchDebug>
|
<MtouchDebug>true</MtouchDebug>
|
||||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||||
|
<MtouchTlsProvider>Legacy</MtouchTlsProvider>
|
||||||
|
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
|
@ -57,6 +59,8 @@
|
||||||
</CodesignExtraArgs>
|
</CodesignExtraArgs>
|
||||||
<MtouchSdkVersion>9.3</MtouchSdkVersion>
|
<MtouchSdkVersion>9.3</MtouchSdkVersion>
|
||||||
<MtouchLink>None</MtouchLink>
|
<MtouchLink>None</MtouchLink>
|
||||||
|
<MtouchTlsProvider>Legacy</MtouchTlsProvider>
|
||||||
|
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
|
@ -124,6 +128,22 @@
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Acr.Support.iOS, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Acr.UserDialogs, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Acr.UserDialogs.5.3.0\lib\Xamarin.iOS10\Acr.UserDialogs.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Acr.UserDialogs.Interface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Acr.UserDialogs.5.3.0\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="BTProgressHUD, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\BTProgressHUD.1.2.0.3\lib\Xamarin.iOS10\BTProgressHUD.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
@ -136,6 +156,14 @@
|
||||||
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.2\lib\Xamarin.iOS10\Plugin.Connectivity.Abstractions.dll</HintPath>
|
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.2\lib\Xamarin.iOS10\Plugin.Connectivity.Abstractions.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Plugin.Fingerprint, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Plugin.Fingerprint.1.2.0\lib\Xamarin.iOS10\Plugin.Fingerprint.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Plugin.Fingerprint.Abstractions, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Plugin.Fingerprint.1.2.0\lib\Xamarin.iOS10\Plugin.Fingerprint.Abstractions.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Plugin.Settings, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Plugin.Settings, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.dll</HintPath>
|
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
@ -144,6 +172,10 @@
|
||||||
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll</HintPath>
|
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Splat.1.6.2\lib\Xamarin.iOS10\Splat.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="SQLite-net, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="SQLite-net, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\sqlite-net-pcl.1.1.2\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll</HintPath>
|
<HintPath>..\..\packages\sqlite-net-pcl.1.1.2\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="Acr.Support" version="2.1.0" targetFramework="xamarinios10" />
|
||||||
|
<package id="Acr.UserDialogs" version="5.3.0" targetFramework="xamarinios10" />
|
||||||
|
<package id="BTProgressHUD" version="1.2.0.3" targetFramework="xamarinios10" />
|
||||||
<package id="CommonServiceLocator" version="1.3" targetFramework="xamarinios10" />
|
<package id="CommonServiceLocator" version="1.3" targetFramework="xamarinios10" />
|
||||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="xamarinios10" />
|
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="xamarinios10" />
|
||||||
|
<package id="Plugin.Fingerprint" version="1.2.0" targetFramework="xamarinios10" />
|
||||||
|
<package id="Splat" version="1.6.2" targetFramework="xamarinios10" />
|
||||||
<package id="sqlite-net-pcl" version="1.1.2" targetFramework="xamarinios10" />
|
<package id="sqlite-net-pcl" version="1.1.2" targetFramework="xamarinios10" />
|
||||||
<package id="SQLitePCL.bundle_green" version="0.9.2" targetFramework="xamarinios10" />
|
<package id="SQLitePCL.bundle_green" version="0.9.2" targetFramework="xamarinios10" />
|
||||||
<package id="SQLitePCL.raw" version="0.9.2" targetFramework="xamarinios10" />
|
<package id="SQLitePCL.raw" version="0.9.2" targetFramework="xamarinios10" />
|
||||||
|
|
Loading…
Reference in a new issue