mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-29 12:45:20 +01:00
add type to deviceinfo to avoid using XF
This commit is contained in:
parent
379a82972a
commit
2b4ffaa357
@ -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
|
||||
|
@ -2,6 +2,7 @@
|
||||
{
|
||||
public interface IDeviceInfoService
|
||||
{
|
||||
string Type { get; }
|
||||
string Model { get; }
|
||||
int Version { get; }
|
||||
float Scale { get; }
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user