mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
UUID Support
This commit is contained in:
@ -16,6 +16,7 @@ export class device implements definition.device {
|
|||||||
private static _osVersion: string;
|
private static _osVersion: string;
|
||||||
private static _sdkVersion: string;
|
private static _sdkVersion: string;
|
||||||
private static _deviceType: string;
|
private static _deviceType: string;
|
||||||
|
private static _uuid: string;
|
||||||
|
|
||||||
static get os(): string {
|
static get os(): string {
|
||||||
return platformNames.android;
|
return platformNames.android;
|
||||||
@ -48,7 +49,7 @@ export class device implements definition.device {
|
|||||||
static get deviceType(): string {
|
static get deviceType(): string {
|
||||||
if (!device._deviceType) {
|
if (!device._deviceType) {
|
||||||
var dips = Math.min(screen.mainScreen.widthPixels, screen.mainScreen.heightPixels) / screen.mainScreen.scale;
|
var dips = Math.min(screen.mainScreen.widthPixels, screen.mainScreen.heightPixels) / screen.mainScreen.scale;
|
||||||
|
|
||||||
// If the device has more than 600 dips it is considered to be a tablet.
|
// If the device has more than 600 dips it is considered to be a tablet.
|
||||||
if (dips >= device.MIN_TABLET_PIXELS) {
|
if (dips >= device.MIN_TABLET_PIXELS) {
|
||||||
device._deviceType = enums.DeviceType.Tablet;
|
device._deviceType = enums.DeviceType.Tablet;
|
||||||
@ -60,6 +61,17 @@ export class device implements definition.device {
|
|||||||
|
|
||||||
return device._deviceType;
|
return device._deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get uuid(): string {
|
||||||
|
if (!device._uuid) {
|
||||||
|
device._uuid = android.provider.Settings.Secure.getString(
|
||||||
|
application.android.context.getContentResolver(),
|
||||||
|
android.provider.Settings.Secure.ANDROID_ID
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return device._uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainScreenInfo: definition.ScreenMetrics;
|
var mainScreenInfo: definition.ScreenMetrics;
|
||||||
@ -80,4 +92,4 @@ export class screen implements definition.screen {
|
|||||||
}
|
}
|
||||||
return mainScreenInfo;
|
return mainScreenInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
platform/platform.d.ts
vendored
9
platform/platform.d.ts
vendored
@ -3,7 +3,7 @@
|
|||||||
* Contains all kinds of information about the device, its operating system and software.
|
* Contains all kinds of information about the device, its operating system and software.
|
||||||
*/
|
*/
|
||||||
declare module "platform" {
|
declare module "platform" {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enum holding platform names.
|
* Enum holding platform names.
|
||||||
*/
|
*/
|
||||||
@ -45,6 +45,11 @@ declare module "platform" {
|
|||||||
* Available values: "phone", "tablet".
|
* Available values: "phone", "tablet".
|
||||||
*/
|
*/
|
||||||
static deviceType: string;
|
static deviceType: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the uuid
|
||||||
|
*/
|
||||||
|
static uuid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,4 +91,4 @@ declare module "platform" {
|
|||||||
*/
|
*/
|
||||||
static mainScreen: ScreenMetrics;
|
static mainScreen: ScreenMetrics;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,18 @@ export class device implements definition.device {
|
|||||||
|
|
||||||
return device._deviceType;
|
return device._deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get uuid(): string {
|
||||||
|
if (!device._uuid) {
|
||||||
|
/*NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
var UUID_KEY = @"CDVUUID";
|
||||||
|
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
|
||||||
|
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
return device._uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainScreenInfo: definition.ScreenMetrics = null;
|
var mainScreenInfo: definition.ScreenMetrics = null;
|
||||||
|
Reference in New Issue
Block a user