Merge pull request #3320 from crazyserver/MOBILE-4081

Mobile 4081
main
Noel De Martin 2022-06-15 17:26:50 +02:00 committed by GitHub
commit 9254871d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 29 deletions

View File

@ -482,9 +482,9 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
* Mark course as not downloaded. * Mark course as not downloaded.
*/ */
protected markCourseAsNotDownloaded(): void { protected markCourseAsNotDownloaded(): void {
// @TODO This is a workaround that should be more specific solving MOBILE-3305. // @TODO In order to correctly check the status of the course we should check all module statuses.
// Also should take into account all modules are not downloaded. // We are currently marking as not downloaded if size is 0 but we should take into account that
// Check after MOBILE-3188 is integrated. // resources without files can be downloaded and cached.
CoreCourse.setCourseStatus(this.courseId, CoreConstants.NOT_DOWNLOADED); CoreCourse.setCourseStatus(this.courseId, CoreConstants.NOT_DOWNLOADED);
} }
@ -506,7 +506,6 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy {
* Confirm and prefetch a section. If the section is "all sections", prefetch all the sections. * Confirm and prefetch a section. If the section is "all sections", prefetch all the sections.
* *
* @param section Section to download. * @param section Section to download.
* @param refresh Refresh clicked (not used).
*/ */
async prefecthSection(section: AddonStorageManagerCourseSection): Promise<void> { async prefecthSection(section: AddonStorageManagerCourseSection): Promise<void> {
section.isCalculating = true; section.isCalculating = true;

View File

@ -94,6 +94,7 @@ import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/
import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler'; import { CoreCourseResourcePrefetchHandlerBase } from '@features/course/classes/resource-prefetch-handler';
import { CoreGeolocationError, CoreGeolocationErrorReason } from '@services/geolocation'; import { CoreGeolocationError, CoreGeolocationErrorReason } from '@services/geolocation';
import { CORE_ERRORS_CLASSES } from '@classes/errors/errors'; import { CORE_ERRORS_CLASSES } from '@classes/errors/errors';
import { CoreNetwork } from '@services/network';
// Import all core modules that define components, directives and pipes. // Import all core modules that define components, directives and pipes.
import { CoreSharedModule } from '@/core/shared.module'; import { CoreSharedModule } from '@/core/shared.module';
@ -343,6 +344,7 @@ export class CoreCompileProvider {
instance['CoreLoggerProvider'] = CoreLogger; instance['CoreLoggerProvider'] = CoreLogger;
instance['moment'] = moment; instance['moment'] = moment;
instance['Md5'] = Md5; instance['Md5'] = Md5;
instance['Network'] = CoreNetwork.instance;
instance['CoreSyncBaseProvider'] = CoreSyncBaseProvider; instance['CoreSyncBaseProvider'] = CoreSyncBaseProvider;
instance['CoreArray'] = CoreArray; instance['CoreArray'] = CoreArray;
instance['CoreComponentsRegistry'] = CoreComponentsRegistry; instance['CoreComponentsRegistry'] = CoreComponentsRegistry;

View File

@ -82,7 +82,6 @@ import { GeolocationMock } from './services/geolocation';
import { InAppBrowserMock } from './services/inappbrowser'; import { InAppBrowserMock } from './services/inappbrowser';
import { MediaCaptureMock } from './services/media-capture'; import { MediaCaptureMock } from './services/media-capture';
import { ZipMock } from './services/zip'; import { ZipMock } from './services/zip';
import { CoreNetworkService } from '@services/network';
/** /**
* This module handles the emulation of Cordova plugins in browser and desktop. * This module handles the emulation of Cordova plugins in browser and desktop.
@ -142,17 +141,12 @@ import { CoreNetworkService } from '@services/network';
}, },
Keyboard, Keyboard,
LocalNotifications, LocalNotifications,
{ Media,
provide: Media,
deps: [],
useFactory: (): Media => new Media(),
},
{ {
provide: MediaCapture, provide: MediaCapture,
deps: [Platform], deps: [Platform],
useFactory: (platform: Platform): MediaCapture => platform.is('cordova') ? new MediaCapture() : new MediaCaptureMock(), useFactory: (platform: Platform): MediaCapture => platform.is('cordova') ? new MediaCapture() : new MediaCaptureMock(),
}, },
CoreNetworkService,
Push, Push,
QRScanner, QRScanner,
SplashScreen, SplashScreen,

View File

@ -16,6 +16,7 @@ import { CoreConfig } from '@services/config';
import { CoreFilepool } from '@services/filepool'; import { CoreFilepool } from '@services/filepool';
import { CoreLang } from '@services/lang'; import { CoreLang } from '@services/lang';
import { CoreLocalNotifications } from '@services/local-notifications'; import { CoreLocalNotifications } from '@services/local-notifications';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { CoreUpdateManager } from '@services/update-manager'; import { CoreUpdateManager } from '@services/update-manager';
import { CoreTimeUtils } from '@services/utils/time'; import { CoreTimeUtils } from '@services/utils/time';
@ -27,6 +28,7 @@ export default async function(): Promise<void> {
CoreSites.initialize(), CoreSites.initialize(),
CoreLang.initialize(), CoreLang.initialize(),
CoreLocalNotifications.initialize(), CoreLocalNotifications.initialize(),
CoreNetwork.initialize(),
CoreUpdateManager.initialize(), CoreUpdateManager.initialize(),
CoreTimeUtils.initialize(), CoreTimeUtils.initialize(),
]); ]);

View File

@ -14,17 +14,15 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CorePlatform } from '@services/platform'; import { CorePlatform } from '@services/platform';
import { Network as NetworkService } from '@ionic-native/network/ngx'; import { Network } from '@ionic-native/network/ngx';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { Observable, Subject, merge } from 'rxjs'; import { Observable, Subject, merge } from 'rxjs';
const Network = makeSingleton(NetworkService);
/** /**
* Service to manage network connections. * Service to manage network connections.
*/ */
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class CoreNetworkService extends NetworkService { export class CoreNetworkService extends Network {
type!: string; type!: string;
@ -33,13 +31,14 @@ export class CoreNetworkService extends NetworkService {
protected forceOffline = false; protected forceOffline = false;
protected online = false; protected online = false;
constructor() { /**
super(); * Initialize the service.
*/
initialize(): void {
this.checkOnline(); this.checkOnline();
if (CorePlatform.isMobile()) { if (CorePlatform.isMobile()) {
Network.onChange().subscribe(() => { this.onChange().subscribe(() => {
this.fireObservable(); this.fireObservable();
}); });
} else { } else {
@ -165,13 +164,13 @@ export class CoreNetworkService extends NetworkService {
} }
const limited = [ const limited = [
Network.Connection.CELL_2G, this.Connection.CELL_2G,
Network.Connection.CELL_3G, this.Connection.CELL_3G,
Network.Connection.CELL_4G, this.Connection.CELL_4G,
Network.Connection.CELL, this.Connection.CELL,
]; ];
return limited.indexOf(Network.type) > -1; return limited.indexOf(this.type) > -1;
} }
/** /**

View File

@ -55,7 +55,6 @@ import { Keyboard as KeyboardService } from '@ionic-native/keyboard/ngx';
import { LocalNotifications as LocalNotificationsService } from '@ionic-native/local-notifications/ngx'; import { LocalNotifications as LocalNotificationsService } from '@ionic-native/local-notifications/ngx';
import { Media as MediaService } from '@ionic-native/media/ngx'; import { Media as MediaService } from '@ionic-native/media/ngx';
import { MediaCapture as MediaCaptureService } from '@ionic-native/media-capture/ngx'; import { MediaCapture as MediaCaptureService } from '@ionic-native/media-capture/ngx';
import { Network as NetworkService } from '@ionic-native/network/ngx';
import { Push as PushService } from '@ionic-native/push/ngx'; import { Push as PushService } from '@ionic-native/push/ngx';
import { QRScanner as QRScannerService } from '@ionic-native/qr-scanner/ngx'; import { QRScanner as QRScannerService } from '@ionic-native/qr-scanner/ngx';
import { StatusBar as StatusBarService } from '@ionic-native/status-bar/ngx'; import { StatusBar as StatusBarService } from '@ionic-native/status-bar/ngx';
@ -187,10 +186,6 @@ export const LocalNotifications = makeSingleton(LocalNotificationsService);
export const Media = makeSingleton(MediaService); export const Media = makeSingleton(MediaService);
export const MediaCapture = makeSingleton(MediaCaptureService); export const MediaCapture = makeSingleton(MediaCaptureService);
export const NativeHttp = makeSingleton(HTTP); export const NativeHttp = makeSingleton(HTTP);
/**
* @deprecated on 4.1 use CoreNetwork instead.
*/
export const Network = makeSingleton(NetworkService);
export const Push = makeSingleton(PushService); export const Push = makeSingleton(PushService);
export const QRScanner = makeSingleton(QRScannerService); export const QRScanner = makeSingleton(QRScannerService);
export const StatusBar = makeSingleton(StatusBarService); export const StatusBar = makeSingleton(StatusBarService);