resolving warnings for obsolete APIs

This commit is contained in:
Kyle Spearrin 2017-05-30 14:13:53 -04:00
parent 65438e837d
commit 24382b8607
45 changed files with 160 additions and 123 deletions

View file

@ -124,7 +124,7 @@ namespace Bit.App
SetMainPageFromAutofill(); SetMainPageFromAutofill();
if(Device.OS == TargetPlatform.Android && !TopPageIsLock()) if(Device.RuntimePlatform == Device.Android && !TopPageIsLock())
{ {
_lockService.UpdateLastActivity(); _lockService.UpdateLastActivity();
} }
@ -141,7 +141,7 @@ namespace Bit.App
// Handle when your app resumes // Handle when your app resumes
Debug.WriteLine("OnResume"); Debug.WriteLine("OnResume");
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
await CheckLockAsync(false); await CheckLockAsync(false);
} }
@ -152,7 +152,7 @@ namespace Bit.App
lockPinPage.PinControl.Entry.FocusWithDelay(); lockPinPage.PinControl.Entry.FocusWithDelay();
} }
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
await Task.Run(() => FullSyncAsync()).ConfigureAwait(false); await Task.Run(() => FullSyncAsync()).ConfigureAwait(false);
} }
@ -160,7 +160,7 @@ namespace Bit.App
private void SetMainPageFromAutofill() private void SetMainPageFromAutofill()
{ {
if(Device.OS == TargetPlatform.Android && !string.IsNullOrWhiteSpace(_uri)) if(Device.RuntimePlatform == Device.Android && !string.IsNullOrWhiteSpace(_uri))
{ {
Task.Run(() => Task.Run(() =>
{ {
@ -386,7 +386,7 @@ namespace Bit.App
Debug.WriteLine("===================================="); Debug.WriteLine("====================================");
// This lookup NOT required for Windows platforms - the Culture will be automatically set // This lookup NOT required for Windows platforms - the Culture will be automatically set
if(Device.OS == TargetPlatform.iOS || Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Android)
{ {
var ci = _localizeService.GetCurrentCultureInfo(); var ci = _localizeService.GetCurrentCultureInfo();
AppResources.Culture = ci; AppResources.Culture = ci;

View file

@ -275,6 +275,7 @@
<Compile Include="Pages\Vault\VaultEditLoginPage.cs" /> <Compile Include="Pages\Vault\VaultEditLoginPage.cs" />
<Compile Include="Pages\Vault\VaultListLoginsPage.cs" /> <Compile Include="Pages\Vault\VaultListLoginsPage.cs" />
<Compile Include="Services\PasswordGenerationService.cs" /> <Compile Include="Services\PasswordGenerationService.cs" />
<Compile Include="Utilities\Helpers.cs" />
<Compile Include="Utilities\IdentityHttpClient.cs" /> <Compile Include="Utilities\IdentityHttpClient.cs" />
<Compile Include="Utilities\Extentions.cs" /> <Compile Include="Utilities\Extentions.cs" />
<Compile Include="Utilities\ExtendedObservableCollection.cs" /> <Compile Include="Utilities\ExtendedObservableCollection.cs" />

View file

@ -1,4 +1,5 @@
using Bit.App.Enums; using Bit.App.Enums;
using Bit.App.Utilities;
using System; using System;
using Xamarin.Forms; using Xamarin.Forms;
@ -10,7 +11,7 @@ namespace Bit.App.Controls
BindableProperty.Create(nameof(Padding), typeof(Thickness), typeof(ExtendedButton), default(Thickness)); BindableProperty.Create(nameof(Padding), typeof(Thickness), typeof(ExtendedButton), default(Thickness));
public static readonly BindableProperty UppercaseProperty = public static readonly BindableProperty UppercaseProperty =
BindableProperty.Create(nameof(Uppercase), typeof(bool), typeof(ExtendedButton), BindableProperty.Create(nameof(Uppercase), typeof(bool), typeof(ExtendedButton),
Device.OnPlatform(iOS: false, Android: true, WinPhone: false)); Helpers.OnPlatform(iOS: false, Android: true, WinPhone: false));
public Thickness Padding public Thickness Padding
{ {

View file

@ -8,7 +8,7 @@ namespace Bit.App.Controls
{ {
public ExtendedEntry() public ExtendedEntry()
{ {
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
PlaceholderColor = Color.FromHex("c7c7cd"); PlaceholderColor = Color.FromHex("c7c7cd");
} }

View file

@ -7,7 +7,7 @@ namespace Bit.App.Controls
{ {
public ExtendedTextCell() public ExtendedTextCell()
{ {
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
TextColor = Color.Black; TextColor = Color.Black;
} }

View file

@ -87,7 +87,7 @@ namespace Bit.App.Controls
VerticalOptions = LayoutOptions.CenterAndExpand VerticalOptions = LayoutOptions.CenterAndExpand
}; };
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
var deviceInfo = Resolver.Resolve<IDeviceInfoService>(); var deviceInfo = Resolver.Resolve<IDeviceInfoService>();
if(useLabelAsPlaceholder) if(useLabelAsPlaceholder)
@ -125,7 +125,7 @@ namespace Bit.App.Controls
Button = new ExtendedButton(); Button = new ExtendedButton();
imageStackLayout.Children.Add(Button); imageStackLayout.Children.Add(Button);
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
Button.Padding = new Thickness(0); Button.Padding = new Thickness(0);
Button.BackgroundColor = Color.Transparent; Button.BackgroundColor = Color.Transparent;

View file

@ -34,7 +34,7 @@ namespace Bit.App.Controls
stackLayout.Children.Add(Label); stackLayout.Children.Add(Label);
stackLayout.Children.Add(Picker); stackLayout.Children.Add(Picker);
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
stackLayout.Spacing = 0; stackLayout.Spacing = 0;
} }

View file

@ -51,7 +51,7 @@ namespace Bit.App.Controls
Grid.SetColumnSpan(Detail, 2); Grid.SetColumnSpan(Detail, 2);
Grid.SetRowSpan(Button, 2); Grid.SetRowSpan(Button, 2);
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
Label.TextColor = Color.Black; Label.TextColor = Color.Black;
} }

View file

@ -41,7 +41,7 @@ namespace Bit.App.Controls
LineBreakMode = LineBreakMode.TailTruncation LineBreakMode = LineBreakMode.TailTruncation
}; };
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
Value.TextColor = Color.Black; Value.TextColor = Color.Black;
} }
@ -82,7 +82,7 @@ namespace Bit.App.Controls
buttonStackLayout.Children.Add(Button2); buttonStackLayout.Children.Add(Button2);
} }
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
buttonStackLayout.Spacing = 5; buttonStackLayout.Spacing = 5;

View file

@ -1,4 +1,5 @@
using System; using Bit.App.Utilities;
using System;
using Xamarin.Forms; using Xamarin.Forms;
namespace Bit.App.Controls namespace Bit.App.Controls
@ -13,7 +14,7 @@ namespace Bit.App.Controls
{ {
HorizontalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center,
FontSize = 35, FontSize = 35,
FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier") FontFamily = Helpers.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier")
}; };
Entry = new ExtendedEntry Entry = new ExtendedEntry
@ -23,7 +24,7 @@ namespace Bit.App.Controls
Margin = new Thickness(0, int.MaxValue, 0, 0) Margin = new Thickness(0, int.MaxValue, 0, 0)
}; };
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
Label.TextColor = Color.Black; Label.TextColor = Color.Black;
} }

View file

@ -1,4 +1,5 @@
using Xamarin.Forms; using Bit.App.Utilities;
using Xamarin.Forms;
namespace Bit.App.Controls namespace Bit.App.Controls
{ {
@ -39,13 +40,13 @@ namespace Bit.App.Controls
Orientation = StackOrientation.Horizontal, Orientation = StackOrientation.Horizontal,
Children = { Label, StepperValueLabel, Stepper }, Children = { Label, StepperValueLabel, Stepper },
Spacing = 15, Spacing = 15,
Padding = Device.OnPlatform( Padding = Helpers.OnPlatform(
iOS: new Thickness(15, 8), iOS: new Thickness(15, 8),
Android: new Thickness(15, 2), Android: new Thickness(15, 2),
WinPhone: new Thickness(15, 8)) WinPhone: new Thickness(15, 8))
}; };
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
Label.TextColor = Color.Black; Label.TextColor = Color.Black;
} }

View file

@ -12,9 +12,9 @@ namespace Bit.App.Controls
public VaultListViewCell(Action<VaultListPageModel.Login> moreClickedAction) public VaultListViewCell(Action<VaultListPageModel.Login> moreClickedAction)
{ {
SetBinding(LoginParameterProperty, new Binding(".")); SetBinding(LoginParameterProperty, new Binding("."));
Label.SetBinding<VaultListPageModel.Login>(Label.TextProperty, l => l.Name); Label.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Login.Name));
Detail.SetBinding<VaultListPageModel.Login>(Label.TextProperty, l => l.Username); Detail.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Login.Username));
LabelIcon.SetBinding<VaultListPageModel.Login>(VisualElement.IsVisibleProperty, l => l.Shared); LabelIcon.SetBinding(VisualElement.IsVisibleProperty, nameof(VaultListPageModel.Login.Shared));
Button.Image = "more"; Button.Image = "more";
Button.Command = new Command(() => moreClickedAction?.Invoke(LoginParameter)); Button.Command = new Command(() => moreClickedAction?.Invoke(LoginParameter));

View file

@ -12,7 +12,7 @@ namespace Bit.App.Models.Api
{ {
Identifier = appIdService.AppId; Identifier = appIdService.AppId;
Name = deviceInfoService.Model; Name = deviceInfoService.Model;
Type = Device.OS == TargetPlatform.Android ? DeviceType.Android : DeviceType.iOS; Type = Device.RuntimePlatform == Device.Android ? DeviceType.Android : DeviceType.iOS;
} }
public DeviceType Type { get; set; } public DeviceType Type { get; set; }

View file

@ -13,7 +13,6 @@ namespace Bit.App.Models.Page
private string _uri; private string _uri;
private string _notes; private string _notes;
private bool _revealPassword; private bool _revealPassword;
private string _uriHost;
public VaultViewLoginPageModel() { } public VaultViewLoginPageModel() { }
@ -44,7 +43,7 @@ namespace Bit.App.Models.Page
{ {
get get
{ {
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
var length = Username?.Length ?? 0; var length = Username?.Length ?? 0;
@ -79,7 +78,7 @@ namespace Bit.App.Models.Page
{ {
get get
{ {
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
var length = Password?.Length ?? 0; var length = Password?.Length ?? 0;
@ -121,11 +120,6 @@ namespace Bit.App.Models.Page
return null; return null;
} }
if(_uriHost != null)
{
return _uriHost;
}
Uri uri; Uri uri;
if(!System.Uri.TryCreate(Uri, UriKind.Absolute, out uri)) if(!System.Uri.TryCreate(Uri, UriKind.Absolute, out uri))
{ {

View file

@ -20,7 +20,7 @@ namespace Bit.App.Pages
protected override bool OnBackButtonPressed() protected override bool OnBackButtonPressed()
{ {
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
MessagingCenter.Send(Application.Current, "BackgroundApp"); MessagingCenter.Send(Application.Current, "BackgroundApp");
} }

View file

@ -6,6 +6,7 @@ using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Bit.App.Controls; using Bit.App.Controls;
using System.Linq; using System.Linq;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -29,7 +30,7 @@ namespace Bit.App.Pages
public void Init() public void Init()
{ {
var padding = Device.OnPlatform( var padding = Helpers.OnPlatform(
iOS: new Thickness(15, 20), iOS: new Thickness(15, 20),
Android: new Thickness(15, 8), Android: new Thickness(15, 8),
WinPhone: new Thickness(15, 20)); WinPhone: new Thickness(15, 20));
@ -74,7 +75,7 @@ namespace Bit.App.Pages
var scrollView = new ScrollView { Content = stackLayout }; var scrollView = new ScrollView { Content = stackLayout };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 70; table.EstimatedRowHeight = 70;

View file

@ -38,8 +38,8 @@ namespace Bit.App.Pages
}; };
PinControl = new PinControl(); PinControl = new PinControl();
PinControl.Label.SetBinding<PinPageModel>(Label.TextProperty, s => s.LabelText); PinControl.Label.SetBinding(Label.TextProperty, nameof(PinPageModel.LabelText));
PinControl.Entry.SetBinding<PinPageModel>(Entry.TextProperty, s => s.PIN); PinControl.Entry.SetBinding(Entry.TextProperty, nameof(PinPageModel.PIN));
var logoutButton = new ExtendedButton var logoutButton = new ExtendedButton
{ {

View file

@ -8,6 +8,7 @@ using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;
using PushNotification.Plugin.Abstractions; using PushNotification.Plugin.Abstractions;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -42,7 +43,7 @@ namespace Bit.App.Pages
{ {
MessagingCenter.Send(Application.Current, "ShowStatusBar", true); MessagingCenter.Send(Application.Current, "ShowStatusBar", true);
var padding = Device.OnPlatform( var padding = Helpers.OnPlatform(
iOS: new Thickness(15, 20), iOS: new Thickness(15, 20),
Android: new Thickness(15, 8), Android: new Thickness(15, 8),
WinPhone: new Thickness(15, 20)); WinPhone: new Thickness(15, 20));
@ -97,12 +98,12 @@ namespace Bit.App.Pages
var layout = new StackLayout var layout = new StackLayout
{ {
Children = { table, forgotPasswordButton }, Children = { table, forgotPasswordButton },
Spacing = Device.OnPlatform(iOS: 0, Android: 10, WinPhone: 0) Spacing = Helpers.OnPlatform(iOS: 0, Android: 10, WinPhone: 0)
}; };
var scrollView = new ScrollView { Content = layout }; var scrollView = new ScrollView { Content = layout };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 70; table.EstimatedRowHeight = 70;
@ -197,7 +198,7 @@ namespace Bit.App.Pages
_googleAnalyticsService.TrackAppEvent("LoggedIn"); _googleAnalyticsService.TrackAppEvent("LoggedIn");
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
_pushNotification.Register(); _pushNotification.Register();
} }

View file

@ -8,6 +8,7 @@ using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
using PushNotification.Plugin.Abstractions; using PushNotification.Plugin.Abstractions;
using Bit.App.Models; using Bit.App.Models;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -42,7 +43,7 @@ namespace Bit.App.Pages
private void Init() private void Init()
{ {
var padding = Device.OnPlatform( var padding = Helpers.OnPlatform(
iOS: new Thickness(15, 20), iOS: new Thickness(15, 20),
Android: new Thickness(15, 8), Android: new Thickness(15, 8),
WinPhone: new Thickness(15, 20)); WinPhone: new Thickness(15, 20));
@ -97,7 +98,7 @@ namespace Bit.App.Pages
var scrollView = new ScrollView { Content = layout }; var scrollView = new ScrollView { Content = layout };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 70; table.EstimatedRowHeight = 70;
@ -158,7 +159,7 @@ namespace Bit.App.Pages
_googleAnalyticsService.TrackAppEvent("LoggedIn From Two-step"); _googleAnalyticsService.TrackAppEvent("LoggedIn From Two-step");
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
_pushNotification.Register(); _pushNotification.Register();
} }

View file

@ -8,6 +8,7 @@ using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Acr.UserDialogs; using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -29,7 +30,7 @@ namespace Bit.App.Pages
private void Init() private void Init()
{ {
var padding = Device.OnPlatform( var padding = Helpers.OnPlatform(
iOS: new Thickness(15, 20), iOS: new Thickness(15, 20),
Android: new Thickness(15, 8), Android: new Thickness(15, 8),
WinPhone: new Thickness(15, 20)); WinPhone: new Thickness(15, 20));
@ -73,7 +74,7 @@ namespace Bit.App.Pages
var scrollView = new ScrollView { Content = layout }; var scrollView = new ScrollView { Content = layout };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 70; table.EstimatedRowHeight = 70;

View file

@ -8,6 +8,7 @@ using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Acr.UserDialogs; using Acr.UserDialogs;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -43,7 +44,7 @@ namespace Bit.App.Pages
{ {
MessagingCenter.Send(Application.Current, "ShowStatusBar", true); MessagingCenter.Send(Application.Current, "ShowStatusBar", true);
var padding = Device.OnPlatform( var padding = Helpers.OnPlatform(
iOS: new Thickness(15, 20), iOS: new Thickness(15, 20),
Android: new Thickness(15, 8), Android: new Thickness(15, 8),
WinPhone: new Thickness(15, 20)); WinPhone: new Thickness(15, 20));
@ -121,7 +122,7 @@ namespace Bit.App.Pages
await Register(); await Register();
}, ToolbarItemOrder.Default, 0); }, ToolbarItemOrder.Default, 0);
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = table2.RowHeight = -1; table.RowHeight = table2.RowHeight = -1;
table.EstimatedRowHeight = table2.EstimatedRowHeight = 70; table.EstimatedRowHeight = table2.EstimatedRowHeight = 70;

View file

@ -66,7 +66,7 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 44; table.EstimatedRowHeight = 44;
@ -78,7 +78,7 @@ namespace Bit.App.Pages
Spacing = 0 Spacing = 0
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }

View file

@ -49,7 +49,7 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 70; table.EstimatedRowHeight = 70;
@ -105,7 +105,7 @@ namespace Bit.App.Pages
Title = AppResources.AddFolder; Title = AppResources.AddFolder;
Content = table; Content = table;
ToolbarItems.Add(saveToolBarItem); ToolbarItems.Add(saveToolBarItem);
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }

View file

@ -2,6 +2,7 @@
using Bit.App.Controls; using Bit.App.Controls;
using Xamarin.Forms; using Xamarin.Forms;
using Bit.App.Resources; using Bit.App.Resources;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -37,7 +38,7 @@ Fingerprint by masterpage.com from the Noun Project")
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 100; table.EstimatedRowHeight = 100;
@ -61,14 +62,14 @@ Fingerprint by masterpage.com from the Noun Project")
var layout = new StackLayout var layout = new StackLayout
{ {
Children = { label }, Children = { label },
Padding = Device.OnPlatform( Padding = Helpers.OnPlatform(
iOS: new Thickness(15, 20), iOS: new Thickness(15, 20),
Android: new Thickness(16, 20), Android: new Thickness(16, 20),
WinPhone: new Thickness(15, 20)), WinPhone: new Thickness(15, 20)),
BackgroundColor = Color.White BackgroundColor = Color.White
}; };
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
label.TextColor = Color.Black; label.TextColor = Color.Black;
} }

View file

@ -66,7 +66,7 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
mainTable.RowHeight = -1; mainTable.RowHeight = -1;
mainTable.EstimatedRowHeight = 70; mainTable.EstimatedRowHeight = 70;
@ -119,7 +119,7 @@ namespace Bit.App.Pages
Title = AppResources.EditFolder; Title = AppResources.EditFolder;
Content = mainTable; Content = mainTable;
ToolbarItems.Add(saveToolBarItem); ToolbarItems.Add(saveToolBarItem);
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }

View file

@ -78,7 +78,7 @@ namespace Bit.App.Pages
Spacing = 0 Spacing = 0
}; };
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
AutofillAlwaysCell = new ExtendedSwitchCell AutofillAlwaysCell = new ExtendedSwitchCell
{ {
@ -161,7 +161,7 @@ namespace Bit.App.Pages
Content = StackLayout Content = StackLayout
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
analyticsTable.RowHeight = -1; analyticsTable.RowHeight = -1;
analyticsTable.EstimatedRowHeight = 70; analyticsTable.EstimatedRowHeight = 70;

View file

@ -102,7 +102,7 @@ namespace Bit.App.Pages
Spacing = 0 Spacing = 0
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }
@ -165,7 +165,7 @@ namespace Bit.App.Pages
VerticalOptions = LayoutOptions.Start; VerticalOptions = LayoutOptions.Start;
NoFooter = true; NoFooter = true;
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
RowHeight = -1; RowHeight = -1;
EstimatedRowHeight = 44; EstimatedRowHeight = 44;

View file

@ -41,7 +41,7 @@ namespace Bit.App.Pages
ItemTemplate = new DataTemplate(() => new SettingsFolderListViewCell(this)) ItemTemplate = new DataTemplate(() => new SettingsFolderListViewCell(this))
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }
@ -102,7 +102,7 @@ namespace Bit.App.Pages
{ {
public SettingsFolderListViewCell(SettingsListFoldersPage page) public SettingsFolderListViewCell(SettingsListFoldersPage page)
{ {
this.SetBinding<SettingsFolderPageModel>(TextProperty, s => s.Name); this.SetBinding(TextProperty, nameof(SettingsFolderPageModel.Name));
} }
} }
} }

View file

@ -8,6 +8,7 @@ using Acr.UserDialogs;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;
using Plugin.Fingerprint.Abstractions; using Plugin.Fingerprint.Abstractions;
using PushNotification.Plugin.Abstractions; using PushNotification.Plugin.Abstractions;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -81,7 +82,7 @@ namespace Bit.App.Pages
if(_fingerprint.IsAvailable) if(_fingerprint.IsAvailable)
{ {
var fingerprintName = Device.OnPlatform(iOS: AppResources.TouchID, Android: AppResources.Fingerprint, var fingerprintName = Helpers.OnPlatform(iOS: AppResources.TouchID, Android: AppResources.Fingerprint,
WinPhone: AppResources.Fingerprint); WinPhone: AppResources.Fingerprint);
FingerprintCell = new ExtendedSwitchCell FingerprintCell = new ExtendedSwitchCell
{ {
@ -151,7 +152,7 @@ namespace Bit.App.Pages
HelpCell HelpCell
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
RateCellLong = new LongDetailViewCell(AppResources.RateTheApp, AppResources.RateTheAppDescriptionAppStore); RateCellLong = new LongDetailViewCell(AppResources.RateTheApp, AppResources.RateTheAppDescriptionAppStore);
otherSection.Add(RateCellLong); otherSection.Add(RateCellLong);
@ -328,12 +329,12 @@ namespace Bit.App.Pages
private void RateCell_Tapped(object sender, EventArgs e) private void RateCell_Tapped(object sender, EventArgs e)
{ {
_googleAnalyticsService.TrackAppEvent("OpenedSetting", "RateApp"); _googleAnalyticsService.TrackAppEvent("OpenedSetting", "RateApp");
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
Device.OpenUri(new Uri($"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews" + Device.OpenUri(new Uri($"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews" +
"?id=1137397744&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software")); "?id=1137397744&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software"));
} }
else if(Device.OS == TargetPlatform.Android) else if(Device.RuntimePlatform == Device.Android)
{ {
MessagingCenter.Send(Application.Current, "RateApp"); MessagingCenter.Send(Application.Current, "RateApp");
} }
@ -484,7 +485,7 @@ namespace Bit.App.Pages
Intent = TableIntent.Settings; Intent = TableIntent.Settings;
HasUnevenRows = true; HasUnevenRows = true;
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
RowHeight = -1; RowHeight = -1;
EstimatedRowHeight = 44; EstimatedRowHeight = 44;

View file

@ -42,8 +42,8 @@ namespace Bit.App.Pages
}; };
PinControl = new PinControl(); PinControl = new PinControl();
PinControl.Label.SetBinding<PinPageModel>(Label.TextProperty, s => s.LabelText); PinControl.Label.SetBinding(Label.TextProperty, nameof(PinPageModel.LabelText));
PinControl.Entry.SetBinding<PinPageModel>(Entry.TextProperty, s => s.PIN); PinControl.Entry.SetBinding(Entry.TextProperty, nameof(PinPageModel.PIN));
var stackLayout = new StackLayout var stackLayout = new StackLayout
{ {
@ -56,7 +56,7 @@ namespace Bit.App.Pages
PinControl.Label.GestureRecognizers.Add(Tgr); PinControl.Label.GestureRecognizers.Add(Tgr);
instructionLabel.GestureRecognizers.Add(Tgr); instructionLabel.GestureRecognizers.Add(Tgr);
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }

View file

@ -57,7 +57,7 @@ namespace Bit.App.Pages
Padding = new Thickness(15, 0) Padding = new Thickness(15, 0)
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }

View file

@ -167,7 +167,7 @@ namespace Bit.App.Pages
ScrollView = new ScrollView { Content = DisabledStackLayout }; ScrollView = new ScrollView { Content = DisabledStackLayout };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
} }

View file

@ -81,7 +81,7 @@ namespace Bit.App.Pages
VerticalOptions = LayoutOptions.FillAndExpand VerticalOptions = LayoutOptions.FillAndExpand
}; };
notStartedStackLayout.SetBinding<AppExtensionPageModel>(IsVisibleProperty, m => m.NotStarted); notStartedStackLayout.SetBinding(IsVisibleProperty, nameof(AppExtensionPageModel.NotStarted));
// Not Activated // Not Activated
@ -132,7 +132,7 @@ namespace Bit.App.Pages
VerticalOptions = LayoutOptions.FillAndExpand VerticalOptions = LayoutOptions.FillAndExpand
}; };
notActivatedStackLayout.SetBinding<AppExtensionPageModel>(IsVisibleProperty, m => m.StartedAndNotActivated); notActivatedStackLayout.SetBinding(IsVisibleProperty, nameof(AppExtensionPageModel.StartedAndNotActivated));
// Activated // Activated
@ -197,7 +197,7 @@ namespace Bit.App.Pages
Children = { activatedLabel, activatedSublabel, activatedImage, activatedButton, activatedButtonReenable } Children = { activatedLabel, activatedSublabel, activatedImage, activatedButton, activatedButtonReenable }
}; };
activatedStackLayout.SetBinding<AppExtensionPageModel>(IsVisibleProperty, m => m.StartedAndActivated); activatedStackLayout.SetBinding(IsVisibleProperty, nameof(AppExtensionPageModel.StartedAndActivated));
var stackLayout = new StackLayout var stackLayout = new StackLayout
{ {
@ -205,7 +205,7 @@ namespace Bit.App.Pages
VerticalOptions = LayoutOptions.FillAndExpand VerticalOptions = LayoutOptions.FillAndExpand
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
} }

View file

@ -40,7 +40,7 @@ namespace Bit.App.Pages
var section = new TableSection(" ") { GeneratorCell }; var section = new TableSection(" ") { GeneratorCell };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ExtensionCell = new ToolsViewCell(AppResources.BitwardenAppExtension, ExtensionCell = new ToolsViewCell(AppResources.BitwardenAppExtension,
AppResources.BitwardenAppExtensionDescription, "upload"); AppResources.BitwardenAppExtensionDescription, "upload");
@ -68,7 +68,7 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 100; table.EstimatedRowHeight = 100;
@ -163,7 +163,7 @@ namespace Bit.App.Pages
Text = labelText Text = labelText
}; };
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
label.TextColor = Color.Black; label.TextColor = Color.Black;
} }

View file

@ -7,6 +7,7 @@ using Bit.App.Resources;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -48,14 +49,14 @@ namespace Bit.App.Pages
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
Margin = new Thickness(15, 40, 15, 40), Margin = new Thickness(15, 40, 15, 40),
HorizontalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center,
FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"), FontFamily = Helpers.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"),
LineBreakMode = LineBreakMode.TailTruncation, LineBreakMode = LineBreakMode.TailTruncation,
VerticalOptions = LayoutOptions.Start VerticalOptions = LayoutOptions.Start
}; };
Tgr = new TapGestureRecognizer(); Tgr = new TapGestureRecognizer();
Password.GestureRecognizers.Add(Tgr); Password.GestureRecognizers.Add(Tgr);
Password.SetBinding<PasswordGeneratorPageModel>(Label.TextProperty, m => m.Password); Password.SetBinding(Label.TextProperty, nameof(PasswordGeneratorPageModel.Password));
SliderCell = new SliderViewCell(this, _passwordGenerationService, _settings); SliderCell = new SliderViewCell(this, _passwordGenerationService, _settings);
SettingsCell = new ExtendedTextCell { Text = AppResources.MoreSettings, ShowDisclousure = true }; SettingsCell = new ExtendedTextCell { Text = AppResources.MoreSettings, ShowDisclousure = true };
@ -86,7 +87,7 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 44; table.EstimatedRowHeight = 44;
@ -248,21 +249,21 @@ namespace Bit.App.Pages
Style = (Style)Application.Current.Resources["text-muted"] Style = (Style)Application.Current.Resources["text-muted"]
}; };
Value.SetBinding<PasswordGeneratorPageModel>(Label.TextProperty, m => m.Length); Value.SetBinding(Label.TextProperty, nameof(PasswordGeneratorPageModel.Length));
var stackLayout = new StackLayout var stackLayout = new StackLayout
{ {
Orientation = StackOrientation.Horizontal, Orientation = StackOrientation.Horizontal,
Spacing = 15, Spacing = 15,
Children = { label, LengthSlider, Value }, Children = { label, LengthSlider, Value },
Padding = Device.OnPlatform( Padding = Helpers.OnPlatform(
iOS: new Thickness(15, 8), iOS: new Thickness(15, 8),
Android: new Thickness(16, 10), Android: new Thickness(16, 10),
WinPhone: new Thickness(15, 8)) WinPhone: new Thickness(15, 8))
}; };
stackLayout.AdjustPaddingForDevice(); stackLayout.AdjustPaddingForDevice();
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
label.TextColor = Color.Black; label.TextColor = Color.Black;
} }

View file

@ -96,7 +96,7 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 44; table.EstimatedRowHeight = 44;

View file

@ -10,6 +10,7 @@ using Plugin.Connectivity.Abstractions;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -62,7 +63,7 @@ namespace Bit.App.Pages
PasswordCell.Button.Image = "eye"; PasswordCell.Button.Image = "eye";
PasswordCell.Entry.DisableAutocapitalize = true; PasswordCell.Entry.DisableAutocapitalize = true;
PasswordCell.Entry.Autocorrect = false; PasswordCell.Entry.Autocorrect = false;
PasswordCell.Entry.FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"); PasswordCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier");
UsernameCell = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry); UsernameCell = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry);
UsernameCell.Entry.DisableAutocapitalize = true; UsernameCell.Entry.DisableAutocapitalize = true;
@ -124,12 +125,12 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 70; table.EstimatedRowHeight = 70;
} }
else if(Device.OS == TargetPlatform.Android) else if(Device.RuntimePlatform == Device.Android)
{ {
PasswordCell.Button.WidthRequest = 40; PasswordCell.Button.WidthRequest = 40;
} }
@ -200,7 +201,7 @@ namespace Bit.App.Pages
Title = AppResources.AddLogin; Title = AppResources.AddLogin;
Content = table; Content = table;
ToolbarItems.Add(saveToolBarItem); ToolbarItems.Add(saveToolBarItem);
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }
@ -226,12 +227,12 @@ namespace Bit.App.Pages
if(!_fromAutofill && !_settings.GetValueOrDefault(AddedLoginAlertKey, false)) if(!_fromAutofill && !_settings.GetValueOrDefault(AddedLoginAlertKey, false))
{ {
_settings.AddOrUpdateValue(AddedLoginAlertKey, true); _settings.AddOrUpdateValue(AddedLoginAlertKey, true);
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
DisplayAlert(AppResources.BitwardenAppExtension, AppResources.BitwardenAppExtensionAlert, DisplayAlert(AppResources.BitwardenAppExtension, AppResources.BitwardenAppExtensionAlert,
AppResources.Ok); AppResources.Ok);
} }
else if(Device.OS == TargetPlatform.Android && !_appInfoService.AutofillServiceEnabled) else if(Device.RuntimePlatform == Device.Android && !_appInfoService.AutofillServiceEnabled)
{ {
DisplayAlert(AppResources.BitwardenAutofillService, AppResources.BitwardenAutofillServiceAlert, DisplayAlert(AppResources.BitwardenAutofillService, AppResources.BitwardenAutofillServiceAlert,
AppResources.Ok); AppResources.Ok);

View file

@ -106,7 +106,7 @@ namespace Bit.App.Pages
(VaultListPageModel.Login l) => MoreClickedAsync(l))) (VaultListPageModel.Login l) => MoreClickedAsync(l)))
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ListView.RowHeight = -1; ListView.RowHeight = -1;
} }
@ -325,7 +325,7 @@ namespace Bit.App.Pages
VerticalTextAlignment = TextAlignment.Center VerticalTextAlignment = TextAlignment.Center
}; };
label.SetBinding<VaultListPageModel.AutofillGrouping>(Label.TextProperty, s => s.Name); label.SetBinding(Label.TextProperty, nameof(VaultListPageModel.AutofillGrouping.Name));
var grid = new ContentView var grid = new ContentView
{ {

View file

@ -8,6 +8,7 @@ using Bit.App.Resources;
using Plugin.Connectivity.Abstractions; using Plugin.Connectivity.Abstractions;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -60,7 +61,7 @@ namespace Bit.App.Pages
PasswordCell.Button.Image = "eye"; PasswordCell.Button.Image = "eye";
PasswordCell.Entry.DisableAutocapitalize = true; PasswordCell.Entry.DisableAutocapitalize = true;
PasswordCell.Entry.Autocorrect = false; PasswordCell.Entry.Autocorrect = false;
PasswordCell.Entry.FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"); PasswordCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier");
UsernameCell = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry); UsernameCell = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry);
UsernameCell.Entry.Text = login.Username?.Decrypt(login.OrganizationId); UsernameCell.Entry.Text = login.Username?.Decrypt(login.OrganizationId);
@ -135,12 +136,12 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 70; table.EstimatedRowHeight = 70;
} }
else if(Device.OS == TargetPlatform.Android) else if(Device.RuntimePlatform == Device.Android)
{ {
PasswordCell.Button.WidthRequest = 40; PasswordCell.Button.WidthRequest = 40;
} }
@ -206,7 +207,7 @@ namespace Bit.App.Pages
Title = AppResources.EditLogin; Title = AppResources.EditLogin;
Content = table; Content = table;
ToolbarItems.Add(saveToolBarItem); ToolbarItems.Add(saveToolBarItem);
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }

View file

@ -95,7 +95,7 @@ namespace Bit.App.Pages
(VaultListPageModel.Login l) => MoreClickedAsync(l))) (VaultListPageModel.Login l) => MoreClickedAsync(l)))
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ListView.RowHeight = -1; ListView.RowHeight = -1;
} }
@ -107,7 +107,7 @@ namespace Bit.App.Pages
CancelButtonColor = Color.FromHex("3c8dbc") CancelButtonColor = Color.FromHex("3c8dbc")
}; };
// Bug with searchbar on android 7, ref https://bugzilla.xamarin.com/show_bug.cgi?id=43975 // Bug with searchbar on android 7, ref https://bugzilla.xamarin.com/show_bug.cgi?id=43975
if(Device.OS == TargetPlatform.Android && _deviceInfoService.Version >= 24) if(Device.RuntimePlatform == Device.Android && _deviceInfoService.Version >= 24)
{ {
Search.HeightRequest = 50; Search.HeightRequest = 50;
} }
@ -239,7 +239,7 @@ namespace Bit.App.Pages
_filterResultsCancellationTokenSource = FetchAndLoadVault(); _filterResultsCancellationTokenSource = FetchAndLoadVault();
} }
if(_connectivity.IsConnected && Device.OS == TargetPlatform.iOS && !_favorites) if(_connectivity.IsConnected && Device.RuntimePlatform == Device.iOS && !_favorites)
{ {
var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false); var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false);
Action registerAction = () => Action registerAction = () =>
@ -512,7 +512,7 @@ namespace Bit.App.Pages
VerticalTextAlignment = TextAlignment.Center VerticalTextAlignment = TextAlignment.Center
}; };
label.SetBinding<VaultListPageModel.Folder>(Label.TextProperty, s => s.Name); label.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Folder.Name));
var grid = new Grid var grid = new Grid
{ {

View file

@ -7,6 +7,7 @@ using Bit.App.Resources;
using Xamarin.Forms; using Xamarin.Forms;
using XLabs.Ioc; using XLabs.Ioc;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bit.App.Utilities;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -41,44 +42,44 @@ namespace Bit.App.Pages
{ {
EditItem = new EditLoginToolBarItem(this, _loginId); EditItem = new EditLoginToolBarItem(this, _loginId);
ToolbarItems.Add(EditItem); ToolbarItems.Add(EditItem);
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this)); ToolbarItems.Add(new DismissModalToolBarItem(this));
} }
// Name // Name
var nameCell = new LabeledValueCell(AppResources.Name); var nameCell = new LabeledValueCell(AppResources.Name);
nameCell.Value.SetBinding<VaultViewLoginPageModel>(Label.TextProperty, s => s.Name); nameCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.Name));
// Username // Username
UsernameCell = new LabeledValueCell(AppResources.Username, button1Text: AppResources.Copy); UsernameCell = new LabeledValueCell(AppResources.Username, button1Text: AppResources.Copy);
UsernameCell.Value.SetBinding<VaultViewLoginPageModel>(Label.TextProperty, s => s.Username); UsernameCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.Username));
UsernameCell.Value.SetBinding<VaultViewLoginPageModel>(Label.FontSizeProperty, s => s.UsernameFontSize); UsernameCell.Value.SetBinding(Label.FontSizeProperty, nameof(VaultViewLoginPageModel.UsernameFontSize));
UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username)); UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username));
// Password // Password
PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: string.Empty, PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: string.Empty,
button2Text: AppResources.Copy); button2Text: AppResources.Copy);
PasswordCell.Value.SetBinding<VaultViewLoginPageModel>(Label.TextProperty, s => s.MaskedPassword); PasswordCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.MaskedPassword));
PasswordCell.Value.SetBinding<VaultViewLoginPageModel>(Label.FontSizeProperty, s => s.PasswordFontSize); PasswordCell.Value.SetBinding(Label.FontSizeProperty, nameof(VaultViewLoginPageModel.PasswordFontSize));
PasswordCell.Button1.SetBinding<VaultViewLoginPageModel>(Button.ImageProperty, s => s.ShowHideImage); PasswordCell.Value.SetBinding(Button.ImageProperty, nameof(VaultViewLoginPageModel.ShowHideImage));
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
PasswordCell.Button1.Margin = new Thickness(10, 0); PasswordCell.Button1.Margin = new Thickness(10, 0);
} }
PasswordCell.Button1.Command = new Command(() => Model.RevealPassword = !Model.RevealPassword); PasswordCell.Button1.Command = new Command(() => Model.RevealPassword = !Model.RevealPassword);
PasswordCell.Button2.Command = new Command(() => Copy(Model.Password, AppResources.Password)); PasswordCell.Button2.Command = new Command(() => Copy(Model.Password, AppResources.Password));
PasswordCell.Value.FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"); PasswordCell.Value.FontFamily = Helpers.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier");
// URI // URI
UriCell = new LabeledValueCell(AppResources.Website, button1Text: AppResources.Launch); UriCell = new LabeledValueCell(AppResources.Website, button1Text: AppResources.Launch);
UriCell.Value.SetBinding<VaultViewLoginPageModel>(Label.TextProperty, s => s.UriHost); UriCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.UriHost));
UriCell.Button1.SetBinding<VaultViewLoginPageModel>(IsVisibleProperty, s => s.ShowLaunch); UriCell.Value.SetBinding(IsVisibleProperty, nameof(VaultViewLoginPageModel.ShowLaunch));
UriCell.Button1.Command = new Command(() => Device.OpenUri(new Uri(Model.Uri))); UriCell.Button1.Command = new Command(() => Device.OpenUri(new Uri(Model.Uri)));
// Notes // Notes
NotesCell = new LabeledValueCell(); NotesCell = new LabeledValueCell();
NotesCell.Value.SetBinding<VaultViewLoginPageModel>(Label.TextProperty, s => s.Notes); NotesCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.Notes));
NotesCell.Value.LineBreakMode = LineBreakMode.WordWrap; NotesCell.Value.LineBreakMode = LineBreakMode.WordWrap;
LoginInformationSection = new TableSection(AppResources.LoginInformation) LoginInformationSection = new TableSection(AppResources.LoginInformation)
@ -104,12 +105,12 @@ namespace Bit.App.Pages
} }
}; };
if(Device.OS == TargetPlatform.iOS) if(Device.RuntimePlatform == Device.iOS)
{ {
Table.RowHeight = -1; Table.RowHeight = -1;
Table.EstimatedRowHeight = 70; Table.EstimatedRowHeight = 70;
} }
else if(Device.OS == TargetPlatform.Android) else if(Device.RuntimePlatform == Device.Android)
{ {
// NOTE: This is going to cause problems with i18n strings since various languages have difference string sizes // NOTE: This is going to cause problems with i18n strings since various languages have difference string sizes
PasswordCell.Button1.WidthRequest = 40; PasswordCell.Button1.WidthRequest = 40;

View file

@ -39,7 +39,7 @@ namespace Bit.App
public static void FocusWithDelay(this Entry entry, int delay = 1000) public static void FocusWithDelay(this Entry entry, int delay = 1000)
{ {
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
Task.Run(async () => Task.Run(async () =>
{ {
@ -65,7 +65,7 @@ namespace Bit.App
public static void AdjustMarginsForDevice(this View view) public static void AdjustMarginsForDevice(this View view)
{ {
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
var deviceInfo = Resolver.Resolve<IDeviceInfoService>(); var deviceInfo = Resolver.Resolve<IDeviceInfoService>();
if(deviceInfo.Version < 21) if(deviceInfo.Version < 21)
@ -85,7 +85,7 @@ namespace Bit.App
public static void AdjustPaddingForDevice(this Layout view) public static void AdjustPaddingForDevice(this Layout view)
{ {
if(Device.OS == TargetPlatform.Android) if(Device.RuntimePlatform == Device.Android)
{ {
var deviceInfo = Resolver.Resolve<IDeviceInfoService>(); var deviceInfo = Resolver.Resolve<IDeviceInfoService>();
if(deviceInfo.Scale == 1) // mdpi if(deviceInfo.Scale == 1) // mdpi

View file

@ -0,0 +1,26 @@
using System;
using Xamarin.Forms;
namespace Bit.App.Utilities
{
public static class Helpers
{
public static T OnPlatform<T>(T iOS = default(T), T Android = default(T),
T WinPhone = default(T), T Windows = default(T))
{
switch(Device.RuntimePlatform)
{
case Device.iOS:
return iOS;
case Device.Android:
return Android;
case Device.WinPhone:
return WinPhone;
case Device.Windows:
return Windows;
default:
throw new Exception("Unsupported platform.");
}
}
}
}

View file

@ -122,10 +122,10 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AndroidResource Include="Resources\values\styles.xml" /> <AndroidResource Include="Resources\xml\accessibilityservice.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AndroidResource Include="Resources\xml\accessibilityservice.xml" /> <AndroidResource Include="Resources\values\styles.xml" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<resources> <resources>
<style name="BitwardenTheme.Splash" parent="BitwardenTheme.Base"> <style name="BitwardenTheme.Splash" parent="BitwardenTheme.Base">
<item name="android:windowNoTitle">true</item>
</style> </style>
<style name="BitwardenTheme" parent="BitwardenTheme.Base"> <style name="BitwardenTheme" parent="BitwardenTheme.Base">
</style> </style>
<style name="BitwardenTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> <style name="BitwardenTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionModeOverlay">true</item>
</style> </style>
</resources> </resources>