Merge pull request #1549 from crazyserver/MOBILE-2654

qMOBILE-2654 settings: Fix wifi connection check
main
Juan Leyva 2018-10-04 12:39:19 +02:00 committed by GitHub
commit 3b526366ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 8 deletions

View File

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

View File

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

View File

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

View File

@ -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.
*

View File

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

View File

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

View File

@ -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) {