Skip to content

Commit 2258c11

Browse files
committed
MOBILE-4166 core: Move some CoreApp functions to CorePlatform
1 parent 884827a commit 2258c11

File tree

40 files changed

+153
-191
lines changed

40 files changed

+153
-191
lines changed

src/addons/filter/mediaplugin/classes/videojs-ogvjs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class VideoJSOgvJS extends Tech {
123123
this.playerId = options.playerId;
124124

125125
this.on('loadedmetadata', () => {
126-
if (CoreApp.isIPhone()) {
126+
if (CorePlatform.isIPhone()) {
127127
// iPhoneOS add some inline styles to the canvas, we need to remove it.
128128
const canvas = this.el_.getElementsByTagName('canvas')[0];
129129

@@ -186,7 +186,7 @@ export class VideoJSOgvJS extends Tech {
186186
* @returns True if volume can be controlled.
187187
*/
188188
static canControlVolume(): boolean {
189-
if (CoreApp.isIPhone()) {
189+
if (CorePlatform.isIPhone()) {
190190
return false;
191191
}
192192

@@ -393,7 +393,7 @@ export class VideoJSOgvJS extends Tech {
393393
*/
394394
setVolume(percentAsDecimal: number): void {
395395
// eslint-disable-next-line no-prototype-builtins
396-
if (!CoreApp.isIPhone() && this.el_.hasOwnProperty('volume')) {
396+
if (!CorePlatform.isIPhone() && this.el_.hasOwnProperty('volume')) {
397397
this.el_.volume = percentAsDecimal;
398398
}
399399
}

src/addons/mod/data/fields/latlong/component/latlong.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { Component } from '@angular/core';
1818
import { FormBuilder } from '@angular/forms';
1919
import { SafeUrl } from '@angular/platform-browser';
2020
import { CoreAnyError } from '@classes/errors/error';
21-
import { CoreApp } from '@services/app';
2221
import { CoreGeolocation, CoreGeolocationError, CoreGeolocationErrorReason } from '@services/geolocation';
22+
import { CorePlatform } from '@services/platform';
2323
import { CoreDomUtils } from '@services/utils/dom';
2424
import { DomSanitizer } from '@singletons';
2525

@@ -73,7 +73,7 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginBa
7373
const northFixed = north ? north.toFixed(4) : '0.0000';
7474
const eastFixed = east ? east.toFixed(4) : '0.0000';
7575

76-
if (CoreApp.isIOS()) {
76+
if (CorePlatform.isIOS()) {
7777
url = 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed;
7878
} else {
7979
url = 'geo:' + northFixed + ',' + eastFixed;

src/addons/mod/resource/components/index/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { CoreCourseModuleMainResourceComponent } from '@features/course/classes/
1919
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
2020
import { CoreCourse } from '@features/course/services/course';
2121
import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate';
22-
import { CoreApp } from '@services/app';
2322
import { CoreNetwork } from '@services/network';
2423
import { CoreFileHelper } from '@services/file-helper';
2524
import { CoreSites } from '@services/sites';
@@ -35,6 +34,7 @@ import {
3534
AddonModResourceProvider,
3635
} from '../../services/resource';
3736
import { AddonModResourceHelper } from '../../services/resource-helper';
37+
import { CorePlatform } from '@services/platform';
3838

3939
/**
4040
* Component that displays a resource.
@@ -79,7 +79,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
7979
async ngOnInit(): Promise<void> {
8080
super.ngOnInit();
8181

82-
this.isIOS = CoreApp.isIOS();
82+
this.isIOS = CorePlatform.isIOS();
8383
this.isOnline = CoreNetwork.isOnline();
8484

8585
// Refresh online status when changes.

src/core/components/file/file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core';
16-
import { CoreApp } from '@services/app';
1716
import { CoreNetwork } from '@services/network';
1817
import { CoreFilepool } from '@services/filepool';
1918
import { CoreFileHelper } from '@services/file-helper';
@@ -27,6 +26,7 @@ import { CoreTextUtils } from '@services/utils/text';
2726
import { CoreConstants } from '@/core/constants';
2827
import { CoreEventObserver, CoreEvents } from '@singletons/events';
2928
import { CoreWSFile } from '@services/ws';
29+
import { CorePlatform } from '@services/platform';
3030

3131
/**
3232
* Component to handle a remote file. Shows the file name, icon (depending on mimetype) and a button
@@ -87,7 +87,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
8787
this.fileSize = this.file.filesize;
8888
this.fileName = this.file.filename || '';
8989

90-
this.isIOS = CoreApp.isIOS();
90+
this.isIOS = CorePlatform.isIOS();
9191
this.defaultIsOpenWithPicker = CoreFileHelper.defaultIsOpenWithPicker();
9292
this.openButtonIcon = this.defaultIsOpenWithPicker ? 'fas-file' : 'fas-share-square';
9393
this.openButtonLabel = this.defaultIsOpenWithPicker ? 'core.openfile' : 'core.openwith';

src/core/components/loading/loading.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Translate } from '@singletons';
2121
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
2222
import { CorePromisedValue } from '@classes/promised-value';
2323
import { AsyncDirective } from '@classes/async-directive';
24-
import { CoreApp } from '@services/app';
24+
import { CorePlatform } from '@services/platform';
2525

2626
/**
2727
* Component to show a loading spinner and message while data is being loaded.
@@ -146,7 +146,7 @@ export class CoreLoadingComponent implements OnInit, OnChanges, AfterViewInit, A
146146
if (loaded) {
147147
this.onReadyPromise.resolve();
148148
this.restoreScrollPosition();
149-
if (CoreApp.isIOS()) {
149+
if (CorePlatform.isIOS()) {
150150
this.mutationObserver.observe(this.element, { childList: true });
151151
}
152152
} else {

src/core/components/local-file/local-file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { CoreTextUtils } from '@services/utils/text';
2525
import { CoreTimeUtils } from '@services/utils/time';
2626
import { CoreUtils, CoreUtilsOpenFileOptions, OpenFileAction } from '@services/utils/utils';
2727
import { CoreForms } from '@singletons/form';
28-
import { CoreApp } from '@services/app';
2928
import { CorePath } from '@singletons/path';
29+
import { CorePlatform } from '@services/platform';
3030

3131
/**
3232
* Component to handle a local file. Only files inside the app folder can be managed.
@@ -83,7 +83,7 @@ export class CoreLocalFileComponent implements OnInit {
8383

8484
this.timemodified = CoreTimeUtils.userDate(metadata.modificationTime.getTime(), 'core.strftimedatetimeshort');
8585

86-
this.isIOS = CoreApp.isIOS();
86+
this.isIOS = CorePlatform.isIOS();
8787
this.defaultIsOpenWithPicker = CoreFileHelper.defaultIsOpenWithPicker();
8888
this.openButtonIcon = this.defaultIsOpenWithPicker ? 'fas-file' : 'fas-share-square';
8989
this.openButtonLabel = this.defaultIsOpenWithPicker ? 'core.openfile' : 'core.openwith';

src/core/components/show-password/show-password.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import { Component, OnInit, AfterViewInit, Input, ElementRef, ContentChild } from '@angular/core';
1616
import { IonInput } from '@ionic/angular';
1717

18-
import { CoreApp } from '@services/app';
18+
import { CorePlatform } from '@services/platform';
1919
import { CoreDomUtils } from '@services/utils/dom';
2020
import { CoreUtils } from '@services/utils/utils';
2121

@@ -121,7 +121,7 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
121121

122122
this.setData(this.input);
123123
// In Android, the keyboard is closed when the input type changes. Focus it again.
124-
if (isFocused && CoreApp.isAndroid()) {
124+
if (isFocused && CorePlatform.isAndroid()) {
125125
CoreDomUtils.focusElement(this.input);
126126
}
127127
}

src/core/directives/external-content.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
EventEmitter,
2424
OnDestroy,
2525
} from '@angular/core';
26-
import { CoreApp } from '@services/app';
2726
import { CoreFile } from '@services/file';
2827
import { CoreFilepool, CoreFilepoolFileActions, CoreFilepoolFileEventData } from '@services/filepool';
2928
import { CoreSites } from '@services/sites';
@@ -39,6 +38,7 @@ import { Translate } from '@singletons';
3938
import { AsyncDirective } from '@classes/async-directive';
4039
import { CoreDirectivesRegistry } from '@singletons/directives-registry';
4140
import { CorePromisedValue } from '@classes/promised-value';
41+
import { CorePlatform } from '@services/platform';
4242

4343
/**
4444
* Directive to handle external content.
@@ -117,7 +117,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges, O
117117
newSource.setAttribute('src', url);
118118

119119
if (type) {
120-
if (CoreApp.isAndroid() && type == 'video/quicktime') {
120+
if (CorePlatform.isAndroid() && type == 'video/quicktime') {
121121
// Fix for VideoJS/Chrome bug https://github.com/videojs/video.js/issues/423 .
122122
newSource.setAttribute('type', 'video/mp4');
123123
} else {

src/core/features/fileuploader/services/fileuploader-helper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { ChooserResult } from '@ionic-native/chooser/ngx';
1919
import { FileEntry, IFile } from '@ionic-native/file/ngx';
2020
import { MediaFile } from '@ionic-native/media-capture/ngx';
2121

22-
import { CoreApp } from '@services/app';
2322
import { CoreNetwork } from '@services/network';
2423
import { CoreFile, CoreFileProvider, CoreFileProgressEvent } from '@services/file';
2524
import { CoreDomUtils } from '@services/utils/dom';
@@ -652,7 +651,7 @@ export class CoreFileUploaderHelperProvider {
652651
options.mediaType = Camera.MediaType.PICTURE;
653652
} else if (!imageSupported && videoSupported) {
654653
options.mediaType = Camera.MediaType.VIDEO;
655-
} else if (CoreApp.isIOS()) {
654+
} else if (CorePlatform.isIOS()) {
656655
// Only get all media in iOS because in Android using this option allows uploading any kind of file.
657656
options.mediaType = Camera.MediaType.ALLMEDIA;
658657
}

src/core/features/fileuploader/services/fileuploader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { FileEntry } from '@ionic-native/file/ngx';
1818
import { MediaFile, CaptureError, CaptureAudioOptions, CaptureVideoOptions } from '@ionic-native/media-capture/ngx';
1919
import { Subject } from 'rxjs';
2020

21-
import { CoreApp } from '@services/app';
2221
import { CoreFile, CoreFileProvider } from '@services/file';
2322
import { CoreFilepool } from '@services/filepool';
2423
import { CoreSites } from '@services/sites';
@@ -33,6 +32,7 @@ import { CoreError } from '@classes/errors/error';
3332
import { CoreSite } from '@classes/site';
3433
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
3534
import { CorePath } from '@singletons/path';
35+
import { CorePlatform } from '@services/platform';
3636

3737
/**
3838
* File upload options.
@@ -236,7 +236,7 @@ export class CoreFileUploaderProvider {
236236
getCameraUploadOptions(uri: string, isFromAlbum?: boolean): CoreFileUploaderOptions {
237237
const extension = CoreMimetypeUtils.guessExtensionFromUrl(uri);
238238
const mimetype = CoreMimetypeUtils.getMimeType(extension);
239-
const isIOS = CoreApp.isIOS();
239+
const isIOS = CorePlatform.isIOS();
240240
const options: CoreFileUploaderOptions = {
241241
deleteAfterUpload: !isFromAlbum,
242242
mimeType: mimetype,
@@ -259,7 +259,7 @@ export class CoreFileUploaderProvider {
259259
// If the file was picked from the album, delete it only if it was copied to the app's folder.
260260
options.deleteAfterUpload = CoreFile.isFileInAppFolder(uri);
261261

262-
if (CoreApp.isAndroid()) {
262+
if (CorePlatform.isAndroid()) {
263263
// Picking an image from album in Android adds a timestamp at the end of the file. Delete it.
264264
options.fileName = options.fileName.replace(/(\.[^.]*)\?[^.]*$/, '$1');
265265
}

0 commit comments

Comments
 (0)