File tree Expand file tree Collapse file tree 4 files changed +13
-3
lines changed Expand file tree Collapse file tree 4 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 14711471 "core.cannotconnecttrouble" : " local_moodlemobileapp" ,
14721472 "core.cannotconnectverify" : " local_moodlemobileapp" ,
14731473 "core.cannotdownloadfiles" : " local_moodlemobileapp" ,
1474+ "core.cannotinstallapk" : " local_moodlemobileapp" ,
14741475 "core.cannotlogoutpageblocks" : " local_moodlemobileapp" ,
14751476 "core.cannotopeninapp" : " local_moodlemobileapp" ,
14761477 "core.cannotopeninappdownload" : " local_moodlemobileapp" ,
Original file line number Diff line number Diff line change 1818 "cannotconnecttrouble" : " We're having trouble connecting to your site." ,
1919 "cannotconnectverify" : " <strong>Please check the address is correct.</strong>" ,
2020 "cannotdownloadfiles" : " File downloading is disabled. Please contact your site administrator." ,
21+ "cannotinstallapk" : " For security reasons, it is not allowed to install unknown apps from the Moodle app. Please open the file using a browser." ,
2122 "cannotlogoutpageblocks" : " Please save or discard your changes before continuing." ,
2223 "cannotopeninapp" : " This file may not work as expected on this device. Would you like to open it anyway?" ,
2324 "cannotopeninappdownload" : " This file may not work as expected on this device. Would you like to download it anyway?" ,
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import { CoreConstants } from '@/core/constants';
2727import { CoreError } from '@classes/errors/error' ;
2828import { makeSingleton , Translate } from '@singletons' ;
2929import { CoreNetworkError } from '@classes/errors/network-error' ;
30+ import { CoreMimetypeUtils } from './utils/mimetype' ;
3031
3132/**
3233 * Provider to provide some helper functions regarding files and packages.
@@ -303,18 +304,22 @@ export class CoreFileHelperProvider {
303304 }
304305
305306 /**
306- * Whether the file has to be opened in browser (external repository).
307- * The file must have a mimetype attribute.
307+ * Whether the file has to be opened in browser.
308308 *
309309 * @param file The file to check.
310310 * @return Whether the file should be opened in browser.
311311 */
312312 shouldOpenInBrowser ( file : CoreWSFile ) : boolean {
313- if ( ! file || ! ( 'isexternalfile' in file ) || ! file . isexternalfile || ! file . mimetype ) {
313+ if ( ! file . mimetype ) {
314314 return false ;
315315 }
316316
317317 const mimetype = file . mimetype ;
318+ if ( ! ( 'isexternalfile' in file ) || ! file . isexternalfile ) {
319+ return mimetype === 'application/vnd.android.package-archive' ||
320+ CoreMimetypeUtils . getFileExtension ( file . filename ?? '' ) === 'apk' ;
321+ }
322+
318323 if ( mimetype . indexOf ( 'application/vnd.google-apps.' ) != - 1 ) {
319324 // Google Docs file, always open in browser.
320325 return true ;
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import { CoreFileEntry } from '@services/file-helper';
3434import { CoreConstants } from '@/core/constants' ;
3535import { CoreWindow } from '@singletons/window' ;
3636import { CoreColors } from '@singletons/colors' ;
37+ import { CoreError } from '@classes/errors/error' ;
3738
3839type TreeNode < T > = T & { children : TreeNode < T > [ ] } ;
3940
@@ -958,6 +959,8 @@ export class CoreUtilsProvider {
958959 this . openInApp ( path ) ;
959960
960961 return ;
962+ } else if ( extension === 'apk' && CoreApp . isAndroid ( ) ) {
963+ throw new CoreError ( Translate . instant ( 'core.cannotinstallapk' ) ) ;
961964 }
962965
963966 // Path needs to be decoded, the file won't be opened if the path has %20 instead of spaces and so.
You can’t perform that action at this time.
0 commit comments