MOBILE-3321 core: Decouple isMobile from App
parent
7fd6a4bd22
commit
a0a138f686
|
@ -20,7 +20,6 @@ import {
|
||||||
AddonMessages,
|
AddonMessages,
|
||||||
} from '../../services/messages';
|
} from '../../services/messages';
|
||||||
import { CoreUser } from '@features/user/services/user';
|
import { CoreUser } from '@features/user/services/user';
|
||||||
import { CoreApp } from '@services/app';
|
|
||||||
import { CoreConfig } from '@services/config';
|
import { CoreConfig } from '@services/config';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
|
@ -28,6 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { IonRefresher } from '@ionic/angular';
|
import { IonRefresher } from '@ionic/angular';
|
||||||
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
|
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays the messages settings page.
|
* Page that displays the messages settings page.
|
||||||
|
@ -66,7 +66,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async asyncInit(): Promise<void> {
|
protected async asyncInit(): Promise<void> {
|
||||||
this.sendOnEnter = !!(await CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CoreApp.isMobile()));
|
this.sendOnEnter = !!(await CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CorePlatform.isMobile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,8 +17,8 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
|
||||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
import { CoreApp } from '@services/app';
|
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { CoreUrlUtils } from '@services/utils/url';
|
import { CoreUrlUtils } from '@services/utils/url';
|
||||||
|
@ -251,7 +251,7 @@ export class AddonModLtiProvider {
|
||||||
// Generate launcher and open it.
|
// Generate launcher and open it.
|
||||||
const launcherUrl = await this.generateLauncher(url, params);
|
const launcherUrl = await this.generateLauncher(url, params);
|
||||||
|
|
||||||
if (CoreApp.isMobile()) {
|
if (CorePlatform.isMobile()) {
|
||||||
CoreUtils.openInApp(launcherUrl);
|
CoreUtils.openInApp(launcherUrl);
|
||||||
} else {
|
} else {
|
||||||
// In desktop open in browser, we found some cases where inapp caused JS issues.
|
// In desktop open in browser, we found some cases where inapp caused JS issues.
|
||||||
|
|
|
@ -16,9 +16,9 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
|
import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler';
|
||||||
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course';
|
||||||
import { CoreApp } from '@services/app';
|
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
|
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
|
||||||
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
|
@ -394,7 +394,7 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe
|
||||||
|
|
||||||
// Remove the unzipped folder.
|
// Remove the unzipped folder.
|
||||||
promises.push(CoreFile.removeDir(path).catch((error) => {
|
promises.push(CoreFile.removeDir(path).catch((error) => {
|
||||||
if (error && (error.code == 1 || !CoreApp.isMobile())) {
|
if (error && (error.code == 1 || !CorePlatform.isMobile())) {
|
||||||
// Not found, ignore error.
|
// Not found, ignore error.
|
||||||
} else {
|
} else {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
|
||||||
import { CoreCronHandler } from '@services/cron';
|
import { CoreCronHandler } from '@services/cron';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
|
@ -35,7 +35,7 @@ export class AddonNotificationsCronHandlerService implements CoreCronHandler {
|
||||||
* @return Time between consecutive executions (in ms).
|
* @return Time between consecutive executions (in ms).
|
||||||
*/
|
*/
|
||||||
getInterval(): number {
|
getInterval(): number {
|
||||||
return CoreApp.isMobile() ? 600000 : 60000; // 1 or 10 minutes.
|
return CorePlatform.isMobile() ? 600000 : 60000; // 1 or 10 minutes.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, Input, Output, EventEmitter, OnInit, ViewChild, ElementRef } from '@angular/core';
|
import { Component, Input, Output, EventEmitter, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||||
import { CoreApp } from '@services/app';
|
|
||||||
import { CoreConfig } from '@services/config';
|
import { CoreConfig } from '@services/config';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
|
@ -21,6 +20,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreForms } from '@singletons/form';
|
import { CoreForms } from '@singletons/form';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to display a "send message form".
|
* Component to display a "send message form".
|
||||||
|
@ -55,7 +55,7 @@ export class CoreSendMessageFormComponent implements OnInit {
|
||||||
this.onSubmit = new EventEmitter();
|
this.onSubmit = new EventEmitter();
|
||||||
this.onResize = new EventEmitter();
|
this.onResize = new EventEmitter();
|
||||||
|
|
||||||
CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CoreApp.isMobile()).then((sendOnEnter) => {
|
CoreConfig.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !CorePlatform.isMobile()).then((sendOnEnter) => {
|
||||||
this.sendOnEnter = !!sendOnEnter;
|
this.sendOnEnter = !!sendOnEnter;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -117,7 +117,7 @@ export class CoreSendMessageFormComponent implements OnInit {
|
||||||
// Enter clicked, send the message.
|
// Enter clicked, send the message.
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
} else if (!this.sendOnEnter && !CoreApp.isMobile() && other == 'control') {
|
} else if (!this.sendOnEnter && !CorePlatform.isMobile() && other == 'control') {
|
||||||
// Cmd+Enter or Ctrl+Enter, send message.
|
// Cmd+Enter or Ctrl+Enter, send message.
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -138,7 +138,7 @@ export class CoreSendMessageFormComponent implements OnInit {
|
||||||
if (this.sendOnEnter && !other) {
|
if (this.sendOnEnter && !other) {
|
||||||
// Enter clicked, send the message.
|
// Enter clicked, send the message.
|
||||||
this.submitForm(e);
|
this.submitForm(e);
|
||||||
} else if (!this.sendOnEnter && !CoreApp.isMobile() && other == 'control') {
|
} else if (!this.sendOnEnter && !CorePlatform.isMobile() && other == 'control') {
|
||||||
// Cmd+Enter or Ctrl+Enter, send message.
|
// Cmd+Enter or Ctrl+Enter, send message.
|
||||||
this.submitForm(e);
|
this.submitForm(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import { FormControl } from '@angular/forms';
|
||||||
import { IonTextarea, IonContent, IonSlides } from '@ionic/angular';
|
import { IonTextarea, IonContent, IonSlides } from '@ionic/angular';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreFilepool } from '@services/filepool';
|
import { CoreFilepool } from '@services/filepool';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
|
@ -42,6 +41,7 @@ import { CoreLoadingComponent } from '@components/loading/loading';
|
||||||
import { CoreScreen } from '@services/screen';
|
import { CoreScreen } from '@services/screen';
|
||||||
import { CoreCancellablePromise } from '@classes/cancellable-promise';
|
import { CoreCancellablePromise } from '@classes/cancellable-promise';
|
||||||
import { CoreDom } from '@singletons/dom';
|
import { CoreDom } from '@singletons/dom';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to display a rich text editor if enabled.
|
* Component to display a rich text editor if enabled.
|
||||||
|
@ -797,7 +797,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
|
||||||
const selection = window.getSelection()?.toString();
|
const selection = window.getSelection()?.toString();
|
||||||
|
|
||||||
// When RTE is focused with a whole paragraph in desktop the stopBubble will not fire click.
|
// When RTE is focused with a whole paragraph in desktop the stopBubble will not fire click.
|
||||||
if (CoreApp.isMobile() || !this.rteEnabled || document.activeElement != this.editorElement || selection == '') {
|
if (CorePlatform.isMobile() || !this.rteEnabled || document.activeElement != this.editorElement || selection == '') {
|
||||||
this.stopBubble(event);
|
this.stopBubble(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import { MediaObject } from '@ionic-native/media/ngx';
|
||||||
import { FileEntry } from '@ionic-native/file/ngx';
|
import { FileEntry } from '@ionic-native/file/ngx';
|
||||||
import { MediaFile } from '@ionic-native/media-capture/ngx';
|
import { MediaFile } from '@ionic-native/media-capture/ngx';
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
|
||||||
import { CoreFile, CoreFileProvider } from '@services/file';
|
import { CoreFile, CoreFileProvider } from '@services/file';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
import { CoreMimetypeUtils } from '@services/utils/mimetype';
|
||||||
|
@ -27,6 +26,7 @@ import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreCaptureError } from '@classes/errors/captureerror';
|
import { CoreCaptureError } from '@classes/errors/captureerror';
|
||||||
import { CoreCanceledError } from '@classes/errors/cancelederror';
|
import { CoreCanceledError } from '@classes/errors/cancelederror';
|
||||||
import { CoreText } from '@singletons/text';
|
import { CoreText } from '@singletons/text';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page to capture media in browser, or to capture audio in mobile devices.
|
* Page to capture media in browser, or to capture audio in mobile devices.
|
||||||
|
@ -116,7 +116,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy {
|
||||||
this.title = 'core.captureimage';
|
this.title = 'core.captureimage';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isCordovaAudioCapture = CoreApp.isMobile() && this.isAudio;
|
this.isCordovaAudioCapture = CorePlatform.isMobile() && this.isAudio;
|
||||||
|
|
||||||
if (this.isCordovaAudioCapture) {
|
if (this.isCordovaAudioCapture) {
|
||||||
this.extension = Platform.is('ios') ? 'wav' : 'aac';
|
this.extension = Platform.is('ios') ? 'wav' : 'aac';
|
||||||
|
|
|
@ -37,6 +37,7 @@ import { CoreWSUploadFileResult } from '@services/ws';
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreText } from '@singletons/text';
|
import { CoreText } from '@singletons/text';
|
||||||
import { CorePromisedValue } from '@classes/promised-value';
|
import { CorePromisedValue } from '@classes/promised-value';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper service to upload files.
|
* Helper service to upload files.
|
||||||
|
@ -551,7 +552,7 @@ export class CoreFileUploaderHelperProvider {
|
||||||
media = medias[0]; // We used limit 1, we only want 1 media.
|
media = medias[0]; // We used limit 1, we only want 1 media.
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
if (isAudio && this.isNoAppError(error) && CoreApp.isMobile()) {
|
if (isAudio && this.isNoAppError(error) && CorePlatform.isMobile()) {
|
||||||
// No app to record audio, fallback to capture it ourselves.
|
// No app to record audio, fallback to capture it ourselves.
|
||||||
try {
|
try {
|
||||||
media = await CoreFileUploader.captureAudioInApp();
|
media = await CoreFileUploader.captureAudioInApp();
|
||||||
|
@ -574,7 +575,7 @@ export class CoreFileUploaderHelperProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the path has the protocol. In iOS it doesn't.
|
// Make sure the path has the protocol. In iOS it doesn't.
|
||||||
if (CoreApp.isMobile() && path.indexOf('file://') == -1) {
|
if (CorePlatform.isMobile() && path.indexOf('file://') == -1) {
|
||||||
path = 'file://' + path;
|
path = 'file://' + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
|
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
|
||||||
|
@ -35,7 +35,7 @@ export class CoreFileUploaderAlbumHandlerService implements CoreFileUploaderHand
|
||||||
* @return Promise resolved with true if enabled.
|
* @return Promise resolved with true if enabled.
|
||||||
*/
|
*/
|
||||||
async isEnabled(): Promise<boolean> {
|
async isEnabled(): Promise<boolean> {
|
||||||
return CoreApp.isMobile();
|
return CorePlatform.isMobile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
|
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
|
||||||
|
@ -34,7 +35,7 @@ export class CoreFileUploaderAudioHandlerService implements CoreFileUploaderHand
|
||||||
* @return Promise resolved with true if enabled.
|
* @return Promise resolved with true if enabled.
|
||||||
*/
|
*/
|
||||||
async isEnabled(): Promise<boolean> {
|
async isEnabled(): Promise<boolean> {
|
||||||
return CoreApp.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
|
return CorePlatform.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
|
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
|
||||||
|
@ -35,7 +36,7 @@ export class CoreFileUploaderCameraHandlerService implements CoreFileUploaderHan
|
||||||
* @return Promise resolved with true if enabled.
|
* @return Promise resolved with true if enabled.
|
||||||
*/
|
*/
|
||||||
async isEnabled(): Promise<boolean> {
|
async isEnabled(): Promise<boolean> {
|
||||||
return CoreApp.isMobile() || CoreApp.canGetUserMedia();
|
return CorePlatform.isMobile() || CoreApp.canGetUserMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderH
|
||||||
import { CoreFileUploaderHelper } from '../fileuploader-helper';
|
import { CoreFileUploaderHelper } from '../fileuploader-helper';
|
||||||
import { CoreFileUploader } from '../fileuploader';
|
import { CoreFileUploader } from '../fileuploader';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to upload any type of file.
|
* Handler to upload any type of file.
|
||||||
|
@ -61,7 +62,7 @@ export class CoreFileUploaderFileHandlerService implements CoreFileUploaderHandl
|
||||||
icon: 'folder', // Cannot use font-awesome in action sheet.
|
icon: 'folder', // Cannot use font-awesome in action sheet.
|
||||||
};
|
};
|
||||||
|
|
||||||
if (CoreApp.isMobile()) {
|
if (CorePlatform.isMobile()) {
|
||||||
handler.action = async (
|
handler.action = async (
|
||||||
maxSize?: number,
|
maxSize?: number,
|
||||||
upload?: boolean,
|
upload?: boolean,
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
|
import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate';
|
||||||
|
@ -34,7 +35,7 @@ export class CoreFileUploaderVideoHandlerService implements CoreFileUploaderHand
|
||||||
* @return Promise resolved with true if enabled.
|
* @return Promise resolved with true if enabled.
|
||||||
*/
|
*/
|
||||||
async isEnabled(): Promise<boolean> {
|
async isEnabled(): Promise<boolean> {
|
||||||
return CoreApp.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
|
return CorePlatform.isMobile() || (CoreApp.canGetUserMedia() && CoreApp.canRecordMedia());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,6 +46,7 @@ import { CoreDatabaseTable } from '@classes/database/database-table';
|
||||||
import { CoreDatabaseCachingStrategy, CoreDatabaseTableProxy } from '@classes/database/database-table-proxy';
|
import { CoreDatabaseCachingStrategy, CoreDatabaseTableProxy } from '@classes/database/database-table-proxy';
|
||||||
import { CoreObject } from '@singletons/object';
|
import { CoreObject } from '@singletons/object';
|
||||||
import { lazyMap, LazyMap } from '@/core/utils/lazy-map';
|
import { lazyMap, LazyMap } from '@/core/utils/lazy-map';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to handle push notifications.
|
* Service to handle push notifications.
|
||||||
|
@ -204,7 +205,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 && CoreApp.isMobile();
|
return !!this.pushID && CorePlatform.isMobile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -542,7 +543,7 @@ export class CorePushNotificationsProvider {
|
||||||
* @return Promise resolved when device is unregistered.
|
* @return Promise resolved when device is unregistered.
|
||||||
*/
|
*/
|
||||||
async unregisterDeviceOnMoodle(site: CoreSite): Promise<void> {
|
async unregisterDeviceOnMoodle(site: CoreSite): Promise<void> {
|
||||||
if (!site || !CoreApp.isMobile()) {
|
if (!site || !CorePlatform.isMobile()) {
|
||||||
throw new CoreError('Cannot unregister device');
|
throw new CoreError('Cannot unregister device');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +625,7 @@ export class CorePushNotificationsProvider {
|
||||||
|
|
||||||
const total = counters.reduce((previous, counter) => previous + counter, 0);
|
const total = counters.reduce((previous, counter) => previous + counter, 0);
|
||||||
|
|
||||||
if (!CoreApp.isMobile()) {
|
if (!CorePlatform.isMobile()) {
|
||||||
// Browser doesn't have an app badge, stop.
|
// Browser doesn't have an app badge, stop.
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import { CorePushNotifications } from '@features/pushnotifications/services/push
|
||||||
import { CoreConfig } from '@services/config';
|
import { CoreConfig } from '@services/config';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Device Info to be shown and copied to clipboard.
|
* Device Info to be shown and copied to clipboard.
|
||||||
|
@ -108,7 +109,7 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
' (' + window.screen.width + 'x' + window.screen.height + ')';
|
' (' + window.screen.width + 'x' + window.screen.height + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appProvider.isMobile()) {
|
if (CorePlatform.isMobile()) {
|
||||||
this.deviceInfo.deviceType = Platform.is('tablet') ? 'tablet' : 'phone';
|
this.deviceInfo.deviceType = Platform.is('tablet') ? 'tablet' : 'phone';
|
||||||
if (appProvider.isAndroid()) {
|
if (appProvider.isAndroid()) {
|
||||||
this.deviceInfo.deviceOs = 'android';
|
this.deviceInfo.deviceOs = 'android';
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { CoreEvents } from '@singletons/events';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
import { CoreLogger } from '@singletons/logger';
|
||||||
import { CoreSitePluginsModuleHandler } from '../classes/handlers/module-handler';
|
import { CoreSitePluginsModuleHandler } from '../classes/handlers/module-handler';
|
||||||
import { CorePromisedValue } from '@classes/promised-value';
|
import { CorePromisedValue } from '@classes/promised-value';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
const ROOT_CACHE_KEY = 'CoreSitePlugins:';
|
const ROOT_CACHE_KEY = 'CoreSitePlugins:';
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ export class CoreSitePluginsProvider {
|
||||||
applang: lang,
|
applang: lang,
|
||||||
appcustomurlscheme: CoreConstants.CONFIG.customurlscheme,
|
appcustomurlscheme: CoreConstants.CONFIG.customurlscheme,
|
||||||
appisdesktop: false,
|
appisdesktop: false,
|
||||||
appismobile: CoreApp.isMobile(),
|
appismobile: CorePlatform.isMobile(),
|
||||||
appiswide: CoreApp.isWide(),
|
appiswide: CoreApp.isWide(),
|
||||||
appplatform: 'browser',
|
appplatform: 'browser',
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
import { CorePlatform } from '@services/platform';
|
||||||
import { NativeHttp, Platform } from '@singletons';
|
import { NativeHttp, Platform } from '@singletons';
|
||||||
|
|
||||||
export default async function(): Promise<void> {
|
export default async function(): Promise<void> {
|
||||||
if (!CoreApp.isMobile()) {
|
if (!CorePlatform.isMobile()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import { asyncInstance } from '../utils/async-instance';
|
||||||
import { CoreDatabaseTable } from '@classes/database/database-table';
|
import { CoreDatabaseTable } from '@classes/database/database-table';
|
||||||
import { CorePromisedValue } from '@classes/promised-value';
|
import { CorePromisedValue } from '@classes/promised-value';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory to provide some global functionalities, like access to the global app database.
|
* Factory to provide some global functionalities, like access to the global app database.
|
||||||
|
@ -111,7 +112,7 @@ export class CoreAppProvider {
|
||||||
* Closes the keyboard.
|
* Closes the keyboard.
|
||||||
*/
|
*/
|
||||||
closeKeyboard(): void {
|
closeKeyboard(): void {
|
||||||
if (this.isMobile()) {
|
if (CorePlatform.isMobile()) {
|
||||||
Keyboard.hide();
|
Keyboard.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +193,7 @@ export class CoreAppProvider {
|
||||||
return 'market://details?id=' + storesConfig.android;
|
return 'market://details?id=' + storesConfig.android;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isMobile() && storesConfig.mobile) {
|
if (CorePlatform.isMobile() && storesConfig.mobile) {
|
||||||
return storesConfig.mobile;
|
return storesConfig.mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +204,7 @@ export class CoreAppProvider {
|
||||||
* Get platform major version number.
|
* Get platform major version number.
|
||||||
*/
|
*/
|
||||||
getPlatformMajorVersion(): number {
|
getPlatformMajorVersion(): number {
|
||||||
if (!this.isMobile()) {
|
if (!CorePlatform.isMobile()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +227,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.isMobile() && Platform.is('android');
|
return CorePlatform.isMobile() && Platform.is('android');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,7 +246,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.isMobile() && !Platform.is('android');
|
return CorePlatform.isMobile() && !Platform.is('android');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -309,9 +310,10 @@ export class CoreAppProvider {
|
||||||
* Checks if the app is running in a mobile or tablet device (Cordova).
|
* Checks if the app is running in a mobile or tablet device (Cordova).
|
||||||
*
|
*
|
||||||
* @return Whether the app is running in a mobile or tablet device.
|
* @return Whether the app is running in a mobile or tablet device.
|
||||||
|
* @deprecated since 4.1. use CorePlatform instead.
|
||||||
*/
|
*/
|
||||||
isMobile(): boolean {
|
isMobile(): boolean {
|
||||||
return Platform.is('cordova');
|
return CorePlatform.isMobile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -630,7 +632,7 @@ export class CoreAppProvider {
|
||||||
* @param color RGB color to use as status bar background. If not set the css variable will be read.
|
* @param color RGB color to use as status bar background. If not set the css variable will be read.
|
||||||
*/
|
*/
|
||||||
setStatusBarColor(color?: string): void {
|
setStatusBarColor(color?: string): void {
|
||||||
if (!this.isMobile()) {
|
if (!CorePlatform.isMobile()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import { CoreLogger } from '@singletons/logger';
|
||||||
import { makeSingleton, File, Zip, Platform, WebView } from '@singletons';
|
import { makeSingleton, File, Zip, Platform, WebView } from '@singletons';
|
||||||
import { CoreFileEntry } from '@services/file-helper';
|
import { CoreFileEntry } from '@services/file-helper';
|
||||||
import { CoreText } from '@singletons/text';
|
import { CoreText } from '@singletons/text';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Progress event used when writing a file data into a file.
|
* Progress event used when writing a file data into a file.
|
||||||
|
@ -1261,7 +1262,7 @@ export class CoreFileProvider {
|
||||||
* @return Converted src.
|
* @return Converted src.
|
||||||
*/
|
*/
|
||||||
convertFileSrc(src: string): string {
|
convertFileSrc(src: string): string {
|
||||||
return CoreApp.isMobile() ? WebView.convertFileSrc(src) : src;
|
return CorePlatform.isMobile() ? WebView.convertFileSrc(src) : src;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1271,7 +1272,7 @@ export class CoreFileProvider {
|
||||||
* @return Unconverted src.
|
* @return Unconverted src.
|
||||||
*/
|
*/
|
||||||
unconvertFileSrc(src: string): string {
|
unconvertFileSrc(src: string): string {
|
||||||
if (!CoreApp.isMobile()) {
|
if (!CorePlatform.isMobile()) {
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ import { CoreUrlUtils } from '@services/utils/url';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { makeSingleton, NavController, Router } from '@singletons';
|
import { makeSingleton, NavController, Router } from '@singletons';
|
||||||
import { CoreScreen } from './screen';
|
import { CoreScreen } from './screen';
|
||||||
import { CoreApp } from './app';
|
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
|
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redirect payload.
|
* Redirect payload.
|
||||||
|
@ -318,7 +318,7 @@ export class CoreNavigatorService {
|
||||||
// Remove the parameter from our map if it's in there.
|
// Remove the parameter from our map if it's in there.
|
||||||
delete this.storedParams[value];
|
delete this.storedParams[value];
|
||||||
|
|
||||||
if (!CoreApp.isMobile() && !storedParam) {
|
if (!CorePlatform.isMobile() && !storedParam) {
|
||||||
// Try to retrieve the param from local storage in browser.
|
// Try to retrieve the param from local storage in browser.
|
||||||
const storageParam = localStorage.getItem(value);
|
const storageParam = localStorage.getItem(value);
|
||||||
if (storageParam) {
|
if (storageParam) {
|
||||||
|
@ -604,7 +604,7 @@ export class CoreNavigatorService {
|
||||||
this.storedParams[id] = value;
|
this.storedParams[id] = value;
|
||||||
queryParams[name] = id;
|
queryParams[name] = id;
|
||||||
|
|
||||||
if (!CoreApp.isMobile()) {
|
if (!CorePlatform.isMobile()) {
|
||||||
// In browser, save the param in local storage to be able to retrieve it if the app is refreshed.
|
// In browser, save the param in local storage to be able to retrieve it if the app is refreshed.
|
||||||
localStorage.setItem(id, JSON.stringify(value));
|
localStorage.setItem(id, JSON.stringify(value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { makeSingleton, Platform } from '@singletons';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend Ionic's Platform service.
|
||||||
|
*/
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class CorePlatformService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the app is running in a mobile or tablet device (Cordova).
|
||||||
|
*
|
||||||
|
* @return Whether the app is running in a mobile or tablet device.
|
||||||
|
*/
|
||||||
|
isMobile(): boolean {
|
||||||
|
return Platform.is('cordova');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CorePlatform = makeSingleton(CorePlatformService);
|
|
@ -19,9 +19,9 @@ import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreUrl } from '@singletons/url';
|
import { CoreUrl } from '@singletons/url';
|
||||||
import { CoreApp } from '@services/app';
|
|
||||||
import { CoreSites } from '@services/sites';
|
import { CoreSites } from '@services/sites';
|
||||||
import { CoreText } from '@singletons/text';
|
import { CoreText } from '@singletons/text';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "Utils" service with helper functions for URLs.
|
* "Utils" service with helper functions for URLs.
|
||||||
|
@ -461,7 +461,7 @@ export class CoreUrlUtilsProvider {
|
||||||
scheme == 'file' ||
|
scheme == 'file' ||
|
||||||
scheme == 'filesystem' ||
|
scheme == 'filesystem' ||
|
||||||
scheme == CoreConstants.CONFIG.ioswebviewscheme ||
|
scheme == CoreConstants.CONFIG.ioswebviewscheme ||
|
||||||
(CoreApp.isMobile() && scheme === 'http' && domain === 'localhost'); // @todo: Get served domain from ENV.
|
(CorePlatform.isMobile() && scheme === 'http' && domain === 'localhost'); // @todo: Get served domain from ENV.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,6 +35,7 @@ import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreWindow } from '@singletons/window';
|
import { CoreWindow } from '@singletons/window';
|
||||||
import { CoreColors } from '@singletons/colors';
|
import { CoreColors } from '@singletons/colors';
|
||||||
import { CorePromisedValue } from '@classes/promised-value';
|
import { CorePromisedValue } from '@classes/promised-value';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
type TreeNode<T> = T & { children: TreeNode<T>[] };
|
type TreeNode<T> = T & { children: TreeNode<T>[] };
|
||||||
|
|
||||||
|
@ -1015,7 +1016,7 @@ export class CoreUtilsProvider {
|
||||||
|
|
||||||
this.iabInstance = InAppBrowser.create(url, '_blank', options);
|
this.iabInstance = InAppBrowser.create(url, '_blank', options);
|
||||||
|
|
||||||
if (CoreApp.isMobile()) {
|
if (CorePlatform.isMobile()) {
|
||||||
let loadStopSubscription;
|
let loadStopSubscription;
|
||||||
const loadStartUrls: string[] = [];
|
const loadStartUrls: string[] = [];
|
||||||
|
|
||||||
|
@ -1590,7 +1591,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 CoreApp.isMobile();
|
return CorePlatform.isMobile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1615,7 +1616,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.
|
||||||
*/
|
*/
|
||||||
async startScanQR(): Promise<string | undefined> {
|
async startScanQR(): Promise<string | undefined> {
|
||||||
if (!CoreApp.isMobile()) {
|
if (!CorePlatform.isMobile()) {
|
||||||
return Promise.reject('QRScanner isn\'t available in browser.');
|
return Promise.reject('QRScanner isn\'t available in browser.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import { CoreNetworkError } from '@classes/errors/network-error';
|
||||||
import { CoreSite } from '@classes/site';
|
import { CoreSite } from '@classes/site';
|
||||||
import { CoreHttpError } from '@classes/errors/httperror';
|
import { CoreHttpError } from '@classes/errors/httperror';
|
||||||
import { CorePromisedValue } from '@classes/promised-value';
|
import { CorePromisedValue } from '@classes/promised-value';
|
||||||
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This service allows performing WS calls and download/upload files.
|
* This service allows performing WS calls and download/upload files.
|
||||||
|
@ -994,7 +995,7 @@ export class CoreWSProvider {
|
||||||
options.responseType = options.responseType || 'json';
|
options.responseType = options.responseType || 'json';
|
||||||
options.timeout = options.timeout === undefined ? this.getRequestTimeout() : options.timeout;
|
options.timeout = options.timeout === undefined ? this.getRequestTimeout() : options.timeout;
|
||||||
|
|
||||||
if (CoreApp.isMobile()) {
|
if (CorePlatform.isMobile()) {
|
||||||
// Use the cordova plugin.
|
// Use the cordova plugin.
|
||||||
if (url.indexOf('file://') === 0) {
|
if (url.indexOf('file://') === 0) {
|
||||||
// We cannot load local files using the http native plugin. Use file provider instead.
|
// We cannot load local files using the http native plugin. Use file provider instead.
|
||||||
|
|
Loading…
Reference in New Issue