From 3bcfd0128288c0b4c02f86a1f95e6114d9dc9090 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 6 Feb 2019 16:05:21 +0100 Subject: [PATCH] MOBILE-2807 message: Add setting to configure send --- scripts/langindex.json | 5 +++ src/addon/messages/lang/en.json | 3 ++ .../messages/pages/settings/settings.html | 16 ++++++++ src/addon/messages/pages/settings/settings.ts | 28 +++++++++++++- src/assets/lang/en.json | 3 ++ .../core-send-message-form.html | 2 +- .../send-message-form/send-message-form.ts | 37 ++++++++++++++++++- src/core/constants.ts | 1 + src/providers/events.ts | 1 + 9 files changed, 92 insertions(+), 4 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index 22b33e825..3993e76f7 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -214,6 +214,9 @@ "addon.messages.unabletomessage": "message", "addon.messages.unblockuser": "message", "addon.messages.unblockuserconfirm": "message", + "addon.messages.useentertosend": "message", + "addon.messages.useentertosenddescdesktop": "local_moodlemobileapp", + "addon.messages.useentertosenddescmac": "local_moodlemobileapp", "addon.messages.userwouldliketocontactyou": "message", "addon.messages.warningconversationmessagenotsent": "local_moodlemobileapp", "addon.messages.warningmessagenotsent": "local_moodlemobileapp", @@ -602,6 +605,7 @@ "addon.mod_lti.modulenameplural": "lti", "addon.mod_page.errorwhileloadingthepage": "local_moodlemobileapp", "addon.mod_page.modulenameplural": "page", + "addon.mod_quiz.answercolon": "qtype_numerical", "addon.mod_quiz.attemptfirst": "quiz", "addon.mod_quiz.attemptlast": "quiz", "addon.mod_quiz.attemptnumber": "quiz", @@ -1246,6 +1250,7 @@ "core.courses.enrolme": "local_moodlemobileapp", "core.courses.errorloadcategories": "local_moodlemobileapp", "core.courses.errorloadcourses": "local_moodlemobileapp", + "core.courses.errorloadplugins": "local_moodlemobileapp", "core.courses.errorsearching": "local_moodlemobileapp", "core.courses.errorselfenrol": "local_moodlemobileapp", "core.courses.filtermycourses": "local_moodlemobileapp", diff --git a/src/addon/messages/lang/en.json b/src/addon/messages/lang/en.json index 2ec162f66..75419bf5b 100644 --- a/src/addon/messages/lang/en.json +++ b/src/addon/messages/lang/en.json @@ -66,6 +66,9 @@ "unabletomessage": "You are unable to message this user", "unblockuser": "Unblock user", "unblockuserconfirm": "Are you sure you want to unblock {{$a}}?", + "useentertosend": "Use enter to send", + "useentertosenddescdesktop": "If disabled, you can use Ctrl+Enter to send the message.", + "useentertosenddescmac": "If disabled, you can use Cmd+Enter to send the message.", "userwouldliketocontactyou": "{{$a}} would like to contact you", "warningconversationmessagenotsent": "Couldn't send message(s) to conversation {{conversation}}. {{error}}", "warningmessagenotsent": "Couldn't send message(s) to user {{user}}. {{error}}", diff --git a/src/addon/messages/pages/settings/settings.html b/src/addon/messages/pages/settings/settings.html index 4048bb8f6..0172888d9 100644 --- a/src/addon/messages/pages/settings/settings.html +++ b/src/addon/messages/pages/settings/settings.html @@ -32,6 +32,7 @@ +
@@ -90,5 +91,20 @@
+ + + + + {{ 'core.settings.general' | translate }} + + +

{{ 'addon.messages.useentertosend' | translate }}

+

{{ 'addon.messages.useentertosenddescdesktop' | translate }}

+

{{ 'addon.messages.useentertosenddescmac' | translate }}

+
+ +
+
+
diff --git a/src/addon/messages/pages/settings/settings.ts b/src/addon/messages/pages/settings/settings.ts index 7b524ff3c..d7e30cd01 100644 --- a/src/addon/messages/pages/settings/settings.ts +++ b/src/addon/messages/pages/settings/settings.ts @@ -16,8 +16,12 @@ import { Component, OnDestroy } from '@angular/core'; import { IonicPage } from 'ionic-angular'; import { AddonMessagesProvider } from '../../providers/messages'; import { CoreUserProvider } from '@core/user/providers/user'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; +import { CoreAppProvider } from '@providers/app'; +import { CoreConfigProvider } from '@providers/config'; +import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider } from '@providers/sites'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; +import { CoreConstants } from '@core/constants'; /** * Page that displays the messages settings page. @@ -39,16 +43,27 @@ export class AddonMessagesSettingsPage implements OnDestroy { courseMemberValue = AddonMessagesProvider.MESSAGE_PRIVACY_COURSEMEMBER; siteValue = AddonMessagesProvider.MESSAGE_PRIVACY_SITE; groupMessagingEnabled: boolean; + sendOnEnter: boolean; + isDesktop: boolean; + isMac: boolean; protected previousContactableValue: number | boolean; constructor(private messagesProvider: AddonMessagesProvider, private domUtils: CoreDomUtilsProvider, - private userProvider: CoreUserProvider, sitesProvider: CoreSitesProvider) { + private userProvider: CoreUserProvider, private sitesProvider: CoreSitesProvider, appProvider: CoreAppProvider, + private configProvider: CoreConfigProvider, private eventsProvider: CoreEventsProvider) { const currentSite = sitesProvider.getCurrentSite(); this.advancedContactable = currentSite && currentSite.isVersionGreaterEqualThan('3.6'); this.allowSiteMessaging = currentSite && currentSite.canUseAdvancedFeature('messagingallusers'); this.groupMessagingEnabled = this.messagesProvider.isGroupMessagingEnabled(); + + this.configProvider.get(CoreConstants.SETTINGS_SEND_ON_ENTER, !appProvider.isMobile()).then((sendOnEnter) => { + this.sendOnEnter = !!sendOnEnter; + }); + + this.isDesktop = !appProvider.isMobile(); + this.isMac = appProvider.isMac(); } /** @@ -233,6 +248,15 @@ export class AddonMessagesSettingsPage implements OnDestroy { }); } + sendOnEnterChanged(): void { + // Save the value. + this.configProvider.set(CoreConstants.SETTINGS_SEND_ON_ENTER, this.sendOnEnter ? 1 : 0); + + // Notify the app. + this.eventsProvider.trigger(CoreEventsProvider.SEND_ON_ENTER_CHANGED, {sendOnEnter: !!this.sendOnEnter}, + this.sitesProvider.getCurrentSiteId()); + } + /** * Page destroyed. */ diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 47566d043..048521fcd 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -214,6 +214,9 @@ "addon.messages.unabletomessage": "You are unable to message this user", "addon.messages.unblockuser": "Unblock user", "addon.messages.unblockuserconfirm": "Are you sure you want to unblock {{$a}}?", + "addon.messages.useentertosend": "Use enter to send", + "addon.messages.useentertosenddescdesktop": "If disabled, you can use Ctrl+Enter to send the message.", + "addon.messages.useentertosenddescmac": "If disabled, you can use Cmd+Enter to send the message.", "addon.messages.userwouldliketocontactyou": "{{$a}} would like to contact you", "addon.messages.warningconversationmessagenotsent": "Couldn't send message(s) to conversation {{conversation}}. {{error}}", "addon.messages.warningmessagenotsent": "Couldn't send message(s) to user {{user}}. {{error}}", diff --git a/src/components/send-message-form/core-send-message-form.html b/src/components/send-message-form/core-send-message-form.html index aea20f503..f02a7ee2c 100644 --- a/src/components/send-message-form/core-send-message-form.html +++ b/src/components/send-message-form/core-send-message-form.html @@ -1,5 +1,5 @@
- +