Merge pull request #1549 from crazyserver/MOBILE-2654
qMOBILE-2654 settings: Fix wifi connection checkmain
commit
3b526366ab
|
@ -613,7 +613,7 @@ export class CoreCourseHelperProvider {
|
||||||
return this.filepoolProvider.getPackageStatus(siteId, component, componentId).then((status) => {
|
return this.filepoolProvider.getPackageStatus(siteId, component, componentId).then((status) => {
|
||||||
result.status = status;
|
result.status = status;
|
||||||
|
|
||||||
const isWifi = !this.appProvider.isNetworkAccessLimited(),
|
const isWifi = this.appProvider.isWifi(),
|
||||||
isOnline = this.appProvider.isOnline();
|
isOnline = this.appProvider.isOnline();
|
||||||
|
|
||||||
if (status === CoreConstants.DOWNLOADED) {
|
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.
|
// 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);
|
this.downloadModule(module, courseId, component, componentId, files, siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ export class CoreSettingsAboutPage {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.networkStatus = appProvider.isOnline() ? 'core.online' : 'core.offline';
|
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.deviceWebWorkers = !!window['Worker'] && !!window['URL'] ? 'core.yes' : 'core.no';
|
||||||
this.device = device;
|
this.device = device;
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ export class CoreExternalContentDirective implements AfterViewInit {
|
||||||
clickableEl.addEventListener(eventName, () => {
|
clickableEl.addEventListener(eventName, () => {
|
||||||
// User played media or opened a downloadable link.
|
// User played media or opened a downloadable link.
|
||||||
// Download the file if in wifi and it hasn't been downloaded already (for big files).
|
// 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.
|
// 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);
|
this.filepoolProvider.getUrlByUrl(siteId, url, this.component, this.componentId, 0, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,6 +244,15 @@ export class CoreAppProvider {
|
||||||
return limited.indexOf(type) > -1;
|
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.
|
* Check if the app is running in a Windows environment.
|
||||||
*
|
*
|
||||||
|
|
|
@ -162,7 +162,7 @@ export class CoreCronDelegate {
|
||||||
if (isSync) {
|
if (isSync) {
|
||||||
// Check network connection.
|
// Check network connection.
|
||||||
promise = this.configProvider.get(CoreConstants.SETTINGS_SYNC_ONLY_ON_WIFI, false).then((syncOnlyOnWifi) => {
|
promise = this.configProvider.get(CoreConstants.SETTINGS_SYNC_ONLY_ON_WIFI, false).then((syncOnlyOnWifi) => {
|
||||||
return !syncOnlyOnWifi || !this.appProvider.isNetworkAccessLimited();
|
return !syncOnlyOnWifi || this.appProvider.isWifi();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
promise = Promise.resolve(true);
|
promise = Promise.resolve(true);
|
||||||
|
|
|
@ -132,7 +132,7 @@ export class CoreFileHelperProvider {
|
||||||
|
|
||||||
return promise.then((state) => {
|
return promise.then((state) => {
|
||||||
// The file system is available.
|
// The file system is available.
|
||||||
const isWifi = !this.appProvider.isNetworkAccessLimited(),
|
const isWifi = this.appProvider.isWifi(),
|
||||||
isOnline = this.appProvider.isOnline();
|
isOnline = this.appProvider.isOnline();
|
||||||
|
|
||||||
if (state == CoreConstants.DOWNLOADED) {
|
if (state == CoreConstants.DOWNLOADED) {
|
||||||
|
@ -160,7 +160,7 @@ export class CoreFileHelperProvider {
|
||||||
return this.downloadFile(fileUrl, component, componentId, timemodified, onProgress, file, siteId);
|
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.
|
// 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);
|
this.downloadFile(fileUrl, component, componentId, timemodified, onProgress, file, siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -775,7 +775,7 @@ export class CoreFilepoolProvider {
|
||||||
|
|
||||||
// Calculate the size of the file.
|
// Calculate the size of the file.
|
||||||
return promise.then((size) => {
|
return promise.then((size) => {
|
||||||
const isWifi = !this.appProvider.isNetworkAccessLimited(),
|
const isWifi = this.appProvider.isWifi(),
|
||||||
sizeUnknown = size <= 0;
|
sizeUnknown = size <= 0;
|
||||||
|
|
||||||
if (!sizeUnknown) {
|
if (!sizeUnknown) {
|
||||||
|
|
Loading…
Reference in New Issue