Merge lp:~pat-mcgowan/messaging-app/fix-1278790 into lp:messaging-app

Proposed by Pat McGowan
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 587
Merged at revision: 586
Proposed branch: lp:~pat-mcgowan/messaging-app/fix-1278790
Merge into: lp:messaging-app
Diff against target: 192 lines (+81/-30)
4 files modified
src/qml/ComposeBar.qml (+67/-28)
src/qml/Messages.qml (+1/-0)
src/qml/SettingsPage.qml (+7/-2)
src/qml/messaging-app.qml (+6/-0)
To merge this branch: bzr merge lp:~pat-mcgowan/messaging-app/fix-1278790
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
Review via email: mp+301952@code.launchpad.net

Commit message

This adds support for showing the current character count and number of messages to be sent via SMS. It includes a new label on top of the text area showing number of characters / 160 (number of messages). It is shown once the message is over 1 line in length, per other systems.
A new settings option is added to enable the feature which is off by default.
Emojis are counted as two characters. I did not test with multibyte character sets but expect that QML TextArea does the correct thing.
See lp:1278790

Description of the change

This adds support for showing the current character count and number of messages to be sent via SMS. It includes a new label on top of the text area showing number of characters / 160 (number of messages). It is shown once the message is over 1 line in length, per other systems.
A new settings option is added to enable the feature which is off by default.
Emojis are counted as two characters. I did not test with multibyte character sets but expect that QML TextArea does the correct thing.
See lp:1278790

To post a comment you must log in.
Revision history for this message
Bill Filler (bfiller) wrote :

few comments
1) drop the (1) suffix if the count is < 160
2) hide the count label if it's an MMS message (either MMS group chat or single recipient with an attachment) as the rules are different I suppose

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

Thanks for the patch.
I left some comments.

You can check if the conversation is mms with the following code in ComposeBar.qml:

// more than one participant and mms group chat enabled or only one participant and any attachment
property var isMms = ((messages.participants.length > 1 && telepathyHelper.mmsGroupChat) || (messages.participants.length == 1 && attachments.count > 0))

review: Needs Fixing
583. By Pat McGowan

Indicate when using MMS, show partial composition with italics, only show message count when more than 1

584. By Pat McGowan

cleanup

585. By Pat McGowan

MMS needs to be translated

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

Ready for another pass

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

Waiting for final design inputs

586. By Pat McGowan

Match UX design specs, don't show the 160 limit, move to lower right, always show the message count

587. By Pat McGowan

add a space per mockup

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

Just tested and it works fine.
Code looks good too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/ComposeBar.qml'
2--- src/qml/ComposeBar.qml 2016-06-29 20:43:16 +0000
3+++ src/qml/ComposeBar.qml 2016-08-12 18:33:08 +0000
4@@ -39,6 +39,8 @@
5 property alias audioRecordedDuration: audioRecordingBar.duration
6 property alias recording: audioRecordingBar.recording
7 property bool oskEnabled: true
8+ property bool usingMMS: false
9+
10 onRecordingChanged: {
11 if (recording) {
12 manuallyRecorded = true
13@@ -49,7 +51,9 @@
14
15 // internal properties
16 property int _activeAttachmentIndex: -1
17- property int _defaultHeight: textEntry.height + attachmentPanel.height + stickersPicker.height + units.gu(2)
18+ property int _defaultHeight: charCount.height + textEntry.height + attachmentPanel.height + stickersPicker.height + units.gu(2)
19+ property int messageCount: 0
20+ property int smsLength: 160
21
22 Component.onDestruction: {
23 composeBar.reset()
24@@ -323,6 +327,7 @@
25 if (text !== "" && composeBar.audioAttached) {
26 attachments.clear()
27 }
28+ messageCount = (messageTextArea.length + smsLength - 1) / smsLength
29 }
30
31 focus: false
32@@ -396,40 +401,74 @@
33 visible: attachments.count > 0
34 }
35
36- TextArea {
37- id: messageTextArea
38- objectName: "messageTextArea"
39+ Item {
40 anchors {
41 top: attachments.count == 0 ? textEntry.top : attachmentThumbnails.bottom
42 left: parent.left
43 right: parent.right
44 }
45- // this value is to avoid letter being cut off
46- height: units.gu(4.3)
47- style: LocalTextAreaStyle {}
48- autoSize: true
49- maximumLineCount: attachments.count == 0 ? 8 : 4
50- placeholderText: {
51- if (telepathyHelper.ready) {
52- var account = telepathyHelper.accountForId(presenceRequest.accountId)
53- if (account &&
54- (presenceRequest.type != PresenceRequest.PresenceTypeUnknown &&
55- presenceRequest.type != PresenceRequest.PresenceTypeUnset) &&
56- account.protocolInfo.serviceName !== "") {
57- console.log(presenceRequest.accountId)
58- console.log(presenceRequest.type)
59- return account.protocolInfo.serviceName
60- }
61- }
62- return i18n.tr("Write a message...")
63- }
64- focus: textEntry.focus
65- font.family: "Ubuntu"
66- font.pixelSize: FontUtils.sizeToPixels("medium")
67- color: Theme.palette.normal.backgroundText
68+ TextArea {
69+ id: messageTextArea
70+ objectName: "messageTextArea"
71+ anchors {
72+ top: parent.top
73+ left: parent.left
74+ right: parent.right
75+ }
76+ // this value is to avoid letter being cut off
77+ height: units.gu(4.3)
78+ style: LocalTextAreaStyle {}
79+ autoSize: true
80+ maximumLineCount: attachments.count == 0 ? 8 : 4
81+ placeholderText: {
82+ if (telepathyHelper.ready) {
83+ var account = telepathyHelper.accountForId(presenceRequest.accountId)
84+ if (account &&
85+ (presenceRequest.type != PresenceRequest.PresenceTypeUnknown &&
86+ presenceRequest.type != PresenceRequest.PresenceTypeUnset) &&
87+ account.protocolInfo.serviceName !== "") {
88+ console.log(presenceRequest.accountId)
89+ console.log(presenceRequest.type)
90+ return account.protocolInfo.serviceName
91+ }
92+ }
93+ return i18n.tr("Write a message...")
94+ }
95+ focus: textEntry.focus
96+ font.family: "Ubuntu"
97+ font.pixelSize: FontUtils.sizeToPixels("medium")
98+ color: Theme.palette.normal.backgroundText
99+ }
100+
101+ // show the counts if option is enabled, and more than one line
102+ // If MMS indicate such on the label and don't show the count
103+ // if word prediction is on italicize the count while its still composing
104+ Label {
105+ id: charCount
106+ anchors {
107+ right: messageTextArea.right
108+ top: messageTextArea.bottom
109+ topMargin: visible ? units.gu(.5) : 0
110+ bottomMargin: visible ? units.gu(.5) : 0
111+ }
112+ height: visible ? units.gu(2) : 0
113+ text: {
114+ if ((attachments.count > 0) || usingMMS) {
115+ i18n.tr("MMS")
116+ } else {
117+ messageTextArea.length + " (" + messageCount + ")"
118+ }
119+ }
120+ fontSize: "small"
121+ font.italic: messageTextArea.inputMethodComposing && (attachments.count == 0) && !usingMMS
122+ color: Theme.palette.normal.backgroundTertiaryText
123+ visible: msgSettings.showCharacterCount && (messageTextArea.lineCount > 1)
124+ }
125+
126 }
127+
128 }
129-
130+
131 AttachmentPanel {
132 id: attachmentPanel
133
134
135=== modified file 'src/qml/Messages.qml'
136--- src/qml/Messages.qml 2016-07-28 16:04:52 +0000
137+++ src/qml/Messages.qml 2016-08-12 18:33:08 +0000
138@@ -1119,6 +1119,7 @@
139 text: messages.text
140 canSend: participants.length > 0 || multiRecipient.recipientCount > 0 || multiRecipient.searchString !== ""
141 oskEnabled: messages.oskEnabled
142+ usingMMS: (participantIds.length > 1 || multiRecipient.recipientCount > 1 ) && telepathyHelper.mmsGroupChat && messages.account.type == AccountEntry.PhoneAccount
143
144 Component.onCompleted: {
145 // if page is active, it means this is not a bottom edge page
146
147=== modified file 'src/qml/SettingsPage.qml'
148--- src/qml/SettingsPage.qml 2016-07-21 15:39:09 +0000
149+++ src/qml/SettingsPage.qml 2016-08-12 18:33:08 +0000
150@@ -23,13 +23,19 @@
151 Page {
152 id: settingsPage
153 title: i18n.tr("Settings")
154+
155 property var setMethods: {
156- "mmsGroupChatEnabled": function(value) { telepathyHelper.mmsGroupChat = value }
157+ "mmsGroupChatEnabled": function(value) { telepathyHelper.mmsGroupChat = value },
158+ "characterCountEnabled": function(value) { msgSettings.showCharacterCount = value }
159 }
160 property var settingsModel: [
161 { "name": "mmsGroupChatEnabled",
162 "description": i18n.tr("Enable MMS group chat"),
163 "property": telepathyHelper.mmsGroupChat
164+ },
165+ { "name": "characterCountEnabled",
166+ "description": i18n.tr("Show character count"),
167+ "property": msgSettings.showCharacterCount
168 }
169 ]
170
171@@ -109,4 +115,3 @@
172 }
173 }
174 }
175-
176
177=== modified file 'src/qml/messaging-app.qml'
178--- src/qml/messaging-app.qml 2016-07-28 04:14:35 +0000
179+++ src/qml/messaging-app.qml 2016-08-12 18:33:08 +0000
180@@ -197,6 +197,12 @@
181 property bool mainViewIgnoreFirstTimeDialog: false
182 }
183
184+ Settings {
185+ id: msgSettings
186+ category: "SMS"
187+ property bool showCharacterCount: false
188+ }
189+
190 StickerPacksModel {
191 id: stickerPacksModel
192 }

Subscribers

People subscribed via source and target branches