forked from EVOgeek/Vmeda.Online
		
	
						commit
						a93667c9f9
					
				| @ -13,7 +13,7 @@ | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import { Component, OnInit, NgZone } from '@angular/core'; | ||||
| import { Platform, IonicApp } from 'ionic-angular'; | ||||
| import { Config, Platform, IonicApp } from 'ionic-angular'; | ||||
| import { Network } from '@ionic-native/network'; | ||||
| import { CoreApp, CoreAppProvider } from '@providers/app'; | ||||
| import { CoreEventsProvider } from '@providers/events'; | ||||
| @ -28,6 +28,7 @@ import { Keyboard } from '@ionic-native/keyboard'; | ||||
| import { ScreenOrientation } from '@ionic-native/screen-orientation'; | ||||
| import { CoreLoginSitesPage } from '@core/login/pages/sites/sites'; | ||||
| import { CoreWindow } from '@singletons/window'; | ||||
| import { Device } from '@ionic-native/device'; | ||||
| 
 | ||||
| @Component({ | ||||
|     templateUrl: 'app.html' | ||||
| @ -40,13 +41,62 @@ export class MoodleMobileApp implements OnInit { | ||||
|     protected lastUrls = {}; | ||||
|     protected lastInAppUrl: string; | ||||
| 
 | ||||
|     constructor(private platform: Platform, logger: CoreLoggerProvider, keyboard: Keyboard, private app: IonicApp, | ||||
|             private eventsProvider: CoreEventsProvider, private loginHelper: CoreLoginHelperProvider, private zone: NgZone, | ||||
|             private appProvider: CoreAppProvider, private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider, | ||||
|             private screenOrientation: ScreenOrientation, private urlSchemesProvider: CoreCustomURLSchemesProvider, | ||||
|             private utils: CoreUtilsProvider, private urlUtils: CoreUrlUtilsProvider, private network: Network) { | ||||
|     constructor( | ||||
|             private platform: Platform, | ||||
|             logger: CoreLoggerProvider, | ||||
|             keyboard: Keyboard, | ||||
|             config: Config, | ||||
|             device: Device, | ||||
|             private app: IonicApp, | ||||
|             private eventsProvider: CoreEventsProvider, | ||||
|             private loginHelper: CoreLoginHelperProvider, | ||||
|             private zone: NgZone, | ||||
|             private appProvider: CoreAppProvider, | ||||
|             private langProvider: CoreLangProvider, | ||||
|             private sitesProvider: CoreSitesProvider, | ||||
|             private screenOrientation: ScreenOrientation, | ||||
|             private urlSchemesProvider: CoreCustomURLSchemesProvider, | ||||
|             private utils: CoreUtilsProvider, | ||||
|             private urlUtils: CoreUrlUtilsProvider, | ||||
|             private network: Network | ||||
|             ) { | ||||
|         this.logger = logger.getInstance('AppComponent'); | ||||
| 
 | ||||
|         if (this.appProvider.isIOS() && !platform.is('ios')) { | ||||
|             // Solve problem with wrong detected iPadOS.
 | ||||
|             const platforms = platform.platforms(); | ||||
|             const index = platforms.indexOf('core'); | ||||
|             if (index > -1) { | ||||
|                 platforms.splice(index, 1); | ||||
|             } | ||||
|             platforms.push('mobile'); | ||||
|             platforms.push('ios'); | ||||
|             platforms.push('ipad'); | ||||
|             platforms.push('tablet'); | ||||
| 
 | ||||
|             app.setElementClass('app-root-ios', true); | ||||
|             platform.ready().then(() => { | ||||
|                 if (device.version) { | ||||
|                     const [major, minor]: string[] = device.version.split('.', 2); | ||||
|                     app.setElementClass('platform-ios' + major, true); | ||||
|                     app.setElementClass('platform-ios' + major + '_' + minor, true); | ||||
|                 } | ||||
|             }); | ||||
| 
 | ||||
|             app._elementRef.nativeElement.classList.remove('app-root-md'); | ||||
| 
 | ||||
|             const iosConfig = config.getModeConfig('ios'); | ||||
| 
 | ||||
|             config.set('mode', 'ios'); | ||||
| 
 | ||||
|             Object.keys(iosConfig).forEach((key) => { | ||||
|                 // Already overriden: pageTransition, do not change.
 | ||||
|                 if (key != 'pageTransition') { | ||||
|                     config.set('ios', key, iosConfig[key]); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
| 
 | ||||
|         platform.ready().then(() => { | ||||
|             // Okay, so the platform is ready and our plugins are available.
 | ||||
|             // Here you can do any higher level native things you might need.
 | ||||
|  | ||||
| @ -49,7 +49,6 @@ export class CoreSharedFilesModule { | ||||
|         // Register the handler.
 | ||||
|         delegate.registerHandler(handler); | ||||
| 
 | ||||
|         platform.ready().then(() => { | ||||
|         if (appsProvider.isIOS()) { | ||||
|             let lastCheck = 0; | ||||
| 
 | ||||
| @ -76,6 +75,5 @@ export class CoreSharedFilesModule { | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -17,7 +17,6 @@ import { Platform, App, NavController, MenuController } from 'ionic-angular'; | ||||
| import { Keyboard } from '@ionic-native/keyboard'; | ||||
| import { Network } from '@ionic-native/network'; | ||||
| import { StatusBar } from '@ionic-native/status-bar'; | ||||
| import { Device } from '@ionic-native/device'; | ||||
| 
 | ||||
| import { CoreDbProvider } from './db'; | ||||
| import { CoreLoggerProvider } from './logger'; | ||||
| @ -179,7 +178,6 @@ export class CoreAppProvider { | ||||
|             zone: NgZone, | ||||
|             private menuCtrl: MenuController, | ||||
|             private statusBar: StatusBar, | ||||
|             private device: Device, | ||||
|             appRef: ApplicationRef) { | ||||
| 
 | ||||
|         this.logger = logger.getInstance('CoreAppProvider'); | ||||
| @ -392,8 +390,7 @@ export class CoreAppProvider { | ||||
|      * @return Whether the app is running in an Android mobile or tablet device. | ||||
|      */ | ||||
|     isAndroid(): boolean { | ||||
|         return this.isMobile() && | ||||
|             ((this.device.platform && this.device.platform.toLowerCase() == 'android') || this.platform.is('android')); | ||||
|         return this.isMobile() && this.platform.is('android'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -413,8 +410,7 @@ export class CoreAppProvider { | ||||
|      * @return Whether the app is running in an iOS mobile or tablet device. | ||||
|      */ | ||||
|     isIOS(): boolean { | ||||
|         return this.isMobile() && | ||||
|             ((this.device.platform && this.device.platform.toLowerCase() == 'ios') || this.platform.is('ios')); | ||||
|         return this.isMobile() && !this.platform.is('android'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -572,7 +568,7 @@ export class CoreAppProvider { | ||||
|      */ | ||||
|     openKeyboard(): void { | ||||
|         // Open keyboard is not supported in desktop and in iOS.
 | ||||
|         if (this.isMobile() && !this.isIOS()) { | ||||
|         if (this.isAndroid()) { | ||||
|             this.keyboard.show(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -81,10 +81,8 @@ export class CoreFileProvider { | ||||
| 
 | ||||
|         this.logger = logger.getInstance('CoreFileProvider'); | ||||
| 
 | ||||
|         platform.ready().then(() => { | ||||
|         if (appProvider.isAndroid() && !Object.getOwnPropertyDescriptor(FileReader.prototype, 'onloadend')) { | ||||
|                 // Cordova File plugin creates some getters and setter for FileReader, but
 | ||||
|                 // Ionic's polyfills override them in Android.
 | ||||
|             // Cordova File plugin creates some getters and setter for FileReader, but Ionic's polyfills override them in Android.
 | ||||
|             // Create the getters and setters again. This code comes from FileReader.js in cordova-plugin-file.
 | ||||
|             this.defineGetterSetter(FileReader.prototype, 'readyState', function(): any { | ||||
|                 return this._localURL ? this._readyState : this._realReader.readyState; | ||||
| @ -105,7 +103,6 @@ export class CoreFileProvider { | ||||
|             this.defineEvent('onloadend'); | ||||
|             this.defineEvent('onabort'); | ||||
|         } | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -57,8 +57,8 @@ export class CoreIframeUtilsProvider { | ||||
| 
 | ||||
|         const win = <WKUserScriptWindow> window; | ||||
| 
 | ||||
|         platform.ready().then(() => { | ||||
|         if (appProvider.isIOS() && win.WKUserScript) { | ||||
|             platform.ready().then(() => { | ||||
|                 // Inject code to the iframes because we cannot access the online ones.
 | ||||
|                 const wwwPath = fileProvider.getWWWAbsolutePath(); | ||||
|                 const linksPath = textUtils.concatenatePaths(wwwPath, 'assets/js/iframe-treat-links.js'); | ||||
| @ -73,9 +73,9 @@ export class CoreIframeUtilsProvider { | ||||
| 
 | ||||
|                 // Handle post messages received by iframes.
 | ||||
|                 window.addEventListener('message', this.handleIframeMessage.bind(this)); | ||||
|             } | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Check if a frame uses an online URL but the app is offline. If it does, the iframe is hidden and a warning is shown. | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user