forked from EVOgeek/Vmeda.Online
		
	MOBILE-3394 utils: Manage store links
This commit is contained in:
		
							parent
							
								
									636906e522
								
							
						
					
					
						commit
						27ceabde62
					
				| @ -94,5 +94,12 @@ | ||||
|     "statusbarlighttextremotetheme": true, | ||||
|     "enableanalytics": false, | ||||
|     "forceColorScheme": "", | ||||
|     "webviewscheme": "moodleappfs" | ||||
|     "webviewscheme": "moodleappfs", | ||||
|     "appstores": { | ||||
|         "android": "com.moodle.moodlemobile", | ||||
|         "ios": "id633359593", | ||||
|         "windows": "moodle-desktop/9p9bwvhdc8c8", | ||||
|         "mac": "id1255924440", | ||||
|         "linux": "https://download.moodle.org/desktop/download.php?platform=linux&arch=64" | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; | ||||
| import { Location } from '@angular/common'; | ||||
| import { Platform, AlertController, NavController, NavOptions } from 'ionic-angular'; | ||||
| import { TranslateService } from '@ngx-translate/core'; | ||||
| import { CoreAppProvider } from '@providers/app'; | ||||
| import { CoreAppProvider, CoreStoreConfig } from '@providers/app'; | ||||
| import { CoreConfigProvider } from '@providers/config'; | ||||
| import { CoreEventsProvider } from '@providers/events'; | ||||
| import { CoreInitDelegate } from '@providers/init'; | ||||
| @ -1180,13 +1180,7 @@ export class CoreLoginHelperProvider { | ||||
|      * @param message The warning message. | ||||
|      */ | ||||
|     protected showWorkplaceNoticeModal(message: string): void { | ||||
|         let link; | ||||
| 
 | ||||
|         if (this.platform.is('android')) { | ||||
|             link = 'market://details?id=com.moodle.workplace'; | ||||
|         } else if (this.platform.is('ios')) { | ||||
|             link = 'itms-apps://itunes.apple.com/app/id1470929705'; | ||||
|         } | ||||
|         const link = this.appProvider.getAppStoreUrl({android: 'com.moodle.workplace', ios: 'id1470929705' }); | ||||
| 
 | ||||
|         this.showDownloadAppNoticeModal(message, link); | ||||
|     } | ||||
| @ -1197,20 +1191,12 @@ export class CoreLoginHelperProvider { | ||||
|      * @param message The warning message. | ||||
|      */ | ||||
|     protected showMoodleAppNoticeModal(message: string): void { | ||||
|         let link; | ||||
|         const storesConfig: CoreStoreConfig = CoreConfigConstants.appstores; | ||||
|         storesConfig.desktop = 'https://download.moodle.org/desktop/'; | ||||
|         storesConfig.mobile = 'https://download.moodle.org/mobile/'; | ||||
|         storesConfig.default = 'https://download.moodle.org/mobile/'; | ||||
| 
 | ||||
|         if (this.appProvider.isWindows()) { | ||||
|             link = 'https://download.moodle.org/desktop/download.php?platform=windows'; | ||||
|         } else if (this.appProvider.isLinux()) { | ||||
|             link = 'https://download.moodle.org/desktop/download.php?platform=linux&arch=' + | ||||
|                     (this.appProvider.is64Bits() ? '64' : '32'); | ||||
|         } else if (this.appProvider.isMac()) { | ||||
|             link = 'itms-apps://itunes.apple.com/app/id1255924440'; | ||||
|         } else if (this.platform.is('android')) { | ||||
|             link = 'market://details?id=com.moodle.moodlemobile'; | ||||
|         } else if (this.platform.is('ios')) { | ||||
|             link = 'itms-apps://itunes.apple.com/app/id633359593'; | ||||
|         } | ||||
|         const link = this.appProvider.getAppStoreUrl(storesConfig); | ||||
| 
 | ||||
|         this.showDownloadAppNoticeModal(message, link); | ||||
|     } | ||||
|  | ||||
| @ -50,6 +50,51 @@ export interface CoreRedirectData { | ||||
|     timemodified?: number; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Store config data. | ||||
|  */ | ||||
| export interface CoreStoreConfig { | ||||
|     /** | ||||
|      * ID of the Apple store where the desktop Mac app is uploaded. | ||||
|      */ | ||||
|     mac?: string; | ||||
| 
 | ||||
|     /** | ||||
|      * ID of the Windows store where the desktop Windows app is uploaded. | ||||
|      */ | ||||
|     windows?: string; | ||||
| 
 | ||||
|     /** | ||||
|      * Url with the desktop linux download link. | ||||
|      */ | ||||
|     linux?: string; | ||||
| 
 | ||||
|     /** | ||||
|      * Fallback URL when the desktop options is not set. | ||||
|      */ | ||||
|     desktop?: string; | ||||
| 
 | ||||
|     /** | ||||
|      * ID of the Apple store where the mobile iOS app is uploaded. | ||||
|      */ | ||||
|     ios?: string; | ||||
| 
 | ||||
|     /** | ||||
|      * ID of the Google play store where the android app is uploaded. | ||||
|      */ | ||||
|     android?: string; | ||||
| 
 | ||||
|     /** | ||||
|      * Fallback URL when the mobile options is not set. | ||||
|      */ | ||||
|     mobile?: string; | ||||
| 
 | ||||
|     /** | ||||
|      * Fallback URL when the other fallbacks options are not set. | ||||
|      */ | ||||
|     default?: string; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * App DB schema and migration function. | ||||
|  */ | ||||
| @ -255,6 +300,44 @@ export class CoreAppProvider { | ||||
|         return this.appCtrl.getRootNavs()[0]; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get app store URL. | ||||
|      * | ||||
|      * @param  storesConfig Config params to send the user to the right place. | ||||
|      * @return Store URL. | ||||
|      */ | ||||
|      getAppStoreUrl(storesConfig: CoreStoreConfig): string { | ||||
|         if (this.isMac() && storesConfig.mac) { | ||||
|             return 'itms-apps://itunes.apple.com/app/' + storesConfig.mac; | ||||
|         } | ||||
| 
 | ||||
|         if (this.isWindows() && storesConfig.windows) { | ||||
|             return 'https://www.microsoft.com/p/' + storesConfig.windows; | ||||
|         } | ||||
| 
 | ||||
|         if (this.isLinux() && storesConfig.linux) { | ||||
|             return storesConfig.linux; | ||||
|         } | ||||
| 
 | ||||
|         if (this.isDesktop() && storesConfig.desktop) { | ||||
|             return storesConfig.desktop; | ||||
|         } | ||||
| 
 | ||||
|         if (this.isIOS() && storesConfig.ios) { | ||||
|             return 'itms-apps://itunes.apple.com/app/' + storesConfig.ios; | ||||
|         } | ||||
| 
 | ||||
|         if (this.isAndroid() && storesConfig.android) { | ||||
|             return 'market://details?id=' + storesConfig.android; | ||||
|         } | ||||
| 
 | ||||
|         if (this.isMobile() && storesConfig.mobile) { | ||||
|             return storesConfig.mobile; | ||||
|         } | ||||
| 
 | ||||
|         return storesConfig.default || null; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Returns whether the user agent is controlled by automation. I.e. Behat testing. | ||||
|      * | ||||
|  | ||||
| @ -15,7 +15,7 @@ | ||||
| import { Injectable, Injector } from '@angular/core'; | ||||
| import { HttpClient } from '@angular/common/http'; | ||||
| import { TranslateService } from '@ngx-translate/core'; | ||||
| import { CoreAppProvider, CoreAppSchema } from './app'; | ||||
| import { CoreAppProvider, CoreAppSchema, CoreStoreConfig } from './app'; | ||||
| import { CoreEventsProvider } from './events'; | ||||
| import { CoreLoggerProvider } from './logger'; | ||||
| import { CoreSitesFactoryProvider } from './sites-factory'; | ||||
| @ -1001,19 +1001,15 @@ export class CoreSitesProvider { | ||||
|                 appVersion = this.convertVersionName(CoreConfigConstants.versionname); | ||||
| 
 | ||||
|             if (requiredVersion > appVersion) { | ||||
|                 let downloadUrl = ''; | ||||
|                 const storesConfig: CoreStoreConfig = { | ||||
|                     android: config.tool_mobile_androidappid || false, | ||||
|                     ios: config.tool_mobile_iosappid || false, | ||||
|                     desktop: config.tool_mobile_setuplink || 'https://download.moodle.org/desktop/', | ||||
|                     mobile: config.tool_mobile_setuplink || 'https://download.moodle.org/mobile/', | ||||
|                     default: config.tool_mobile_setuplink, | ||||
|                 }; | ||||
| 
 | ||||
|                 if (this.appProvider.isAndroid() && config.tool_mobile_androidappid) { | ||||
|                     downloadUrl = 'market://details?id=' + config.tool_mobile_androidappid; | ||||
|                 } else if (this.appProvider.isIOS() && config.tool_mobile_iosappid) { | ||||
|                     downloadUrl = 'itms-apps://itunes.apple.com/app/id' + config.tool_mobile_iosappid; | ||||
|                 } else if (config.tool_mobile_setuplink) { | ||||
|                     downloadUrl = config.tool_mobile_setuplink; | ||||
|                 } else if (this.appProvider.isMobile()) { | ||||
|                     downloadUrl = 'https://download.moodle.org/mobile/'; | ||||
|                 } else { | ||||
|                     downloadUrl = 'https://download.moodle.org/desktop/'; | ||||
|                 } | ||||
|                 const downloadUrl = this.appProvider.getAppStoreUrl(storesConfig); | ||||
| 
 | ||||
|                 siteId = siteId || this.getCurrentSiteId(); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user