Merge lp:~tiagosh/messaging-app/information-messageType into lp:messaging-app

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Bill Filler
Approved revision: 264
Merged at revision: 262
Proposed branch: lp:~tiagosh/messaging-app/information-messageType
Merge into: lp:messaging-app
Diff against target: 352 lines (+211/-56)
7 files modified
src/qml/AccountSectionDelegate.qml (+75/-0)
src/qml/MessageBubble.qml (+1/-1)
src/qml/MessageDateSection.qml (+2/-0)
src/qml/MessageDelegateFactory.qml (+1/-1)
src/qml/Messages.qml (+16/-2)
src/qml/MessagesListView.qml (+30/-52)
src/qml/RegularMessageDelegate.qml (+86/-0)
To merge this branch: bzr merge lp:~tiagosh/messaging-app/information-messageType
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Bill Filler (community) Approve
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+235860@code.launchpad.net

Commit message

- Add initial support for the new information messageType.
- Notify users when the active sim card was switched.

Description of the change

- Add initial support for the new information messageType.
- Notify users when the active sim card was switched.

--Checklist--
Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~tiagosh/telephony-service/sim-lock/+merge/235505

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/messaging-app) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
Yes

If you changed UI labels, did you update the pot file?
Will be done later.

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

130 + var fakeString = i18n.tr("You switched to %1")
139 + "You switched to %1")

This approach is not good, because if at any time we decide to change the displayed message, the existing events will lose the translation.

Maybe we can use a dynamic message and save a well known eventId or something like that to indicate the event is a SIM switch?

review: Needs Fixing
Revision history for this message
Gustavo Pichorim Boiko (boiko) :
review: Needs Fixing
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
No, but not related to the MR

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

Code looks good and works as expected!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

The last commit for scrolling into view is not working correctly.

- If the keyboard is visible and the list is scrolled all the way to the top, when you receive a new message it does scroll the list but the new message is only partially visible.

- Same with sending a message. If you are scrolled up and send a new message it's only partially visible. If you send a second message it will be fully visible.

Might be better to move this to a separate MR, just so we can land this?

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
262. By Tiago Salem Herrmann

disable highlightFollowsCurrentItem

263. By Tiago Salem Herrmann

update displayLabel on demand

264. By Tiago Salem Herrmann

revert scroll patch

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

works now

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'src/qml/AccountSectionDelegate.qml'
2--- src/qml/AccountSectionDelegate.qml 1970-01-01 00:00:00 +0000
3+++ src/qml/AccountSectionDelegate.qml 2014-10-07 16:50:23 +0000
4@@ -0,0 +1,75 @@
5+/*
6+ * Copyright 2012, 2013, 2014 Canonical Ltd.
7+ *
8+ * This file is part of messaging-app.
9+ *
10+ * messaging-app is free software; you can redistribute it and/or modify
11+ * it under the terms of the GNU General Public License as published by
12+ * the Free Software Foundation; version 3.
13+ *
14+ * messaging-app is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU General Public License
20+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+
23+import QtQuick 2.2
24+
25+import Ubuntu.Components 1.1
26+import Ubuntu.Components.ListItems 0.1 as ListItem
27+import Ubuntu.Contacts 0.1
28+
29+import "dateUtils.js" as DateUtils
30+
31+ListItemWithActions {
32+ property var messageData: null
33+ property int index: -1
34+ property Item delegateItem
35+ property string accountLabel: multipleAccounts ? telepathyHelper.accountForId(messageData.accountId).displayName : ""
36+
37+ height: sectionLabel.height + units.gu(2)
38+ anchors.left: parent.left
39+ anchors.right: parent.right
40+ ListItem.ThinDivider {
41+ id: leftDivider
42+ anchors.verticalCenter: sectionLabel.verticalCenter
43+ anchors.left: parent.left
44+ anchors.right: sectionLabel.left
45+ anchors.rightMargin: 0
46+ anchors.leftMargin: 0
47+ }
48+
49+ ListItem.ThinDivider {
50+ id: rightDivider
51+ anchors.verticalCenter: sectionLabel.verticalCenter
52+ anchors.left: sectionLabel.right
53+ anchors.right: parent.right
54+ anchors.rightMargin: 0
55+ anchors.leftMargin: 0
56+ }
57+
58+ onItemClicked: {
59+ if (root.isInSelectionMode) {
60+ if (!root.selectItem(delegateItem)) {
61+ root.deselectItem(delegateItem)
62+ }
63+ }
64+ }
65+
66+ Label {
67+ id: sectionLabel
68+ anchors.horizontalCenter: parent.horizontalCenter
69+ height: paintedHeight
70+ clip: true
71+ // TRANSLATORS: %1 is the SIM card name and %2 is the timestamp
72+ text: i18n.tr("You switched to %1 @ %2")
73+ .arg(accountLabel)
74+ .arg(DateUtils.formatLogDate(messageData.timestamp))
75+ fontSize: "x-small"
76+ horizontalAlignment: Text.AlignHCenter
77+ }
78+}
79+
80
81=== modified file 'src/qml/MessageBubble.qml'
82--- src/qml/MessageBubble.qml 2014-09-18 12:17:16 +0000
83+++ src/qml/MessageBubble.qml 2014-10-07 16:50:23 +0000
84@@ -130,7 +130,7 @@
85 return ""
86
87 var str = Qt.formatTime(messageTimeStamp).toLowerCase()
88- if (root.accountName.length === 0) {
89+ if (root.accountName.length === 0 || !root.messageIncoming) {
90 return str
91 }
92 str += " @ %1".arg(root.accountName)
93
94=== modified file 'src/qml/MessageDateSection.qml'
95--- src/qml/MessageDateSection.qml 2014-08-11 22:59:14 +0000
96+++ src/qml/MessageDateSection.qml 2014-10-07 16:50:23 +0000
97@@ -34,5 +34,7 @@
98 }
99 ListItem.ThinDivider {
100 anchors.bottom: parent.bottom
101+ anchors.rightMargin: 0
102+ anchors.leftMargin: 0
103 }
104 }
105
106=== modified file 'src/qml/MessageDelegateFactory.qml'
107--- src/qml/MessageDelegateFactory.qml 2014-09-16 20:21:27 +0000
108+++ src/qml/MessageDelegateFactory.qml 2014-10-07 16:50:23 +0000
109@@ -76,7 +76,7 @@
110 Binding {
111 target: loader.item
112 property: "messageData"
113- value: model
114+ value: messageData
115 when: (loader.status === Loader.Ready)
116 }
117 Binding {
118
119=== modified file 'src/qml/Messages.qml'
120--- src/qml/Messages.qml 2014-09-17 15:48:56 +0000
121+++ src/qml/Messages.qml 2014-10-07 16:50:23 +0000
122@@ -857,12 +857,26 @@
123 participants = multiRecipient.recipients
124 }
125 // create the new thread and update the threadId list
126- eventModel.threadIdForParticipants(messages.account.accountId,
127+ var threadId = eventModel.threadIdForParticipants(messages.account.accountId,
128 HistoryThreadModel.EventTypeText,
129 participants,
130 HistoryThreadModel.MatchPhoneNumber,
131 true)
132-
133+ for (var i=0; i < eventModel.count; i++) {
134+ var event = eventModel.get(i)
135+ if (event.senderId == "self" && event.accountId != messages.account.accountId) {
136+ // if the last outgoing message used a different accountId, add an
137+ // information event and quit the loop
138+ eventModel.writeTextInformationEvent(messages.account.accountId,
139+ threadId,
140+ participants,
141+ "")
142+ break;
143+ } else if (event.senderId == "self" && event.accountId == messages.account.accountId) {
144+ // in case last ougoing event used the same accountId, just skip
145+ break;
146+ }
147+ }
148 updateFilters()
149 if (attachments.count > 0) {
150 var newAttachments = []
151
152=== modified file 'src/qml/MessagesListView.qml'
153--- src/qml/MessagesListView.qml 2014-09-16 20:21:27 +0000
154+++ src/qml/MessagesListView.qml 2014-10-07 16:50:23 +0000
155@@ -19,6 +19,7 @@
156 import QtQuick 2.2
157
158 import Ubuntu.Components 1.1
159+import Ubuntu.Components.ListItems 0.1 as ListItem
160 import Ubuntu.Contacts 0.1
161 import Ubuntu.History 0.1
162
163@@ -92,69 +93,46 @@
164 }
165 ]
166
167- listDelegate: Column {
168- id: messageDelegate
169-
170- // WORKAROUND: we can not use sections because the verticalLayoutDirection is ListView.BottomToTop the sections will appear
171- // bellow the item
172- MessageDateSection {
173- text: visible ? DateUtils.friendlyDay(timestamp) : ""
174- anchors {
175- left: parent.left
176- right: parent.right
177- leftMargin: units.gu(2)
178- rightMargin: units.gu(2)
179- }
180- visible: (index === root.count) || !DateUtils.areSameDay(eventModel.get(index+1).timestamp, timestamp)
181- }
182-
183- MessageDelegateFactory {
184- objectName: "message%1".arg(index)
185-
186- incoming: senderId != "self"
187- // TODO: we have several items inside
188- selected: root.isSelected(messageDelegate)
189- selectionMode: root.isInSelectionMode
190- accountLabel: multipleAccounts ? telepathyHelper.accountForId(accountId).displayName : ""
191- rightSideActions: {
192- var actions = []
193- if (textMessageStatus === HistoryThreadModel.MessageStatusPermanentlyFailed) {
194- actions.push(reloadAction)
195- }
196- actions.push(copyAction)
197- actions.push(infoAction)
198- return actions
199- }
200-
201- // TODO: need select only the item
202- onItemClicked: {
203- if (root.isInSelectionMode) {
204- if (!root.selectItem(messageDelegate)) {
205- root.deselectItem(messageDelegate)
206- }
207- }
208- }
209- onItemPressAndHold: {
210- root.startSelection()
211- root.selectItem(messageDelegate)
212- }
213- Component.onCompleted: {
214- if (newEvent) {
215- messages.markMessageAsRead(accountId, threadId, eventId, type);
216- }
217- }
218+ listDelegate: Loader {
219+ id: loader
220+ anchors.left: parent.left
221+ anchors.right: parent.right
222+ height: status == Loader.Ready ? item.height : 0
223+
224+ Component.onCompleted: {
225+ var properties = {"messageData": model}
226+ var sourceFile = textMessageType == HistoryThreadModel.MessageTypeInformation ? "AccountSectionDelegate.qml" : "RegularMessageDelegate.qml"
227+ loader.setSource(sourceFile, properties)
228+ }
229+
230+ Binding {
231+ target: loader.item
232+ property: "index"
233+ value: index
234+ when: (loader.status === Loader.Ready)
235+ }
236+
237+ Binding {
238+ target: loader.item
239+ property: "delegateItem"
240+ value: loader
241+ when: (loader.status === Loader.Ready)
242 }
243 }
244
245 onSelectionDone: {
246+ var removeDividers = (items.count == eventModel.count)
247 for (var i=0; i < items.count; i++) {
248 var event = items.get(i).model
249+ if (!removeDividers && event.textMessageType == HistoryThreadModel.MessageTypeInformation) {
250+ continue;
251+ }
252 eventModel.removeEvent(event.accountId, event.threadId, event.eventId, event.type)
253 }
254 }
255
256 onCountChanged: {
257- // list is in the bootom we should scroll to the new message
258+ // list is in the bottom we should scroll to the new message
259 if (Math.abs(height + contentY) < units.gu(3)) {
260 currentIndex = 0
261 positionViewAtBeginning()
262
263=== added file 'src/qml/RegularMessageDelegate.qml'
264--- src/qml/RegularMessageDelegate.qml 1970-01-01 00:00:00 +0000
265+++ src/qml/RegularMessageDelegate.qml 2014-10-07 16:50:23 +0000
266@@ -0,0 +1,86 @@
267+/*
268+ * Copyright 2012, 2013, 2014 Canonical Ltd.
269+ *
270+ * This file is part of messaging-app.
271+ *
272+ * messaging-app is free software; you can redistribute it and/or modify
273+ * it under the terms of the GNU General Public License as published by
274+ * the Free Software Foundation; version 3.
275+ *
276+ * messaging-app is distributed in the hope that it will be useful,
277+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
278+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
279+ * GNU General Public License for more details.
280+ *
281+ * You should have received a copy of the GNU General Public License
282+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
283+ */
284+
285+import QtQuick 2.2
286+import Ubuntu.History 0.1
287+import "dateUtils.js" as DateUtils
288+
289+Column {
290+ height: childrenRect.height
291+ property var messageData: null
292+ property Item delegateItem
293+ property var timestamp: messageData.timestamp
294+ property string senderId: messageData.senderId
295+ property var textReadTimestamp: messageData.textReadTimestamp
296+ property int textMessageStatus: messageData.textMessageStatus
297+ property var textMessageAttachments: messageData.textMessageAttachments
298+ property bool newEvent: messageData.newEvent
299+ property var textMessage: messageData.textMessage
300+ property string accountId: messageData.accountId
301+ property int index: -1
302+
303+ // WORKAROUND: we can not use sections because the verticalLayoutDirection is ListView.BottomToTop the sections will appear
304+ // bellow the item
305+ MessageDateSection {
306+ text: visible ? DateUtils.friendlyDay(timestamp) : ""
307+ anchors {
308+ left: parent.left
309+ right: parent.right
310+ leftMargin: units.gu(2)
311+ rightMargin: units.gu(2)
312+ }
313+ visible: (index === root.count) || !DateUtils.areSameDay(eventModel.get(index+1).timestamp, timestamp)
314+ }
315+
316+ MessageDelegateFactory {
317+ objectName: "message%1".arg(index)
318+
319+ incoming: senderId != "self"
320+ // TODO: we have several items inside
321+ selected: root.isSelected(delegateItem)
322+ selectionMode: root.isInSelectionMode
323+ accountLabel: multipleAccounts ? telepathyHelper.accountForId(accountId).displayName : ""
324+ rightSideActions: {
325+ var actions = []
326+ if (textMessageStatus === HistoryThreadModel.MessageStatusPermanentlyFailed) {
327+ actions.push(reloadAction)
328+ }
329+ actions.push(copyAction)
330+ actions.push(infoAction)
331+ return actions
332+ }
333+
334+ // TODO: need select only the item
335+ onItemClicked: {
336+ if (root.isInSelectionMode) {
337+ if (!root.selectItem(delegateItem)) {
338+ root.deselectItem(delegateItem)
339+ }
340+ }
341+ }
342+ onItemPressAndHold: {
343+ root.startSelection()
344+ root.selectItem(delegateItem)
345+ }
346+ Component.onCompleted: {
347+ if (newEvent) {
348+ messages.markMessageAsRead(accountId, threadId, eventId, type);
349+ }
350+ }
351+ }
352+}

Subscribers

People subscribed via source and target branches