From 9838d2305d167774928891a78df364dfacc4b576 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 30 Aug 2018 15:21:48 +0200 Subject: [PATCH 1/8] MOBILE-2567 sitehome: Fix site news moving to another section --- src/core/sitehome/components/index/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/sitehome/components/index/index.ts b/src/core/sitehome/components/index/index.ts index b11a585c9..df8452399 100644 --- a/src/core/sitehome/components/index/index.ts +++ b/src/core/sitehome/components/index/index.ts @@ -146,7 +146,7 @@ export class CoreSiteHomeIndexComponent implements OnInit { if (hasNewsItem && this.block && this.block.modules) { // Remove forum activity (news one only) to prevent duplicates. - this.siteHomeProvider.getNewsForum(this.siteHomeId).then((forum) => { + return this.siteHomeProvider.getNewsForum(this.siteHomeId).then((forum) => { // Search the module that belongs to site news. for (let i = 0; i < this.block.modules.length; i++) { const module = this.block.modules[i]; From 7126c449174a8cdf2e42a796976d437271474528 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 30 Aug 2018 16:17:20 +0200 Subject: [PATCH 2/8] MOBILE-2567 course: Don't show next/previous in all sections --- src/core/course/components/format/format.ts | 33 ++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts index b6ec4c1de..cd9a0bd00 100644 --- a/src/core/course/components/format/format.ts +++ b/src/core/course/components/format/format.ts @@ -250,25 +250,30 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { this.selectedSection = newSection; this.data.section = this.selectedSection; - // Select next and previous sections to show the arrows. - const i = this.sections.findIndex((value, index) => { - return this.compareSections(value, this.selectedSection); - }); + if (newSection.id != this.allSectionsId) { + // Select next and previous sections to show the arrows. + const i = this.sections.findIndex((value, index) => { + return this.compareSections(value, this.selectedSection); + }); - let j; - for (j = i - 1; j >= 1; j--) { - if (this.sections[j].uservisible !== false && this.sections[j].hasContent) { - break; + let j; + for (j = i - 1; j >= 1; j--) { + if (this.sections[j].uservisible !== false && this.sections[j].hasContent) { + break; + } } - } - this.previousSection = j >= 1 ? this.sections[j] : null; + this.previousSection = j >= 1 ? this.sections[j] : null; - for (j = i + 1; j < this.sections.length; j++) { - if (this.sections[j].uservisible !== false && this.sections[j].hasContent) { - break; + for (j = i + 1; j < this.sections.length; j++) { + if (this.sections[j].uservisible !== false && this.sections[j].hasContent) { + break; + } } + this.nextSection = j < this.sections.length ? this.sections[j] : null; + } else { + this.previousSection = null; + this.nextSection = null; } - this.nextSection = j < this.sections.length ? this.sections[j] : null; if (this.moduleId && typeof previousValue == 'undefined') { setTimeout(() => { From d3807fd48e09926da383901f65c63f372dad3c73 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 31 Aug 2018 09:41:39 +0200 Subject: [PATCH 3/8] MOBILE-2567 user: Sanitize address URLs --- src/core/user/pages/about/about.html | 5 +---- src/core/user/pages/about/about.ts | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/user/pages/about/about.html b/src/core/user/pages/about/about.html index f5db37701..3e6932169 100644 --- a/src/core/user/pages/about/about.html +++ b/src/core/user/pages/about/about.html @@ -31,10 +31,7 @@

{{ 'core.user.address' | translate}}

-

- - - +

diff --git a/src/core/user/pages/about/about.ts b/src/core/user/pages/about/about.ts index 9d9b77a05..2054e9754 100644 --- a/src/core/user/pages/about/about.ts +++ b/src/core/user/pages/about/about.ts @@ -13,6 +13,7 @@ // limitations under the License. import { Component } from '@angular/core'; +import { DomSanitizer } from '@angular/platform-browser'; import { IonicPage, NavParams, Platform } from 'ionic-angular'; import { CoreUserProvider } from '../../providers/user'; import { CoreUserHelperProvider } from '../../providers/helper'; @@ -41,7 +42,7 @@ export class CoreUserAboutPage { title: string; constructor(navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider, - private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider, + private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider, private sanitizer: DomSanitizer, private sitesProvider: CoreSitesProvider, private platform: Platform) { this.userId = navParams.get('userId'); @@ -68,7 +69,8 @@ export class CoreUserAboutPage { if (user.address) { user.address = this.userHelper.formatAddress(user.address, user.city, user.country); - user.encodedAddress = encodeURIComponent(user.address); + user.encodedAddress = this.sanitizer.bypassSecurityTrustUrl( + (this.isAndroid ? 'geo:0,0?q=' : 'http://maps.google.com?q=') + encodeURIComponent(user.address)); } this.hasContact = user.email || user.phone1 || user.phone2 || user.city || user.country || user.address; From eae69814fd02410d01a96c23440b05f786ee5df3 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 31 Aug 2018 11:39:51 +0200 Subject: [PATCH 4/8] MOBILE-2567 sharedfiles: Fix renaming a shared file --- src/core/sharedfiles/pages/list/list.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/sharedfiles/pages/list/list.ts b/src/core/sharedfiles/pages/list/list.ts index ad3f6f136..db1f706b5 100644 --- a/src/core/sharedfiles/pages/list/list.ts +++ b/src/core/sharedfiles/pages/list/list.ts @@ -121,10 +121,10 @@ export class CoreSharedFilesListPage implements OnInit, OnDestroy { * Called when a file is renamed. Update the list. * * @param {number} index Position of the file. - * @param {any} file New FileEntry. + * @param {any} data Data containing the new FileEntry. */ - fileRenamed(index: number, file: any): void { - this.files[index] = file; + fileRenamed(index: number, data: any): void { + this.files[index] = data.file; } /** From f93ea360b14a271657dc815f3fe30cd6be21170a Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 31 Aug 2018 12:44:04 +0200 Subject: [PATCH 5/8] MOBILE-2567 course: Fix hiddenoncoursepage shown when it shouldn't --- src/core/course/providers/helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts index 87eb371d9..b9797a732 100644 --- a/src/core/course/providers/helper.ts +++ b/src/core/course/providers/helper.ts @@ -153,7 +153,7 @@ export class CoreCourseHelperProvider { } // Check if the module is stealth. - module.isStealth = !module.visibleoncoursepage || (module.visible && !section.visible); + module.isStealth = module.visibleoncoursepage === 0 || (module.visible && !section.visible); }); }); From 7e809080c886952f12ec12cef85d45af723f980b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 31 Aug 2018 12:59:53 +0200 Subject: [PATCH 6/8] MOBILE-2567 settings: Apply text-wrap in synchronization --- src/core/settings/pages/synchronization/synchronization.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/settings/pages/synchronization/synchronization.html b/src/core/settings/pages/synchronization/synchronization.html index 8bc615145..cf802612b 100644 --- a/src/core/settings/pages/synchronization/synchronization.html +++ b/src/core/settings/pages/synchronization/synchronization.html @@ -8,7 +8,7 @@

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

- + {{ 'core.settings.enablesyncwifi' | translate }} @@ -16,7 +16,7 @@

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

- +

{{ site.fullName }}

{{ site.siteUrl }}

From 13307322faa081b6395b3f8ad2a73f94334103fd Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 31 Aug 2018 12:09:46 +0200 Subject: [PATCH 7/8] MOBILE-2567 settings: Don't display free space --- .../pages/space-usage/space-usage.html | 4 --- .../settings/pages/space-usage/space-usage.ts | 34 ++----------------- src/providers/file.ts | 9 ++++- 3 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/core/settings/pages/space-usage/space-usage.html b/src/core/settings/pages/space-usage/space-usage.html index d2eef1677..1d2af6c8d 100644 --- a/src/core/settings/pages/space-usage/space-usage.html +++ b/src/core/settings/pages/space-usage/space-usage.html @@ -20,9 +20,5 @@

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

{{ totalUsage | coreBytesToSize }}

- -

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

-

{{ freeSpace | coreBytesToSize }}

-
diff --git a/src/core/settings/pages/space-usage/space-usage.ts b/src/core/settings/pages/space-usage/space-usage.ts index 0f10c8545..3fec9f5d1 100644 --- a/src/core/settings/pages/space-usage/space-usage.ts +++ b/src/core/settings/pages/space-usage/space-usage.ts @@ -16,7 +16,6 @@ import { Component, } from '@angular/core'; import { IonicPage } from 'ionic-angular'; import { TranslateService } from '@ngx-translate/core'; import { CoreAppProvider } from '@providers/app'; -import { CoreFileProvider } from '@providers/file'; import { CoreFilepoolProvider } from '@providers/filepool'; import { CoreSitesProvider } from '@providers/sites'; import { CoreTextUtilsProvider } from '@providers/utils/text'; @@ -36,14 +35,11 @@ export class CoreSettingsSpaceUsagePage { sites = []; currentSiteId = ''; totalUsage = 0; - freeSpace = 0; - showFreeSpace = true; - constructor(private fileProvider: CoreFileProvider, private filePoolProvider: CoreFilepoolProvider, + constructor(private filePoolProvider: CoreFilepoolProvider, private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider, private translate: TranslateService, private domUtils: CoreDomUtilsProvider, appProvider: CoreAppProvider) { this.currentSiteId = this.sitesProvider.getCurrentSiteId(); - this.showFreeSpace = !appProvider.isDesktop(); } /** @@ -91,26 +87,7 @@ export class CoreSettingsSpaceUsagePage { } /** - * Convenience function to calculate free space in the device. - * - * @return {Promise} Resolved when done. - */ - protected calculateFreeSpace(): Promise { - if (this.fileProvider.isAvailable()) { - return this.fileProvider.calculateFreeSpace().then((freeSpace) => { - this.freeSpace = freeSpace; - }).catch(() => { - this.freeSpace = 0; - }); - } else { - this.freeSpace = 0; - - return Promise.resolve(null); - } - } - - /** - * Convenience function to calculate space usage and free space in the device. + * Convenience function to calculate space usage. * * @return {Promise} Resolved when done. */ @@ -119,10 +96,6 @@ export class CoreSettingsSpaceUsagePage { this.calculateSizeUsage().then(() => this.calculateTotalUsage()), ]; - if (this.showFreeSpace) { - promises.push(this.calculateFreeSpace()); - } - return Promise.all(promises); } @@ -138,7 +111,7 @@ export class CoreSettingsSpaceUsagePage { } /** - * Convenience function to update site size, along with total usage and free space. + * Convenience function to update site size, along with total usage. * * @param {any} site Site object with space usage. * @param {number} newUsage New space usage of the site in bytes. @@ -147,7 +120,6 @@ export class CoreSettingsSpaceUsagePage { const oldUsage = site.spaceUsage; site.spaceUsage = newUsage; this.totalUsage -= oldUsage - newUsage; - this.freeSpace += oldUsage - newUsage; } /** diff --git a/src/providers/file.ts b/src/providers/file.ts index 15ac2513a..6b7469f32 100644 --- a/src/providers/file.ts +++ b/src/providers/file.ts @@ -360,12 +360,19 @@ export class CoreFileProvider { /** * Calculate the free space in the disk. + * Please notice that this function isn't reliable and it's not documented in the Cordova File plugin. * * @return {Promise} Promise resolved with the estimated free space in bytes. */ calculateFreeSpace(): Promise { return this.file.getFreeDiskSpace().then((size) => { - return size; // GetFreeDiskSpace returns KB. + if (this.platform.is('ios')) { + // In iOS the size is in bytes. + return Number(size); + } + + // The size is in KB, convert it to bytes. + return Number(size) * 1024; }); } From 8257341d137963b1d7e342b5d39f8cf047db3831 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 3 Sep 2018 08:44:36 +0200 Subject: [PATCH 8/8] MOBILE-2567 ios: Fix download of streamed media --- src/core/course/providers/helper.ts | 4 ++++ src/providers/file-helper.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts index b9797a732..eb3f239b5 100644 --- a/src/core/course/providers/helper.ts +++ b/src/core/course/providers/helper.ts @@ -539,6 +539,10 @@ export class CoreCourseHelperProvider { return this.downloadModuleWithMainFileIfNeeded(module, courseId, component, componentId, files, siteId) .then((result) => { if (result.path.indexOf('http') === 0) { + /* In iOS, if we use the same URL in embedded browser and background download then the download only + downloads a few bytes (cached ones). Add a hash to the URL so both URLs are different. */ + result.path = result.path + '#moodlemobile-embedded'; + return this.utils.openOnlineFile(result.path).catch((error) => { // Error opening the file, some apps don't allow opening online files. if (!this.fileProvider.isAvailable()) { diff --git a/src/providers/file-helper.ts b/src/providers/file-helper.ts index 4bd5d3f37..79c76d1fc 100644 --- a/src/providers/file-helper.ts +++ b/src/providers/file-helper.ts @@ -56,6 +56,10 @@ export class CoreFileHelperProvider { } if (url.indexOf('http') === 0) { + /* In iOS, if we use the same URL in embedded browser and background download then the download only + downloads a few bytes (cached ones). Add a hash to the URL so both URLs are different. */ + url = url + '#moodlemobile-embedded'; + return this.utils.openOnlineFile(url).catch((error) => { // Error opening the file, some apps don't allow opening online files. if (!this.fileProvider.isAvailable()) {