mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 23:31:52 +03:00
Update ios extension to use new login service lookup by uristring
This commit is contained in:
parent
539121070a
commit
4af91b5ab6
5 changed files with 23 additions and 92 deletions
|
@ -328,7 +328,7 @@ namespace Bit.iOS.Extension
|
|||
_googleAnalyticsService.TrackExtensionEvent("ProcessItemProvider", type);
|
||||
|
||||
Debug.WriteLine("BW LOG, ProviderType: " + _context.ProviderType);
|
||||
Debug.WriteLine("BW LOG, Url: " + _context.Url);
|
||||
Debug.WriteLine("BW LOG, Url: " + _context.UrlString);
|
||||
Debug.WriteLine("BW LOG, Title: " + _context.LoginTitle);
|
||||
Debug.WriteLine("BW LOG, Username: " + _context.Username);
|
||||
Debug.WriteLine("BW LOG, Password: " + _context.Password);
|
||||
|
@ -359,7 +359,7 @@ namespace Bit.iOS.Extension
|
|||
return;
|
||||
}
|
||||
|
||||
_context.Url = new Uri(result.ValueForKey(new NSString(Constants.AppExtensionUrlStringKey)) as NSString);
|
||||
_context.UrlString = result.ValueForKey(new NSString(Constants.AppExtensionUrlStringKey)) as NSString;
|
||||
var jsonStr = result.ValueForKey(new NSString(Constants.AppExtensionWebViewPageDetails)) as NSString;
|
||||
_context.Details = DeserializeString<PageDetails>(jsonStr);
|
||||
});
|
||||
|
@ -374,7 +374,7 @@ namespace Bit.iOS.Extension
|
|||
|
||||
if(url != null)
|
||||
{
|
||||
_context.Url = new Uri(url);
|
||||
_context.UrlString = url;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ namespace Bit.iOS.Extension
|
|||
var url = dict[Constants.AppExtensionUrlStringKey] as NSString;
|
||||
if(url != null)
|
||||
{
|
||||
_context.Url = new Uri(url);
|
||||
_context.UrlString = url;
|
||||
}
|
||||
|
||||
_context.Details = DeserializeDictionary<PageDetails>(dict[Constants.AppExtensionWebViewPageDetails] as NSDictionary);
|
||||
|
@ -409,7 +409,7 @@ namespace Bit.iOS.Extension
|
|||
|
||||
if(url != null)
|
||||
{
|
||||
_context.Url = new Uri(url);
|
||||
_context.UrlString = url;
|
||||
}
|
||||
|
||||
_context.LoginTitle = title;
|
||||
|
@ -436,7 +436,7 @@ namespace Bit.iOS.Extension
|
|||
|
||||
if(url != null)
|
||||
{
|
||||
_context.Url = new Uri(url);
|
||||
_context.UrlString = url;
|
||||
}
|
||||
|
||||
_context.LoginTitle = title;
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Bit.iOS.Extension
|
|||
SaveBarButton.Title = AppResources.Save;
|
||||
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
|
||||
|
||||
NameCell.TextField.Text = Context?.Url?.Host ?? string.Empty;
|
||||
NameCell.TextField.Text = Context?.Uri?.Host ?? string.Empty;
|
||||
NameCell.TextField.ReturnKeyType = UIReturnKeyType.Next;
|
||||
NameCell.TextField.ShouldReturn += (UITextField tf) =>
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ namespace Bit.iOS.Extension
|
|||
return true;
|
||||
};
|
||||
|
||||
UriCell.TextField.Text = Context?.Url?.ToString() ?? string.Empty;
|
||||
UriCell.TextField.Text = Context?.UrlString ?? string.Empty;
|
||||
UriCell.TextField.KeyboardType = UIKeyboardType.Url;
|
||||
UriCell.TextField.ReturnKeyType = UIReturnKeyType.Next;
|
||||
UriCell.TextField.ShouldReturn += (UITextField tf) =>
|
||||
|
|
|
@ -113,17 +113,13 @@ namespace Bit.iOS.Extension
|
|||
|
||||
public async Task LoadItemsAsync()
|
||||
{
|
||||
_tableItems = new List<LoginViewModel>();
|
||||
if(_context.DomainName != null)
|
||||
{
|
||||
var loginService = Resolver.Resolve<ILoginService>();
|
||||
var logins = await loginService.GetAllAsync();
|
||||
var loginModels = logins.Select(s => new LoginViewModel(s));
|
||||
_tableItems = loginModels
|
||||
.Where(s => s.Domain != null && s.Domain.BaseDomain == _context.DomainName.BaseDomain)
|
||||
.OrderBy(s => s.Name).ThenBy(s => s.Username)
|
||||
.ToList();
|
||||
}
|
||||
var loginService = Resolver.Resolve<ILoginService>();
|
||||
var logins = await loginService.GetAllAsync(_context.UrlString);
|
||||
var loginModels = logins;
|
||||
_tableItems = logins.Select(s => new LoginViewModel(s))
|
||||
.OrderBy(s => s.Name)
|
||||
.ThenBy(s => s.Username)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<LoginViewModel> TableItems { get; set; }
|
||||
|
|
|
@ -10,25 +10,20 @@ namespace Bit.iOS.Extension.Models
|
|||
|
||||
public NSExtensionContext ExtContext { get; set; }
|
||||
public string ProviderType { get; set; }
|
||||
public Uri Url { get; set; }
|
||||
public DomainName DomainName
|
||||
public Uri Uri
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_domainName != null)
|
||||
Uri uri;
|
||||
if(string.IsNullOrWhiteSpace(UrlString) || !Uri.TryCreate(UrlString, UriKind.Absolute, out uri))
|
||||
{
|
||||
return _domainName;
|
||||
return null;
|
||||
}
|
||||
|
||||
DomainName domain;
|
||||
if(Url?.Host != null && DomainName.TryParse(Url?.Host, out domain))
|
||||
{
|
||||
_domainName = domain;
|
||||
}
|
||||
|
||||
return _domainName;
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
public string UrlString { get; set; }
|
||||
public string LoginTitle { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Bit.App.Models;
|
||||
using Bit.App.Models;
|
||||
|
||||
namespace Bit.iOS.Extension.Models
|
||||
{
|
||||
public class LoginViewModel
|
||||
{
|
||||
private string _uri;
|
||||
private DomainName _domain = null;
|
||||
private bool _domainParsed = false;
|
||||
|
||||
public LoginViewModel(Login login)
|
||||
{
|
||||
Id = login.Id;
|
||||
|
@ -24,59 +17,6 @@ namespace Bit.iOS.Extension.Models
|
|||
public string Name { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Uri
|
||||
{
|
||||
get { return _uri; }
|
||||
set
|
||||
{
|
||||
_domainParsed = false;
|
||||
_uri = value;
|
||||
}
|
||||
}
|
||||
public string HostName
|
||||
{
|
||||
get
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(Uri))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return new Uri(Uri)?.Host;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public DomainName Domain
|
||||
{
|
||||
get
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(Uri))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(_domainParsed)
|
||||
{
|
||||
return _domain;
|
||||
}
|
||||
|
||||
_domainParsed = true;
|
||||
|
||||
DomainName domain;
|
||||
if(DomainName.TryParse(HostName, out domain))
|
||||
{
|
||||
_domain = domain;
|
||||
}
|
||||
|
||||
return _domain;
|
||||
}
|
||||
}
|
||||
public string Uri { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue