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:
Erjan Gavalji
2015-04-24 15:03:52 +03:00
3 changed files with 26 additions and 0 deletions

View File

@ -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;

View File

@ -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;
} }
/** /**

View File

@ -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;