commit
e97394ddcb
|
@ -17,7 +17,7 @@ import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
import { Geolocation, GeolocationOptions } from '@ionic-native/geolocation';
|
import { Geolocation, GeolocationOptions } from '@ionic-native/geolocation';
|
||||||
import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component';
|
import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreApp, CoreAppProvider } from '@providers/app';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,10 +38,11 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
|
||||||
protected geolocation: Geolocation,
|
protected geolocation: Geolocation,
|
||||||
protected domUtils: CoreDomUtilsProvider,
|
protected domUtils: CoreDomUtilsProvider,
|
||||||
protected sanitizer: DomSanitizer,
|
protected sanitizer: DomSanitizer,
|
||||||
protected appProvider: CoreAppProvider) {
|
appProvider: CoreAppProvider
|
||||||
|
) {
|
||||||
super(fb);
|
super(fb);
|
||||||
|
|
||||||
this.showGeolocation = !this.appProvider.isDesktop();
|
this.showGeolocation = !appProvider.isDesktop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +74,7 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
|
||||||
const eastFixed = east ? east.toFixed(4) : '0.0000';
|
const eastFixed = east ? east.toFixed(4) : '0.0000';
|
||||||
let url;
|
let url;
|
||||||
|
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
url = 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed;
|
url = 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed;
|
||||||
} else {
|
} else {
|
||||||
url = 'geo:' + northFixed + ',' + eastFixed;
|
url = 'geo:' + northFixed + ',' + eastFixed;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, OnInit, NgZone } from '@angular/core';
|
import { Component, OnInit, NgZone } from '@angular/core';
|
||||||
import { Platform, IonicApp } from 'ionic-angular';
|
import { Platform, IonicApp } from 'ionic-angular';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreApp, CoreAppProvider } from '@providers/app';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreLangProvider } from '@providers/lang';
|
import { CoreLangProvider } from '@providers/lang';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
|
@ -146,7 +146,7 @@ export class MoodleMobileApp implements OnInit {
|
||||||
});
|
});
|
||||||
this.utils.closeInAppBrowser(false);
|
this.utils.closeInAppBrowser(false);
|
||||||
|
|
||||||
} else if (this.platform.is('android')) {
|
} else if (CoreApp.instance.isAndroid()) {
|
||||||
// Check if the URL has a custom URL scheme. In Android they need to be opened manually.
|
// Check if the URL has a custom URL scheme. In Android they need to be opened manually.
|
||||||
const urlScheme = this.urlUtils.getUrlProtocol(url);
|
const urlScheme = this.urlUtils.getUrlProtocol(url);
|
||||||
if (urlScheme && urlScheme !== 'file' && urlScheme !== 'cdvfile') {
|
if (urlScheme && urlScheme !== 'file' && urlScheme !== 'cdvfile') {
|
||||||
|
@ -260,7 +260,7 @@ export class MoodleMobileApp implements OnInit {
|
||||||
|
|
||||||
// Pause Youtube videos in Android when app is put in background or screen is locked.
|
// Pause Youtube videos in Android when app is put in background or screen is locked.
|
||||||
this.platform.pause.subscribe(() => {
|
this.platform.pause.subscribe(() => {
|
||||||
if (!this.platform.is('android')) {
|
if (!CoreApp.instance.isAndroid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ export class MoodleMobileApp implements OnInit {
|
||||||
// Detect orientation changes.
|
// Detect orientation changes.
|
||||||
this.screenOrientation.onChange().subscribe(
|
this.screenOrientation.onChange().subscribe(
|
||||||
() => {
|
() => {
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
// Force ios to recalculate safe areas when rotating.
|
// Force ios to recalculate safe areas when rotating.
|
||||||
// This can be erased when https://issues.apache.org/jira/browse/CB-13448 issue is solved or
|
// This can be erased when https://issues.apache.org/jira/browse/CB-13448 issue is solved or
|
||||||
// After switching to WkWebview.
|
// After switching to WkWebview.
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
Component, Input, Output, ViewChild, ElementRef, EventEmitter, OnChanges, SimpleChange, Optional
|
Component, Input, Output, ViewChild, ElementRef, EventEmitter, OnChanges, SimpleChange, Optional
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||||
import { NavController, Platform } from 'ionic-angular';
|
import { NavController } from 'ionic-angular';
|
||||||
import { CoreFile } from '@providers/file';
|
import { CoreFile } from '@providers/file';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
|
@ -25,6 +25,7 @@ import { CoreIframeUtilsProvider } from '@providers/utils/iframe';
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
|
import { CoreApp } from '@providers/app';
|
||||||
import { WKWebViewCookiesWindow } from 'cordova-plugin-wkwebview-cookies';
|
import { WKWebViewCookiesWindow } from 'cordova-plugin-wkwebview-cookies';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -54,7 +55,7 @@ export class CoreIframeComponent implements OnChanges {
|
||||||
protected urlUtils: CoreUrlUtilsProvider,
|
protected urlUtils: CoreUrlUtilsProvider,
|
||||||
protected utils: CoreUtilsProvider,
|
protected utils: CoreUtilsProvider,
|
||||||
@Optional() protected svComponent: CoreSplitViewComponent,
|
@Optional() protected svComponent: CoreSplitViewComponent,
|
||||||
protected platform: Platform) {
|
) {
|
||||||
|
|
||||||
this.logger = logger.getInstance('CoreIframe');
|
this.logger = logger.getInstance('CoreIframe');
|
||||||
this.loaded = new EventEmitter<HTMLIFrameElement>();
|
this.loaded = new EventEmitter<HTMLIFrameElement>();
|
||||||
|
@ -106,7 +107,7 @@ export class CoreIframeComponent implements OnChanges {
|
||||||
if (changes.src) {
|
if (changes.src) {
|
||||||
const url = this.urlUtils.getYoutubeEmbedUrl(changes.src.currentValue) || changes.src.currentValue;
|
const url = this.urlUtils.getYoutubeEmbedUrl(changes.src.currentValue) || changes.src.currentValue;
|
||||||
|
|
||||||
if (this.platform.is('ios') && url && !this.urlUtils.isLocalFileUrl(url)) {
|
if (CoreApp.instance.isIOS() && url && !this.urlUtils.isLocalFileUrl(url)) {
|
||||||
// Save a "fake" cookie for the iframe's domain to fix a bug in WKWebView.
|
// Save a "fake" cookie for the iframe's domain to fix a bug in WKWebView.
|
||||||
try {
|
try {
|
||||||
const win = <WKWebViewCookiesWindow> window;
|
const win = <WKWebViewCookiesWindow> window;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Component, OnInit, AfterViewInit, Input, ElementRef } from '@angular/core';
|
import { Component, OnInit, AfterViewInit, Input, ElementRef } from '@angular/core';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { Platform } from 'ionic-angular';
|
import { CoreApp } from '@providers/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to allow showing and hiding a password. The affected input MUST have a name to identify it.
|
* Component to allow showing and hiding a password. The affected input MUST have a name to identify it.
|
||||||
|
@ -47,8 +47,11 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
|
||||||
protected input: HTMLInputElement; // Input affected.
|
protected input: HTMLInputElement; // Input affected.
|
||||||
protected element: HTMLElement; // Current element.
|
protected element: HTMLElement; // Current element.
|
||||||
|
|
||||||
constructor(element: ElementRef, private utils: CoreUtilsProvider, private domUtils: CoreDomUtilsProvider,
|
constructor(
|
||||||
private platform: Platform) {
|
element: ElementRef,
|
||||||
|
private utils: CoreUtilsProvider,
|
||||||
|
private domUtils: CoreDomUtilsProvider
|
||||||
|
) {
|
||||||
this.element = element.nativeElement;
|
this.element = element.nativeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +117,7 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
|
||||||
this.shown = !this.shown;
|
this.shown = !this.shown;
|
||||||
this.setData();
|
this.setData();
|
||||||
|
|
||||||
if (isFocused && this.platform.is('android')) {
|
if (isFocused && CoreApp.instance.isAndroid()) {
|
||||||
// In Android, the keyboard is closed when the input type changes. Focus it again.
|
// In Android, the keyboard is closed when the input type changes. Focus it again.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.domUtils.focusElement(this.input);
|
this.domUtils.focusElement(this.input);
|
||||||
|
|
|
@ -218,7 +218,7 @@ export class CoreEditorRichTextEditorComponent implements AfterContentInit, OnDe
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let contentVisibleHeight = this.domUtils.getContentHeight(this.content);
|
let contentVisibleHeight = this.domUtils.getContentHeight(this.content);
|
||||||
if (!this.platform.is('android')) {
|
if (!CoreApp.instance.isAndroid()) {
|
||||||
// In Android we ignore the keyboard height because it is not part of the web view.
|
// In Android we ignore the keyboard height because it is not part of the web view.
|
||||||
contentVisibleHeight -= this.kbHeight;
|
contentVisibleHeight -= this.kbHeight;
|
||||||
}
|
}
|
||||||
|
@ -233,10 +233,10 @@ export class CoreEditorRichTextEditorComponent implements AfterContentInit, OnDe
|
||||||
// Editor is ready, adjust Height if needed.
|
// Editor is ready, adjust Height if needed.
|
||||||
let height;
|
let height;
|
||||||
|
|
||||||
if (this.platform.is('android')) {
|
if (CoreApp.instance.isAndroid()) {
|
||||||
// In Android we ignore the keyboard height because it is not part of the web view.
|
// In Android we ignore the keyboard height because it is not part of the web view.
|
||||||
height = this.domUtils.getContentHeight(this.content) - this.getSurroundingHeight(this.element);
|
height = this.domUtils.getContentHeight(this.content) - this.getSurroundingHeight(this.element);
|
||||||
} else if (this.platform.is('ios') && this.kbHeight > 0 && this.platform.version().major < 12) {
|
} else if (CoreApp.instance.isIOS() && this.kbHeight > 0 && this.platform.version().major < 12) {
|
||||||
// Keyboard open in iOS 11 or previous. The window height changes when the keyboard is open.
|
// Keyboard open in iOS 11 or previous. The window height changes when the keyboard is open.
|
||||||
height = window.innerHeight - this.getSurroundingHeight(this.element);
|
height = window.innerHeight - this.getSurroundingHeight(this.element);
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { CoreApp } from '@providers/app';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData } from './delegate';
|
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData } from './delegate';
|
||||||
import { CoreFileUploaderHelperProvider } from './helper';
|
import { CoreFileUploaderHelperProvider } from './helper';
|
||||||
|
@ -26,8 +25,10 @@ export class CoreFileUploaderAudioHandler implements CoreFileUploaderHandler {
|
||||||
name = 'CoreFileUploaderAudio';
|
name = 'CoreFileUploaderAudio';
|
||||||
priority = 1600;
|
priority = 1600;
|
||||||
|
|
||||||
constructor(private appProvider: CoreAppProvider, private utils: CoreUtilsProvider, private platform: Platform,
|
constructor(
|
||||||
private uploaderHelper: CoreFileUploaderHelperProvider) { }
|
private utils: CoreUtilsProvider,
|
||||||
|
private uploaderHelper: CoreFileUploaderHelperProvider
|
||||||
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the handler is enabled on a site level.
|
* Whether or not the handler is enabled on a site level.
|
||||||
|
@ -35,7 +36,7 @@ export class CoreFileUploaderAudioHandler implements CoreFileUploaderHandler {
|
||||||
* @return True or promise resolved with true if enabled.
|
* @return True or promise resolved with true if enabled.
|
||||||
*/
|
*/
|
||||||
isEnabled(): boolean | Promise<boolean> {
|
isEnabled(): boolean | Promise<boolean> {
|
||||||
return this.appProvider.isMobile() || (this.appProvider.canGetUserMedia() && this.appProvider.canRecordMedia());
|
return CoreApp.instance.isMobile() || (CoreApp.instance.canGetUserMedia() && CoreApp.instance.canRecordMedia());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,10 +46,10 @@ export class CoreFileUploaderAudioHandler implements CoreFileUploaderHandler {
|
||||||
* @return Supported mimetypes.
|
* @return Supported mimetypes.
|
||||||
*/
|
*/
|
||||||
getSupportedMimetypes(mimetypes: string[]): string[] {
|
getSupportedMimetypes(mimetypes: string[]): string[] {
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
// In iOS it's recorded as WAV.
|
// In iOS it's recorded as WAV.
|
||||||
return this.utils.filterByRegexp(mimetypes, /^audio\/wav$/);
|
return this.utils.filterByRegexp(mimetypes, /^audio\/wav$/);
|
||||||
} else if (this.platform.is('android')) {
|
} else if (CoreApp.instance.isAndroid()) {
|
||||||
// In Android we don't know the format the audio will be recorded, so accept any audio mimetype.
|
// In Android we don't know the format the audio will be recorded, so accept any audio mimetype.
|
||||||
return this.utils.filterByRegexp(mimetypes, /^audio\//);
|
return this.utils.filterByRegexp(mimetypes, /^audio\//);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreApp } from '@providers/app';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||||
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData } from './delegate';
|
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData } from './delegate';
|
||||||
|
@ -30,7 +30,7 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler {
|
||||||
name = 'CoreFileUploaderFile';
|
name = 'CoreFileUploaderFile';
|
||||||
priority = 1200;
|
priority = 1200;
|
||||||
|
|
||||||
constructor(protected appProvider: CoreAppProvider,
|
constructor(
|
||||||
protected platform: Platform,
|
protected platform: Platform,
|
||||||
protected timeUtils: CoreTimeUtilsProvider,
|
protected timeUtils: CoreTimeUtilsProvider,
|
||||||
protected uploaderHelper: CoreFileUploaderHelperProvider,
|
protected uploaderHelper: CoreFileUploaderHelperProvider,
|
||||||
|
@ -44,8 +44,8 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler {
|
||||||
* @return True or promise resolved with true if enabled.
|
* @return True or promise resolved with true if enabled.
|
||||||
*/
|
*/
|
||||||
isEnabled(): boolean | Promise<boolean> {
|
isEnabled(): boolean | Promise<boolean> {
|
||||||
return this.platform.is('android') || !this.appProvider.isMobile() ||
|
return CoreApp.instance.isAndroid() || !CoreApp.instance.isMobile() ||
|
||||||
(this.platform.is('ios') && this.platform.version().major >= 9);
|
(CoreApp.instance.isIOS() && this.platform.version().major >= 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +70,7 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler {
|
||||||
icon: 'folder',
|
icon: 'folder',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.appProvider.isMobile()) {
|
if (CoreApp.instance.isMobile()) {
|
||||||
handler.action = (maxSize?: number, upload?: boolean, allowOffline?: boolean, mimetypes?: string[]): Promise<any> => {
|
handler.action = (maxSize?: number, upload?: boolean, allowOffline?: boolean, mimetypes?: string[]): Promise<any> => {
|
||||||
return this.uploaderHelper.chooseAndUploadFile(maxSize, upload, allowOffline, mimetypes).then((result) => {
|
return this.uploaderHelper.chooseAndUploadFile(maxSize, upload, allowOffline, mimetypes).then((result) => {
|
||||||
return {
|
return {
|
||||||
|
@ -89,7 +89,7 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler {
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.setAttribute('type', 'file');
|
input.setAttribute('type', 'file');
|
||||||
input.classList.add('core-fileuploader-file-handler-input');
|
input.classList.add('core-fileuploader-file-handler-input');
|
||||||
if (mimetypes && mimetypes.length && (!this.platform.is('android') || mimetypes.length == 1)) {
|
if (mimetypes && mimetypes.length && (!CoreApp.instance.isAndroid() || mimetypes.length == 1)) {
|
||||||
// Don't use accept attribute in Android with several mimetypes, it's not supported.
|
// Don't use accept attribute in Android with several mimetypes, it's not supported.
|
||||||
input.setAttribute('accept', mimetypes.join(', '));
|
input.setAttribute('accept', mimetypes.join(', '));
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
// In iOS, the click on the input stopped working for some reason. We need to put it 1 level higher.
|
// In iOS, the click on the input stopped working for some reason. We need to put it 1 level higher.
|
||||||
element.parentElement.appendChild(input);
|
element.parentElement.appendChild(input);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Platform, ModalController } from 'ionic-angular';
|
import { ModalController } from 'ionic-angular';
|
||||||
import { Camera, CameraOptions } from '@ionic-native/camera';
|
import { Camera, CameraOptions } from '@ionic-native/camera';
|
||||||
import { MediaCapture, MediaFile, CaptureError, CaptureAudioOptions, CaptureVideoOptions } from '@ionic-native/media-capture';
|
import { MediaCapture, MediaFile, CaptureError, CaptureAudioOptions, CaptureVideoOptions } from '@ionic-native/media-capture';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
@ -27,6 +27,7 @@ import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreWSFileUploadOptions } from '@providers/ws';
|
import { CoreWSFileUploadOptions } from '@providers/ws';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
import { CoreApp } from '@providers/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File upload options.
|
* File upload options.
|
||||||
|
@ -61,7 +62,6 @@ export class CoreFileUploaderProvider {
|
||||||
protected timeUtils: CoreTimeUtilsProvider,
|
protected timeUtils: CoreTimeUtilsProvider,
|
||||||
protected mimeUtils: CoreMimetypeUtilsProvider,
|
protected mimeUtils: CoreMimetypeUtilsProvider,
|
||||||
protected filepoolProvider: CoreFilepoolProvider,
|
protected filepoolProvider: CoreFilepoolProvider,
|
||||||
protected platform: Platform,
|
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected mediaCapture: MediaCapture,
|
protected mediaCapture: MediaCapture,
|
||||||
protected camera: Camera,
|
protected camera: Camera,
|
||||||
|
@ -183,7 +183,7 @@ export class CoreFileUploaderProvider {
|
||||||
getCameraUploadOptions(uri: string, isFromAlbum?: boolean): CoreFileUploaderOptions {
|
getCameraUploadOptions(uri: string, isFromAlbum?: boolean): CoreFileUploaderOptions {
|
||||||
const extension = this.mimeUtils.guessExtensionFromUrl(uri);
|
const extension = this.mimeUtils.guessExtensionFromUrl(uri);
|
||||||
const mimetype = this.mimeUtils.getMimeType(extension);
|
const mimetype = this.mimeUtils.getMimeType(extension);
|
||||||
const isIOS = this.platform.is('ios');
|
const isIOS = CoreApp.instance.isIOS();
|
||||||
const options: CoreFileUploaderOptions = {
|
const options: CoreFileUploaderOptions = {
|
||||||
deleteAfterUpload: !isFromAlbum,
|
deleteAfterUpload: !isFromAlbum,
|
||||||
mimeType: mimetype
|
mimeType: mimetype
|
||||||
|
@ -206,7 +206,7 @@ export class CoreFileUploaderProvider {
|
||||||
// If the file was picked from the album, delete it only if it was copied to the app's folder.
|
// If the file was picked from the album, delete it only if it was copied to the app's folder.
|
||||||
options.deleteAfterUpload = this.fileProvider.isFileInAppFolder(uri);
|
options.deleteAfterUpload = this.fileProvider.isFileInAppFolder(uri);
|
||||||
|
|
||||||
if (this.platform.is('android')) {
|
if (CoreApp.instance.isAndroid()) {
|
||||||
// Picking an image from album in Android adds a timestamp at the end of the file. Delete it.
|
// Picking an image from album in Android adds a timestamp at the end of the file. Delete it.
|
||||||
options.fileName = options.fileName.replace(/(\.[^\.]*)\?[^\.]*$/, '$1');
|
options.fileName = options.fileName.replace(/(\.[^\.]*)\?[^\.]*$/, '$1');
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { MediaFile } from '@ionic-native/media-capture';
|
||||||
import { Camera, CameraOptions } from '@ionic-native/camera';
|
import { Camera, CameraOptions } from '@ionic-native/camera';
|
||||||
import { Chooser, ChooserResult } from '@ionic-native/chooser';
|
import { Chooser, ChooserResult } from '@ionic-native/chooser';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreApp, CoreAppProvider } from '@providers/app';
|
||||||
import { CoreFileProvider, CoreFileProgressEvent } from '@providers/file';
|
import { CoreFileProvider, CoreFileProgressEvent } from '@providers/file';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
|
@ -628,7 +628,7 @@ export class CoreFileUploaderHelperProvider {
|
||||||
options.mediaType = this.camera.MediaType.PICTURE;
|
options.mediaType = this.camera.MediaType.PICTURE;
|
||||||
} else if (!imageSupported && videoSupported) {
|
} else if (!imageSupported && videoSupported) {
|
||||||
options.mediaType = this.camera.MediaType.VIDEO;
|
options.mediaType = this.camera.MediaType.VIDEO;
|
||||||
} else if (this.platform.is('ios')) {
|
} else if (CoreApp.instance.isIOS()) {
|
||||||
// Only get all media in iOS because in Android using this option allows uploading any kind of file.
|
// Only get all media in iOS because in Android using this option allows uploading any kind of file.
|
||||||
options.mediaType = this.camera.MediaType.ALLMEDIA;
|
options.mediaType = this.camera.MediaType.ALLMEDIA;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { CoreApp } from '@providers/app';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData } from './delegate';
|
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData } from './delegate';
|
||||||
import { CoreFileUploaderHelperProvider } from './helper';
|
import { CoreFileUploaderHelperProvider } from './helper';
|
||||||
|
@ -26,8 +25,10 @@ export class CoreFileUploaderVideoHandler implements CoreFileUploaderHandler {
|
||||||
name = 'CoreFileUploaderVideo';
|
name = 'CoreFileUploaderVideo';
|
||||||
priority = 1400;
|
priority = 1400;
|
||||||
|
|
||||||
constructor(private appProvider: CoreAppProvider, private utils: CoreUtilsProvider, private platform: Platform,
|
constructor(
|
||||||
private uploaderHelper: CoreFileUploaderHelperProvider) { }
|
private utils: CoreUtilsProvider,
|
||||||
|
private uploaderHelper: CoreFileUploaderHelperProvider
|
||||||
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the handler is enabled on a site level.
|
* Whether or not the handler is enabled on a site level.
|
||||||
|
@ -35,7 +36,7 @@ export class CoreFileUploaderVideoHandler implements CoreFileUploaderHandler {
|
||||||
* @return True or promise resolved with true if enabled.
|
* @return True or promise resolved with true if enabled.
|
||||||
*/
|
*/
|
||||||
isEnabled(): boolean | Promise<boolean> {
|
isEnabled(): boolean | Promise<boolean> {
|
||||||
return this.appProvider.isMobile() || (this.appProvider.canGetUserMedia() && this.appProvider.canRecordMedia());
|
return CoreApp.instance.isMobile() || (CoreApp.instance.canGetUserMedia() && CoreApp.instance.canRecordMedia());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,10 +46,10 @@ export class CoreFileUploaderVideoHandler implements CoreFileUploaderHandler {
|
||||||
* @return Supported mimetypes.
|
* @return Supported mimetypes.
|
||||||
*/
|
*/
|
||||||
getSupportedMimetypes(mimetypes: string[]): string[] {
|
getSupportedMimetypes(mimetypes: string[]): string[] {
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
// In iOS it's recorded as MOV.
|
// In iOS it's recorded as MOV.
|
||||||
return this.utils.filterByRegexp(mimetypes, /^video\/quicktime$/);
|
return this.utils.filterByRegexp(mimetypes, /^video\/quicktime$/);
|
||||||
} else if (this.platform.is('android')) {
|
} else if (CoreApp.instance.isAndroid()) {
|
||||||
// In Android we don't know the format the video will be recorded, so accept any video mimetype.
|
// In Android we don't know the format the video will be recorded, so accept any video mimetype.
|
||||||
return this.utils.filterByRegexp(mimetypes, /^video\//);
|
return this.utils.filterByRegexp(mimetypes, /^video\//);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { Platform, AlertController, NavController, NavOptions } from 'ionic-angular';
|
import { AlertController, NavController, NavOptions } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider, CoreStoreConfig } from '@providers/app';
|
import { CoreApp, CoreStoreConfig } from '@providers/app';
|
||||||
import { CoreConfigProvider } from '@providers/config';
|
import { CoreConfigProvider } from '@providers/config';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreInitDelegate } from '@providers/init';
|
import { CoreInitDelegate } from '@providers/init';
|
||||||
|
@ -87,12 +87,23 @@ export class CoreLoginHelperProvider {
|
||||||
protected isOpeningReconnect = false;
|
protected isOpeningReconnect = false;
|
||||||
waitingForBrowser = false;
|
waitingForBrowser = false;
|
||||||
|
|
||||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private domUtils: CoreDomUtilsProvider,
|
constructor(
|
||||||
private wsProvider: CoreWSProvider, private translate: TranslateService, private textUtils: CoreTextUtilsProvider,
|
logger: CoreLoggerProvider,
|
||||||
private eventsProvider: CoreEventsProvider, private appProvider: CoreAppProvider, private utils: CoreUtilsProvider,
|
private sitesProvider: CoreSitesProvider,
|
||||||
private urlUtils: CoreUrlUtilsProvider, private configProvider: CoreConfigProvider, private platform: Platform,
|
private domUtils: CoreDomUtilsProvider,
|
||||||
private initDelegate: CoreInitDelegate, private sitePluginsProvider: CoreSitePluginsProvider,
|
private wsProvider: CoreWSProvider,
|
||||||
private location: Location, private alertCtrl: AlertController, private courseProvider: CoreCourseProvider) {
|
private translate: TranslateService,
|
||||||
|
private textUtils: CoreTextUtilsProvider,
|
||||||
|
private eventsProvider: CoreEventsProvider,
|
||||||
|
private utils: CoreUtilsProvider,
|
||||||
|
private urlUtils: CoreUrlUtilsProvider,
|
||||||
|
private configProvider: CoreConfigProvider,
|
||||||
|
private initDelegate: CoreInitDelegate,
|
||||||
|
private sitePluginsProvider: CoreSitePluginsProvider,
|
||||||
|
private location: Location,
|
||||||
|
private alertCtrl: AlertController,
|
||||||
|
private courseProvider: CoreCourseProvider
|
||||||
|
) {
|
||||||
this.logger = logger.getInstance('CoreLoginHelper');
|
this.logger = logger.getInstance('CoreLoginHelper');
|
||||||
|
|
||||||
this.eventsProvider.on(CoreEventsProvider.MAIN_MENU_OPEN, () => {
|
this.eventsProvider.on(CoreEventsProvider.MAIN_MENU_OPEN, () => {
|
||||||
|
@ -149,17 +160,17 @@ export class CoreLoginHelperProvider {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.appProvider.isSSOAuthenticationOngoing()) {
|
if (CoreApp.instance.isSSOAuthenticationOngoing()) {
|
||||||
// Authentication ongoing, probably duplicated request.
|
// Authentication ongoing, probably duplicated request.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (this.appProvider.isDesktop()) {
|
if (CoreApp.instance.isDesktop()) {
|
||||||
// In desktop, make sure InAppBrowser is closed.
|
// In desktop, make sure InAppBrowser is closed.
|
||||||
this.utils.closeInAppBrowser(true);
|
this.utils.closeInAppBrowser(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// App opened using custom URL scheme. Probably an SSO authentication.
|
// App opened using custom URL scheme. Probably an SSO authentication.
|
||||||
this.appProvider.startSSOAuthentication();
|
CoreApp.instance.startSSOAuthentication();
|
||||||
this.logger.debug('App launched by URL with an SSO');
|
this.logger.debug('App launched by URL with an SSO');
|
||||||
|
|
||||||
// Delete the sso scheme from the URL.
|
// Delete the sso scheme from the URL.
|
||||||
|
@ -195,7 +206,7 @@ export class CoreLoginHelperProvider {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (siteData.pageName) {
|
if (siteData.pageName) {
|
||||||
// State defined, go to that state instead of site initial page.
|
// State defined, go to that state instead of site initial page.
|
||||||
this.appProvider.getRootNavController().push(siteData.pageName, siteData.pageParams);
|
CoreApp.instance.getRootNavController().push(siteData.pageName, siteData.pageParams);
|
||||||
} else {
|
} else {
|
||||||
this.goToSiteInitialPage();
|
this.goToSiteInitialPage();
|
||||||
}
|
}
|
||||||
|
@ -207,7 +218,7 @@ export class CoreLoginHelperProvider {
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
modal.dismiss();
|
modal.dismiss();
|
||||||
this.appProvider.finishSSOAuthentication();
|
CoreApp.instance.finishSSOAuthentication();
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -232,8 +243,8 @@ export class CoreLoginHelperProvider {
|
||||||
* Function called when an SSO InAppBrowser is closed or the app is resumed. Check if user needs to be logged out.
|
* Function called when an SSO InAppBrowser is closed or the app is resumed. Check if user needs to be logged out.
|
||||||
*/
|
*/
|
||||||
checkLogout(): void {
|
checkLogout(): void {
|
||||||
const navCtrl = this.appProvider.getRootNavController();
|
const navCtrl = CoreApp.instance.getRootNavController();
|
||||||
if (!this.appProvider.isSSOAuthenticationOngoing() && this.sitesProvider.isLoggedIn() &&
|
if (!CoreApp.instance.isSSOAuthenticationOngoing() && this.sitesProvider.isLoggedIn() &&
|
||||||
this.sitesProvider.getCurrentSite().isLoggedOut() && navCtrl.getActive().name == 'CoreLoginReconnectPage') {
|
this.sitesProvider.getCurrentSite().isLoggedOut() && navCtrl.getActive().name == 'CoreLoginReconnectPage') {
|
||||||
// User must reauthenticate but he closed the InAppBrowser without doing so, logout him.
|
// User must reauthenticate but he closed the InAppBrowser without doing so, logout him.
|
||||||
this.sitesProvider.logout();
|
this.sitesProvider.logout();
|
||||||
|
@ -515,9 +526,9 @@ export class CoreLoginHelperProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setRoot) {
|
if (setRoot) {
|
||||||
return this.appProvider.getRootNavController().setRoot(pageName, params, { animate: false });
|
return CoreApp.instance.getRootNavController().setRoot(pageName, params, { animate: false });
|
||||||
} else {
|
} else {
|
||||||
return this.appProvider.getRootNavController().push(pageName, params);
|
return CoreApp.instance.getRootNavController().push(pageName, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +541,7 @@ export class CoreLoginHelperProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
goToNoSitePage(navCtrl: NavController, page: string, params?: any): Promise<any> {
|
goToNoSitePage(navCtrl: NavController, page: string, params?: any): Promise<any> {
|
||||||
navCtrl = navCtrl || this.appProvider.getRootNavController();
|
navCtrl = navCtrl || CoreApp.instance.getRootNavController();
|
||||||
|
|
||||||
const currentPage = navCtrl && navCtrl.getActive().component.name;
|
const currentPage = navCtrl && navCtrl.getActive().component.name;
|
||||||
|
|
||||||
|
@ -728,7 +739,7 @@ export class CoreLoginHelperProvider {
|
||||||
* @return True if embedded browser, false othwerise.
|
* @return True if embedded browser, false othwerise.
|
||||||
*/
|
*/
|
||||||
isSSOEmbeddedBrowser(code: number): boolean {
|
isSSOEmbeddedBrowser(code: number): boolean {
|
||||||
if (this.appProvider.isLinux()) {
|
if (CoreApp.instance.isLinux()) {
|
||||||
// In Linux desktop app, always use embedded browser.
|
// In Linux desktop app, always use embedded browser.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -755,7 +766,7 @@ export class CoreLoginHelperProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected loadSiteAndPage(page: string, params: any, siteId: string): Promise<any> {
|
protected loadSiteAndPage(page: string, params: any, siteId: string): Promise<any> {
|
||||||
const navCtrl = this.appProvider.getRootNavController();
|
const navCtrl = CoreApp.instance.getRootNavController();
|
||||||
|
|
||||||
if (siteId == CoreConstants.NO_SITE_ID) {
|
if (siteId == CoreConstants.NO_SITE_ID) {
|
||||||
// Page doesn't belong to a site, just load the page.
|
// Page doesn't belong to a site, just load the page.
|
||||||
|
@ -783,7 +794,7 @@ export class CoreLoginHelperProvider {
|
||||||
* @param params Params to pass to the page.
|
* @param params Params to pass to the page.
|
||||||
*/
|
*/
|
||||||
loadPageInMainMenu(page: string, params: any): void {
|
loadPageInMainMenu(page: string, params: any): void {
|
||||||
if (!this.appProvider.isMainMenuOpen()) {
|
if (!CoreApp.instance.isMainMenuOpen()) {
|
||||||
// Main menu not open. Store the page to be loaded later.
|
// Main menu not open. Store the page to be loaded later.
|
||||||
this.pageToLoad = {
|
this.pageToLoad = {
|
||||||
page: page,
|
page: page,
|
||||||
|
@ -813,7 +824,7 @@ export class CoreLoginHelperProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected openMainMenu(navCtrl: NavController, page: string, params: any, options?: NavOptions, url?: string): Promise<any> {
|
protected openMainMenu(navCtrl: NavController, page: string, params: any, options?: NavOptions, url?: string): Promise<any> {
|
||||||
navCtrl = navCtrl || this.appProvider.getRootNavController();
|
navCtrl = navCtrl || CoreApp.instance.getRootNavController();
|
||||||
|
|
||||||
// Due to DeepLinker, we need to remove the path from the URL before going to main menu.
|
// Due to DeepLinker, we need to remove the path from the URL before going to main menu.
|
||||||
// IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL.
|
// IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL.
|
||||||
|
@ -857,7 +868,7 @@ export class CoreLoginHelperProvider {
|
||||||
oauthsso: params.id,
|
oauthsso: params.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.appProvider.isLinux()) {
|
if (CoreApp.instance.isLinux()) {
|
||||||
// In Linux desktop app, always use embedded browser.
|
// In Linux desktop app, always use embedded browser.
|
||||||
this.utils.openInApp(loginUrl);
|
this.utils.openInApp(loginUrl);
|
||||||
} else {
|
} else {
|
||||||
|
@ -974,7 +985,7 @@ export class CoreLoginHelperProvider {
|
||||||
return; // Site that triggered the event is not current site.
|
return; // Site that triggered the event is not current site.
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootNavCtrl = this.appProvider.getRootNavController(),
|
const rootNavCtrl = CoreApp.instance.getRootNavController(),
|
||||||
activePage = rootNavCtrl.getActive();
|
activePage = rootNavCtrl.getActive();
|
||||||
|
|
||||||
// If current page is already change password, stop.
|
// If current page is already change password, stop.
|
||||||
|
@ -1041,7 +1052,7 @@ export class CoreLoginHelperProvider {
|
||||||
// Target page belongs to a different site. Change site.
|
// Target page belongs to a different site. Change site.
|
||||||
if (this.sitePluginsProvider.hasSitePluginsLoaded) {
|
if (this.sitePluginsProvider.hasSitePluginsLoaded) {
|
||||||
// The site has site plugins so the app will be restarted. Store the data and logout.
|
// The site has site plugins so the app will be restarted. Store the data and logout.
|
||||||
this.appProvider.storeRedirect(siteId, page, params);
|
CoreApp.instance.storeRedirect(siteId, page, params);
|
||||||
|
|
||||||
return this.sitesProvider.logout();
|
return this.sitesProvider.logout();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1056,7 +1067,7 @@ export class CoreLoginHelperProvider {
|
||||||
if (siteId) {
|
if (siteId) {
|
||||||
return this.loadSiteAndPage(page, params, siteId);
|
return this.loadSiteAndPage(page, params, siteId);
|
||||||
} else {
|
} else {
|
||||||
return this.appProvider.getRootNavController().setRoot('CoreLoginSitesPage');
|
return CoreApp.instance.getRootNavController().setRoot('CoreLoginSitesPage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1113,7 +1124,7 @@ export class CoreLoginHelperProvider {
|
||||||
|
|
||||||
if (this.isSSOLoginNeeded(result.code)) {
|
if (this.isSSOLoginNeeded(result.code)) {
|
||||||
// SSO. User needs to authenticate in a browser. Check if we need to display a message.
|
// SSO. User needs to authenticate in a browser. Check if we need to display a message.
|
||||||
if (!this.appProvider.isSSOAuthenticationOngoing() && !this.isSSOConfirmShown && !this.waitingForBrowser) {
|
if (!CoreApp.instance.isSSOAuthenticationOngoing() && !this.isSSOConfirmShown && !this.waitingForBrowser) {
|
||||||
this.isSSOConfirmShown = true;
|
this.isSSOConfirmShown = true;
|
||||||
|
|
||||||
if (this.shouldShowSSOConfirm(result.code)) {
|
if (this.shouldShowSSOConfirm(result.code)) {
|
||||||
|
@ -1146,7 +1157,7 @@ export class CoreLoginHelperProvider {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (providerToUse) {
|
if (providerToUse) {
|
||||||
if (!this.appProvider.isSSOAuthenticationOngoing() && !this.isSSOConfirmShown && !this.waitingForBrowser) {
|
if (!CoreApp.instance.isSSOAuthenticationOngoing() && !this.isSSOConfirmShown && !this.waitingForBrowser) {
|
||||||
// Open browser to perform the OAuth.
|
// Open browser to perform the OAuth.
|
||||||
this.isSSOConfirmShown = true;
|
this.isSSOConfirmShown = true;
|
||||||
|
|
||||||
|
@ -1173,7 +1184,7 @@ export class CoreLoginHelperProvider {
|
||||||
|
|
||||||
const info = currentSite.getInfo();
|
const info = currentSite.getInfo();
|
||||||
if (typeof info != 'undefined' && typeof info.username != 'undefined' && !this.isOpeningReconnect) {
|
if (typeof info != 'undefined' && typeof info.username != 'undefined' && !this.isOpeningReconnect) {
|
||||||
const rootNavCtrl = this.appProvider.getRootNavController(),
|
const rootNavCtrl = CoreApp.instance.getRootNavController(),
|
||||||
activePage = rootNavCtrl.getActive();
|
activePage = rootNavCtrl.getActive();
|
||||||
|
|
||||||
// If current page is already reconnect, stop.
|
// If current page is already reconnect, stop.
|
||||||
|
@ -1222,7 +1233,7 @@ export class CoreLoginHelperProvider {
|
||||||
* @param message The warning message.
|
* @param message The warning message.
|
||||||
*/
|
*/
|
||||||
protected showWorkplaceNoticeModal(message: string): void {
|
protected showWorkplaceNoticeModal(message: string): void {
|
||||||
const link = this.appProvider.getAppStoreUrl({android: 'com.moodle.workplace', ios: 'id1470929705' });
|
const link = CoreApp.instance.getAppStoreUrl({android: 'com.moodle.workplace', ios: 'id1470929705' });
|
||||||
|
|
||||||
this.showDownloadAppNoticeModal(message, link);
|
this.showDownloadAppNoticeModal(message, link);
|
||||||
}
|
}
|
||||||
|
@ -1238,7 +1249,7 @@ export class CoreLoginHelperProvider {
|
||||||
storesConfig.mobile = 'https://download.moodle.org/mobile/';
|
storesConfig.mobile = 'https://download.moodle.org/mobile/';
|
||||||
storesConfig.default = 'https://download.moodle.org/mobile/';
|
storesConfig.default = 'https://download.moodle.org/mobile/';
|
||||||
|
|
||||||
const link = this.appProvider.getAppStoreUrl(storesConfig);
|
const link = CoreApp.instance.getAppStoreUrl(storesConfig);
|
||||||
|
|
||||||
this.showDownloadAppNoticeModal(message, link);
|
this.showDownloadAppNoticeModal(message, link);
|
||||||
}
|
}
|
||||||
|
@ -1272,7 +1283,7 @@ export class CoreLoginHelperProvider {
|
||||||
});
|
});
|
||||||
|
|
||||||
alert.present().then(() => {
|
alert.present().then(() => {
|
||||||
const isDevice = this.platform.is('android') || this.platform.is('ios');
|
const isDevice = CoreApp.instance.isAndroid() || CoreApp.instance.isIOS();
|
||||||
if (!isDevice) {
|
if (!isDevice) {
|
||||||
// Treat all anchors so they don't override the app.
|
// Treat all anchors so they don't override the app.
|
||||||
const alertMessageEl: HTMLElement = alert.pageRef().nativeElement.querySelector('.alert-message');
|
const alertMessageEl: HTMLElement = alert.pageRef().nativeElement.querySelector('.alert-message');
|
||||||
|
@ -1358,7 +1369,7 @@ export class CoreLoginHelperProvider {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootNavCtrl = this.appProvider.getRootNavController(),
|
const rootNavCtrl = CoreApp.instance.getRootNavController(),
|
||||||
activePage = rootNavCtrl.getActive();
|
activePage = rootNavCtrl.getActive();
|
||||||
|
|
||||||
// If current page is already site policy, stop.
|
// If current page is already site policy, stop.
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnDestroy, ViewChild, ChangeDetectorRef } from '@angular/core';
|
import { Component, OnDestroy, ViewChild, ChangeDetectorRef } from '@angular/core';
|
||||||
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
|
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreApp } from '@providers/app';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreIonTabsComponent } from '@components/ion-tabs/ion-tabs';
|
import { CoreIonTabsComponent } from '@components/ion-tabs/ion-tabs';
|
||||||
|
@ -58,10 +58,9 @@ export class CoreMainMenuPage implements OnDestroy {
|
||||||
protected mainMenuProvider: CoreMainMenuProvider,
|
protected mainMenuProvider: CoreMainMenuProvider,
|
||||||
protected linksDelegate: CoreContentLinksDelegate,
|
protected linksDelegate: CoreContentLinksDelegate,
|
||||||
protected linksHelper: CoreContentLinksHelperProvider,
|
protected linksHelper: CoreContentLinksHelperProvider,
|
||||||
protected appProvider: CoreAppProvider,
|
) {
|
||||||
protected platform: Platform) {
|
|
||||||
|
|
||||||
this.mainMenuId = this.appProvider.getMainMenuId();
|
this.mainMenuId = CoreApp.instance.getMainMenuId();
|
||||||
|
|
||||||
// Check if the menu was loaded with a redirect.
|
// Check if the menu was loaded with a redirect.
|
||||||
const redirectPage = navParams.get('redirectPage');
|
const redirectPage = navParams.get('redirectPage');
|
||||||
|
@ -118,7 +117,7 @@ export class CoreMainMenuPage implements OnDestroy {
|
||||||
|
|
||||||
window.addEventListener('resize', this.initHandlers.bind(this));
|
window.addEventListener('resize', this.initHandlers.bind(this));
|
||||||
|
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
// In iOS, the resize event is triggered before the keyboard is opened/closed and not triggered again once done.
|
// In iOS, the resize event is triggered before the keyboard is opened/closed and not triggered again once done.
|
||||||
// Init handlers again once keyboard is closed since the resize event doesn't have the updated height.
|
// Init handlers again once keyboard is closed since the resize event doesn't have the updated height.
|
||||||
this.keyboardObserver = this.eventsProvider.on(CoreEventsProvider.KEYBOARD_CHANGE, (kbHeight) => {
|
this.keyboardObserver = this.eventsProvider.on(CoreEventsProvider.KEYBOARD_CHANGE, (kbHeight) => {
|
||||||
|
@ -133,7 +132,7 @@ export class CoreMainMenuPage implements OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.appProvider.setMainMenuOpen(this.mainMenuId, true);
|
CoreApp.instance.setMainMenuOpen(this.mainMenuId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,7 +242,7 @@ export class CoreMainMenuPage implements OnDestroy {
|
||||||
this.subscription && this.subscription.unsubscribe();
|
this.subscription && this.subscription.unsubscribe();
|
||||||
this.redirectObs && this.redirectObs.off();
|
this.redirectObs && this.redirectObs.off();
|
||||||
window.removeEventListener('resize', this.initHandlers.bind(this));
|
window.removeEventListener('resize', this.initHandlers.bind(this));
|
||||||
this.appProvider.setMainMenuOpen(this.mainMenuId, false);
|
CoreApp.instance.setMainMenuOpen(this.mainMenuId, false);
|
||||||
this.keyboardObserver && this.keyboardObserver.off();
|
this.keyboardObserver && this.keyboardObserver.off();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { Badge } from '@ionic-native/badge';
|
||||||
import { Push, PushObject, PushOptions } from '@ionic-native/push';
|
import { Push, PushObject, PushOptions } from '@ionic-native/push';
|
||||||
import { Device } from '@ionic-native/device';
|
import { Device } from '@ionic-native/device';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider, CoreAppSchema } from '@providers/app';
|
import { CoreApp, CoreAppProvider, CoreAppSchema } from '@providers/app';
|
||||||
import { CoreInitDelegate } from '@providers/init';
|
import { CoreInitDelegate } from '@providers/init';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
import { CoreSitesProvider, CoreSiteSchema } from '@providers/sites';
|
||||||
|
@ -178,13 +178,26 @@ export class CorePushNotificationsProvider {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(logger: CoreLoggerProvider, protected appProvider: CoreAppProvider, private initDelegate: CoreInitDelegate,
|
constructor(
|
||||||
protected pushNotificationsDelegate: CorePushNotificationsDelegate, protected sitesProvider: CoreSitesProvider,
|
logger: CoreLoggerProvider,
|
||||||
private badge: Badge, private localNotificationsProvider: CoreLocalNotificationsProvider,
|
private initDelegate: CoreInitDelegate,
|
||||||
private utils: CoreUtilsProvider, private textUtils: CoreTextUtilsProvider, private push: Push,
|
protected pushNotificationsDelegate: CorePushNotificationsDelegate,
|
||||||
private configProvider: CoreConfigProvider, private device: Device, private zone: NgZone,
|
protected sitesProvider: CoreSitesProvider,
|
||||||
private translate: TranslateService, private platform: Platform, private sitesFactory: CoreSitesFactoryProvider,
|
private badge: Badge,
|
||||||
private filterProvider: CoreFilterProvider, private filterDelegate: CoreFilterDelegate) {
|
private localNotificationsProvider: CoreLocalNotificationsProvider,
|
||||||
|
private utils: CoreUtilsProvider,
|
||||||
|
private textUtils: CoreTextUtilsProvider,
|
||||||
|
private push: Push,
|
||||||
|
private configProvider: CoreConfigProvider,
|
||||||
|
private device: Device,
|
||||||
|
private zone: NgZone,
|
||||||
|
private translate: TranslateService,
|
||||||
|
platform: Platform,
|
||||||
|
appProvider: CoreAppProvider,
|
||||||
|
private sitesFactory: CoreSitesFactoryProvider,
|
||||||
|
private filterProvider: CoreFilterProvider,
|
||||||
|
private filterDelegate: CoreFilterDelegate
|
||||||
|
) {
|
||||||
this.logger = logger.getInstance('CorePushNotificationsProvider');
|
this.logger = logger.getInstance('CorePushNotificationsProvider');
|
||||||
this.appDB = appProvider.getDB();
|
this.appDB = appProvider.getDB();
|
||||||
this.dbReady = appProvider.createTablesFromSchema(this.appTablesSchema).catch(() => {
|
this.dbReady = appProvider.createTablesFromSchema(this.appTablesSchema).catch(() => {
|
||||||
|
@ -209,7 +222,7 @@ export class CorePushNotificationsProvider {
|
||||||
* @return Whether the device can be registered in Moodle.
|
* @return Whether the device can be registered in Moodle.
|
||||||
*/
|
*/
|
||||||
canRegisterOnMoodle(): boolean {
|
canRegisterOnMoodle(): boolean {
|
||||||
return this.pushID && this.appProvider.isMobile();
|
return this.pushID && CoreApp.instance.isMobile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,7 +247,7 @@ export class CorePushNotificationsProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected createDefaultChannel(): Promise<any> {
|
protected createDefaultChannel(): Promise<any> {
|
||||||
if (!this.platform.is('android')) {
|
if (!CoreApp.instance.isAndroid()) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +480,7 @@ export class CorePushNotificationsProvider {
|
||||||
instanceId: 0,
|
instanceId: 0,
|
||||||
filter: true
|
filter: true
|
||||||
},
|
},
|
||||||
isAndroid = this.platform.is('android'),
|
isAndroid = CoreApp.instance.isAndroid(),
|
||||||
extraFeatures = this.utils.isTrueOrOne(data.extrafeatures);
|
extraFeatures = this.utils.isTrueOrOne(data.extrafeatures);
|
||||||
|
|
||||||
// Get the filters to apply to text and message. Don't use FIlterHelper to prevent circular dependencies.
|
// Get the filters to apply to text and message. Don't use FIlterHelper to prevent circular dependencies.
|
||||||
|
@ -544,7 +557,7 @@ export class CorePushNotificationsProvider {
|
||||||
* @return Promise resolved when device is unregistered.
|
* @return Promise resolved when device is unregistered.
|
||||||
*/
|
*/
|
||||||
async unregisterDeviceOnMoodle(site: CoreSite): Promise<any> {
|
async unregisterDeviceOnMoodle(site: CoreSite): Promise<any> {
|
||||||
if (!site || !this.appProvider.isMobile()) {
|
if (!site || !CoreApp.instance.isMobile()) {
|
||||||
return Promise.reject(null);
|
return Promise.reject(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,7 +645,7 @@ export class CorePushNotificationsProvider {
|
||||||
return previous + parseInt(counter, 10);
|
return previous + parseInt(counter, 10);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
if (!this.appProvider.isDesktop() && !this.appProvider.isMobile()) {
|
if (!CoreApp.instance.isDesktop() && !CoreApp.instance.isMobile()) {
|
||||||
// Browser doesn't have an app badge, stop.
|
// Browser doesn't have an app badge, stop.
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, ViewChild } from '@angular/core';
|
import { Component, ViewChild } from '@angular/core';
|
||||||
import { IonicPage, NavParams, Platform } from 'ionic-angular';
|
import { IonicPage, NavParams } from 'ionic-angular';
|
||||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||||
|
import { CoreApp } from '@providers/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays the list of app settings pages.
|
* Page that displays the list of app settings pages.
|
||||||
|
@ -30,9 +31,8 @@ export class CoreAppSettingsPage {
|
||||||
isIOS: boolean;
|
isIOS: boolean;
|
||||||
selectedPage: string;
|
selectedPage: string;
|
||||||
|
|
||||||
constructor(platorm: Platform,
|
constructor(navParams: NavParams) {
|
||||||
navParams: NavParams) {
|
this.isIOS = CoreApp.instance.isIOS();
|
||||||
this.isIOS = platorm.is('ios');
|
|
||||||
|
|
||||||
this.selectedPage = navParams.get('page') || false;
|
this.selectedPage = navParams.get('page') || false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, ViewChild } from '@angular/core';
|
import { Component, ViewChild } from '@angular/core';
|
||||||
import { IonicPage, NavParams, Platform } from 'ionic-angular';
|
import { IonicPage, NavParams } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreSettingsDelegate, CoreSettingsHandlerData } from '../../providers/delegate';
|
import { CoreSettingsDelegate, CoreSettingsHandlerData } from '../../providers/delegate';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
|
@ -22,6 +22,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
import { CoreSplitViewComponent } from '@components/split-view/split-view';
|
||||||
import { CoreSharedFilesProvider } from '@core/sharedfiles/providers/sharedfiles';
|
import { CoreSharedFilesProvider } from '@core/sharedfiles/providers/sharedfiles';
|
||||||
import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper';
|
import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper';
|
||||||
|
import { CoreApp } from '@providers/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays the list of site settings pages.
|
* Page that displays the list of site settings pages.
|
||||||
|
@ -57,11 +58,10 @@ export class CoreSitePreferencesPage {
|
||||||
protected eventsProvider: CoreEventsProvider,
|
protected eventsProvider: CoreEventsProvider,
|
||||||
protected sharedFilesProvider: CoreSharedFilesProvider,
|
protected sharedFilesProvider: CoreSharedFilesProvider,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
platorm: Platform,
|
|
||||||
navParams: NavParams,
|
navParams: NavParams,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.isIOS = platorm.is('ios');
|
this.isIOS = CoreApp.instance.isIOS();
|
||||||
|
|
||||||
this.selectedPage = navParams.get('page') || false;
|
this.selectedPage = navParams.get('page') || false;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { CoreApp } from '@providers/app';
|
||||||
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData } from '@core/fileuploader/providers/delegate';
|
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData } from '@core/fileuploader/providers/delegate';
|
||||||
import { CoreSharedFilesHelperProvider } from './helper';
|
import { CoreSharedFilesHelperProvider } from './helper';
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ export class CoreSharedFilesUploadHandler implements CoreFileUploaderHandler {
|
||||||
name = 'CoreSharedFilesUpload';
|
name = 'CoreSharedFilesUpload';
|
||||||
priority = 1300;
|
priority = 1300;
|
||||||
|
|
||||||
constructor(private sharedFilesHelper: CoreSharedFilesHelperProvider, private platform: Platform) { }
|
constructor(private sharedFilesHelper: CoreSharedFilesHelperProvider) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the handler is enabled on a site level.
|
* Whether or not the handler is enabled on a site level.
|
||||||
|
@ -32,7 +32,7 @@ export class CoreSharedFilesUploadHandler implements CoreFileUploaderHandler {
|
||||||
* @return True or promise resolved with true if enabled.
|
* @return True or promise resolved with true if enabled.
|
||||||
*/
|
*/
|
||||||
isEnabled(): boolean | Promise<boolean> {
|
isEnabled(): boolean | Promise<boolean> {
|
||||||
return this.platform.is('ios');
|
return CoreApp.instance.isIOS();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { CoreSharedFilesHelperProvider } from './providers/helper';
|
||||||
import { CoreSharedFilesUploadHandler } from './providers/upload-handler';
|
import { CoreSharedFilesUploadHandler } from './providers/upload-handler';
|
||||||
import { CoreFileUploaderDelegate } from '@core/fileuploader/providers/delegate';
|
import { CoreFileUploaderDelegate } from '@core/fileuploader/providers/delegate';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
|
import { CoreAppProvider } from '@providers/app';
|
||||||
|
|
||||||
// List of providers (without handlers).
|
// List of providers (without handlers).
|
||||||
export const CORE_SHAREDFILES_PROVIDERS: any[] = [
|
export const CORE_SHAREDFILES_PROVIDERS: any[] = [
|
||||||
|
@ -38,12 +39,17 @@ export const CORE_SHAREDFILES_PROVIDERS: any[] = [
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class CoreSharedFilesModule {
|
export class CoreSharedFilesModule {
|
||||||
constructor(platform: Platform, delegate: CoreFileUploaderDelegate, handler: CoreSharedFilesUploadHandler,
|
constructor(platform: Platform,
|
||||||
helper: CoreSharedFilesHelperProvider, eventsProvider: CoreEventsProvider) {
|
delegate: CoreFileUploaderDelegate,
|
||||||
|
handler: CoreSharedFilesUploadHandler,
|
||||||
|
helper: CoreSharedFilesHelperProvider,
|
||||||
|
appsProvider: CoreAppProvider,
|
||||||
|
eventsProvider: CoreEventsProvider
|
||||||
|
) {
|
||||||
// Register the handler.
|
// Register the handler.
|
||||||
delegate.registerHandler(handler);
|
delegate.registerHandler(handler);
|
||||||
|
|
||||||
if (platform.is('ios')) {
|
if (appsProvider.isIOS()) {
|
||||||
let lastCheck = 0;
|
let lastCheck = 0;
|
||||||
|
|
||||||
// Check if there are new files at app start and when the app is resumed.
|
// Check if there are new files at app start and when the app is resumed.
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { CoreApp } from '@providers/app';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
|
||||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||||
import { CoreLangProvider } from '@providers/lang';
|
import { CoreLangProvider } from '@providers/lang';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
|
@ -67,10 +66,15 @@ export class CoreSitePluginsProvider {
|
||||||
hasSitePluginsLoaded = false;
|
hasSitePluginsLoaded = false;
|
||||||
sitePluginsFinishedLoading = false;
|
sitePluginsFinishedLoading = false;
|
||||||
|
|
||||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private utils: CoreUtilsProvider,
|
constructor(logger: CoreLoggerProvider,
|
||||||
private langProvider: CoreLangProvider, private appProvider: CoreAppProvider, private platform: Platform,
|
private sitesProvider: CoreSitesProvider,
|
||||||
private filepoolProvider: CoreFilepoolProvider, private coursesProvider: CoreCoursesProvider,
|
private utils: CoreUtilsProvider,
|
||||||
private textUtils: CoreTextUtilsProvider, private eventsProvider: CoreEventsProvider) {
|
private langProvider: CoreLangProvider,
|
||||||
|
private filepoolProvider: CoreFilepoolProvider,
|
||||||
|
private coursesProvider: CoreCoursesProvider,
|
||||||
|
private textUtils: CoreTextUtilsProvider,
|
||||||
|
private eventsProvider: CoreEventsProvider
|
||||||
|
) {
|
||||||
this.logger = logger.getInstance('CoreUserProvider');
|
this.logger = logger.getInstance('CoreUserProvider');
|
||||||
|
|
||||||
const observer = this.eventsProvider.on(CoreEventsProvider.SITE_PLUGINS_LOADED, () => {
|
const observer = this.eventsProvider.on(CoreEventsProvider.SITE_PLUGINS_LOADED, () => {
|
||||||
|
@ -107,20 +111,20 @@ export class CoreSitePluginsProvider {
|
||||||
argsToSend.appversionname = CoreConfigConstants.versionname;
|
argsToSend.appversionname = CoreConfigConstants.versionname;
|
||||||
argsToSend.applang = lang;
|
argsToSend.applang = lang;
|
||||||
argsToSend.appcustomurlscheme = CoreConfigConstants.customurlscheme;
|
argsToSend.appcustomurlscheme = CoreConfigConstants.customurlscheme;
|
||||||
argsToSend.appisdesktop = this.appProvider.isDesktop();
|
argsToSend.appisdesktop = CoreApp.instance.isDesktop();
|
||||||
argsToSend.appismobile = this.appProvider.isMobile();
|
argsToSend.appismobile = CoreApp.instance.isMobile();
|
||||||
argsToSend.appiswide = this.appProvider.isWide();
|
argsToSend.appiswide = CoreApp.instance.isWide();
|
||||||
|
|
||||||
if (argsToSend.appisdevice) {
|
if (argsToSend.appisdevice) {
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
argsToSend.appplatform = 'ios';
|
argsToSend.appplatform = 'ios';
|
||||||
} else {
|
} else {
|
||||||
argsToSend.appplatform = 'android';
|
argsToSend.appplatform = 'android';
|
||||||
}
|
}
|
||||||
} else if (argsToSend.appisdesktop) {
|
} else if (argsToSend.appisdesktop) {
|
||||||
if (this.appProvider.isMac()) {
|
if (CoreApp.instance.isMac()) {
|
||||||
argsToSend.appplatform = 'mac';
|
argsToSend.appplatform = 'mac';
|
||||||
} else if (this.appProvider.isLinux()) {
|
} else if (CoreApp.instance.isLinux()) {
|
||||||
argsToSend.appplatform = 'linux';
|
argsToSend.appplatform = 'linux';
|
||||||
} else {
|
} else {
|
||||||
argsToSend.appplatform = 'windows';
|
argsToSend.appplatform = 'windows';
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
|
|
||||||
import { Directive, OnInit, OnDestroy } from '@angular/core';
|
import { Directive, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Navbar, Platform } from 'ionic-angular';
|
import { Navbar } from 'ionic-angular';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
|
import { CoreApp } from '@providers/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directive to tramslate the back button of navigation bars in iOS.
|
* Directive to tramslate the back button of navigation bars in iOS.
|
||||||
|
@ -30,8 +31,10 @@ import { CoreEventsProvider } from '@providers/events';
|
||||||
export class CoreBackButtonDirective implements OnInit, OnDestroy {
|
export class CoreBackButtonDirective implements OnInit, OnDestroy {
|
||||||
protected languageObserver: any;
|
protected languageObserver: any;
|
||||||
|
|
||||||
constructor(private host: Navbar, private platform: Platform,
|
constructor(private host: Navbar,
|
||||||
private translate: TranslateService, private eventsProvider: CoreEventsProvider) {}
|
private translate: TranslateService,
|
||||||
|
private eventsProvider: CoreEventsProvider
|
||||||
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
|
@ -56,7 +59,7 @@ export class CoreBackButtonDirective implements OnInit, OnDestroy {
|
||||||
* Set the trasnlated back button text in iOS.
|
* Set the trasnlated back button text in iOS.
|
||||||
*/
|
*/
|
||||||
protected setTranslatedBackButtonText(): void {
|
protected setTranslatedBackButtonText(): void {
|
||||||
if (this.host && this.platform.is('ios')) {
|
if (this.host && CoreApp.instance.isIOS()) {
|
||||||
this.host.setBackButtonText(this.translate.instant('core.back'));
|
this.host.setBackButtonText(this.translate.instant('core.back'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Directive, Input, AfterViewInit, ElementRef, OnChanges, SimpleChange, Output, EventEmitter } from '@angular/core';
|
import { Directive, Input, AfterViewInit, ElementRef, OnChanges, SimpleChange, Output, EventEmitter } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreApp } from '@providers/app';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
import { CoreFile } from '@providers/file';
|
import { CoreFile } from '@providers/file';
|
||||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||||
|
@ -60,7 +60,6 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
|
||||||
protected sitesProvider: CoreSitesProvider,
|
protected sitesProvider: CoreSitesProvider,
|
||||||
protected domUtils: CoreDomUtilsProvider,
|
protected domUtils: CoreDomUtilsProvider,
|
||||||
protected urlUtils: CoreUrlUtilsProvider,
|
protected urlUtils: CoreUrlUtilsProvider,
|
||||||
protected appProvider: CoreAppProvider,
|
|
||||||
protected utils: CoreUtilsProvider) {
|
protected utils: CoreUtilsProvider) {
|
||||||
|
|
||||||
this.element = element.nativeElement;
|
this.element = element.nativeElement;
|
||||||
|
@ -104,7 +103,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
|
||||||
newSource.setAttribute('src', url);
|
newSource.setAttribute('src', url);
|
||||||
|
|
||||||
if (type) {
|
if (type) {
|
||||||
if (this.platform.is('android') && type == 'video/quicktime') {
|
if (CoreApp.instance.isAndroid() && type == 'video/quicktime') {
|
||||||
// Fix for VideoJS/Chrome bug https://github.com/videojs/video.js/issues/423 .
|
// Fix for VideoJS/Chrome bug https://github.com/videojs/video.js/issues/423 .
|
||||||
newSource.setAttribute('type', 'video/mp4');
|
newSource.setAttribute('type', 'video/mp4');
|
||||||
} else {
|
} else {
|
||||||
|
@ -198,7 +197,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
|
||||||
const track = <TextTrack> event.track;
|
const track = <TextTrack> event.track;
|
||||||
if (track) {
|
if (track) {
|
||||||
track.oncuechange = (): void => {
|
track.oncuechange = (): void => {
|
||||||
const line = this.platform.is('tablet') || this.platform.is('android') ? 90 : 80;
|
const line = this.platform.is('tablet') || CoreApp.instance.isAndroid() ? 90 : 80;
|
||||||
// Position all subtitles to a percentage of video height.
|
// Position all subtitles to a percentage of video height.
|
||||||
Array.from(track.cues).forEach((cue: any) => {
|
Array.from(track.cues).forEach((cue: any) => {
|
||||||
cue.snapToLines = false;
|
cue.snapToLines = false;
|
||||||
|
@ -281,7 +280,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
|
||||||
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.isWifi()) {
|
if (CoreApp.instance.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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { Platform, NavController, Content } from 'ionic-angular';
|
import { Platform, NavController, Content } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||||
import { CoreLoggerProvider } from '@providers/logger';
|
import { CoreLoggerProvider } from '@providers/logger';
|
||||||
|
@ -84,7 +83,6 @@ export class CoreFormatTextDirective implements OnChanges {
|
||||||
protected urlUtils: CoreUrlUtilsProvider,
|
protected urlUtils: CoreUrlUtilsProvider,
|
||||||
protected loggerProvider: CoreLoggerProvider,
|
protected loggerProvider: CoreLoggerProvider,
|
||||||
protected filepoolProvider: CoreFilepoolProvider,
|
protected filepoolProvider: CoreFilepoolProvider,
|
||||||
protected appProvider: CoreAppProvider,
|
|
||||||
protected contentLinksHelper: CoreContentLinksHelperProvider,
|
protected contentLinksHelper: CoreContentLinksHelperProvider,
|
||||||
@Optional() protected navCtrl: NavController,
|
@Optional() protected navCtrl: NavController,
|
||||||
@Optional() protected content: Content, @Optional()
|
@Optional() protected content: Content, @Optional()
|
||||||
|
@ -124,7 +122,7 @@ export class CoreFormatTextDirective implements OnChanges {
|
||||||
protected addExternalContent(element: Element): CoreExternalContentDirective {
|
protected addExternalContent(element: Element): CoreExternalContentDirective {
|
||||||
// Angular 2 doesn't let adding directives dynamically. Create the CoreExternalContentDirective manually.
|
// Angular 2 doesn't let adding directives dynamically. Create the CoreExternalContentDirective manually.
|
||||||
const extContent = new CoreExternalContentDirective(new ElementRef(element), this.loggerProvider, this.filepoolProvider,
|
const extContent = new CoreExternalContentDirective(new ElementRef(element), this.loggerProvider, this.filepoolProvider,
|
||||||
this.platform, this.sitesProvider, this.domUtils, this.urlUtils, this.appProvider, this.utils);
|
this.platform, this.sitesProvider, this.domUtils, this.urlUtils, this.utils);
|
||||||
|
|
||||||
extContent.component = this.component;
|
extContent.component = this.component;
|
||||||
extContent.componentId = this.componentId;
|
extContent.componentId = this.componentId;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { Platform, App, NavController, MenuController } from 'ionic-angular';
|
||||||
import { Keyboard } from '@ionic-native/keyboard';
|
import { Keyboard } from '@ionic-native/keyboard';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import { StatusBar } from '@ionic-native/status-bar';
|
import { StatusBar } from '@ionic-native/status-bar';
|
||||||
|
import { Device } from '@ionic-native/device';
|
||||||
|
|
||||||
import { CoreDbProvider } from './db';
|
import { CoreDbProvider } from './db';
|
||||||
import { CoreLoggerProvider } from './logger';
|
import { CoreLoggerProvider } from './logger';
|
||||||
|
@ -178,6 +179,7 @@ export class CoreAppProvider {
|
||||||
zone: NgZone,
|
zone: NgZone,
|
||||||
private menuCtrl: MenuController,
|
private menuCtrl: MenuController,
|
||||||
private statusBar: StatusBar,
|
private statusBar: StatusBar,
|
||||||
|
private device: Device,
|
||||||
appRef: ApplicationRef) {
|
appRef: ApplicationRef) {
|
||||||
|
|
||||||
this.logger = logger.getInstance('CoreAppProvider');
|
this.logger = logger.getInstance('CoreAppProvider');
|
||||||
|
@ -390,7 +392,7 @@ export class CoreAppProvider {
|
||||||
* @return Whether the app is running in an Android mobile or tablet device.
|
* @return Whether the app is running in an Android mobile or tablet device.
|
||||||
*/
|
*/
|
||||||
isAndroid(): boolean {
|
isAndroid(): boolean {
|
||||||
return this.platform.is('android');
|
return this.isMobile() && this.device.platform.toLowerCase() == 'android';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -410,7 +412,7 @@ export class CoreAppProvider {
|
||||||
* @return Whether the app is running in an iOS mobile or tablet device.
|
* @return Whether the app is running in an iOS mobile or tablet device.
|
||||||
*/
|
*/
|
||||||
isIOS(): boolean {
|
isIOS(): boolean {
|
||||||
return this.platform.is('ios');
|
return this.isMobile() && this.device.platform.toLowerCase() == 'ios';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -568,7 +570,7 @@ export class CoreAppProvider {
|
||||||
*/
|
*/
|
||||||
openKeyboard(): void {
|
openKeyboard(): void {
|
||||||
// Open keyboard is not supported in desktop and in iOS.
|
// Open keyboard is not supported in desktop and in iOS.
|
||||||
if (this.isMobile() && !this.platform.is('ios')) {
|
if (this.isMobile() && !this.isIOS()) {
|
||||||
this.keyboard.show();
|
this.keyboard.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -797,23 +799,23 @@ export class CoreAppProvider {
|
||||||
* Set StatusBar color depending on platform.
|
* Set StatusBar color depending on platform.
|
||||||
*/
|
*/
|
||||||
setStatusBarColor(): void {
|
setStatusBarColor(): void {
|
||||||
if (typeof CoreConfigConstants.statusbarbgios == 'string' && this.platform.is('ios')) {
|
if (typeof CoreConfigConstants.statusbarbgios == 'string' && this.isIOS()) {
|
||||||
// IOS Status bar properties.
|
// IOS Status bar properties.
|
||||||
this.statusBar.overlaysWebView(false);
|
this.statusBar.overlaysWebView(false);
|
||||||
this.statusBar.backgroundColorByHexString(CoreConfigConstants.statusbarbgios);
|
this.statusBar.backgroundColorByHexString(CoreConfigConstants.statusbarbgios);
|
||||||
CoreConfigConstants.statusbarlighttextios ? this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
CoreConfigConstants.statusbarlighttextios ? this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
||||||
} else if (typeof CoreConfigConstants.statusbarbgandroid == 'string' && this.platform.is('android')) {
|
} else if (typeof CoreConfigConstants.statusbarbgandroid == 'string' && this.isAndroid()) {
|
||||||
// Android Status bar properties.
|
// Android Status bar properties.
|
||||||
this.statusBar.backgroundColorByHexString(CoreConfigConstants.statusbarbgandroid);
|
this.statusBar.backgroundColorByHexString(CoreConfigConstants.statusbarbgandroid);
|
||||||
CoreConfigConstants.statusbarlighttextandroid ? this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
CoreConfigConstants.statusbarlighttextandroid ? this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
||||||
} else if (typeof CoreConfigConstants.statusbarbg == 'string') {
|
} else if (typeof CoreConfigConstants.statusbarbg == 'string') {
|
||||||
// Generic Status bar properties.
|
// Generic Status bar properties.
|
||||||
this.platform.is('ios') && this.statusBar.overlaysWebView(false);
|
this.isIOS() && this.statusBar.overlaysWebView(false);
|
||||||
this.statusBar.backgroundColorByHexString(CoreConfigConstants.statusbarbg);
|
this.statusBar.backgroundColorByHexString(CoreConfigConstants.statusbarbg);
|
||||||
CoreConfigConstants.statusbarlighttext ? this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
CoreConfigConstants.statusbarlighttext ? this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
||||||
} else {
|
} else {
|
||||||
// Default Status bar properties.
|
// Default Status bar properties.
|
||||||
this.platform.is('android') ? this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
this.isAndroid() ? this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,11 +824,11 @@ export class CoreAppProvider {
|
||||||
*/
|
*/
|
||||||
resetStatusBarColor(): void {
|
resetStatusBarColor(): void {
|
||||||
if (typeof CoreConfigConstants.statusbarbgremotetheme == 'string' &&
|
if (typeof CoreConfigConstants.statusbarbgremotetheme == 'string' &&
|
||||||
((typeof CoreConfigConstants.statusbarbgios == 'string' && this.platform.is('ios')) ||
|
((typeof CoreConfigConstants.statusbarbgios == 'string' && this.isIOS()) ||
|
||||||
(typeof CoreConfigConstants.statusbarbgandroid == 'string' && this.platform.is('android')) ||
|
(typeof CoreConfigConstants.statusbarbgandroid == 'string' && this.isAndroid()) ||
|
||||||
typeof CoreConfigConstants.statusbarbg == 'string')) {
|
typeof CoreConfigConstants.statusbarbg == 'string')) {
|
||||||
// If the status bar has been overriden and there's a fallback color for remote themes, use it now.
|
// If the status bar has been overriden and there's a fallback color for remote themes, use it now.
|
||||||
this.platform.is('ios') && this.statusBar.overlaysWebView(false);
|
this.isIOS() && this.statusBar.overlaysWebView(false);
|
||||||
this.statusBar.backgroundColorByHexString(CoreConfigConstants.statusbarbgremotetheme);
|
this.statusBar.backgroundColorByHexString(CoreConfigConstants.statusbarbgremotetheme);
|
||||||
CoreConfigConstants.statusbarlighttextremotetheme ?
|
CoreConfigConstants.statusbarlighttextremotetheme ?
|
||||||
this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
this.statusBar.styleLightContent() : this.statusBar.styleDefault();
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
import { File, FileEntry, DirectoryEntry, Entry, Metadata } from '@ionic-native/file';
|
import { File, FileEntry, DirectoryEntry, Entry, Metadata } from '@ionic-native/file';
|
||||||
|
import { CoreApp, CoreAppProvider } from './app';
|
||||||
import { CoreAppProvider } from './app';
|
|
||||||
import { CoreLoggerProvider } from './logger';
|
import { CoreLoggerProvider } from './logger';
|
||||||
import { CoreMimetypeUtilsProvider } from './utils/mimetype';
|
import { CoreMimetypeUtilsProvider } from './utils/mimetype';
|
||||||
import { CoreTextUtilsProvider } from './utils/text';
|
import { CoreTextUtilsProvider } from './utils/text';
|
||||||
|
@ -73,16 +72,16 @@ export class CoreFileProvider {
|
||||||
protected isHTMLAPI = false;
|
protected isHTMLAPI = false;
|
||||||
|
|
||||||
constructor(logger: CoreLoggerProvider,
|
constructor(logger: CoreLoggerProvider,
|
||||||
|
appProvider: CoreAppProvider,
|
||||||
protected platform: Platform,
|
protected platform: Platform,
|
||||||
protected file: File,
|
protected file: File,
|
||||||
protected appProvider: CoreAppProvider,
|
|
||||||
protected textUtils: CoreTextUtilsProvider,
|
protected textUtils: CoreTextUtilsProvider,
|
||||||
protected zip: Zip,
|
protected zip: Zip,
|
||||||
protected mimeUtils: CoreMimetypeUtilsProvider) {
|
protected mimeUtils: CoreMimetypeUtilsProvider) {
|
||||||
|
|
||||||
this.logger = logger.getInstance('CoreFileProvider');
|
this.logger = logger.getInstance('CoreFileProvider');
|
||||||
|
|
||||||
if (platform.is('android') && !Object.getOwnPropertyDescriptor(FileReader.prototype, 'onloadend')) {
|
if (appProvider.isAndroid() && !Object.getOwnPropertyDescriptor(FileReader.prototype, 'onloadend')) {
|
||||||
// Cordova File plugin creates some getters and setter for FileReader, but Ionic's polyfills override them in Android.
|
// Cordova File plugin creates some getters and setter for FileReader, but Ionic's polyfills override them in Android.
|
||||||
// Create the getters and setters again. This code comes from FileReader.js in cordova-plugin-file.
|
// Create the getters and setters again. This code comes from FileReader.js in cordova-plugin-file.
|
||||||
this.defineGetterSetter(FileReader.prototype, 'readyState', function(): any {
|
this.defineGetterSetter(FileReader.prototype, 'readyState', function(): any {
|
||||||
|
@ -178,9 +177,9 @@ export class CoreFileProvider {
|
||||||
|
|
||||||
return this.platform.ready().then(() => {
|
return this.platform.ready().then(() => {
|
||||||
|
|
||||||
if (this.platform.is('android')) {
|
if (CoreApp.instance.isAndroid()) {
|
||||||
this.basePath = this.file.externalApplicationStorageDirectory || this.basePath;
|
this.basePath = this.file.externalApplicationStorageDirectory || this.basePath;
|
||||||
} else if (this.platform.is('ios')) {
|
} else if (CoreApp.instance.isIOS()) {
|
||||||
this.basePath = this.file.documentsDirectory || this.basePath;
|
this.basePath = this.file.documentsDirectory || this.basePath;
|
||||||
} else if (!this.isAvailable() || this.basePath === '') {
|
} else if (!this.isAvailable() || this.basePath === '') {
|
||||||
this.logger.error('Error getting device OS.');
|
this.logger.error('Error getting device OS.');
|
||||||
|
@ -475,7 +474,7 @@ export class CoreFileProvider {
|
||||||
*/
|
*/
|
||||||
calculateFreeSpace(): Promise<number> {
|
calculateFreeSpace(): Promise<number> {
|
||||||
return this.file.getFreeDiskSpace().then((size) => {
|
return this.file.getFreeDiskSpace().then((size) => {
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
// In iOS the size is in bytes.
|
// In iOS the size is in bytes.
|
||||||
return Number(size);
|
return Number(size);
|
||||||
}
|
}
|
||||||
|
@ -622,7 +621,7 @@ export class CoreFileProvider {
|
||||||
|
|
||||||
// Create file (and parent folders) to prevent errors.
|
// Create file (and parent folders) to prevent errors.
|
||||||
return this.createFile(path).then((fileEntry) => {
|
return this.createFile(path).then((fileEntry) => {
|
||||||
if (this.isHTMLAPI && !this.appProvider.isDesktop() &&
|
if (this.isHTMLAPI && !CoreApp.instance.isDesktop() &&
|
||||||
(typeof data == 'string' || data.toString() == '[object ArrayBuffer]')) {
|
(typeof data == 'string' || data.toString() == '[object ArrayBuffer]')) {
|
||||||
// We need to write Blobs.
|
// We need to write Blobs.
|
||||||
const type = this.mimeUtils.getMimeType(this.mimeUtils.getFileExtension(path));
|
const type = this.mimeUtils.getMimeType(this.mimeUtils.getFileExtension(path));
|
||||||
|
@ -745,7 +744,7 @@ export class CoreFileProvider {
|
||||||
*/
|
*/
|
||||||
getBasePathToDownload(): Promise<string> {
|
getBasePathToDownload(): Promise<string> {
|
||||||
return this.init().then(() => {
|
return this.init().then(() => {
|
||||||
if (this.platform.is('ios')) {
|
if (CoreApp.instance.isIOS()) {
|
||||||
// In iOS we want the internal URL (cdvfile://localhost/persistent/...).
|
// In iOS we want the internal URL (cdvfile://localhost/persistent/...).
|
||||||
return this.file.resolveDirectoryUrl(this.basePath).then((dirEntry) => {
|
return this.file.resolveDirectoryUrl(this.basePath).then((dirEntry) => {
|
||||||
return dirEntry.toInternalURL();
|
return dirEntry.toInternalURL();
|
||||||
|
@ -1252,7 +1251,7 @@ export class CoreFileProvider {
|
||||||
* @return Converted src.
|
* @return Converted src.
|
||||||
*/
|
*/
|
||||||
convertFileSrc(src: string): string {
|
convertFileSrc(src: string): string {
|
||||||
return this.appProvider.isIOS() ? (<any> window).Ionic.WebView.convertFileSrc(src) : src;
|
return CoreApp.instance.isIOS() ? (<any> window).Ionic.WebView.convertFileSrc(src) : src;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1262,7 +1261,7 @@ export class CoreFileProvider {
|
||||||
* @return Unconverted src.
|
* @return Unconverted src.
|
||||||
*/
|
*/
|
||||||
unconvertFileSrc(src: string): string {
|
unconvertFileSrc(src: string): string {
|
||||||
if (!this.appProvider.isIOS()) {
|
if (!CoreApp.instance.isIOS()) {
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { Platform, Alert, AlertController } from 'ionic-angular';
|
||||||
import { LocalNotifications, ILocalNotification } from '@ionic-native/local-notifications';
|
import { LocalNotifications, ILocalNotification } from '@ionic-native/local-notifications';
|
||||||
import { Push } from '@ionic-native/push';
|
import { Push } from '@ionic-native/push';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider, CoreAppSchema } from './app';
|
import { CoreApp, CoreAppProvider, CoreAppSchema } from './app';
|
||||||
import { CoreConfigProvider } from './config';
|
import { CoreConfigProvider } from './config';
|
||||||
import { CoreEventsProvider } from './events';
|
import { CoreEventsProvider } from './events';
|
||||||
import { CoreLoggerProvider } from './logger';
|
import { CoreLoggerProvider } from './logger';
|
||||||
|
@ -115,10 +115,19 @@ export class CoreLocalNotificationsProvider {
|
||||||
protected updateSubscription: Subscription;
|
protected updateSubscription: Subscription;
|
||||||
protected queueRunner: CoreQueueRunner; // Queue to decrease the number of concurrent calls to the plugin (see MOBILE-3477).
|
protected queueRunner: CoreQueueRunner; // Queue to decrease the number of concurrent calls to the plugin (see MOBILE-3477).
|
||||||
|
|
||||||
constructor(logger: CoreLoggerProvider, private localNotifications: LocalNotifications, private platform: Platform,
|
constructor(
|
||||||
private appProvider: CoreAppProvider, private utils: CoreUtilsProvider, private configProvider: CoreConfigProvider,
|
logger: CoreLoggerProvider,
|
||||||
private textUtils: CoreTextUtilsProvider, private translate: TranslateService, private alertCtrl: AlertController,
|
private localNotifications: LocalNotifications,
|
||||||
eventsProvider: CoreEventsProvider, private push: Push, private zone: NgZone) {
|
private platform: Platform,
|
||||||
|
private utils: CoreUtilsProvider,
|
||||||
|
private configProvider: CoreConfigProvider,
|
||||||
|
private textUtils: CoreTextUtilsProvider,
|
||||||
|
private translate: TranslateService,
|
||||||
|
private alertCtrl: AlertController,
|
||||||
|
eventsProvider: CoreEventsProvider,
|
||||||
|
appProvider: CoreAppProvider,
|
||||||
|
private push: Push,
|
||||||
|
private zone: NgZone) {
|
||||||
|
|
||||||
this.logger = logger.getInstance('CoreLocalNotificationsProvider');
|
this.logger = logger.getInstance('CoreLocalNotificationsProvider');
|
||||||
this.queueRunner = new CoreQueueRunner(10);
|
this.queueRunner = new CoreQueueRunner(10);
|
||||||
|
@ -228,7 +237,7 @@ export class CoreLocalNotificationsProvider {
|
||||||
*/
|
*/
|
||||||
canDisableSound(): boolean {
|
canDisableSound(): boolean {
|
||||||
// Only allow disabling sound in Android 7 or lower. In iOS and Android 8+ it can easily be done with system settings.
|
// Only allow disabling sound in Android 7 or lower. In iOS and Android 8+ it can easily be done with system settings.
|
||||||
return this.isAvailable() && !this.appProvider.isDesktop() && this.platform.is('android') &&
|
return this.isAvailable() && !CoreApp.instance.isDesktop() && CoreApp.instance.isAndroid() &&
|
||||||
this.platform.version().major < 8;
|
this.platform.version().major < 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +247,7 @@ export class CoreLocalNotificationsProvider {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected createDefaultChannel(): Promise<any> {
|
protected createDefaultChannel(): Promise<any> {
|
||||||
if (!this.platform.is('android')) {
|
if (!CoreApp.instance.isAndroid()) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +377,7 @@ export class CoreLocalNotificationsProvider {
|
||||||
isAvailable(): boolean {
|
isAvailable(): boolean {
|
||||||
const win = <any> window;
|
const win = <any> window;
|
||||||
|
|
||||||
return this.appProvider.isDesktop() || !!(win.cordova && win.cordova.plugins && win.cordova.plugins.notification &&
|
return CoreApp.instance.isDesktop() || !!(win.cordova && win.cordova.plugins && win.cordova.plugins.notification &&
|
||||||
win.cordova.plugins.notification.local);
|
win.cordova.plugins.notification.local);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +618,7 @@ export class CoreLocalNotificationsProvider {
|
||||||
notification.data.component = component;
|
notification.data.component = component;
|
||||||
notification.data.siteId = siteId;
|
notification.data.siteId = siteId;
|
||||||
|
|
||||||
if (this.platform.is('android')) {
|
if (CoreApp.instance.isAndroid()) {
|
||||||
notification.icon = notification.icon || 'res://icon';
|
notification.icon = notification.icon || 'res://icon';
|
||||||
notification.smallIcon = notification.smallIcon || 'res://smallicon';
|
notification.smallIcon = notification.smallIcon || 'res://smallicon';
|
||||||
notification.color = notification.color || CoreConfigConstants.notificoncolor;
|
notification.color = notification.color || CoreConfigConstants.notificoncolor;
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
|
|
||||||
import { Injectable, SimpleChange, ElementRef } from '@angular/core';
|
import { Injectable, SimpleChange, ElementRef } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
LoadingController, Loading, ToastController, Toast, AlertController, Alert, Platform, Content, PopoverController,
|
LoadingController, Loading, ToastController, Toast, AlertController, Alert, Content, PopoverController,
|
||||||
ModalController, AlertButton, AlertOptions
|
ModalController, AlertButton, AlertOptions
|
||||||
} from 'ionic-angular';
|
} from 'ionic-angular';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreTextUtilsProvider } from './text';
|
import { CoreTextUtilsProvider } from './text';
|
||||||
import { CoreAppProvider } from '../app';
|
import { CoreApp } from '../app';
|
||||||
import { CoreConfigProvider } from '../config';
|
import { CoreConfigProvider } from '../config';
|
||||||
import { CoreEventsProvider } from '../events';
|
import { CoreEventsProvider } from '../events';
|
||||||
import { CoreLoggerProvider } from '../logger';
|
import { CoreLoggerProvider } from '../logger';
|
||||||
|
@ -71,8 +71,6 @@ export class CoreDomUtilsProvider {
|
||||||
protected toastCtrl: ToastController,
|
protected toastCtrl: ToastController,
|
||||||
protected alertCtrl: AlertController,
|
protected alertCtrl: AlertController,
|
||||||
protected textUtils: CoreTextUtilsProvider,
|
protected textUtils: CoreTextUtilsProvider,
|
||||||
protected appProvider: CoreAppProvider,
|
|
||||||
protected platform: Platform,
|
|
||||||
protected configProvider: CoreConfigProvider,
|
protected configProvider: CoreConfigProvider,
|
||||||
protected urlUtils: CoreUrlUtilsProvider,
|
protected urlUtils: CoreUrlUtilsProvider,
|
||||||
protected modalCtrl: ModalController,
|
protected modalCtrl: ModalController,
|
||||||
|
@ -147,12 +145,12 @@ export class CoreDomUtilsProvider {
|
||||||
const readableSize = this.textUtils.bytesToSize(size.size, 2);
|
const readableSize = this.textUtils.bytesToSize(size.size, 2);
|
||||||
|
|
||||||
const getAvailableBytes = new Promise((resolve): void => {
|
const getAvailableBytes = new Promise((resolve): void => {
|
||||||
if (this.appProvider.isDesktop()) {
|
if (CoreApp.instance.isDesktop()) {
|
||||||
// Free space calculation is not supported on desktop.
|
// Free space calculation is not supported on desktop.
|
||||||
resolve(null);
|
resolve(null);
|
||||||
} else {
|
} else {
|
||||||
this.fileProvider.calculateFreeSpace().then((availableBytes) => {
|
this.fileProvider.calculateFreeSpace().then((availableBytes) => {
|
||||||
if (this.platform.is('android')) {
|
if (CoreApp.instance.isAndroid()) {
|
||||||
return availableBytes;
|
return availableBytes;
|
||||||
} else {
|
} else {
|
||||||
// Space calculation is not accurate on iOS, but it gets more accurate when space is lower.
|
// Space calculation is not accurate on iOS, but it gets more accurate when space is lower.
|
||||||
|
@ -174,7 +172,7 @@ export class CoreDomUtilsProvider {
|
||||||
return '';
|
return '';
|
||||||
} else {
|
} else {
|
||||||
const availableSize = this.textUtils.bytesToSize(availableBytes, 2);
|
const availableSize = this.textUtils.bytesToSize(availableBytes, 2);
|
||||||
if (this.platform.is('android') && size.size > availableBytes - CoreConstants.MINIMUM_FREE_SPACE) {
|
if (CoreApp.instance.isAndroid() && size.size > availableBytes - CoreConstants.MINIMUM_FREE_SPACE) {
|
||||||
return Promise.reject(this.translate.instant('core.course.insufficientavailablespace', { size: readableSize }));
|
return Promise.reject(this.translate.instant('core.course.insufficientavailablespace', { size: readableSize }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +185,7 @@ export class CoreDomUtilsProvider {
|
||||||
limitedThreshold = typeof limitedThreshold == 'undefined' ? CoreConstants.DOWNLOAD_THRESHOLD : limitedThreshold;
|
limitedThreshold = typeof limitedThreshold == 'undefined' ? CoreConstants.DOWNLOAD_THRESHOLD : limitedThreshold;
|
||||||
|
|
||||||
let wifiPrefix = '';
|
let wifiPrefix = '';
|
||||||
if (this.appProvider.isNetworkAccessLimited()) {
|
if (CoreApp.instance.isNetworkAccessLimited()) {
|
||||||
wifiPrefix = this.translate.instant('core.course.confirmlimiteddownload');
|
wifiPrefix = this.translate.instant('core.course.confirmlimiteddownload');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +200,7 @@ export class CoreDomUtilsProvider {
|
||||||
return this.showConfirm(wifiPrefix + this.translate.instant('core.course.confirmpartialdownloadsize',
|
return this.showConfirm(wifiPrefix + this.translate.instant('core.course.confirmpartialdownloadsize',
|
||||||
{ size: readableSize, availableSpace: availableSpace }));
|
{ size: readableSize, availableSpace: availableSpace }));
|
||||||
} else if (alwaysConfirm || size.size >= wifiThreshold ||
|
} else if (alwaysConfirm || size.size >= wifiThreshold ||
|
||||||
(this.appProvider.isNetworkAccessLimited() && size.size >= limitedThreshold)) {
|
(CoreApp.instance.isNetworkAccessLimited() && size.size >= limitedThreshold)) {
|
||||||
message = message || (size.size === 0 ? 'core.course.confirmdownloadzerosize' : 'core.course.confirmdownload');
|
message = message || (size.size === 0 ? 'core.course.confirmdownloadzerosize' : 'core.course.confirmdownload');
|
||||||
|
|
||||||
return this.showConfirm(wifiPrefix + this.translate.instant(message,
|
return this.showConfirm(wifiPrefix + this.translate.instant(message,
|
||||||
|
@ -377,9 +375,9 @@ export class CoreDomUtilsProvider {
|
||||||
focusElement(el: HTMLElement): void {
|
focusElement(el: HTMLElement): void {
|
||||||
if (el && el.focus) {
|
if (el && el.focus) {
|
||||||
el.focus();
|
el.focus();
|
||||||
if (this.platform.is('android') && this.supportsInputKeyboard(el)) {
|
if (CoreApp.instance.isAndroid() && this.supportsInputKeyboard(el)) {
|
||||||
// On some Android versions the keyboard doesn't open automatically.
|
// On some Android versions the keyboard doesn't open automatically.
|
||||||
this.appProvider.openKeyboard();
|
CoreApp.instance.openKeyboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1562,7 +1560,7 @@ export class CoreDomUtilsProvider {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
// We cannot use CoreDomUtilsProvider.openInBrowser due to circular dependencies.
|
// We cannot use CoreDomUtilsProvider.openInBrowser due to circular dependencies.
|
||||||
if (this.appProvider.isDesktop()) {
|
if (CoreApp.instance.isDesktop()) {
|
||||||
// It's a desktop app, use Electron shell library to open the browser.
|
// It's a desktop app, use Electron shell library to open the browser.
|
||||||
const shell = require('electron').shell;
|
const shell = require('electron').shell;
|
||||||
if (!shell.openExternal(href)) {
|
if (!shell.openExternal(href)) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable, NgZone } from '@angular/core';
|
||||||
import { Config, Platform, NavController } from 'ionic-angular';
|
import { Config, Platform, NavController } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Network } from '@ionic-native/network';
|
import { Network } from '@ionic-native/network';
|
||||||
import { CoreAppProvider } from '../app';
|
import { CoreApp } from '../app';
|
||||||
import { CoreFileProvider } from '../file';
|
import { CoreFileProvider } from '../file';
|
||||||
import { CoreLoggerProvider } from '../logger';
|
import { CoreLoggerProvider } from '../logger';
|
||||||
import { CoreSitesProvider } from '../sites';
|
import { CoreSitesProvider } from '../sites';
|
||||||
|
@ -39,16 +39,24 @@ export class CoreIframeUtilsProvider {
|
||||||
|
|
||||||
protected logger;
|
protected logger;
|
||||||
|
|
||||||
constructor(logger: CoreLoggerProvider, private fileProvider: CoreFileProvider, private sitesProvider: CoreSitesProvider,
|
constructor(logger: CoreLoggerProvider,
|
||||||
private urlUtils: CoreUrlUtilsProvider, private textUtils: CoreTextUtilsProvider, private utils: CoreUtilsProvider,
|
private fileProvider: CoreFileProvider,
|
||||||
private domUtils: CoreDomUtilsProvider, private platform: Platform, private appProvider: CoreAppProvider,
|
private sitesProvider: CoreSitesProvider,
|
||||||
private translate: TranslateService, private network: Network, private zone: NgZone, private config: Config,
|
private urlUtils: CoreUrlUtilsProvider,
|
||||||
private contentLinksHelper: CoreContentLinksHelperProvider) {
|
private textUtils: CoreTextUtilsProvider,
|
||||||
|
private utils: CoreUtilsProvider,
|
||||||
|
private domUtils: CoreDomUtilsProvider,
|
||||||
|
platform: Platform,
|
||||||
|
private translate: TranslateService,
|
||||||
|
private network: Network, private zone: NgZone,
|
||||||
|
private config: Config,
|
||||||
|
private contentLinksHelper: CoreContentLinksHelperProvider
|
||||||
|
) {
|
||||||
this.logger = logger.getInstance('CoreUtilsProvider');
|
this.logger = logger.getInstance('CoreUtilsProvider');
|
||||||
|
|
||||||
const win = <WKUserScriptWindow> window;
|
const win = <WKUserScriptWindow> window;
|
||||||
|
|
||||||
if (platform.is('ios') && win.WKUserScript) {
|
if (CoreApp.instance.isIOS() && win.WKUserScript) {
|
||||||
platform.ready().then(() => {
|
platform.ready().then(() => {
|
||||||
// Inject code to the iframes because we cannot access the online ones.
|
// Inject code to the iframes because we cannot access the online ones.
|
||||||
const wwwPath = fileProvider.getWWWAbsolutePath();
|
const wwwPath = fileProvider.getWWWAbsolutePath();
|
||||||
|
@ -78,7 +86,7 @@ export class CoreIframeUtilsProvider {
|
||||||
checkOnlineFrameInOffline(element: any, isSubframe?: boolean): boolean {
|
checkOnlineFrameInOffline(element: any, isSubframe?: boolean): boolean {
|
||||||
const src = element.src || element.data;
|
const src = element.src || element.data;
|
||||||
|
|
||||||
if (src && src != 'about:blank' && !this.urlUtils.isLocalFileUrl(src) && !this.appProvider.isOnline()) {
|
if (src && src != 'about:blank' && !this.urlUtils.isLocalFileUrl(src) && !CoreApp.instance.isOnline()) {
|
||||||
if (element.classList.contains('core-iframe-offline-disabled')) {
|
if (element.classList.contains('core-iframe-offline-disabled')) {
|
||||||
// Iframe already hidden, stop.
|
// Iframe already hidden, stop.
|
||||||
return true;
|
return true;
|
||||||
|
@ -444,7 +452,7 @@ export class CoreIframeUtilsProvider {
|
||||||
this.utils.openFile(link.href).catch((error) => {
|
this.utils.openFile(link.href).catch((error) => {
|
||||||
this.domUtils.showErrorModal(error);
|
this.domUtils.showErrorModal(error);
|
||||||
});
|
});
|
||||||
} else if (this.platform.is('ios') && (!link.target || link.target == '_self') && element) {
|
} else if (CoreApp.instance.isIOS() && (!link.target || link.target == '_self') && element) {
|
||||||
// In cordova ios 4.1.0 links inside iframes stopped working. We'll manually treat them.
|
// In cordova ios 4.1.0 links inside iframes stopped working. We'll manually treat them.
|
||||||
event && event.preventDefault();
|
event && event.preventDefault();
|
||||||
if (element.tagName.toLowerCase() == 'object') {
|
if (element.tagName.toLowerCase() == 'object') {
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
||||||
import { ModalController, Platform } from 'ionic-angular';
|
import { ModalController } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreLangProvider } from '../lang';
|
import { CoreLangProvider } from '../lang';
|
||||||
import { makeSingleton } from '@singletons/core.singletons';
|
import { makeSingleton } from '@singletons/core.singletons';
|
||||||
|
import { CoreApp } from '../app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Different type of errors the app can treat.
|
* Different type of errors the app can treat.
|
||||||
|
@ -84,8 +85,12 @@ export class CoreTextUtilsProvider {
|
||||||
|
|
||||||
protected template = document.createElement('template'); // A template element to convert HTML to element.
|
protected template = document.createElement('template'); // A template element to convert HTML to element.
|
||||||
|
|
||||||
constructor(private translate: TranslateService, private langProvider: CoreLangProvider, private modalCtrl: ModalController,
|
constructor(
|
||||||
private sanitizer: DomSanitizer, private platform: Platform) { }
|
private translate: TranslateService,
|
||||||
|
private langProvider: CoreLangProvider,
|
||||||
|
private modalCtrl: ModalController,
|
||||||
|
private sanitizer: DomSanitizer
|
||||||
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add ending slash from a path or URL.
|
* Add ending slash from a path or URL.
|
||||||
|
@ -139,7 +144,7 @@ export class CoreTextUtilsProvider {
|
||||||
* @return URL to view the address.
|
* @return URL to view the address.
|
||||||
*/
|
*/
|
||||||
buildAddressURL(address: string): SafeUrl {
|
buildAddressURL(address: string): SafeUrl {
|
||||||
return this.sanitizer.bypassSecurityTrustUrl((this.platform.is('android') ? 'geo:0,0?q=' : 'http://maps.google.com?q=') +
|
return this.sanitizer.bypassSecurityTrustUrl((CoreApp.instance.isAndroid() ? 'geo:0,0?q=' : 'http://maps.google.com?q=') +
|
||||||
encodeURIComponent(address));
|
encodeURIComponent(address));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { Clipboard } from '@ionic-native/clipboard';
|
||||||
import { FileOpener } from '@ionic-native/file-opener';
|
import { FileOpener } from '@ionic-native/file-opener';
|
||||||
import { WebIntent } from '@ionic-native/web-intent';
|
import { WebIntent } from '@ionic-native/web-intent';
|
||||||
import { QRScanner } from '@ionic-native/qr-scanner';
|
import { QRScanner } from '@ionic-native/qr-scanner';
|
||||||
import { CoreAppProvider } from '../app';
|
import { CoreApp } from '../app';
|
||||||
import { CoreDomUtilsProvider } from './dom';
|
import { CoreDomUtilsProvider } from './dom';
|
||||||
import { CoreMimetypeUtilsProvider } from './mimetype';
|
import { CoreMimetypeUtilsProvider } from './mimetype';
|
||||||
import { CoreTextUtilsProvider } from './text';
|
import { CoreTextUtilsProvider } from './text';
|
||||||
|
@ -68,7 +68,6 @@ export class CoreUtilsProvider {
|
||||||
protected qrScanData: {deferred: PromiseDefer, observable: Subscription};
|
protected qrScanData: {deferred: PromiseDefer, observable: Subscription};
|
||||||
|
|
||||||
constructor(protected iab: InAppBrowser,
|
constructor(protected iab: InAppBrowser,
|
||||||
protected appProvider: CoreAppProvider,
|
|
||||||
protected clipboard: Clipboard,
|
protected clipboard: Clipboard,
|
||||||
protected domUtils: CoreDomUtilsProvider,
|
protected domUtils: CoreDomUtilsProvider,
|
||||||
logger: CoreLoggerProvider,
|
logger: CoreLoggerProvider,
|
||||||
|
@ -285,7 +284,7 @@ export class CoreUtilsProvider {
|
||||||
closeInAppBrowser(closeAll?: boolean): void {
|
closeInAppBrowser(closeAll?: boolean): void {
|
||||||
if (this.iabInstance) {
|
if (this.iabInstance) {
|
||||||
this.iabInstance.close();
|
this.iabInstance.close();
|
||||||
if (closeAll && this.appProvider.isDesktop()) {
|
if (closeAll && CoreApp.instance.isDesktop()) {
|
||||||
require('electron').ipcRenderer.send('closeSecondaryWindows');
|
require('electron').ipcRenderer.send('closeSecondaryWindows');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -904,7 +903,7 @@ export class CoreUtilsProvider {
|
||||||
const extension = this.mimetypeUtils.getFileExtension(path);
|
const extension = this.mimetypeUtils.getFileExtension(path);
|
||||||
const mimetype = this.mimetypeUtils.getMimeType(extension);
|
const mimetype = this.mimetypeUtils.getMimeType(extension);
|
||||||
|
|
||||||
if (mimetype == 'text/html' && this.platform.is('android')) {
|
if (mimetype == 'text/html' && CoreApp.instance.isAndroid()) {
|
||||||
// Open HTML local files in InAppBrowser, in system browser some embedded files aren't loaded.
|
// Open HTML local files in InAppBrowser, in system browser some embedded files aren't loaded.
|
||||||
this.openInApp(path);
|
this.openInApp(path);
|
||||||
|
|
||||||
|
@ -959,7 +958,7 @@ export class CoreUtilsProvider {
|
||||||
options.allowInlineMediaPlayback = 'yes'; // Allow playing inline videos in iOS.
|
options.allowInlineMediaPlayback = 'yes'; // Allow playing inline videos in iOS.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.location && this.platform.is('ios') && url.indexOf('file://') === 0) {
|
if (!options.location && CoreApp.instance.isIOS() && url.indexOf('file://') === 0) {
|
||||||
// The URL uses file protocol, don't show it on iOS.
|
// The URL uses file protocol, don't show it on iOS.
|
||||||
// In Android we keep it because otherwise we lose the whole toolbar.
|
// In Android we keep it because otherwise we lose the whole toolbar.
|
||||||
options.location = 'no';
|
options.location = 'no';
|
||||||
|
@ -967,7 +966,7 @@ export class CoreUtilsProvider {
|
||||||
|
|
||||||
this.iabInstance = this.iab.create(url, '_blank', options);
|
this.iabInstance = this.iab.create(url, '_blank', options);
|
||||||
|
|
||||||
if (this.appProvider.isDesktop() || this.appProvider.isMobile()) {
|
if (CoreApp.instance.isDesktop() || CoreApp.instance.isMobile()) {
|
||||||
let loadStopSubscription;
|
let loadStopSubscription;
|
||||||
const loadStartUrls = [];
|
const loadStartUrls = [];
|
||||||
|
|
||||||
|
@ -985,7 +984,7 @@ export class CoreUtilsProvider {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.platform.is('android')) {
|
if (CoreApp.instance.isAndroid()) {
|
||||||
// Load stop is needed with InAppBrowser v3. Custom URL schemes no longer trigger load start, simulate it.
|
// Load stop is needed with InAppBrowser v3. Custom URL schemes no longer trigger load start, simulate it.
|
||||||
loadStopSubscription = this.iabInstance.on('loadstop').subscribe((event) => {
|
loadStopSubscription = this.iabInstance.on('loadstop').subscribe((event) => {
|
||||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
|
@ -1019,7 +1018,7 @@ export class CoreUtilsProvider {
|
||||||
* @param url The URL to open.
|
* @param url The URL to open.
|
||||||
*/
|
*/
|
||||||
openInBrowser(url: string): void {
|
openInBrowser(url: string): void {
|
||||||
if (this.appProvider.isDesktop()) {
|
if (CoreApp.instance.isDesktop()) {
|
||||||
// It's a desktop app, use Electron shell library to open the browser.
|
// It's a desktop app, use Electron shell library to open the browser.
|
||||||
const shell = require('electron').shell;
|
const shell = require('electron').shell;
|
||||||
if (!shell.openExternal(url)) {
|
if (!shell.openExternal(url)) {
|
||||||
|
@ -1039,7 +1038,7 @@ export class CoreUtilsProvider {
|
||||||
* @return Promise resolved when opened.
|
* @return Promise resolved when opened.
|
||||||
*/
|
*/
|
||||||
openOnlineFile(url: string): Promise<void> {
|
openOnlineFile(url: string): Promise<void> {
|
||||||
if (this.platform.is('android')) {
|
if (CoreApp.instance.isAndroid()) {
|
||||||
// In Android we need the mimetype to open it.
|
// In Android we need the mimetype to open it.
|
||||||
return this.getMimeTypeFromUrl(url).catch(() => {
|
return this.getMimeTypeFromUrl(url).catch(() => {
|
||||||
// Error getting mimetype, return undefined.
|
// Error getting mimetype, return undefined.
|
||||||
|
@ -1471,7 +1470,7 @@ export class CoreUtilsProvider {
|
||||||
* @return Whether the app can scan QR codes.
|
* @return Whether the app can scan QR codes.
|
||||||
*/
|
*/
|
||||||
canScanQR(): boolean {
|
canScanQR(): boolean {
|
||||||
return this.appProvider.isMobile();
|
return CoreApp.instance.isMobile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1500,7 +1499,7 @@ export class CoreUtilsProvider {
|
||||||
* @return Promise resolved with the QR string, rejected if error or cancelled.
|
* @return Promise resolved with the QR string, rejected if error or cancelled.
|
||||||
*/
|
*/
|
||||||
startScanQR(): Promise<string> {
|
startScanQR(): Promise<string> {
|
||||||
if (!this.appProvider.isMobile()) {
|
if (!CoreApp.instance.isMobile()) {
|
||||||
return Promise.reject('QRScanner isn\'t available in desktop apps.');
|
return Promise.reject('QRScanner isn\'t available in desktop apps.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue