MOBILE-3532 utils: Wrap is('ios') calls
parent
6281ce13fc
commit
4ba6f0b6fa
|
@ -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';
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -236,7 +236,7 @@ export class CoreEditorRichTextEditorComponent implements AfterContentInit, OnDe
|
||||||
if (this.platform.is('android')) {
|
if (this.platform.is('android')) {
|
||||||
// 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);
|
||||||
|
|
||||||
|
|
|
@ -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 { 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 +26,11 @@ 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 platform: Platform,
|
||||||
|
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 +38,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,7 +48,7 @@ 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 (this.platform.is('android')) {
|
||||||
|
|
|
@ -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, CoreAppProvider } 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';
|
||||||
|
@ -45,7 +45,7 @@ export class CoreFileUploaderFileHandler implements CoreFileUploaderHandler {
|
||||||
*/
|
*/
|
||||||
isEnabled(): boolean | Promise<boolean> {
|
isEnabled(): boolean | Promise<boolean> {
|
||||||
return this.platform.is('android') || !this.appProvider.isMobile() ||
|
return this.platform.is('android') || !this.appProvider.isMobile() ||
|
||||||
(this.platform.is('ios') && this.platform.version().major >= 9);
|
(CoreApp.instance.isIOS() && this.platform.version().major >= 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
@ -183,7 +184,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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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, 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';
|
||||||
|
@ -45,7 +45,7 @@ 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 (this.platform.is('android')) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { Platform, AlertController, NavController, NavOptions } from 'ionic-angular';
|
import { Platform, 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, CoreAppProvider, 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';
|
||||||
|
@ -1272,7 +1272,7 @@ export class CoreLoginHelperProvider {
|
||||||
});
|
});
|
||||||
|
|
||||||
alert.present().then(() => {
|
alert.present().then(() => {
|
||||||
const isDevice = this.platform.is('android') || this.platform.is('ios');
|
const isDevice = this.platform.is('android') || 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');
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,7 +568,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,7 +797,7 @@ 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);
|
||||||
|
@ -808,7 +808,7 @@ export class CoreAppProvider {
|
||||||
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 {
|
||||||
|
@ -822,11 +822,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.platform.is('android')) ||
|
||||||
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 } 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';
|
||||||
|
@ -75,7 +74,6 @@ export class CoreFileProvider {
|
||||||
constructor(logger: CoreLoggerProvider,
|
constructor(logger: CoreLoggerProvider,
|
||||||
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) {
|
||||||
|
@ -180,7 +178,7 @@ export class CoreFileProvider {
|
||||||
|
|
||||||
if (this.platform.is('android')) {
|
if (this.platform.is('android')) {
|
||||||
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 +473,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 +620,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 +743,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 +1250,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 +1260,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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') {
|
||||||
|
|
|
@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 = [];
|
||||||
|
|
||||||
|
@ -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)) {
|
||||||
|
@ -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