diff --git a/scripts/langindex.json b/scripts/langindex.json index c8fd95213..8c2b64ff3 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1933,6 +1933,7 @@ "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", @@ -1943,6 +1944,7 @@ "core.settings.networkstatus": "local_moodlemobileapp", "core.settings.opensourcelicenses": "local_moodlemobileapp", "core.settings.privacypolicy": "local_moodlemobileapp", + "core.settings.publisher": "local_moodlemobileapp", "core.settings.pushid": "local_moodlemobileapp", "core.settings.reportinbackground": "local_moodlemobileapp", "core.settings.screen": "local_moodlemobileapp", diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 76661f0a2..fbc81cd70 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1933,6 +1933,7 @@ "core.settings.fontsizecharacter": "A", "core.settings.general": "General", "core.settings.language": "Language", + "core.settings.license": "License", "core.settings.localnotifavailable": "Local notifications available", "core.settings.locationhref": "Web view URL", "core.settings.locked": "Locked", @@ -1943,6 +1944,7 @@ "core.settings.networkstatus": "Internet connection status", "core.settings.opensourcelicenses": "Open Source Licences", "core.settings.privacypolicy": "Privacy policy", + "core.settings.publisher": "Publisher", "core.settings.pushid": "Push notifications ID", "core.settings.reportinbackground": "Report errors automatically", "core.settings.screen": "Screen information", diff --git a/src/core/settings/lang/en.json b/src/core/settings/lang/en.json index 9d17ca1bb..03861cd72 100644 --- a/src/core/settings/lang/en.json +++ b/src/core/settings/lang/en.json @@ -38,6 +38,7 @@ "fontsizecharacter": "A", "general": "General", "language": "Language", + "license": "License", "opensourcelicenses": "Open Source Licences", "localnotifavailable": "Local notifications available", "locationhref": "Web view URL", @@ -48,6 +49,7 @@ "navigatoruseragent": "Navigator userAgent", "networkstatus": "Internet connection status", "privacypolicy": "Privacy policy", + "publisher": "Publisher", "pushid": "Push notifications ID", "reportinbackground": "Report errors automatically", "entriesincache": "{{$a}} entries in cache", diff --git a/src/core/settings/pages/about/about.html b/src/core/settings/pages/about/about.html index b6d38bc85..b701e0934 100644 --- a/src/core/settings/pages/about/about.html +++ b/src/core/settings/pages/about/about.html @@ -7,10 +7,10 @@

{{ appName }} {{ versionName }}

- + {{ 'core.settings.opensourcelicenses' | translate }} - + {{ 'core.settings.privacypolicy' | translate }} diff --git a/src/core/settings/pages/licenses/licenses.html b/src/core/settings/pages/licenses/licenses.html new file mode 100644 index 000000000..b1a786226 --- /dev/null +++ b/src/core/settings/pages/licenses/licenses.html @@ -0,0 +1,26 @@ + + + {{ 'core.settings.opensourcelicenses' | translate }} + + + + + + {{ 'core.settings.opensourcelicenses' | translate }} + + + + +

+ {{ license.name }} + {{ license.name }} - {{ license.version }} +

+

{{ 'core.settings.publisher' | translate }}{{ 'core.labelsep' | translate }} {{ license.publisher }}

+

{{ 'core.settings.license' | translate }}{{ 'core.labelsep' | translate }} {{ license.licenses }}

+

{{ license.url }}

+

{{ license.email }}

+ {{ 'core.view' | translate }} +
+
+ + diff --git a/src/core/settings/pages/licenses/licenses.module.ts b/src/core/settings/pages/licenses/licenses.module.ts new file mode 100644 index 000000000..08c21a53a --- /dev/null +++ b/src/core/settings/pages/licenses/licenses.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 { CoreSettingsLicensesPage } from './licenses'; +import { CoreComponentsModule } from '@components/components.module'; +import { CoreDirectivesModule } from '@directives/directives.module'; +import { CorePipesModule } from '@pipes/pipes.module'; + +@NgModule({ + declarations: [ + CoreSettingsLicensesPage + ], + imports: [ + CoreComponentsModule, + CoreDirectivesModule, + CorePipesModule, + IonicPageModule.forChild(CoreSettingsLicensesPage), + TranslateModule.forChild() + ], +}) +export class CoreSettingsLicensesPageModule {} diff --git a/src/core/settings/pages/licenses/licenses.ts b/src/core/settings/pages/licenses/licenses.ts new file mode 100644 index 000000000..37595c6e8 --- /dev/null +++ b/src/core/settings/pages/licenses/licenses.ts @@ -0,0 +1,88 @@ +// (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 } from 'ionic-angular'; +import { HttpClient } from '@angular/common/http'; +import { CoreConfigConstants } from '../../../../configconstants'; + +/** + * Defines license info + */ +interface CoreSettingsLicense { + name: string; + version: string; + licenses: string; + repository?: string; + publisher?: string; + url?: string; + email?: string; + licenseUrl?: string; + licenseFile?: string; +} + +/** + * Page that displays the open source licenses information. + */ +@IonicPage({segment: 'core-settings-licenses'}) +@Component({ + selector: 'page-core-settings-licenses', + templateUrl: 'licenses.html', +}) +export class CoreSettingsLicensesPage { + + licensesUrl: string; + loaded = false; + licenses: CoreSettingsLicense[]; + error = false; + + constructor(protected http: HttpClient) { + let version = 'v' + CoreConfigConstants.versionname; + if (version.indexOf('-') > 0) { + version = 'integration'; + } + + this.licensesUrl = 'https://raw.githubusercontent.com/moodlehq/moodleapp/' + version + '/licenses.json'; + } + + /** + * View loaded. + */ + ionViewDidLoad(): void { + this.http.get(this.licensesUrl).toPromise().then((licenses) => { + this.licenses = Object.keys(licenses).map((name) => { + const license = licenses[name]; + + const nameSplit = name.lastIndexOf('@'); + license.name = name.substring(0, nameSplit); + license.version = name.substring(nameSplit + 1); + + if (license.repository) { + license.repository = license.repository.replace('git://', 'https://'); + if (license.repository.indexOf('github.com') > 0) { + license.licenseUrl = license.repository + '/blob/' + license.version + '/' + license.licenseFile; + } + } + + return license; + }); + + this.error = false; + }).catch(() => { + this.error = true; + }).finally(() => { + this.loaded = true; + }); + } +}