-
Notifications
You must be signed in to change notification settings - Fork 760
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: AnalyticsInfo and AnalyticsVersionInfo compatibility adjustments
- Loading branch information
1 parent
fb8ba79
commit 4c4cd9a
Showing
18 changed files
with
105 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
namespace Windows.System.Profile | ||
{ | ||
/// <summary> | ||
/// Provides version information about the device family. | ||
/// </summary> | ||
public static partial class AnalyticsInfo | ||
{ | ||
#if __ANDROID__ || __IOS__ || __WASM__ || __MACOS__ || __SKIA__ | ||
/// <summary> | ||
/// Gets the device form factor running the OS. For example, | ||
/// the app could be running on a phone, tablet, desktop, and so on. | ||
/// </summary> | ||
public static string DeviceForm => GetDeviceForm().ToString(); | ||
|
||
/// <summary> | ||
/// Gets version info about the device family. | ||
/// </summary> | ||
public static AnalyticsVersionInfo VersionInfo { get; } = new AnalyticsVersionInfo(); | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using UIKit; | ||
using Uno.System.Profile; | ||
|
||
namespace Windows.System.Profile | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#if NET461 || __NETSTD_REFERENCE__ | ||
using Uno.System.Profile; | ||
|
||
namespace Windows.System.Profile | ||
{ | ||
public partial class AnalyticsInfo | ||
{ | ||
private static UnoDeviceForm GetDeviceForm() => UnoDeviceForm.Desktop; | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using System; | ||
using Uno.Foundation; | ||
using Uno.System.Profile; | ||
|
||
namespace Windows.System.Profile | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using Uno; | ||
|
||
namespace Windows.System.Profile | ||
{ | ||
/// <summary> | ||
/// Provides version information about the device family. | ||
/// </summary> | ||
public partial class AnalyticsVersionInfo | ||
{ | ||
public AnalyticsVersionInfo() => Initialize(); | ||
|
||
partial void Initialize(); | ||
|
||
/// <summary> | ||
/// Gets a string that represents the type of device the application is running on. | ||
/// </summary> | ||
public string DeviceFamily { get; private set; } = $"{Environment.OSVersion.Platform}.Desktop"; | ||
|
||
/// <summary> | ||
/// Gets the version within the device family. | ||
/// </summary> | ||
/// <remarks> | ||
/// Needs to be parsable long number. | ||
/// </remarks> | ||
[NotImplemented("__WASM__")] | ||
public string DeviceFamilyVersion { get; private set; } = "0"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
#if __IOS__ | ||
using UIKit; | ||
|
||
namespace Windows.System.Profile | ||
{ | ||
public partial class AnalyticsVersionInfo | ||
{ | ||
private const string OsName = "iOS"; | ||
|
||
internal AnalyticsVersionInfo() | ||
partial void Initialize() | ||
{ | ||
DeviceFamily = $"{OsName}.{AnalyticsInfo.DeviceForm}"; | ||
DeviceFamilyVersion = UIDevice.CurrentDevice.SystemVersion; | ||
} | ||
|
||
public string DeviceFamily => OsName + '.' + AnalyticsInfo.DeviceForm; | ||
|
||
public string DeviceFamilyVersion => UIDevice.CurrentDevice.SystemVersion; | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Uno; | ||
using static Uno.Foundation.WebAssemblyRuntime; | ||
|
||
namespace Windows.System.Profile | ||
{ | ||
public partial class AnalyticsVersionInfo | ||
{ | ||
private const string OsName = "Browser"; | ||
private const string BrowserVersionFallback = "Unknown"; | ||
private const string JsType = "Windows.System.Profile.AnalyticsVersionInfo"; | ||
|
||
internal AnalyticsVersionInfo() | ||
{ | ||
} | ||
|
||
public string DeviceFamily => OsName + '.' + AnalyticsInfo.DeviceForm; | ||
|
||
public string DeviceFamilyVersion => GetUserAgent(); | ||
|
||
private string GetUserAgent() | ||
{ | ||
var userAgent = InvokeJS(JsType + ".getUserAgent()"); | ||
if (!string.IsNullOrEmpty(userAgent)) | ||
{ | ||
return userAgent; | ||
} | ||
return BrowserVersionFallback; | ||
} | ||
partial void Initialize() | ||
{ | ||
DeviceFamily = $"{OsName}.{AnalyticsInfo.DeviceForm}"; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Uno.UWP/System/Profile/Internal/IAnalyticsInfoExtension.skia.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#nullable enable | ||
|
||
using Uno.System.Profile; | ||
|
||
namespace Windows.System.Profile.Internal | ||
{ | ||
internal interface IAnalyticsInfoExtension | ||
{ | ||
UnoDeviceForm GetDeviceForm(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Uno.UWP/System/Profile/Internal/IAnalyticsVersionInfoExtension.skia.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#nullable enable | ||
|
||
namespace Uno.System.Profile | ||
{ | ||
internal interface IAnalyticsVersionInfoExtension | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters