mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Merge pull request #279 from anarchicknight/platform_module_enhancements
added ability to retrieve device manufacturer
This commit is contained in:
@ -12,6 +12,7 @@ export module platformNames {
|
|||||||
// It is not meant to be initialized - thus it is not capitalized
|
// It is not meant to be initialized - thus it is not capitalized
|
||||||
export class device implements definition.device {
|
export class device implements definition.device {
|
||||||
private static MIN_TABLET_PIXELS = 600;
|
private static MIN_TABLET_PIXELS = 600;
|
||||||
|
private static _manufacturer: string;
|
||||||
private static _model: string;
|
private static _model: string;
|
||||||
private static _osVersion: string;
|
private static _osVersion: string;
|
||||||
private static _sdkVersion: string;
|
private static _sdkVersion: string;
|
||||||
@ -22,6 +23,14 @@ export class device implements definition.device {
|
|||||||
return platformNames.android;
|
return platformNames.android;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get manufacturer(): string {
|
||||||
|
if (!device._manufacturer) {
|
||||||
|
device._manufacturer = android.os.Build.MANUFACTURER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return device._manufacturer;
|
||||||
|
}
|
||||||
|
|
||||||
static get osVersion(): string {
|
static get osVersion(): string {
|
||||||
if (!device._osVersion) {
|
if (!device._osVersion) {
|
||||||
device._osVersion = android.os.Build.VERSION.RELEASE;
|
device._osVersion = android.os.Build.VERSION.RELEASE;
|
||||||
|
6
platform/platform.d.ts
vendored
6
platform/platform.d.ts
vendored
@ -16,6 +16,12 @@ declare module "platform" {
|
|||||||
* An object containing device specific information.
|
* An object containing device specific information.
|
||||||
*/
|
*/
|
||||||
export class device {
|
export class device {
|
||||||
|
/**
|
||||||
|
* Gets the manufacturer of the device.
|
||||||
|
* For example: "Apple" or "HTC" or "Samsung".
|
||||||
|
*/
|
||||||
|
static manufacturer: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the model of the device.
|
* Gets the model of the device.
|
||||||
* For example: "Nexus 5" or "iPhone".
|
* For example: "Nexus 5" or "iPhone".
|
||||||
|
@ -15,6 +15,10 @@ export class device implements definition.device {
|
|||||||
private static _sdkVersion: string;
|
private static _sdkVersion: string;
|
||||||
private static _deviceType: string;
|
private static _deviceType: string;
|
||||||
|
|
||||||
|
static get manufacturer(): string {
|
||||||
|
return "Apple";
|
||||||
|
}
|
||||||
|
|
||||||
static get os(): string {
|
static get os(): string {
|
||||||
return platformNames.ios;
|
return platformNames.ios;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user