Merge pull request #3760 from dpalou/MOBILE-4373
MOBILE-4373 core: Support pages, numbers and key file extensions
This commit is contained in:
		
						commit
						8c129fe6fe
					
				| @ -1404,6 +1404,9 @@ | ||||
|   "assets.mimetypes.application/json": "mimetypes", | ||||
|   "assets.mimetypes.application/msword": "mimetypes", | ||||
|   "assets.mimetypes.application/pdf": "mimetypes", | ||||
|   "assets.mimetypes.application/vnd.apple.keynote": "local_moodlemobileapp", | ||||
|   "assets.mimetypes.application/vnd.apple.numbers": "local_moodlemobileapp", | ||||
|   "assets.mimetypes.application/vnd.apple.pages": "local_moodlemobileapp", | ||||
|   "assets.mimetypes.application/vnd.google-apps.audio": "local_moodlemobileapp", | ||||
|   "assets.mimetypes.application/vnd.google-apps.document": "local_moodlemobileapp", | ||||
|   "assets.mimetypes.application/vnd.google-apps.drawing": "local_moodlemobileapp", | ||||
| @ -1587,9 +1590,9 @@ | ||||
|   "core.course.errordownloadingsection": "local_moodlemobileapp", | ||||
|   "core.course.errorgetmodule": "local_moodlemobileapp", | ||||
|   "core.course.failed": "completion", | ||||
|   "core.course.guestaccess": "enrol_guest/pluginname", | ||||
|   "core.course.guestaccess_passwordinvalid": "enrol_guest/passwordinvalid", | ||||
|   "core.course.guestaccess_withpassword": "enrol_guest", | ||||
|   "core.course.guestaccess": "enrol_guest/pluginname", | ||||
|   "core.course.hiddenfromstudents": "moodle", | ||||
|   "core.course.hiddenoncoursepage": "moodle", | ||||
|   "core.course.highlighted": "moodle", | ||||
|  | ||||
| @ -471,7 +471,7 @@ | ||||
| "jut": {"type":"image/jutvision"}, | ||||
| "kar": {"type":"audio/midi"}, | ||||
| "karbon": {"type":"application/vnd.kde.karbon"}, | ||||
| "key": {"type":"application/pkcs8"}, | ||||
| "key": {"type":"application/vnd.apple.keynote","icon":"powerpoint","groups":["presentation"],"deprecated":"application/x-iwork-keynote-sffkey"}, | ||||
| "kfo": {"type":"application/vnd.kde.kformula"}, | ||||
| "kia": {"type":"application/vnd.kidspiration"}, | ||||
| "kml": {"type":"application/vnd.google-earth.kml+xml"}, | ||||
| @ -670,6 +670,7 @@ | ||||
| "nsc": {"type":"application/x-conference"}, | ||||
| "nsf": {"type":"application/vnd.lotus-notes"}, | ||||
| "ntf": {"type":"application/vnd.nitf"}, | ||||
| "numbers": {"type":"application/vnd.apple.numbers","icon":"spreadsheet","groups":["spreadsheet"],"deprecated":"application/x-iwork-numbers-sffnumbers"}, | ||||
| "nvd": {"type":"application/x-navidoc"}, | ||||
| "nzb": {"type":"application/x-nzb"}, | ||||
| "o": {"type":"application/octet-stream"}, | ||||
| @ -727,6 +728,7 @@ | ||||
| "p7r": {"type":"application/x-pkcs7-certreqresp"}, | ||||
| "p7s": {"type":"application/pkcs7-signature"}, | ||||
| "p8": {"type":"application/pkcs8"}, | ||||
| "pages": {"type":"application/vnd.apple.pages","icon":"document","groups":["document"],"deprecated":"application/x-iwork-pages-sffpages"}, | ||||
| "part": {"type":"application/pro_eng"}, | ||||
| "pas": {"type":"text/x-pascal"}, | ||||
| "paw": {"type":"application/vnd.pawaafile"}, | ||||
|  | ||||
| @ -192,7 +192,10 @@ | ||||
| "application/vnd.anser-web-funds-transfer-initiation": ["fti"], | ||||
| "application/vnd.antix.game-component": ["atx"], | ||||
| "application/vnd.apple.installer+xml": ["mpkg"], | ||||
| "application/vnd.apple.keynote": ["key"], | ||||
| "application/vnd.apple.mpegurl": ["m3u8"], | ||||
| "application/vnd.apple.numbers": ["numbers"], | ||||
| "application/vnd.apple.pages": ["pages"], | ||||
| "application/vnd.aristanetworks.swi": ["swi"], | ||||
| "application/vnd.astraea-software.iota": ["iota"], | ||||
| "application/vnd.audiograph": ["aep"], | ||||
| @ -626,6 +629,9 @@ | ||||
| "application/x-inventor": ["iv"], | ||||
| "application/x-ip2": ["ip"], | ||||
| "application/x-iso9660-image": ["iso"], | ||||
| "application/x-iwork-keynote-sffkey": ["key"], | ||||
| "application/x-iwork-numbers-sffnumbers": ["numbers"], | ||||
| "application/x-iwork-pages-sffpages": ["pages"], | ||||
| "application/x-java-class": ["class"], | ||||
| "application/x-java-commerce": ["jcm"], | ||||
| "application/x-java-jnlp-file": ["jnlp"], | ||||
|  | ||||
| @ -4,6 +4,9 @@ | ||||
|     "application/json": "{{$a.MIMETYPE2}} text", | ||||
|     "application/msword": "Word document", | ||||
|     "application/pdf": "PDF document", | ||||
|     "application/vnd.apple.keynote": "Apple Keynote presentation", | ||||
|     "application/vnd.apple.numbers": "Apple Numbers spreadsheet", | ||||
|     "application/vnd.apple.pages": "Apple Pages document", | ||||
|     "application/vnd.google-apps.audio": "Google Drive audio", | ||||
|     "application/vnd.google-apps.document": "Google Docs", | ||||
|     "application/vnd.google-apps.drawing": "Google Drawing", | ||||
|  | ||||
| @ -31,9 +31,9 @@ interface MimeTypeInfo { | ||||
|     type: string; | ||||
|     icon?: string; | ||||
|     groups?: string[]; | ||||
| 
 | ||||
|     // eslint-disable-next-line id-blacklist
 | ||||
|     string?: string; | ||||
|     deprecated?: string; // Deprecated mimetype name.
 | ||||
| } | ||||
| 
 | ||||
| interface MimeTypeGroupInfo { | ||||
| @ -394,6 +394,18 @@ export class CoreMimetypeUtilsProvider { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Get the deprecated mimetype of an extension. Returns undefined if not found or no deprecated mimetype. | ||||
|      * | ||||
|      * @param extension Extension. | ||||
|      * @returns Deprecated mimetype. | ||||
|      */ | ||||
|     getDeprecatedMimeType(extension: string): string | undefined { | ||||
|         extension = this.cleanExtension(extension); | ||||
| 
 | ||||
|         return this.extToMime[extension]?.deprecated; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Obtains descriptions for file types (e.g. 'Microsoft Word document') from the language file. | ||||
|      * Based on Moodle's get_mimetype_description. | ||||
|  | ||||
| @ -1033,12 +1033,30 @@ export class CoreUtilsProvider { | ||||
|             // Error, use the original path.
 | ||||
|         } | ||||
| 
 | ||||
|         try { | ||||
|         const openFile = async (mimetype?: string) => { | ||||
|             if (this.shouldOpenWithDialog(options)) { | ||||
|                 await FileOpener.showOpenWithDialog(path, mimetype || ''); | ||||
|             } else { | ||||
|                 await FileOpener.open(path, mimetype || ''); | ||||
|             } | ||||
|         }; | ||||
| 
 | ||||
|         try { | ||||
|             try { | ||||
|                 await openFile(mimetype); | ||||
|             } catch (error) { | ||||
|                 if (!extension || !error || Number(error.status) !== 9) { | ||||
|                     throw error; | ||||
|                 } | ||||
| 
 | ||||
|                 // Cannot open mimetype. Check if there is a deprecated mimetype for the extension.
 | ||||
|                 const deprecatedMimetype = CoreMimetypeUtils.getDeprecatedMimeType(extension); | ||||
|                 if (!deprecatedMimetype || deprecatedMimetype === mimetype) { | ||||
|                     throw error; | ||||
|                 } | ||||
| 
 | ||||
|                 await openFile(deprecatedMimetype); | ||||
|             } | ||||
|         } catch (error) { | ||||
|             this.logger.error('Error opening file ' + path + ' with mimetype ' + mimetype); | ||||
|             this.logger.error('Error: ', JSON.stringify(error)); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user