From 82419c3f5051b087209c169ffa82f25c1f2bcd25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 23 Feb 2022 09:49:06 +0100 Subject: [PATCH 01/13] MOBILE-3811 resource: Remove mimetype icons from resource only on 4.0+ This partially reverts commit 96b172c42ca216aacc986502eb628e5a911d0671. --- .../mod/forum/services/handlers/module.ts | 9 +++-- .../mod/resource/services/handlers/module.ts | 40 ++++++++++++++++++- .../course/services/module-delegate.ts | 3 +- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/addons/mod/forum/services/handlers/module.ts b/src/addons/mod/forum/services/handlers/module.ts index a750b83b6..780f432b1 100644 --- a/src/addons/mod/forum/services/handlers/module.ts +++ b/src/addons/mod/forum/services/handlers/module.ts @@ -23,6 +23,7 @@ import { CoreConstants, ModPurpose } from '@/core/constants'; import { AddonModForumIndexComponent } from '../../components/index'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; import { CoreCourseModuleData } from '@features/course/services/course-helper'; +import { CoreIonicColorNames } from '@singletons/colors'; /** * Handler to support forum modules. @@ -58,7 +59,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp const data = await super.getData(module, courseId); if ('afterlink' in module && !!module.afterlink) { - data.extraBadgeColor = ''; + data.extraBadgeColor = undefined; const match = />(\d+)[^<]+/.exec(module.afterlink); data.extraBadge = match ? Translate.instant('addon.mod_forum.unreadpostsnumber', { $a : match[1] }) : ''; } else { @@ -112,7 +113,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp } data.extraBadge = Translate.instant('core.loading'); - data.extraBadgeColor = 'light'; + data.extraBadgeColor = CoreIonicColorNames.DARK; await CoreUtils.ignoreErrors(AddonModForum.invalidateForumData(courseId)); @@ -120,7 +121,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp // Handle unread posts. const forum = await AddonModForum.getForum(courseId, moduleId, { siteId }); - data.extraBadgeColor = ''; + data.extraBadgeColor = undefined; data.extraBadge = forum.unreadpostscount ? Translate.instant( 'addon.mod_forum.unreadpostsnumber', @@ -129,7 +130,7 @@ export class AddonModForumModuleHandlerService extends CoreModuleHandlerBase imp : ''; } catch { // Ignore errors. - data.extraBadgeColor = ''; + data.extraBadgeColor = undefined; data.extraBadge = ''; } } diff --git a/src/addons/mod/resource/services/handlers/module.ts b/src/addons/mod/resource/services/handlers/module.ts index 0eaab6861..3304a1b8c 100644 --- a/src/addons/mod/resource/services/handlers/module.ts +++ b/src/addons/mod/resource/services/handlers/module.ts @@ -20,6 +20,7 @@ import { CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate'; import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; import { CoreFileHelper } from '@services/file-helper'; +import { CoreSites } from '@services/sites'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreTextUtils } from '@services/utils/text'; import { CoreTimeUtils } from '@services/utils/time'; @@ -95,7 +96,14 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase this.getResourceData(module, courseId, handlerData).then((extra) => { handlerData.extraBadge = extra; - handlerData.extraBadgeColor = ''; + + return; + }).catch(() => { + // Ignore errors. + }); + + this.getIconSrc(module).then((icon) => { + handlerData.icon = icon; return; }).catch(() => { @@ -214,6 +222,36 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase return extra.join(' '); } + /** + * @inheritdoc + */ + async getIconSrc(module?: CoreCourseModuleData): Promise { + if (!module) { + return; + } + + if (CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('4.0')) { + return await CoreCourse.getModuleIconSrc(module.modname, module.modicon); + } + let mimetypeIcon = ''; + + if (module.contentsinfo) { + // No need to use the list of files. + const mimetype = module.contentsinfo.mimetypes[0]; + if (mimetype) { + mimetypeIcon = CoreMimetypeUtils.getMimetypeIcon(mimetype); + } + + } else if (module.contents && module.contents[0]) { + const files = module.contents; + const file = files[0]; + + mimetypeIcon = CoreMimetypeUtils.getFileIcon(file.filename || ''); + } + + return await CoreCourse.getModuleIconSrc(module.modname, module.modicon, mimetypeIcon); + } + /** * @inheritdoc */ diff --git a/src/core/features/course/services/module-delegate.ts b/src/core/features/course/services/module-delegate.ts index 6c9a73055..ba49c4c72 100644 --- a/src/core/features/course/services/module-delegate.ts +++ b/src/core/features/course/services/module-delegate.ts @@ -25,6 +25,7 @@ import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; import { CoreCourseModuleData } from './course-helper'; import { CoreNavigationOptions } from '@services/navigator'; +import { CoreIonicColorNames } from '@singletons/colors'; /** * Interface that all course module handlers must implement. @@ -146,7 +147,7 @@ export interface CoreCourseModuleHandlerData { /** * The color of the extra badge. Default: primary. */ - extraBadgeColor?: string; + extraBadgeColor?: CoreIonicColorNames; /** * Whether to display a button to download/refresh the module if it's downloadable. From 0c684f238e4dbb279d8491d439fb84a29585e3a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 23 Feb 2022 10:12:57 +0100 Subject: [PATCH 02/13] MOBILE-3833 activities: Use black and white icons on the activity block --- .../components/activitymodules/activitymodules.scss | 13 +++++++++++++ .../components/activitymodules/activitymodules.ts | 13 ++++++------- .../addon-block-activitymodules.html | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 src/addons/block/activitymodules/components/activitymodules/activitymodules.scss diff --git a/src/addons/block/activitymodules/components/activitymodules/activitymodules.scss b/src/addons/block/activitymodules/components/activitymodules/activitymodules.scss new file mode 100644 index 000000000..21ce02313 --- /dev/null +++ b/src/addons/block/activitymodules/components/activitymodules/activitymodules.scss @@ -0,0 +1,13 @@ +:host { + --mod-icon-filter: brightness(0); + + core-mod-icon { + background: transparent; + margin: 0; + --filter: var(--mod-icon-filter); + } +} + +:host-context(body.dark) { + --mod-icon-filter: brightness(0) invert(1); +} diff --git a/src/addons/block/activitymodules/components/activitymodules/activitymodules.ts b/src/addons/block/activitymodules/components/activitymodules/activitymodules.ts index 60db4a0c0..129c1ca6d 100644 --- a/src/addons/block/activitymodules/components/activitymodules/activitymodules.ts +++ b/src/addons/block/activitymodules/components/activitymodules/activitymodules.ts @@ -28,6 +28,7 @@ import { CoreNavigator } from '@services/navigator'; @Component({ selector: 'addon-block-activitymodules', templateUrl: 'addon-block-activitymodules.html', + styleUrls: ['activitymodules.scss'], }) export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent implements OnInit { @@ -96,16 +97,13 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i // Sort the modnames alphabetically. modFullNames = CoreUtils.sortValues(modFullNames); for (const modName in modFullNames) { - let icon: string; + const iconModName = modName === 'resources' ? 'page' : modName; - if (modName === 'resources') { - icon = await CoreCourse.getModuleIconSrc('page', modIcons['page']); - } else { - icon = await CoreCourseModuleDelegate.getModuleIconSrc(modName, modIcons[modName]); - } + const icon = await CoreCourseModuleDelegate.getModuleIconSrc(iconModName, modIcons[iconModName]); this.entries.push({ - icon: icon, + icon, + iconModName, name: modFullNames[modName], modName, }); @@ -145,4 +143,5 @@ type AddonBlockActivityModuleEntry = { icon: string; name: string; modName: string; + iconModName: string; }; diff --git a/src/addons/block/activitymodules/components/activitymodules/addon-block-activitymodules.html b/src/addons/block/activitymodules/components/activitymodules/addon-block-activitymodules.html index 44810d334..a22f3d549 100644 --- a/src/addons/block/activitymodules/components/activitymodules/addon-block-activitymodules.html +++ b/src/addons/block/activitymodules/components/activitymodules/addon-block-activitymodules.html @@ -5,7 +5,7 @@ - + {{ entry.name }} From 8ba7da055245d227c5640acbf504de4f5e1f9783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 23 Feb 2022 10:29:11 +0100 Subject: [PATCH 03/13] MOBILE-3833 chips: Do not make it look clickable --- src/theme/theme.base.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/theme/theme.base.scss b/src/theme/theme.base.scss index 064a3dcee..7d39abe82 100644 --- a/src/theme/theme.base.scss +++ b/src/theme/theme.base.scss @@ -983,6 +983,12 @@ ion-chip { min-height: 24px; height: auto; + // Chips are not currently clickable. + &.ion-activatable { + cursor: auto; + pointer-events: none; + } + &.ion-color { background: var(--ion-color-tint); &.chip-outline { From 452acd45e9877f204526868d99d6f7bbd0e56469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 23 Feb 2022 10:33:59 +0100 Subject: [PATCH 04/13] MOBILE-3833 module: Fix get course when non enrolled --- .../course/components/module-summary/module-summary.html | 2 +- .../course/components/module-summary/module-summary.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/features/course/components/module-summary/module-summary.html b/src/core/features/course/components/module-summary/module-summary.html index 6c60ba185..52dc0f284 100644 --- a/src/core/features/course/components/module-summary/module-summary.html +++ b/src/core/features/course/components/module-summary/module-summary.html @@ -37,7 +37,7 @@ {{ 'core.course' | translate}}

- +

diff --git a/src/core/features/course/components/module-summary/module-summary.ts b/src/core/features/course/components/module-summary/module-summary.ts index a82c4801c..f480c8469 100644 --- a/src/core/features/course/components/module-summary/module-summary.ts +++ b/src/core/features/course/components/module-summary/module-summary.ts @@ -249,7 +249,13 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { * Fetch course. */ protected async fetchCourse(): Promise { - this.course = await CoreCourses.getUserCourse(this.courseId, true); + // Fix that. + try { + this.course = await CoreCourses.getUserCourse(this.courseId, true); + } catch { + // The user is not enrolled in the course. Use getCourses to see if it's an admin/manager and can see the course. + this.course = await CoreCourses.getCourse(this.courseId); + } } /** From e8e4b60a20af366954942a849a542f2c268dfcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 23 Feb 2022 11:58:18 +0100 Subject: [PATCH 05/13] MOBILE-3833 course: Increase toggle area on course index --- .../components/course-index/course-index.scss | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/core/features/course/components/course-index/course-index.scss b/src/core/features/course/components/course-index/course-index.scss index 169950d9d..854d9c3a3 100644 --- a/src/core/features/course/components/course-index/course-index.scss +++ b/src/core/features/course/components/course-index/course-index.scss @@ -33,16 +33,35 @@ ion-item.item.item-current { --background: var(--primary); --color: var(--primary-contrast); border: 0; - - ion-badge { - border: 1px solid var(--primary-contrast); - } - - ::ng-deep ion-icon { - color: var(--primary-contrast); - } } ion-icon.restricted { font-size: 14px; } + +ion-item.item.divider.section { + --padding-start: 0px; + + &.item-current { + ion-badge { + border: 1px solid var(--primary-contrast); + } + + ion-icon.expandable-status-icon { + color: var(--primary-contrast); + + &:hover { + background: var(--primary-shade); + } + } + } + + ion-icon.expandable-status-icon { + padding: 13px; + margin: 3px; + border-radius: 50%; + &:hover { + background: var(--gray-300); + } + } +} From c939fd23ca7d03bf2d4841b92ed97ab7b3b56149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 23 Feb 2022 12:51:29 +0100 Subject: [PATCH 06/13] MOBILE-3833 profile: Do not show online when the user can change avatar --- src/core/features/user/pages/about/about.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/features/user/pages/about/about.html b/src/core/features/user/pages/about/about.html index c539e7b3c..d31800b14 100644 --- a/src/core/features/user/pages/about/about.html +++ b/src/core/features/user/pages/about/about.html @@ -15,7 +15,7 @@