1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-26 12:16:07 +01:00

add type to deviceinfo to avoid using XF

This commit is contained in:
Kyle Spearrin 2017-12-21 13:10:55 -05:00
parent 379a82972a
commit 2b4ffaa357
6 changed files with 14 additions and 5 deletions

View File

@ -8,6 +8,7 @@ namespace Bit.Android.Services
{
public class DeviceInfoService : IDeviceInfoService
{
public string Type => Xamarin.Forms.Device.Android;
public string Model => Build.Model;
public int Version => (int)Build.VERSION.SdkInt;
public float Scale

View File

@ -2,6 +2,7 @@
{
public interface IDeviceInfoService
{
string Type { get; }
string Model { get; }
int Version { get; }
float Scale { get; }

View File

@ -23,9 +23,14 @@ namespace Bit.App.Utilities
}
public static T OnPlatform<T>(T iOS = default(T), T Android = default(T),
T WinPhone = default(T), T Windows = default(T))
T WinPhone = default(T), T Windows = default(T), string platform = null)
{
switch(Device.RuntimePlatform)
if(platform == null)
{
platform = Device.RuntimePlatform;
}
switch(platform)
{
case Device.iOS:
return iOS;

View File

@ -14,6 +14,7 @@ namespace Bit.App
{
var tokenService = Resolver.Resolve<ITokenService>();
var appIdService = Resolver.Resolve<IAppIdService>();
var deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
if(!string.IsNullOrWhiteSpace(tokenService.Token))
{
@ -25,7 +26,7 @@ namespace Bit.App
}
Headers.Add("Device-Type", ((int)Helpers.OnPlatform(iOS: DeviceType.iOS,
Android: DeviceType.Android, Windows: DeviceType.UWP)).ToString());
Android: DeviceType.Android, Windows: DeviceType.UWP, platform: deviceInfoService.Type)).ToString());
}
public TokenHttpRequestMessage(object requestObject)

View File

@ -13,6 +13,7 @@ namespace Bit.UWP.Services
{
private const string SmartCardEmulatorType = "Windows.Devices.SmartCards.SmartCardEmulator";
public string Type => Xamarin.Forms.Device.UWP;
public string Model => SystemInformation.DeviceModel;
public int Version => SystemInformation.OperatingSystemVersion.Build;
public float Scale => (float)DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;

View File

@ -7,14 +7,14 @@ namespace Bit.iOS.Core.Services
{
public class DeviceInfoService : IDeviceInfoService
{
public string Type => Xamarin.Forms.Device.iOS;
public string Model => UIDevice.CurrentDevice.Model;
public int Version
{
get
{
int version;
var versionParts = UIDevice.CurrentDevice.SystemVersion.Split('.');
if(versionParts.Length > 0 && int.TryParse(versionParts[0], out version))
if(versionParts.Length > 0 && int.TryParse(versionParts[0], out int version))
{
return version;
}