diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts index eb3f239b5..88c8f433f 100644 --- a/src/core/course/providers/helper.ts +++ b/src/core/course/providers/helper.ts @@ -613,7 +613,7 @@ export class CoreCourseHelperProvider { return this.filepoolProvider.getPackageStatus(siteId, component, componentId).then((status) => { result.status = status; - const isWifi = !this.appProvider.isNetworkAccessLimited(), + const isWifi = this.appProvider.isWifi(), isOnline = this.appProvider.isOnline(); if (status === CoreConstants.DOWNLOADED) { @@ -642,7 +642,7 @@ export class CoreCourseHelperProvider { }); }, () => { // Start the download if in wifi, but return the URL right away so the file is opened. - if (isWifi && isOnline) { + if (isWifi) { this.downloadModule(module, courseId, component, componentId, files, siteId); } diff --git a/src/core/settings/pages/about/about.ts b/src/core/settings/pages/about/about.ts index 95c126a1a..ac61abc68 100644 --- a/src/core/settings/pages/about/about.ts +++ b/src/core/settings/pages/about/about.ts @@ -99,7 +99,7 @@ export class CoreSettingsAboutPage { }); this.networkStatus = appProvider.isOnline() ? 'core.online' : 'core.offline'; - this.wifiConnection = appProvider.isNetworkAccessLimited() ? 'core.no' : 'core.yes'; + this.wifiConnection = appProvider.isWifi() ? 'core.yes' : 'core.no'; this.deviceWebWorkers = !!window['Worker'] && !!window['URL'] ? 'core.yes' : 'core.no'; this.device = device; diff --git a/src/directives/external-content.ts b/src/directives/external-content.ts index 9d11e62ce..1d47cf896 100644 --- a/src/directives/external-content.ts +++ b/src/directives/external-content.ts @@ -219,7 +219,7 @@ export class CoreExternalContentDirective implements AfterViewInit { clickableEl.addEventListener(eventName, () => { // User played media or opened a downloadable link. // Download the file if in wifi and it hasn't been downloaded already (for big files). - if (!this.appProvider.isNetworkAccessLimited()) { + if (this.appProvider.isWifi()) { // We aren't using the result, so it doesn't matter which of the 2 functions we call. this.filepoolProvider.getUrlByUrl(siteId, url, this.component, this.componentId, 0, false); } diff --git a/src/providers/app.ts b/src/providers/app.ts index d072cc89d..b9b1d8138 100644 --- a/src/providers/app.ts +++ b/src/providers/app.ts @@ -244,6 +244,15 @@ export class CoreAppProvider { return limited.indexOf(type) > -1; } + /** + * Check if device uses a wifi connection. + * + * @return {boolean} Whether the device uses a wifi connection. + */ + isWifi(): boolean { + return this.isOnline() && !this.isNetworkAccessLimited(); + } + /** * Check if the app is running in a Windows environment. * diff --git a/src/providers/cron.ts b/src/providers/cron.ts index d578fd1f8..74eae363e 100644 --- a/src/providers/cron.ts +++ b/src/providers/cron.ts @@ -162,7 +162,7 @@ export class CoreCronDelegate { if (isSync) { // Check network connection. promise = this.configProvider.get(CoreConstants.SETTINGS_SYNC_ONLY_ON_WIFI, false).then((syncOnlyOnWifi) => { - return !syncOnlyOnWifi || !this.appProvider.isNetworkAccessLimited(); + return !syncOnlyOnWifi || this.appProvider.isWifi(); }); } else { promise = Promise.resolve(true); diff --git a/src/providers/file-helper.ts b/src/providers/file-helper.ts index 79c76d1fc..0260eb610 100644 --- a/src/providers/file-helper.ts +++ b/src/providers/file-helper.ts @@ -132,7 +132,7 @@ export class CoreFileHelperProvider { return promise.then((state) => { // The file system is available. - const isWifi = !this.appProvider.isNetworkAccessLimited(), + const isWifi = this.appProvider.isWifi(), isOnline = this.appProvider.isOnline(); if (state == CoreConstants.DOWNLOADED) { @@ -160,7 +160,7 @@ export class CoreFileHelperProvider { return this.downloadFile(fileUrl, component, componentId, timemodified, onProgress, file, siteId); }, () => { // Start the download if in wifi, but return the URL right away so the file is opened. - if (isWifi && isOnline) { + if (isWifi) { this.downloadFile(fileUrl, component, componentId, timemodified, onProgress, file, siteId); } diff --git a/src/providers/filepool.ts b/src/providers/filepool.ts index 237fefa08..3074fd91f 100644 --- a/src/providers/filepool.ts +++ b/src/providers/filepool.ts @@ -775,7 +775,7 @@ export class CoreFilepoolProvider { // Calculate the size of the file. return promise.then((size) => { - const isWifi = !this.appProvider.isNetworkAccessLimited(), + const isWifi = this.appProvider.isWifi(), sizeUnknown = size <= 0; if (!sizeUnknown) {