From 9b9493f2c63ba73b2c03ee5ed55cd31016603bf0 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 10 Nov 2020 11:06:44 +0100 Subject: [PATCH] MOBILE-3590 h5p: Don't display embed button in the app --- src/core/h5p/classes/core.ts | 21 ++++++--------------- src/core/h5p/classes/helper.ts | 16 ++++++++++------ src/core/h5p/classes/player.ts | 6 ++---- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/core/h5p/classes/core.ts b/src/core/h5p/classes/core.ts index 7e65b67c7..5ec9929e3 100644 --- a/src/core/h5p/classes/core.ts +++ b/src/core/h5p/classes/core.ts @@ -270,22 +270,13 @@ export class CoreH5PCore { // Never allow downloading in the app. displayOptions[CoreH5PCore.DISPLAY_OPTION_DOWNLOAD] = false; - // Embed - force setting it if always on or always off. In web, this is done when storing in DB. - const embed = this.h5pFramework.getOption(CoreH5PCore.DISPLAY_OPTION_EMBED, CoreH5PDisplayOptionBehaviour.ALWAYS_SHOW); - if (embed == CoreH5PDisplayOptionBehaviour.ALWAYS_SHOW || embed == CoreH5PDisplayOptionBehaviour.NEVER_SHOW) { - displayOptions[CoreH5PCore.DISPLAY_OPTION_EMBED] = (embed == CoreH5PDisplayOptionBehaviour.ALWAYS_SHOW); - } + // Never show the embed option in the app. + displayOptions[CoreH5PCore.DISPLAY_OPTION_EMBED] = false; if (!this.h5pFramework.getOption(CoreH5PCore.DISPLAY_OPTION_FRAME, true)) { displayOptions[CoreH5PCore.DISPLAY_OPTION_FRAME] = false; - } else { - displayOptions[CoreH5PCore.DISPLAY_OPTION_EMBED] = this.setDisplayOptionOverrides( - CoreH5PCore.DISPLAY_OPTION_EMBED, CoreH5PPermission.EMBED_H5P, id, - displayOptions[CoreH5PCore.DISPLAY_OPTION_EMBED]); - - if (this.h5pFramework.getOption(CoreH5PCore.DISPLAY_OPTION_COPYRIGHT, true) == false) { - displayOptions[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT] = false; - } + } else if (this.h5pFramework.getOption(CoreH5PCore.DISPLAY_OPTION_COPYRIGHT, true) == false) { + displayOptions[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT] = false; } displayOptions[CoreH5PCore.DISPLAY_OPTION_COPY] = this.h5pFramework.hasPermission(CoreH5PPermission.COPY_H5P, id); @@ -506,8 +497,8 @@ export class CoreH5PCore { // tslint:disable: no-bitwise displayOptions[CoreH5PCore.DISPLAY_OPTION_FRAME] = !(disable & CoreH5PCore.DISABLE_FRAME); - displayOptions[CoreH5PCore.DISPLAY_OPTION_DOWNLOAD] = !(disable & CoreH5PCore.DISABLE_DOWNLOAD); - displayOptions[CoreH5PCore.DISPLAY_OPTION_EMBED] = !(disable & CoreH5PCore.DISABLE_EMBED); + displayOptions[CoreH5PCore.DISPLAY_OPTION_DOWNLOAD] = false; // Never allow downloading in the app. + displayOptions[CoreH5PCore.DISPLAY_OPTION_EMBED] = false; // Never show the embed option in the app. displayOptions[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT] = !(disable & CoreH5PCore.DISABLE_COPYRIGHT); displayOptions[CoreH5PCore.DISPLAY_OPTION_ABOUT] = !!this.h5pFramework.getOption(CoreH5PCore.DISPLAY_OPTION_ABOUT, true); diff --git a/src/core/h5p/classes/helper.ts b/src/core/h5p/classes/helper.ts index 905ed8c08..25ed01c93 100644 --- a/src/core/h5p/classes/helper.ts +++ b/src/core/h5p/classes/helper.ts @@ -35,14 +35,18 @@ export class CoreH5PHelper { * @return Object with display options. */ static decodeDisplayOptions(displayOptions: number): CoreH5PDisplayOptions { - const config: any = {}; const displayOptionsObject = CoreH5P.instance.h5pCore.getDisplayOptionsAsObject(displayOptions); - config.export = false; // Don't allow downloading in the app. - config.embed = CoreUtils.instance.notNullOrUndefined(displayOptionsObject[CoreH5PCore.DISPLAY_OPTION_EMBED]) ? - displayOptionsObject[CoreH5PCore.DISPLAY_OPTION_EMBED] : false; - config.copyright = CoreUtils.instance.notNullOrUndefined(displayOptionsObject[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT]) ? - displayOptionsObject[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT] : false; + const config: CoreH5PDisplayOptions = { + export: false, // Don't allow downloading in the app. + embed: false, // Don't display the embed button in the app. + copyright: CoreUtils.instance.notNullOrUndefined(displayOptionsObject[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT]) ? + displayOptionsObject[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT] : false, + icon: CoreUtils.instance.notNullOrUndefined(displayOptionsObject[CoreH5PCore.DISPLAY_OPTION_ABOUT]) ? + displayOptionsObject[CoreH5PCore.DISPLAY_OPTION_ABOUT] : false, + }; + + config.frame = config.copyright || config.export || config.embed; return config; } diff --git a/src/core/h5p/classes/player.ts b/src/core/h5p/classes/player.ts index adede11e4..46100b6ad 100644 --- a/src/core/h5p/classes/player.ts +++ b/src/core/h5p/classes/player.ts @@ -301,10 +301,8 @@ export class CoreH5PPlayer { return displayOptions; } - displayOptions[CoreH5PCore.DISPLAY_OPTION_DOWNLOAD] = - CoreUtils.instance.isTrueOrOne(params[CoreH5PCore.DISPLAY_OPTION_DOWNLOAD]); - displayOptions[CoreH5PCore.DISPLAY_OPTION_EMBED] = - CoreUtils.instance.isTrueOrOne(params[CoreH5PCore.DISPLAY_OPTION_EMBED]); + displayOptions[CoreH5PCore.DISPLAY_OPTION_DOWNLOAD] = false; // Never allow downloading in the app. + displayOptions[CoreH5PCore.DISPLAY_OPTION_EMBED] = false; // Never show the embed option in the app. displayOptions[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT] = CoreUtils.instance.isTrueOrOne(params[CoreH5PCore.DISPLAY_OPTION_COPYRIGHT]); displayOptions[CoreH5PCore.DISPLAY_OPTION_FRAME] = displayOptions[CoreH5PCore.DISPLAY_OPTION_DOWNLOAD] ||