MOBILE-3689 android: Enable ionic-webview plugin

main
Noel De Martin 2021-02-02 18:13:30 +01:00
parent bc1d0ee338
commit 033860d18b
6 changed files with 15 additions and 11 deletions

5
package-lock.json generated
View File

@ -7208,8 +7208,9 @@
"integrity": "sha512-6ucQ6FdlLdBm8kJfFnzozmBTjru/0xekHP/dAhjoCZggkGRlgs8TsUJFkxa/bV+qi7Dlo50JjmpE4UMWAO+aOQ=="
},
"cordova-plugin-ionic-webview": {
"version": "git+https://github.com/moodlemobile/cordova-plugin-ionic-webview.git#ac90a8ac88e2c0512d6b250249b1f673f2fbcb68",
"from": "git+https://github.com/moodlemobile/cordova-plugin-ionic-webview.git#500-moodle"
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/cordova-plugin-ionic-webview/-/cordova-plugin-ionic-webview-4.2.1.tgz",
"integrity": "sha512-7KrmqLaOGq1RP8N2z1ezN1kqkWFzTwwMvQ3/qAkd+exxFZuOe3DIN4eaU1gdNphsxdirI8Ajnr9q4So5vQbWqw=="
},
"cordova-plugin-local-notification": {
"version": "git+https://github.com/moodlemobile/cordova-plugin-local-notification.git#0bb96b757fb484553ceabf35a59802f7983a2836",

View File

@ -91,7 +91,7 @@
"cordova-plugin-globalization": "^1.11.0",
"cordova-plugin-inappbrowser": "git+https://github.com/moodlemobile/cordova-plugin-inappbrowser.git#moodle",
"cordova-plugin-ionic-keyboard": "2.1.3",
"cordova-plugin-ionic-webview": "git+https://github.com/moodlemobile/cordova-plugin-ionic-webview.git#500-moodle",
"cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-local-notification": "git+https://github.com/moodlemobile/cordova-plugin-local-notification.git#moodle",
"cordova-plugin-media": "^5.0.3",
"cordova-plugin-media-capture": "^3.0.3",

View File

@ -1233,7 +1233,7 @@ export class CoreFileProvider {
* @return Converted src.
*/
convertFileSrc(src: string): string {
return CoreApp.instance.isIOS() ? WebView.instance.convertFileSrc(src) : src;
return CoreApp.instance.isMobile() ? WebView.instance.convertFileSrc(src) : src;
}
/**
@ -1243,11 +1243,13 @@ export class CoreFileProvider {
* @return Unconverted src.
*/
unconvertFileSrc(src: string): string {
if (!CoreApp.instance.isIOS()) {
if (!CoreApp.instance.isMobile()) {
return src;
}
return src.replace(CoreConstants.CONFIG.ioswebviewscheme + '://localhost/_app_file_', 'file://');
const scheme = CoreApp.instance.isIOS() ? CoreConstants.CONFIG.ioswebviewscheme : 'http';
return src.replace(scheme + '://localhost/_app_file_', 'file://');
}
/**

View File

@ -390,7 +390,7 @@ export class CoreIframeUtilsProvider {
return;
}
if (urlParts.protocol && !CoreUrlUtils.instance.isLocalFileUrlScheme(urlParts.protocol)) {
if (urlParts.protocol && !CoreUrlUtils.instance.isLocalFileUrlScheme(urlParts.protocol, urlParts.domain || '')) {
// Scheme suggests it's an external resource.
event && event.preventDefault();

View File

@ -424,7 +424,7 @@ export class CoreUrlUtilsProvider {
isLocalFileUrl(url: string): boolean {
const urlParts = CoreUrl.parse(url);
return this.isLocalFileUrlScheme(urlParts?.protocol || '');
return this.isLocalFileUrlScheme(urlParts?.protocol || '', urlParts?.domain || '');
}
/**
@ -433,7 +433,7 @@ export class CoreUrlUtilsProvider {
* @param scheme Scheme to check.
* @return Whether the scheme belongs to a local file.
*/
isLocalFileUrlScheme(scheme: string): boolean {
isLocalFileUrlScheme(scheme: string, domain: string): boolean {
if (!scheme) {
return false;
}
@ -442,7 +442,8 @@ export class CoreUrlUtilsProvider {
return scheme == 'cdvfile' ||
scheme == 'file' ||
scheme == 'filesystem' ||
scheme == CoreConstants.CONFIG.ioswebviewscheme;
scheme == CoreConstants.CONFIG.ioswebviewscheme ||
(scheme === 'http' && domain === 'localhost');
}
/**

View File

@ -927,7 +927,7 @@ export class CoreWSProvider {
options.responseType = options.responseType || 'json';
options.timeout = typeof options.timeout == 'undefined' ? this.getRequestTimeout() : options.timeout;
if (CoreApp.instance.isIOS()) {
if (CoreApp.instance.isMobile()) {
// Use the cordova plugin.
if (url.indexOf('file://') === 0) {
// We cannot load local files using the http native plugin. Use file provider instead.