mirror of
https://github.com/bitwarden/android.git
synced 2024-12-23 09:30:41 +03:00
Assigning context to add site cells
This commit is contained in:
parent
ecb7e9921d
commit
3291a0d78d
5 changed files with 141 additions and 92 deletions
|
@ -34,13 +34,12 @@ namespace Bit.iOS.Extension
|
|||
base.ViewDidLoad();
|
||||
|
||||
IEnumerable<SiteViewModel> filteredSiteModels = new List<SiteViewModel>();
|
||||
DomainName domain;
|
||||
if(Context.Url?.Host != null && DomainName.TryParse(Context.Url?.Host, out domain))
|
||||
if(Context.DomainName != null)
|
||||
{
|
||||
var siteService = Resolver.Resolve<ISiteService>();
|
||||
var sites = await siteService.GetAllAsync();
|
||||
var siteModels = sites.Select(s => new SiteViewModel(s));
|
||||
filteredSiteModels = siteModels.Where(s => s.Domain != null && s.Domain.BaseDomain == domain.BaseDomain);
|
||||
filteredSiteModels = siteModels.Where(s => s.Domain != null && s.Domain.BaseDomain == Context.DomainName.BaseDomain);
|
||||
}
|
||||
|
||||
tableView.RowHeight = UITableView.AutomaticDimension;
|
||||
|
|
|
@ -31,6 +31,11 @@ namespace Bit.iOS.Extension
|
|||
|
||||
public override void ViewDidLoad()
|
||||
{
|
||||
View.BackgroundColor = new UIColor(red: 0.93f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
|
||||
|
||||
nameField.Text = Context.Url.Host;
|
||||
uriField.Text = Context.Url.ToString();
|
||||
|
||||
tableView.RowHeight = UITableView.AutomaticDimension;
|
||||
tableView.EstimatedRowHeight = 44;
|
||||
tableView.Source = new TableSource (this);
|
||||
|
@ -38,6 +43,12 @@ namespace Bit.iOS.Extension
|
|||
base.ViewDidLoad();
|
||||
}
|
||||
|
||||
public override void ViewDidAppear(bool animated)
|
||||
{
|
||||
usernameCell.BecomeFirstResponder();
|
||||
base.ViewDidAppear(animated);
|
||||
}
|
||||
|
||||
partial void UIBarButtonItem2289_Activated(UIBarButtonItem sender)
|
||||
{
|
||||
DismissViewController(true, null);
|
||||
|
|
47
src/iOS.Extension/AddSiteViewController.designer.cs
generated
47
src/iOS.Extension/AddSiteViewController.designer.cs
generated
|
@ -16,42 +16,52 @@ namespace Bit.iOS.Extension
|
|||
{
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UITableViewCell generatePasswordCell { get; set; }
|
||||
UITableViewCell generatePasswordCell { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UITableViewCell nameCell { get; set; }
|
||||
UITableViewCell nameCell { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UITextField nameField { get; set; }
|
||||
UITextField nameField { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UILabel nameLabel { get; set; }
|
||||
UILabel nameLabel { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UITableViewCell passwordCell { get; set; }
|
||||
UITableViewCell passwordCell { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UITableView tableView { get; set; }
|
||||
UITextField passwordField { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UITableViewCell uriCell { get; set; }
|
||||
UITableView tableView { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIKit.UITableViewCell usernameCell { get; set; }
|
||||
UITableViewCell uriCell { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UITextField uriField { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UITableViewCell usernameCell { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UITextField usernameField { get; set; }
|
||||
|
||||
[Action ("UIBarButtonItem2289_Activated:")]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
partial void UIBarButtonItem2289_Activated (UIBarButtonItem sender);
|
||||
|
||||
|
||||
[Action ("UIBarButtonItem2290_Activated:")]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
partial void UIBarButtonItem2290_Activated (UIBarButtonItem sender);
|
||||
|
@ -62,41 +72,46 @@ namespace Bit.iOS.Extension
|
|||
generatePasswordCell.Dispose ();
|
||||
generatePasswordCell = null;
|
||||
}
|
||||
|
||||
if (nameCell != null) {
|
||||
nameCell.Dispose ();
|
||||
nameCell = null;
|
||||
}
|
||||
|
||||
if (nameField != null) {
|
||||
nameField.Dispose ();
|
||||
nameField = null;
|
||||
}
|
||||
|
||||
if (nameLabel != null) {
|
||||
nameLabel.Dispose ();
|
||||
nameLabel = null;
|
||||
}
|
||||
|
||||
if (passwordCell != null) {
|
||||
passwordCell.Dispose ();
|
||||
passwordCell = null;
|
||||
}
|
||||
|
||||
if (passwordField != null) {
|
||||
passwordField.Dispose ();
|
||||
passwordField = null;
|
||||
}
|
||||
if (tableView != null) {
|
||||
tableView.Dispose ();
|
||||
tableView = null;
|
||||
}
|
||||
|
||||
if (uriCell != null) {
|
||||
uriCell.Dispose ();
|
||||
uriCell = null;
|
||||
}
|
||||
|
||||
if (uriField != null) {
|
||||
uriField.Dispose ();
|
||||
uriField = null;
|
||||
}
|
||||
if (usernameCell != null) {
|
||||
usernameCell.Dispose ();
|
||||
usernameCell = null;
|
||||
}
|
||||
if (usernameField != null) {
|
||||
usernameField.Dispose ();
|
||||
usernameField = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -137,7 +137,7 @@
|
|||
<objects>
|
||||
<navigationController definesPresentationContext="YES" id="64" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="67" translucent="NO" hidden="YES">
|
||||
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="20" width="880" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
|
@ -154,7 +154,7 @@
|
|||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="oCZ-GQ-aOK" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="8A5-AR-QHS" translucent="NO">
|
||||
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="20" width="880" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<textAttributes key="titleTextAttributes">
|
||||
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
||||
|
@ -175,7 +175,7 @@
|
|||
<navigationController definesPresentationContext="YES" id="1845" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="1848" translucent="NO">
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<rect key="frame" x="0.0" y="20" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="20" width="880" height="44"/>
|
||||
<textAttributes key="titleTextAttributes">
|
||||
<color key="textColor" colorSpace="calibratedWhite" white="1" alpha="1"/>
|
||||
</textAttributes>
|
||||
|
@ -192,7 +192,7 @@
|
|||
<scene sceneID="2086">
|
||||
<objects>
|
||||
<tableViewController id="2087" sceneMemberID="viewController" customClass="AddSiteViewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" rowHeight="50" sectionHeaderHeight="22" sectionFooterHeight="22" id="2088" opaque="NO">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" rowHeight="50" sectionHeaderHeight="22" sectionFooterHeight="22" id="2088" opaque="NO" allowsSelection="NO">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
|
@ -210,14 +210,14 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="600" height="79.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Name" lineBreakMode="tailTruncation" minimumFontSize="10" id="2316" translatesAutoresizingMaskIntoConstraints="NO" misplaced="YES">
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Name" lineBreakMode="tailTruncation" minimumFontSize="10" id="2316" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="15" y="10" width="570" height="21"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="13"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="2317" translatesAutoresizingMaskIntoConstraints="NO" preservesSuperviewLayoutMargins="YES" clearButtonMode="whileEditing" misplaced="YES">
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="2317" translatesAutoresizingMaskIntoConstraints="NO" preservesSuperviewLayoutMargins="YES" clearButtonMode="whileEditing">
|
||||
<rect key="frame" x="15" y="41" width="570" height="30"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
|
@ -242,14 +242,14 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="600" height="79.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="URI" lineBreakMode="tailTruncation" minimumFontSize="10" id="2353" translatesAutoresizingMaskIntoConstraints="NO" misplaced="YES">
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="URI" lineBreakMode="tailTruncation" minimumFontSize="10" id="2353" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="15" y="10" width="570" height="21"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="13"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="2354" translatesAutoresizingMaskIntoConstraints="NO" preservesSuperviewLayoutMargins="YES" clearButtonMode="whileEditing" misplaced="YES">
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="2354" translatesAutoresizingMaskIntoConstraints="NO" preservesSuperviewLayoutMargins="YES" clearButtonMode="whileEditing">
|
||||
<rect key="frame" x="15" y="41" width="570" height="30"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
|
@ -274,14 +274,14 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="600" height="79.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Username" lineBreakMode="tailTruncation" minimumFontSize="10" id="2364" translatesAutoresizingMaskIntoConstraints="NO" misplaced="YES">
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Username" lineBreakMode="tailTruncation" minimumFontSize="10" id="2364" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="15" y="10" width="570" height="21"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="13"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="2365" translatesAutoresizingMaskIntoConstraints="NO" preservesSuperviewLayoutMargins="YES" clearButtonMode="whileEditing" misplaced="YES">
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="2365" translatesAutoresizingMaskIntoConstraints="NO" preservesSuperviewLayoutMargins="YES" clearButtonMode="whileEditing">
|
||||
<rect key="frame" x="15" y="41" width="570" height="30"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
|
@ -306,14 +306,14 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="600" height="79.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Password" lineBreakMode="tailTruncation" minimumFontSize="10" id="2375" translatesAutoresizingMaskIntoConstraints="NO" misplaced="YES">
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Password" lineBreakMode="tailTruncation" minimumFontSize="10" id="2375" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="15" y="10" width="570" height="21"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="13"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="2376" translatesAutoresizingMaskIntoConstraints="NO" preservesSuperviewLayoutMargins="YES" clearButtonMode="whileEditing" misplaced="YES">
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" id="2376" translatesAutoresizingMaskIntoConstraints="NO" preservesSuperviewLayoutMargins="YES" clearButtonMode="whileEditing">
|
||||
<rect key="frame" x="15" y="41" width="570" height="30"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
|
@ -408,6 +408,9 @@
|
|||
<outlet property="usernameCell" destination="2362" id="name-outlet-2362"/>
|
||||
<outlet property="passwordCell" destination="2373" id="name-outlet-2373"/>
|
||||
<outlet property="generatePasswordCell" destination="2305" id="name-outlet-2305"/>
|
||||
<outlet property="uriField" destination="2354" id="name-outlet-2354"/>
|
||||
<outlet property="usernameField" destination="2365" id="name-outlet-2365"/>
|
||||
<outlet property="passwordField" destination="2376" id="name-outlet-2376"/>
|
||||
</connections>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="2093" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
|
|
@ -1,13 +1,34 @@
|
|||
using System;
|
||||
using Bit.App.Models;
|
||||
using Foundation;
|
||||
|
||||
namespace Bit.iOS.Extension.Models
|
||||
{
|
||||
public class Context
|
||||
{
|
||||
private DomainName _domainName;
|
||||
|
||||
public NSExtensionContext ExtContext { get; set; }
|
||||
public string ProviderType { get; set; }
|
||||
public Uri Url { get; set; }
|
||||
public DomainName DomainName
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_domainName != null)
|
||||
{
|
||||
return _domainName;
|
||||
}
|
||||
|
||||
DomainName domain;
|
||||
if(Url?.Host != null && DomainName.TryParse(Url?.Host, out domain))
|
||||
{
|
||||
_domainName = domain;
|
||||
}
|
||||
|
||||
return _domainName;
|
||||
}
|
||||
}
|
||||
public string SiteTitle { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
|
Loading…
Reference in a new issue