diff --git a/scripts/langindex.json b/scripts/langindex.json index 944b7ea67..c8fd95213 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1328,6 +1328,7 @@ "core.areyousure": "moodle", "core.back": "moodle", "core.block.blocks": "moodle", + "core.browser": "local_moodlemobileapp", "core.cancel": "moodle", "core.cannotconnect": "local_moodlemobileapp", "core.cannotdownloadfiles": "local_moodlemobileapp", @@ -1465,6 +1466,7 @@ "core.deleteduser": "bulkusers", "core.deleting": "local_moodlemobileapp", "core.description": "moodle", + "core.desktop": "local_moodlemobileapp", "core.dfdaymonthyear": "local_moodlemobileapp", "core.dfdayweekmonth": "local_moodlemobileapp", "core.dffulldate": "local_moodlemobileapp", @@ -1658,6 +1660,7 @@ "core.lastmodified": "moodle", "core.lastsync": "local_moodlemobileapp", "core.layoutgrid": "workshopform_rubric", + "core.linux": "local_moodlemobileapp", "core.list": "moodle", "core.listsep": "langconfig", "core.loading": "moodle", @@ -1759,6 +1762,7 @@ "core.login.visitchangepassword": "local_moodlemobileapp", "core.login.webservicesnotenabled": "local_moodlemobileapp", "core.lostconnection": "local_moodlemobileapp", + "core.mac": "local_moodlemobileapp", "core.mainmenu.appsettings": "local_moodlemobileapp", "core.mainmenu.changesite": "local_moodlemobileapp", "core.mainmenu.help": "moodle", @@ -1890,7 +1894,7 @@ "core.sending": "chat", "core.serverconnection": "error", "core.settings.about": "local_moodlemobileapp", - "core.settings.appready": "local_moodlemobileapp", + "core.settings.appversion": "local_moodlemobileapp", "core.settings.cannotsyncoffline": "local_moodlemobileapp", "core.settings.cannotsyncwithoutwifi": "local_moodlemobileapp", "core.settings.colorscheme": "local_moodlemobileapp", @@ -1898,6 +1902,7 @@ "core.settings.colorscheme-dark": "local_moodlemobileapp", "core.settings.colorscheme-light": "local_moodlemobileapp", "core.settings.compilationinfo": "local_moodlemobileapp", + "core.settings.copyinfo": "local_moodlemobileapp", "core.settings.cordovadevicemodel": "local_moodlemobileapp", "core.settings.cordovadeviceosversion": "local_moodlemobileapp", "core.settings.cordovadeviceplatform": "local_moodlemobileapp", @@ -1910,7 +1915,6 @@ "core.settings.deletesitefilestitle": "local_moodlemobileapp", "core.settings.deviceinfo": "local_moodlemobileapp", "core.settings.deviceos": "local_moodlemobileapp", - "core.settings.devicewebworkers": "local_moodlemobileapp", "core.settings.disableall": "message", "core.settings.disabled": "lesson", "core.settings.displayformat": "local_moodlemobileapp", @@ -1929,7 +1933,6 @@ "core.settings.fontsizecharacter": "block_accessibility/char", "core.settings.general": "moodle", "core.settings.language": "moodle", - "core.settings.license": "moodle", "core.settings.localnotifavailable": "local_moodlemobileapp", "core.settings.locationhref": "local_moodlemobileapp", "core.settings.locked": "admin", @@ -1938,19 +1941,20 @@ "core.settings.navigatorlanguage": "local_moodlemobileapp", "core.settings.navigatoruseragent": "local_moodlemobileapp", "core.settings.networkstatus": "local_moodlemobileapp", + "core.settings.opensourcelicenses": "local_moodlemobileapp", "core.settings.privacypolicy": "local_moodlemobileapp", "core.settings.pushid": "local_moodlemobileapp", "core.settings.reportinbackground": "local_moodlemobileapp", + "core.settings.screen": "local_moodlemobileapp", "core.settings.settings": "moodle", "core.settings.showdownloadoptions": "local_moodlemobileapp", + "core.settings.siteinfo": "local_moodlemobileapp", "core.settings.sites": "moodle", "core.settings.spaceusage": "local_moodlemobileapp", "core.settings.synchronization": "local_moodlemobileapp", "core.settings.synchronizenow": "local_moodlemobileapp", "core.settings.syncsettings": "local_moodlemobileapp", "core.settings.total": "moodle", - "core.settings.versioncode": "local_moodlemobileapp", - "core.settings.versionname": "local_moodlemobileapp", "core.settings.wificonnection": "local_moodlemobileapp", "core.sharedfiles.chooseaccountstorefile": "local_moodlemobileapp", "core.sharedfiles.chooseactionrepeatedfile": "local_moodlemobileapp", @@ -2068,7 +2072,7 @@ "core.whoops": "local_moodlemobileapp", "core.whyisthishappening": "local_moodlemobileapp", "core.whyisthisrequired": "moodle", - "core.windowsphone": "local_moodlemobileapp", + "core.windows": "local_moodlemobileapp", "core.wsfunctionnotavailable": "local_moodlemobileapp", "core.year": "moodle", "core.years": "moodle", diff --git a/src/app/app.scss b/src/app/app.scss index 25ddf5749..1cd1e835a 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -205,6 +205,10 @@ ion-app.app-root { background-color: $gray-light; } + ion-note.core-note-block { + display: block; + } + // Form items // ------------------------- diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index c7614adfe..76661f0a2 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1328,6 +1328,7 @@ "core.areyousure": "Are you sure?", "core.back": "Back", "core.block.blocks": "Blocks", + "core.browser": "Browser", "core.cancel": "Cancel", "core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle {{$a}} or later.", "core.cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.", @@ -1465,6 +1466,7 @@ "core.deleteduser": "Deleted user", "core.deleting": "Deleting", "core.description": "Description", + "core.desktop": "Desktop", "core.dfdaymonthyear": "MM-DD-YYYY", "core.dfdayweekmonth": "ddd, D MMM", "core.dffulldate": "dddd, D MMMM YYYY h[:]mm A", @@ -1658,6 +1660,7 @@ "core.lastmodified": "Last modified", "core.lastsync": "Last synchronisation", "core.layoutgrid": "Grid", + "core.linux": "Linux", "core.list": "List", "core.listsep": ",", "core.loading": "Loading", @@ -1759,6 +1762,7 @@ "core.login.visitchangepassword": "Do you want to visit the site to change the password?", "core.login.webservicesnotenabled": "Web services are not enabled in your site. Please contact your site administrator if you think they should be enabled.", "core.lostconnection": "Your authentication token is invalid or has expired. You will have to reconnect to the site.", + "core.mac": "MacOS", "core.mainmenu.appsettings": "App settings", "core.mainmenu.changesite": "Change site", "core.mainmenu.help": "Help", @@ -1890,7 +1894,7 @@ "core.sending": "Sending", "core.serverconnection": "Error connecting to the server", "core.settings.about": "About", - "core.settings.appready": "App ready", + "core.settings.appversion": "App version", "core.settings.cannotsyncoffline": "Cannot synchronise offline.", "core.settings.cannotsyncwithoutwifi": "Cannot synchronise because the current settings only allow to synchronise when connected to Wi-Fi. Please connect to a Wi-Fi network.", "core.settings.colorscheme": "Color Scheme", @@ -1898,6 +1902,7 @@ "core.settings.colorscheme-dark": "Dark", "core.settings.colorscheme-light": "Light", "core.settings.compilationinfo": "Compilation info", + "core.settings.copyinfo": "Copy device info on the clipboard", "core.settings.cordovadevicemodel": "Cordova device model", "core.settings.cordovadeviceosversion": "Cordova device OS version", "core.settings.cordovadeviceplatform": "Cordova device platform", @@ -1910,7 +1915,6 @@ "core.settings.deletesitefilestitle": "Delete site files", "core.settings.deviceinfo": "Device info", "core.settings.deviceos": "Device OS", - "core.settings.devicewebworkers": "Device web workers supported", "core.settings.disableall": "Disable notifications", "core.settings.disabled": "Disabled", "core.settings.displayformat": "Display format", @@ -1929,7 +1933,6 @@ "core.settings.fontsizecharacter": "A", "core.settings.general": "General", "core.settings.language": "Language", - "core.settings.license": "Licence", "core.settings.localnotifavailable": "Local notifications available", "core.settings.locationhref": "Web view URL", "core.settings.locked": "Locked", @@ -1938,19 +1941,20 @@ "core.settings.navigatorlanguage": "Navigator language", "core.settings.navigatoruseragent": "Navigator userAgent", "core.settings.networkstatus": "Internet connection status", + "core.settings.opensourcelicenses": "Open Source Licences", "core.settings.privacypolicy": "Privacy policy", "core.settings.pushid": "Push notifications ID", "core.settings.reportinbackground": "Report errors automatically", + "core.settings.screen": "Screen information", "core.settings.settings": "Settings", "core.settings.showdownloadoptions": "Show download options", + "core.settings.siteinfo": "Site info", "core.settings.sites": "Sites", "core.settings.spaceusage": "Space usage", "core.settings.synchronization": "Synchronisation", "core.settings.synchronizenow": "Synchronise now", "core.settings.syncsettings": "Synchronisation settings", "core.settings.total": "Total", - "core.settings.versioncode": "Version code", - "core.settings.versionname": "Version name", "core.settings.wificonnection": "Wi-Fi connection", "core.sharedfiles.chooseaccountstorefile": "Choose an account to store the file in.", "core.sharedfiles.chooseactionrepeatedfile": "A file with this name already exists. Do you want to replace the existing file or rename it to \"{{$a}}\"?", @@ -2068,7 +2072,7 @@ "core.whoops": "Oops!", "core.whyisthishappening": "Why is this happening?", "core.whyisthisrequired": "Why is this required?", - "core.windowsphone": "Windows Phone", + "core.windows": "Windows", "core.wsfunctionnotavailable": "The web service function is not available.", "core.year": "year", "core.years": "years", diff --git a/src/core/mainmenu/pages/more/more.html b/src/core/mainmenu/pages/more/more.html index 2bc22ebfc..a58a1cb37 100644 --- a/src/core/mainmenu/pages/more/more.html +++ b/src/core/mainmenu/pages/more/more.html @@ -8,8 +8,8 @@

{{siteInfo.fullname}}

- - {{ siteUrl }} + + {{ siteUrl }}
diff --git a/src/core/settings/lang/en.json b/src/core/settings/lang/en.json index 32a82c6cc..9d17ca1bb 100644 --- a/src/core/settings/lang/en.json +++ b/src/core/settings/lang/en.json @@ -1,6 +1,6 @@ { "about": "About", - "appready": "App ready", + "appversion": "App version", "cannotsyncoffline": "Cannot synchronise offline.", "cannotsyncwithoutwifi": "Cannot synchronise because the current settings only allow to synchronise when connected to Wi-Fi. Please connect to a Wi-Fi network.", "colorscheme": "Color Scheme", @@ -8,6 +8,7 @@ "colorscheme-dark": "Dark", "colorscheme-light": "Light", "compilationinfo": "Compilation info", + "copyinfo": "Copy device info on the clipboard", "cordovadevicemodel": "Cordova device model", "cordovadeviceosversion": "Cordova device OS version", "cordovadeviceplatform": "Cordova device platform", @@ -20,7 +21,6 @@ "deletesitefilestitle": "Delete site files", "deviceinfo": "Device info", "deviceos": "Device OS", - "devicewebworkers": "Device web workers supported", "disableall": "Disable notifications", "disabled": "Disabled", "displayformat": "Display format", @@ -38,7 +38,7 @@ "fontsizecharacter": "A", "general": "General", "language": "Language", - "license": "Licence", + "opensourcelicenses": "Open Source Licences", "localnotifavailable": "Local notifications available", "locationhref": "Web view URL", "locked": "Locked", @@ -51,15 +51,15 @@ "pushid": "Push notifications ID", "reportinbackground": "Report errors automatically", "entriesincache": "{{$a}} entries in cache", + "screen": "Screen information", "settings": "Settings", "showdownloadoptions": "Show download options", + "siteinfo": "Site info", "sites": "Sites", "spaceusage": "Space usage", "synchronization": "Synchronisation", "synchronizenow": "Synchronise now", "syncsettings": "Synchronisation settings", "total": "Total", - "versioncode": "Version code", - "versionname": "Version name", "wificonnection": "Wi-Fi connection" } diff --git a/src/core/settings/pages/about/about.html b/src/core/settings/pages/about/about.html index 01ec8e930..b6d38bc85 100644 --- a/src/core/settings/pages/about/about.html +++ b/src/core/settings/pages/about/about.html @@ -7,120 +7,16 @@

{{ appName }} {{ versionName }}

- - - {{ 'core.settings.license' | translate }} - - -

Apache 2.0

-

http://www.apache.org/licenses/LICENSE-2.0

-
-
- - - {{ 'core.settings.privacypolicy' | translate }} - - -

{{ privacyPolicy }}

-
-
- - - {{ 'core.login.siteurl' | translate }} * - - -

{{ siteUrl }}

-
-
- - - {{ 'core.settings.deviceinfo' | translate }} - - -

{{ 'core.settings.versionname' | translate}}

-

{{ versionName }}

-
- -

{{ 'core.settings.versioncode' | translate}}

-

{{ versionCode }}

-
- -

{{ 'core.settings.compilationinfo' | translate }}

-

{{ compilationTime | coreFormatDate: "LLL Z": false }}

-

{{ lastCommit }}

-
- -

{{ 'core.settings.filesystemroot' | translate}}

-

{{ fileSystemRoot }}

-

{{ fileSystemRoot }}

-
- -

{{ 'core.settings.navigatoruseragent' | translate}}

-

{{ navigator.userAgent }}

-
- -

{{ 'core.settings.navigatorlanguage' | translate}}

-

{{ navigator.language }}

-
- -

{{ 'core.settings.locationhref' | translate}}

-

{{ locationHref }}

-
- -

{{ 'core.settings.appready' | translate}}

-

{{ appReady | translate }}

-
- -

{{ 'core.settings.displayformat' | translate}}

-

{{ deviceType | translate }}

-
- -

{{ 'core.settings.deviceos' | translate}}

-

{{ deviceOs | translate }}

-
- -

{{ 'core.settings.currentlanguage' | translate}}

-

{{ currentLanguage }}

-
- -

{{ 'core.settings.networkstatus' | translate}}

-

{{ networkStatus | translate }}

-
- -

{{ 'core.settings.wificonnection' | translate}}

-

{{ wifiConnection | translate }}

-
- -

{{ 'core.settings.devicewebworkers' | translate}}

-

{{ deviceWebWorkers | translate }}

-
- -

{{ 'core.settings.cordovaversion' | translate}}

-

{{ device.cordova }}

-
- -

{{ 'core.settings.cordovadeviceplatform' | translate}}

-

{{ device.platform }}

-
- -

{{ 'core.settings.cordovadeviceosversion' | translate}}

-

{{ device.version }}

-
- -

{{ 'core.settings.cordovadevicemodel' | translate}}

-

{{ device.model }}

-
- -

{{ 'core.settings.cordovadeviceuuid' | translate}}

-

{{ device.uuid }}

-
- -

{{ 'core.settings.pushid' | translate}}

-

{{ pushId }}

-
- -

{{ 'core.settings.localnotifavailable' | translate}}

-

{{ localNotifAvailable | translate }}

-
-
+ + + {{ 'core.settings.opensourcelicenses' | translate }} + + + + {{ 'core.settings.privacypolicy' | translate }} + + + +

{{ 'core.settings.deviceinfo' | translate }}

+
diff --git a/src/core/settings/pages/about/about.ts b/src/core/settings/pages/about/about.ts index 4f4474d0a..4c6241663 100644 --- a/src/core/settings/pages/about/about.ts +++ b/src/core/settings/pages/about/about.ts @@ -12,17 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Component, } from '@angular/core'; -import { IonicPage, Platform } from 'ionic-angular'; -import { Device } from '@ionic-native/device'; +import { Component, Optional } from '@angular/core'; +import { IonicPage, NavController } from 'ionic-angular'; import { CoreAppProvider } from '@providers/app'; -import { CoreFileProvider } from '@providers/file'; -import { CoreInitDelegate } from '@providers/init'; -import { CoreLangProvider } from '@providers/lang'; -import { CoreLocalNotificationsProvider } from '@providers/local-notifications'; import { CoreSitesProvider } from '@providers/sites'; +import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreConfigConstants } from '../../../../configconstants'; -import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications'; /** * Page that displays the about settings. @@ -36,89 +31,30 @@ export class CoreSettingsAboutPage { appName: string; versionName: string; - versionCode: number; - compilationTime: number; - lastCommit: string; privacyPolicy: string; - navigator: Navigator; - locationHref: string; - appReady: string; - deviceType: string; - deviceOs: string; - currentLanguage: string; - networkStatus: string; - wifiConnection: string; - deviceWebWorkers: string; - device: Device; - fileSystemRoot: string; - fsClickable: boolean; - storageType: string; - localNotifAvailable: string; - pushId: string; - siteUrl: string; - isPrefixedUrl: boolean; - constructor(platform: Platform, device: Device, appProvider: CoreAppProvider, fileProvider: CoreFileProvider, - initDelegate: CoreInitDelegate, langProvider: CoreLangProvider, sitesProvider: CoreSitesProvider, - localNotificationsProvider: CoreLocalNotificationsProvider, pushNotificationsProvider: CorePushNotificationsProvider) { + constructor(appProvider: CoreAppProvider, + sitesProvider: CoreSitesProvider, + @Optional() private svComponent: CoreSplitViewComponent, + protected navCtrl: NavController) { const currentSite = sitesProvider.getCurrentSite(); this.appName = appProvider.isDesktop() ? CoreConfigConstants.desktopappname : CoreConfigConstants.appname; this.versionName = CoreConfigConstants.versionname; - this.versionCode = CoreConfigConstants.versioncode; - this.compilationTime = CoreConfigConstants.compilationtime; - this.lastCommit = CoreConfigConstants.lastcommit; // Calculate the privacy policy to use. this.privacyPolicy = (currentSite && (currentSite.getStoredConfig('tool_mobile_apppolicy') || currentSite.getStoredConfig('sitepolicy'))) || CoreConfigConstants.privacypolicy; + } - this.navigator = window.navigator; - if (window.location && window.location.href) { - const url = window.location.href; - this.locationHref = url.substr(0, url.indexOf('#')); - } - - this.appReady = initDelegate.isReady() ? 'core.yes' : 'core.no'; - this.deviceType = platform.is('tablet') ? 'core.tablet' : 'core.phone'; - - if (platform.is('android')) { - this.deviceOs = 'core.android'; - } else if (platform.is('ios')) { - this.deviceOs = 'core.ios'; - } else if (platform.is('windows')) { - this.deviceOs = 'core.windowsphone'; - } else { - const matches = navigator.userAgent.match(/\(([^\)]*)\)/); - if (matches && matches.length > 1) { - this.deviceOs = matches[1]; - } else { - this.deviceOs = 'core.unknown'; - } - } - - langProvider.getCurrentLanguage().then((lang) => { - this.currentLanguage = lang; - }); - - this.networkStatus = appProvider.isOnline() ? 'core.online' : 'core.offline'; - this.wifiConnection = appProvider.isWifi() ? 'core.yes' : 'core.no'; - this.deviceWebWorkers = !!window['Worker'] && !!window['URL'] ? 'core.yes' : 'core.no'; - this.device = device; - - if (fileProvider.isAvailable()) { - fileProvider.getBasePath().then((basepath) => { - this.fileSystemRoot = basepath; - this.fsClickable = fileProvider.usesHTMLAPI(); - }); - } - - this.localNotifAvailable = localNotificationsProvider.isAvailable() ? 'core.yes' : 'core.no'; - this.pushId = pushNotificationsProvider.getPushId(); - - this.siteUrl = (currentSite && currentSite.getURL()) || - (typeof CoreConfigConstants.siteurl == 'string' && CoreConfigConstants.siteurl); - this.isPrefixedUrl = !!CoreConfigConstants.siteurl; + /** + * Opens a page. + * + * @param page The component deeplink name you want to push onto the navigation stack. + */ + openPage(page: string): void { + const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl; + navCtrl.push(page); } } diff --git a/src/core/settings/pages/deviceinfo/deviceinfo.html b/src/core/settings/pages/deviceinfo/deviceinfo.html new file mode 100644 index 000000000..dca511446 --- /dev/null +++ b/src/core/settings/pages/deviceinfo/deviceinfo.html @@ -0,0 +1,97 @@ + + + {{ 'core.settings.deviceinfo' | translate }} + + + + + + + +

{{ 'core.settings.appversion' | translate}}

+

{{ deviceInfo.versionName }} ({{ deviceInfo.versionCode }})

+
+ +

{{ 'core.settings.compilationinfo' | translate }}

+

{{ deviceInfo.compilationTime | coreFormatDate: "LLL Z": false }}

+

{{ deviceInfo.lastCommit }}

+
+ +

{{ 'core.settings.siteinfo' | translate }} *

+

{{ deviceInfo.siteUrl }}

+

{{ deviceInfo.siteVersion }}

+

{{ deviceInfo.siteId }}

+
+ +

{{ 'core.settings.filesystemroot' | translate}}

+

{{ deviceInfo.fileSystemRoot }}

+

{{ deviceInfo.fileSystemRoot }}

+
+ +

{{ 'core.settings.navigatoruseragent' | translate}}

+

{{ deviceInfo.userAgent }}

+
+ +

{{ 'core.settings.navigatorlanguage' | translate}}

+

{{ deviceInfo.browserLanguage }}

+
+ +

{{ 'core.settings.currentlanguage' | translate}}

+

{{ currentLangName }} ({{ deviceInfo.currentLanguage }})

+
+ +

{{ 'core.settings.locationhref' | translate}}

+

{{ deviceInfo.locationHref }}

+
+ +

{{ 'core.settings.displayformat' | translate}}

+

{{ 'core.' + deviceInfo.deviceType | translate }}

+
+ +

{{ 'core.settings.deviceos' | translate}}

+

{{ 'core.' + deviceInfo.deviceOs | translate }}

+

{{ deviceInfo.deviceOs }}

+
+ +

{{ 'core.settings.screen' | translate}}

+

{{ deviceInfo.screen | translate }}

+
+ +

{{ 'core.settings.networkstatus' | translate}}

+

{{ 'core.' + deviceInfo.networkStatus | translate }}

+
+ +

{{ 'core.settings.wificonnection' | translate}}

+

{{ 'core.' + deviceInfo.wifiConnection | translate }}

+
+ +

{{ 'core.settings.cordovaversion' | translate}}

+

{{ deviceInfo.cordovaVersion }}

+
+ +

{{ 'core.settings.cordovadeviceplatform' | translate}}

+

{{ deviceInfo.platform }}

+
+ +

{{ 'core.settings.cordovadeviceosversion' | translate}}

+

{{ deviceInfo.osVersion }}

+
+ +

{{ 'core.settings.cordovadevicemodel' | translate}}

+

{{ deviceInfo.model }}

+
+ +

{{ 'core.settings.cordovadeviceuuid' | translate}}

+

{{ deviceInfo.uuid }}

+
+ +

{{ 'core.settings.pushid' | translate}}

+

{{ deviceInfo.pushId }}

+
+ +

{{ 'core.settings.localnotifavailable' | translate}}

+

{{ 'core.' + deviceInfo.localNotifAvailable | translate }}

+
+
diff --git a/src/core/settings/pages/deviceinfo/deviceinfo.module.ts b/src/core/settings/pages/deviceinfo/deviceinfo.module.ts new file mode 100644 index 000000000..7c192b47a --- /dev/null +++ b/src/core/settings/pages/deviceinfo/deviceinfo.module.ts @@ -0,0 +1,35 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreSettingsDeviceInfoPage } from './deviceinfo'; +import { CoreComponentsModule } from '@components/components.module'; +import { CoreDirectivesModule } from '@directives/directives.module'; +import { CorePipesModule } from '@pipes/pipes.module'; + +@NgModule({ + declarations: [ + CoreSettingsDeviceInfoPage + ], + imports: [ + CoreComponentsModule, + CoreDirectivesModule, + CorePipesModule, + IonicPageModule.forChild(CoreSettingsDeviceInfoPage), + TranslateModule.forChild() + ], +}) +export class CoreSettingsDeviceInfoPageModule {} diff --git a/src/core/settings/pages/deviceinfo/deviceinfo.scss b/src/core/settings/pages/deviceinfo/deviceinfo.scss new file mode 100644 index 000000000..79511592c --- /dev/null +++ b/src/core/settings/pages/deviceinfo/deviceinfo.scss @@ -0,0 +1,5 @@ +page-core-settings-deviceinfo { + .item { + user-select: text; + } +} \ No newline at end of file diff --git a/src/core/settings/pages/deviceinfo/deviceinfo.ts b/src/core/settings/pages/deviceinfo/deviceinfo.ts new file mode 100644 index 000000000..72dd9426b --- /dev/null +++ b/src/core/settings/pages/deviceinfo/deviceinfo.ts @@ -0,0 +1,198 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Component } from '@angular/core'; +import { IonicPage, Platform } from 'ionic-angular'; +import { Device } from '@ionic-native/device'; +import { CoreAppProvider } from '@providers/app'; +import { CoreFileProvider } from '@providers/file'; +import { CoreInitDelegate } from '@providers/init'; +import { CoreLangProvider } from '@providers/lang'; +import { CoreUtilsProvider } from '@providers/utils/utils'; +import { CoreLocalNotificationsProvider } from '@providers/local-notifications'; +import { CoreSitesProvider } from '@providers/sites'; +import { CoreConfigConstants } from '../../../../configconstants'; +import { CorePushNotificationsProvider } from '@core/pushnotifications/providers/pushnotifications'; + +/** + * Device Info to be shown and copied to clipboard. + */ +interface CoreSettingsDeviceInfo { + versionName: string; + versionCode: number; + compilationTime: number; + lastCommit: string; + siteUrl?: string; + isPrefixedUrl?: boolean; + siteId?: string; + siteVersion?: number; + fileSystemRoot?: string; + userAgent?: string; + deviceOs?: string; + browserLanguage?: string; + currentLanguage?: string; + locationHref?: string; + deviceType?: string; + screen?: string; + networkStatus: string; + wifiConnection: string; + cordovaVersion?: string; + platform?: string; + osVersion?: string; + model?: string; + uuid?: string; + pushId: string; + localNotifAvailable: string; +} + +/** + * Page that displays the device information. + */ +@IonicPage({segment: 'core-settings-deviceinfo'}) +@Component({ + selector: 'page-core-settings-deviceinfo', + templateUrl: 'deviceinfo.html', +}) +export class CoreSettingsDeviceInfoPage { + + deviceInfo: CoreSettingsDeviceInfo; + currentLangName: string; + fsClickable: boolean; + deviceOSTranslatable: boolean; + + constructor(platform: Platform, + device: Device, + appProvider: CoreAppProvider, + fileProvider: CoreFileProvider, + initDelegate: CoreInitDelegate, + langProvider: CoreLangProvider, + sitesProvider: CoreSitesProvider, + localNotificationsProvider: CoreLocalNotificationsProvider, + pushNotificationsProvider: CorePushNotificationsProvider, + protected utils: CoreUtilsProvider) { + + this.deviceInfo = { + versionName: CoreConfigConstants.versionname, + versionCode: CoreConfigConstants.versioncode, + compilationTime: CoreConfigConstants.compilationtime, + lastCommit: CoreConfigConstants.lastcommit, + networkStatus: appProvider.isOnline() ? 'online' : 'offline', + wifiConnection: appProvider.isWifi() ? 'yes' : 'no', + localNotifAvailable: localNotificationsProvider.isAvailable() ? 'yes' : 'no', + pushId: pushNotificationsProvider.getPushId(), + }; + + if (window.location && window.location.href) { + const url = window.location.href; + this.deviceInfo.locationHref = url.substr(0, url.indexOf('#')); + } + + const navigator = window.navigator; + if (navigator) { + if (navigator.userAgent) { + this.deviceInfo.userAgent = navigator.userAgent; + } + + if (navigator.language) { + this.deviceInfo.browserLanguage = navigator.language; + } + } + + if (device) { + if (device.cordova) { + this.deviceInfo.cordovaVersion = device.cordova; + } + if (device.platform) { + this.deviceInfo.platform = device.platform; + } + if (device.version) { + this.deviceInfo.osVersion = device.version; + } + if (device.model) { + this.deviceInfo.model = device.model; + } + if (device.uuid) { + this.deviceInfo.uuid = device.uuid; + } + } + + this.deviceOSTranslatable = true; + if (appProvider.isMobile()) { + this.deviceInfo.deviceType = platform.is('tablet') ? 'tablet' : 'phone'; + if (appProvider.isAndroid()) { + this.deviceInfo.deviceOs = 'android'; + } else if (appProvider.isIOS()) { + this.deviceInfo.deviceOs = 'ios'; + } else { + const matches = navigator.userAgent.match(/\(([^\)]*)\)/); + if (matches && matches.length > 1) { + this.deviceOSTranslatable = false; + this.deviceInfo.deviceOs = matches[1]; + } else { + this.deviceInfo.deviceOs = 'unknown'; + } + } + } else { + this.deviceInfo.deviceType = appProvider.isDesktop() ? 'desktop' : 'browser'; + if (appProvider.isLinux()) { + this.deviceInfo.deviceOs = 'linux'; + } else if (appProvider.isMac()) { + this.deviceInfo.deviceOs = 'mac'; + } else if (appProvider.isWindows()) { + this.deviceInfo.deviceOs = 'windows'; + } else { + const matches = navigator.userAgent.match(/\(([^\)]*)\)/); + if (matches && matches.length > 1) { + this.deviceOSTranslatable = false; + this.deviceInfo.deviceOs = matches[1]; + } else { + this.deviceInfo.deviceOs = 'unknown'; + } + } + } + + langProvider.getCurrentLanguage().then((lang) => { + this.deviceInfo.currentLanguage = lang; + this.currentLangName = CoreConfigConstants.languages[lang]; + }); + + if (fileProvider.isAvailable()) { + fileProvider.getBasePath().then((basepath) => { + this.deviceInfo.fileSystemRoot = basepath; + this.fsClickable = fileProvider.usesHTMLAPI(); + }); + } + + if (window.screen) { + this.deviceInfo.screen = window.innerWidth + 'x' + window.innerHeight + + ' (' + window.screen.width + 'x' + window.screen.height + ')'; + } + + const currentSite = sitesProvider.getCurrentSite(); + + this.deviceInfo.siteUrl = (currentSite && currentSite.getURL()) || + (typeof CoreConfigConstants.siteurl == 'string' && CoreConfigConstants.siteurl); + this.deviceInfo.isPrefixedUrl = !!CoreConfigConstants.siteurl; + this.deviceInfo.siteId = currentSite && currentSite.getId(); + this.deviceInfo.siteVersion = currentSite && currentSite.getInfo().release; + } + + /** + * Copies device info into the clipboard. + */ + copyInfo(): void { + this.utils.copyToClipboard(JSON.stringify(this.deviceInfo)); + } + +} diff --git a/src/lang/en.json b/src/lang/en.json index 34a7890d1..5ca62b1b9 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -11,6 +11,7 @@ "answered": "Answered", "areyousure": "Are you sure?", "back": "Back", + "browser": "Browser", "cancel": "Cancel", "cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle {{$a}} or later.", "cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.", @@ -63,6 +64,7 @@ "deleteduser": "Deleted user", "deleting": "Deleting", "description": "Description", + "desktop": "Desktop", "dfdaymonthyear": "MM-DD-YYYY", "dfdayweekmonth": "ddd, D MMM", "dffulldate": "dddd, D MMMM YYYY h[:]mm A", @@ -126,12 +128,14 @@ "lastmodified": "Last modified", "lastsync": "Last synchronisation", "layoutgrid": "Grid", + "linux": "Linux", "list": "List", "listsep": ",", "loading": "Loading", "loadmore": "Load more", "location": "Location", "lostconnection": "Your authentication token is invalid or has expired. You will have to reconnect to the site.", + "mac": "MacOS", "maxsizeandattachments": "Maximum file size: {{$a.size}}, maximum number of files: {{$a.attachments}}", "min": "min", "mins": "mins", @@ -295,7 +299,7 @@ "whoops": "Oops!", "whyisthishappening": "Why is this happening?", "whyisthisrequired": "Why is this required?", - "windowsphone": "Windows Phone", + "windows": "Windows", "wsfunctionnotavailable": "The web service function is not available.", "year": "year", "years": "years",