mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #306 from darind/feature/extended-platform-info
Added user agent string and selected language to the platform module
This commit is contained in:
@ -18,6 +18,7 @@ export class device implements definition.device {
|
|||||||
private static _sdkVersion: string;
|
private static _sdkVersion: string;
|
||||||
private static _deviceType: string;
|
private static _deviceType: string;
|
||||||
private static _uuid: string;
|
private static _uuid: string;
|
||||||
|
private static _language: string;
|
||||||
|
|
||||||
static get os(): string {
|
static get os(): string {
|
||||||
return platformNames.android;
|
return platformNames.android;
|
||||||
@ -81,6 +82,16 @@ export class device implements definition.device {
|
|||||||
|
|
||||||
return device._uuid;
|
return device._uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get language(): string {
|
||||||
|
if (!device._language) {
|
||||||
|
var context = application.android.context;
|
||||||
|
var locale = context.getResources().getConfiguration().locale;
|
||||||
|
device._language = locale.getDefault().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return device._language;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainScreenInfo: definition.ScreenMetrics;
|
var mainScreenInfo: definition.ScreenMetrics;
|
||||||
|
5
platform/platform.d.ts
vendored
5
platform/platform.d.ts
vendored
@ -56,6 +56,11 @@ declare module "platform" {
|
|||||||
* Gets the uuid
|
* Gets the uuid
|
||||||
*/
|
*/
|
||||||
static uuid: string;
|
static uuid: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the preferred language. For example "en" or "en_US"
|
||||||
|
*/
|
||||||
|
static language: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,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 _language: string;
|
||||||
|
|
||||||
static get manufacturer(): string {
|
static get manufacturer(): string {
|
||||||
return "Apple";
|
return "Apple";
|
||||||
@ -74,6 +75,15 @@ export class device implements definition.device {
|
|||||||
|
|
||||||
return app_uuid;
|
return app_uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get language(): string {
|
||||||
|
if (!device._language) {
|
||||||
|
var languages = NSLocale.preferredLanguages();
|
||||||
|
device._language = languages[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return device._language;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainScreenInfo: definition.ScreenMetrics = null;
|
var mainScreenInfo: definition.ScreenMetrics = null;
|
||||||
|
Reference in New Issue
Block a user