From 8cafbfdd9f55e7a44b1b3e05599c52376dc6e848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jan 2019 10:34:26 +0100 Subject: [PATCH 1/8] MOBILE-2795 calendar: Hide imposible options in events reminders --- src/addon/calendar/pages/event/event.html | 16 +++++++-------- src/addon/calendar/pages/event/event.ts | 25 +++++++++++++++++++++-- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/addon/calendar/pages/event/event.html b/src/addon/calendar/pages/event/event.html index c8de82b17..f863e1243 100644 --- a/src/addon/calendar/pages/event/event.html +++ b/src/addon/calendar/pages/event/event.html @@ -52,19 +52,19 @@ - + {{ 'addon.calendar.notifications' | translate }} - {{ 'core.defaultvalue' | translate :{$a: defaultTimeReadable} }} + {{ 'core.defaultvalue' | translate :{$a: defaultTimeReadable} }} {{ 'core.settings.disabled' | translate }} {{ 600 | coreDuration }} - {{ 1800 | coreDuration }} - {{ 3600 | coreDuration }} - {{ 7200 | coreDuration }} - {{ 21600 | coreDuration }} - {{ 43200 | coreDuration }} - {{ 86400 | coreDuration }} + {{ 1800 | coreDuration }} + {{ 3600 | coreDuration }} + {{ 7200 | coreDuration }} + {{ 21600 | coreDuration }} + {{ 43200 | coreDuration }} + {{ 86400 | coreDuration }} diff --git a/src/addon/calendar/pages/event/event.ts b/src/addon/calendar/pages/event/event.ts index f8e3dec31..e20a61877 100644 --- a/src/addon/calendar/pages/event/event.ts +++ b/src/addon/calendar/pages/event/event.ts @@ -48,12 +48,14 @@ export class AddonCalendarEventPage { notificationsEnabled = false; moduleUrl = ''; categoryPath = ''; + currentTime: number; + defaultTime: number; constructor(private translate: TranslateService, private calendarProvider: AddonCalendarProvider, navParams: NavParams, - private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, timeUtils: CoreTimeUtilsProvider, + private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, private calendarHelper: AddonCalendarHelperProvider, private sitesProvider: CoreSitesProvider, localNotificationsProvider: CoreLocalNotificationsProvider, private courseProvider: CoreCourseProvider, - private textUtils: CoreTextUtilsProvider) { + private textUtils: CoreTextUtilsProvider, private timeUtils: CoreTimeUtilsProvider) { this.eventId = navParams.get('id'); this.notificationsEnabled = localNotificationsProvider.isAvailable(); @@ -61,9 +63,12 @@ export class AddonCalendarEventPage { if (this.notificationsEnabled) { this.calendarProvider.getEventNotificationTimeOption(this.eventId).then((notificationTime) => { this.notificationTime = notificationTime; + this.loadNotificationTime(); }); this.calendarProvider.getDefaultNotificationTime().then((defaultTime) => { + this.defaultTime = defaultTime * 60; + this.loadNotificationTime(); if (defaultTime === 0) { // Disabled by default. this.defaultTimeReadable = this.translate.instant('core.settings.disabled'); @@ -111,6 +116,9 @@ export class AddonCalendarEventPage { this.calendarHelper.formatEventData(event); this.event = event; + this.currentTime = this.timeUtils.timestamp(); + this.loadNotificationTime(); + // Reset some of the calculated data. this.categoryPath = ''; this.courseName = ''; @@ -178,6 +186,19 @@ export class AddonCalendarEventPage { }); } + /** + * Loads notification time by discarding options not in the list. + */ + loadNotificationTime(): void { + if (typeof this.notificationTime != 'undefined') { + if (this.notificationTime > 0 && this.event.timestart - this.notificationTime * 60 < this.currentTime) { + this.notificationTime = 0; + } else if (this.notificationTime < 0 && this.event.timestart - this.defaultTime < this.currentTime) { + this.notificationTime = 0; + } + } + } + /** * Refresh the event. * From 75551cfc72197e3883978ce53f8b09a2a2e084cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jan 2019 11:15:20 +0100 Subject: [PATCH 2/8] MOBILE-2795 url: Log view on embedded content --- src/addon/mod/url/components/index/index.ts | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/addon/mod/url/components/index/index.ts b/src/addon/mod/url/components/index/index.ts index 18b495e57..d5c92ec80 100644 --- a/src/addon/mod/url/components/index/index.ts +++ b/src/addon/mod/url/components/index/index.ts @@ -57,7 +57,12 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo this.canGetUrl = this.urlProvider.isGetUrlWSAvailable(); - this.loadContent(); + this.loadContent().then(() => { + if ((this.shouldIframe || (this.shouldEmbed && this.isOther)) || + (!this.shouldIframe && (!this.shouldEmbed || !this.isOther))) { + this.logView(); + } + }); } /** @@ -168,14 +173,23 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo } /** - * Opens a file. + * Log view into the site and checks module completion. + * + * @return {Promise} Promise resolved when done. */ - go(): void { - this.urlProvider.logView(this.module.instance).then(() => { + protected logView(): Promise { + return this.urlProvider.logView(this.module.instance).then(() => { this.courseProvider.checkModuleCompletion(this.courseId, this.module.completiondata); }).catch(() => { // Ignore errors. }); + } + + /** + * Opens a file. + */ + go(): void { + this.logView(); this.urlHelper.open(this.url); } } From 86039d0a58b110cb382ed9a719f94c6dcaf2bd42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jan 2019 11:36:43 +0100 Subject: [PATCH 3/8] MOBILE-2795 ux: Auto height on responsive images --- src/app/app.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/app.scss b/src/app/app.scss index 2d719bee0..fa548765c 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -33,6 +33,9 @@ ion-app.app-root { .img-responsive { display: block; max-width: 100%; + &[height] { + height: auto; + } } .opacity-hide { opacity: 0; } From 1c588a214c31b7cc74134b453835ef2e9fb13593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jan 2019 11:54:10 +0100 Subject: [PATCH 4/8] MOBILE-2795 format-text: Handle show more after a text update --- src/directives/format-text.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/directives/format-text.ts b/src/directives/format-text.ts index d907053f1..08b4876e8 100644 --- a/src/directives/format-text.ts +++ b/src/directives/format-text.ts @@ -80,6 +80,7 @@ export class CoreFormatTextDirective implements OnChanges { */ ngOnChanges(changes: { [name: string]: SimpleChange }): void { if (changes.text) { + this.hideShowMore(); this.formatAndRenderContents(); } } From bf509a7fae9f3a043e7d7bd64dafafb55f3ea4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jan 2019 12:01:55 +0100 Subject: [PATCH 5/8] MOBILE-2795 course: Scroll top on section change --- src/core/course/components/format/format.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts index a47d48eee..0252248f5 100644 --- a/src/core/course/components/format/format.ts +++ b/src/core/course/components/format/format.ts @@ -297,6 +297,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { setTimeout(() => { this.domUtils.scrollToElementBySelector(this.content, '#core-course-module-' + this.moduleId); }, 200); + } else { + this.domUtils.scrollToTop(this.content, 0); } } From 7c933ba15e9d67671bff3e22e03aad4175af462f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jan 2019 13:01:42 +0100 Subject: [PATCH 6/8] MOBILE-2795 data: Display table as column on phones --- src/addon/mod/data/data.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/addon/mod/data/data.scss b/src/addon/mod/data/data.scss index 6c646f411..d18a66a08 100644 --- a/src/addon/mod/data/data.scss +++ b/src/addon/mod/data/data.scss @@ -18,10 +18,14 @@ tr { @extend .row; padding: 0; + @include media-breakpoint-down(sm) { + flex-direction: column; + } } td, th { @extend .col; + min-height: auto; } } From 6727325d8eaa512184edbaf42a5cefa35d195ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jan 2019 14:26:37 +0100 Subject: [PATCH 7/8] MOBILE-2795 data: Change toggle search tab behaviour --- src/addon/mod/data/pages/search/search.html | 4 ++-- src/addon/mod/data/pages/search/search.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/addon/mod/data/pages/search/search.html b/src/addon/mod/data/pages/search/search.html index 35b90865d..835a8ff00 100644 --- a/src/addon/mod/data/pages/search/search.html +++ b/src/addon/mod/data/pages/search/search.html @@ -10,8 +10,8 @@
diff --git a/src/addon/mod/data/pages/search/search.ts b/src/addon/mod/data/pages/search/search.ts index 8bd04314b..e7078dfbb 100644 --- a/src/addon/mod/data/pages/search/search.ts +++ b/src/addon/mod/data/pages/search/search.ts @@ -176,9 +176,11 @@ export class AddonModDataSearchPage { /** * Toggles between advanced to normal search. + * + * @param {boolean} advanced True for advanced, false for basic. */ - toggleAdvanced(): void { - this.search.searchingAdvanced = !this.search.searchingAdvanced; + changeAdvanced(advanced: boolean): void { + this.search.searchingAdvanced = advanced; } /** From f4d3ab4c6c4dfe914aa2d11df431d989db2824d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 10 Jan 2019 14:43:18 +0100 Subject: [PATCH 8/8] MOBILE-2795 notifications: Check is triggered on plugin --- src/providers/local-notifications.ts | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/providers/local-notifications.ts b/src/providers/local-notifications.ts index 8f6d66c60..85b5e30fc 100644 --- a/src/providers/local-notifications.ts +++ b/src/providers/local-notifications.ts @@ -298,7 +298,7 @@ export class CoreLocalNotificationsProvider { return this.appDB.getRecord(this.TRIGGERED_TABLE, { id: notification.id }).then((stored) => { return stored.at === notification.at.getTime() / 1000; }).catch(() => { - return false; + return this.localNotifications.isTriggered(notification.id); }); } @@ -478,22 +478,23 @@ export class CoreLocalNotificationsProvider { protected scheduleNotification(notification: CoreILocalNotification): Promise { // Check if the notification has been triggered already. return this.isTriggered(notification).then((triggered) => { - if (!triggered) { - // Check if sound is enabled for notifications. - return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { - if (!soundEnabled) { - notification.sound = null; - } else { - delete notification.sound; // Use default value. - } + // Cancel the current notification in case it gets scheduled twice. + return this.localNotifications.cancel(notification.id).finally(() => { + if (!triggered) { + // Check if sound is enabled for notifications. + return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { + if (!soundEnabled) { + notification.sound = null; + } else { + delete notification.sound; // Use default value. + } - // Remove from triggered, since the notification could be in there with a different time. - this.removeTriggered(notification.id); - this.localNotifications.cancel(notification.id).finally(() => { + // Remove from triggered, since the notification could be in there with a different time. + this.removeTriggered(notification.id); this.localNotifications.schedule(notification); }); - }); - } + } + }); }); }