Merge lp:~renatofilho/messaging-app/swipe-item-demo into lp:messaging-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 366
Merged at revision: 355
Proposed branch: lp:~renatofilho/messaging-app/swipe-item-demo
Merge into: lp:messaging-app
Diff against target: 562 lines (+469/-2)
6 files modified
src/qml/Messages.qml (+27/-1)
src/qml/SwipeItemDemo.qml (+326/-0)
src/qml/assets/swipe_arrow.svg (+17/-0)
tests/autopilot/messaging_app/emulators.py (+4/-0)
tests/autopilot/messaging_app/fixture_setup.py (+41/-1)
tests/autopilot/messaging_app/tests/test_messaging.py (+54/-0)
To merge this branch: bzr merge lp:~renatofilho/messaging-app/swipe-item-demo
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Tiago Salem Herrmann (community) Needs Fixing
Review via email: mp+257706@code.launchpad.net

Commit message

Show a swipe item demo during the first launch.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
355. By Renato Araujo Oliveira Filho

Update swipe item demo visuals.

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

you added a png file but the code is trying to access an svg file.
also, not sure if the Ubuntu.Contacts include is needed.

review: Needs Fixing
356. By Renato Araujo Oliveira Filho

Added missing svg file.

357. By Renato Araujo Oliveira Filho

Show swipe demo after send a message if necessary.

358. By Renato Araujo Oliveira Filho

Created autopilot tests.

359. By Renato Araujo Oliveira Filho

Fixed pep8.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
360. By Renato Araujo Oliveira Filho

Fixed flake8.

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: Needs Fixing (continuous-integration)
361. By Renato Araujo Oliveira Filho

Fixed autopilot tests on device.

362. By Renato Araujo Oliveira Filho

Created animations for the tutorial appear and desapear

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
363. By Renato Araujo Oliveira Filho

Added a fade out on texts during the animation.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
364. By Renato Araujo Oliveira Filho

Fixed flake8 warnings.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

Are there any related MPs required for this MP to build/function as expected?
 - lp:~renatofilho/address-book-app/list-with-actions-animated

Is your branch in sync with latest trunk?
 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 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?
 NO, Will be updated in a diff MR

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
 NO PACKAGE CHANGED

365. By Renato Araujo Oliveira Filho

Fixed autopilot test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
366. By Renato Araujo Oliveira Filho

Fixed fade-out animation.

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 :

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 changes.

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

review: Approve
367. By Renato Araujo Oliveira Filho

Does not show swipe demo if the default sim card is not selected.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/qml/Messages.qml'
--- src/qml/Messages.qml 2015-04-13 13:11:46 +0000
+++ src/qml/Messages.qml 2015-05-11 17:56:31 +0000
@@ -185,7 +185,12 @@
185 if (multipleAccounts && !telepathyHelper.defaultMessagingAccount && !settings.messagesDontAsk) {185 if (multipleAccounts && !telepathyHelper.defaultMessagingAccount && !settings.messagesDontAsk) {
186 Qt.inputMethod.hide()186 Qt.inputMethod.hide()
187 PopupUtils.open(Qt.createComponent("Dialogs/SetDefaultSIMCardDialog.qml").createObject(messages))187 PopupUtils.open(Qt.createComponent("Dialogs/SetDefaultSIMCardDialog.qml").createObject(messages))
188 } else {
189 // FIXME: We only show the swipe tutorial after select the default sim card to avoid problems with the dialog
190 // Since the dialog will be removed soon we do not expend time refactoring the code to make it visible after the dialog
191 swipeItemDemo.enable()
188 }192 }
193
189 return true194 return true
190 }195 }
191196
@@ -264,6 +269,12 @@
264 addAttachmentsToModel(sharedAttachmentsTransfer)269 addAttachmentsToModel(sharedAttachmentsTransfer)
265 }270 }
266271
272 onActiveChanged: {
273 if (active && (eventModel.count > 0)){
274 swipeItemDemo.enable()
275 }
276 }
277
267 function updateFilters() {278 function updateFilters() {
268 if (participants.length == 0) {279 if (participants.length == 0) {
269 eventModel.filter = null280 eventModel.filter = null
@@ -1005,7 +1016,7 @@
1005 for (var i = 0; i < attachments.count; i++) {1016 for (var i = 0; i < attachments.count; i++) {
1006 var attachment = []1017 var attachment = []
1007 var item = attachments.get(i)1018 var item = attachments.get(i)
1008 // we dont include smil files. they will be auto generated 1019 // we dont include smil files. they will be auto generated
1009 if (item.contentType.toLowerCase() === "application/smil") {1020 if (item.contentType.toLowerCase() === "application/smil") {
1010 continue1021 continue
1011 }1022 }
@@ -1033,4 +1044,19 @@
1033 MessageInfoDialog {1044 MessageInfoDialog {
1034 id: messageInfoDialog1045 id: messageInfoDialog
1035 }1046 }
1047
1048 SwipeItemDemo {
1049 id: swipeItemDemo
1050 objectName: "swipeItemDemo"
1051
1052 property bool parentActive: messages.active
1053
1054 parent: QuickUtils.rootItem(this)
1055 anchors.fill: parent
1056 onStatusChanged: {
1057 if (status === Loader.Ready) {
1058 Qt.inputMethod.hide()
1059 }
1060 }
1061 }
1036}1062}
10371063
=== added file 'src/qml/SwipeItemDemo.qml'
--- src/qml/SwipeItemDemo.qml 1970-01-01 00:00:00 +0000
+++ src/qml/SwipeItemDemo.qml 2015-05-11 17:56:31 +0000
@@ -0,0 +1,326 @@
1/*
2 * Copyright 2012-2015 Canonical Ltd.
3 *
4 * This file is part of dialer-app.
5 *
6 * dialer-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * dialer-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 2.0
20import QtQuick.Layouts 1.1
21import Qt.labs.settings 1.0
22
23import Ubuntu.Components 1.1
24import Ubuntu.Contacts 0.1
25
26
27Loader {
28 id: root
29
30 property bool necessary: true
31 property bool enabled: false
32
33
34 function enable() {
35 root.enabled = true;
36 }
37
38 function disable() {
39 if (root.enabled) {
40 root.necessary = false;
41 root.enabled = false;
42 }
43 }
44
45 sourceComponent: necessary && enabled ? listItemDemoComponent : null
46
47 Settings {
48 property alias hintNecessary: root.necessary
49 }
50
51 Component {
52 id: listItemDemoComponent
53
54 Rectangle {
55 id: rectangleContents
56
57 color: "black"
58 opacity: 0.0
59 anchors.fill: parent
60
61 Behavior on opacity {
62 UbuntuNumberAnimation {
63 duration: UbuntuAnimation.SlowDuration
64 }
65 }
66
67 Button {
68 id: gotItButton
69 objectName: "gotItButton"
70
71 anchors {
72 bottom: dragTitle.top
73 horizontalCenter: parent.horizontalCenter
74 bottomMargin: units.gu(19)
75 }
76 width: units.gu(17)
77 strokeColor: UbuntuColors.green
78 text: i18n.tr("Got it")
79 enabled: !dismissAnimation.running
80 onClicked: dismissAnimation.start()
81
82 InverseMouseArea {
83 anchors.fill: parent
84 topmostItem: true
85 }
86 }
87
88 RowLayout {
89 id: dragTitle
90
91 anchors {
92 left: parent.left
93 right: parent.right
94 bottom: listItem.top
95 margins: units.gu(1)
96 }
97 height: units.gu(3)
98 spacing: units.gu(2)
99
100 Image {
101 visible: listItem.swipeState === "RightToLeft"
102 source: Qt.resolvedUrl("./assets/swipe_arrow.svg")
103 rotation: 180
104 Layout.preferredWidth: sourceSize.width
105 height: parent.height
106 verticalAlignment: Image.AlignVCenter
107 fillMode: Image.Pad
108 sourceSize {
109 width: units.gu(7)
110 height: units.gu(2)
111 }
112 }
113
114 Label {
115 id: dragMessage
116
117 Layout.fillWidth: true
118 height: parent.height
119 verticalAlignment: Image.AlignVCenter
120 wrapMode: Text.Wrap
121 fontSize: "large"
122 color: "#ffffff"
123 }
124
125 Image {
126 visible: listItem.swipeState === "LeftToRight"
127 source: Qt.resolvedUrl("./assets/swipe_arrow.svg")
128 Layout.preferredWidth: sourceSize.width
129 height: parent.height
130 verticalAlignment: Image.AlignVCenter
131 fillMode: Image.Pad
132 sourceSize {
133 width: units.gu(7)
134 height: units.gu(2)
135 }
136 }
137 }
138
139 MessageDelegateFactory {
140 id: listItem
141
142 property int xPos: 0
143 // message data
144 property int index: 10
145 property int textMessageStatus: 1
146 property var textMessageAttachments: []
147 property var messageData: null
148
149 incoming: true
150 accountLabel: ""
151
152 anchors {
153 bottom: parent.bottom
154 bottomMargin: units.gu(8)
155 left: parent.left
156 right: parent.right
157 }
158
159 Component.onCompleted: {
160 messageData = {
161 "textMessage": i18n.tr("Welcome to your Ubuntu messaging app."),
162 "timestamp": new Date(),
163 "textMessageStatus": 1,
164 "senderId": "self",
165 "textReadTimestamp": new Date(),
166 "textMessageAttachments": [],
167 "newEvent": false,
168 "accountId": "",
169 "accountLabel" : ""}
170 }
171
172 rightSideActions: [
173 Action {
174 id: infoAction
175
176 iconName: "info"
177 text: i18n.tr("Info")
178 },
179 Action {
180 iconName: "reload"
181 text: i18n.tr("Retry")
182 },
183 Action {
184 iconName: "edit-copy"
185 text: i18n.tr("Copy")
186 }
187 ]
188
189 animated: false
190 onXPosChanged: listItem.updatePosition(xPos)
191
192 }
193
194 SequentialAnimation {
195 id: slideAnimation
196
197 readonly property real leftToRightXpos: (-3 * (listItem.actionWidth + units.gu(2)))
198 readonly property real rightToLeftXpos: listItem.leftActionWidth
199
200 loops: Animation.Infinite
201 running: root.enabled
202
203 PropertyAction {
204 target: dragMessage
205 property: "text"
206 value: i18n.tr("Swipe to reveal actions")
207 }
208
209 PropertyAction {
210 target: dragMessage
211 property: "horizontalAlignment"
212 value: Text.AlignLeft
213 }
214
215 ParallelAnimation {
216 PropertyAnimation {
217 target: listItem
218 property: "xPos"
219 from: 0
220 to: slideAnimation.leftToRightXpos
221 duration: 2000
222 }
223 PropertyAnimation {
224 target: dragTitle
225 property: "opacity"
226 from: 0
227 to: 1
228 duration: UbuntuAnimation.SleepyDuration
229 }
230 }
231
232 PauseAnimation {
233 duration: UbuntuAnimation.SleepyDuration
234 }
235
236 ParallelAnimation {
237 PropertyAnimation {
238 target: dragTitle
239 property: "opacity"
240 to: 0
241 duration: UbuntuAnimation.SlowDuration
242 }
243
244 PropertyAnimation {
245 target: listItem
246 property: "xPos"
247 from: slideAnimation.leftToRightXpos
248 to: 0
249 duration: UbuntuAnimation.SleepyDuration
250 }
251 }
252
253 PropertyAction {
254 target: dragMessage
255 property: "text"
256 value: i18n.tr("Swipe to delete")
257 }
258
259 PropertyAction {
260 target: dragMessage
261 property: "horizontalAlignment"
262 value: Text.AlignRight
263 }
264
265 ParallelAnimation {
266 PropertyAnimation {
267 target: listItem
268 property: "xPos"
269 from: 0
270 to: slideAnimation.rightToLeftXpos
271 duration: UbuntuAnimation.SleepyDuration
272 }
273 PropertyAnimation {
274 target: dragTitle
275 property: "opacity"
276 from: 0
277 to: 1
278 duration: UbuntuAnimation.SlowDuration
279 }
280 }
281
282 PauseAnimation {
283 duration: UbuntuAnimation.SleepyDuration
284 }
285
286 ParallelAnimation {
287 PropertyAnimation {
288 target: dragTitle
289 property: "opacity"
290 to: 0
291 duration: UbuntuAnimation.SlowDuration
292 }
293
294 PropertyAnimation {
295 target: listItem
296 property: "xPos"
297 from: slideAnimation.rightToLeftXpos
298 to: 0
299 duration: UbuntuAnimation.SleepyDuration
300 }
301 }
302 }
303
304 SequentialAnimation {
305 id: dismissAnimation
306
307 alwaysRunToEnd: true
308 running: false
309
310 UbuntuNumberAnimation {
311 target: rectangleContents
312 property: "opacity"
313 to: 0.0
314 duration: UbuntuAnimation.SlowDuration
315 }
316 ScriptAction {
317 script: root.disable()
318 }
319 }
320
321 Component.onCompleted: {
322 opacity = 0.85
323 }
324 }
325 }
326}
0327
=== added file 'src/qml/assets/swipe_arrow.svg'
--- src/qml/assets/swipe_arrow.svg 1970-01-01 00:00:00 +0000
+++ src/qml/assets/swipe_arrow.svg 2015-05-11 17:56:31 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4 viewBox="0 0 96.6 36.7" enable-background="new 0 0 96.6 36.7" xml:space="preserve">
5<g>
6
7 <path id="path2194-5_2_" inkscape:connector-curvature="0" sodipodi:nodetypes="ccsssccc" inkscape:transform-center-x="-0.02188882" inkscape:transform-center-y="-31.980969" fill="#DC4B26" d="
8 M96,18.7c-10.5-7.3-21.3-12-21.3-12l0,24"/>
9 <circle id="circle4146" fill="#DC4B26" cx="69.2" cy="18.3" r="2.4"/>
10 <circle id="circle4148" fill="#DC4B26" cx="58.5" cy="18.3" r="2.4"/>
11 <circle id="circle4150" fill="#DC4B26" cx="47.8" cy="18.3" r="2.4"/>
12 <circle id="circle4152" fill="#DC4B26" cx="37.1" cy="18.3" r="2.4"/>
13 <circle id="circle4154" fill="#DC4B26" cx="26.4" cy="18.3" r="2.4"/>
14 <circle id="circle4156" fill="#DC4B26" cx="15.7" cy="18.3" r="2.4"/>
15</g>
16<circle id="circle4156_1_" fill="#DC4B26" cx="4.9" cy="18.3" r="2.4"/>
17</svg>
018
=== modified file 'tests/autopilot/messaging_app/emulators.py'
--- tests/autopilot/messaging_app/emulators.py 2015-02-17 16:02:59 +0000
+++ tests/autopilot/messaging_app/emulators.py 2015-05-11 17:56:31 +0000
@@ -386,6 +386,10 @@
386386
387 return thread_bubble387 return thread_bubble
388388
389 def get_swipe_item_demo(self):
390 return self.wait_select_single(
391 'SwipeItemDemo', objectName='swipeItemDemo', parentActive=True)
392
389393
390class PageWithBottomEdge(MainView):394class PageWithBottomEdge(MainView):
391 """An emulator class that makes it easy to interact with the bottom edge395 """An emulator class that makes it easy to interact with the bottom edge
392396
=== modified file 'tests/autopilot/messaging_app/fixture_setup.py'
--- tests/autopilot/messaging_app/fixture_setup.py 2015-02-18 12:05:36 +0000
+++ tests/autopilot/messaging_app/fixture_setup.py 2015-05-11 17:56:31 +0000
@@ -11,14 +11,17 @@
11import os11import os
12import subprocess12import subprocess
13import shutil13import shutil
14import tempfile
1415
15import fixtures16import fixtures
17from ubuntuuitoolkit import fixture_setup
1618
1719
18class MessagingTestEnvironment(fixtures.Fixture):20class MessagingTestEnvironment(fixtures.Fixture):
1921
20 def __init__(self, use_testdata_db=False):22 def __init__(self, use_testdata_db=False, use_empty_config=False):
21 self.use_testdata_db = use_testdata_db23 self.use_testdata_db = use_testdata_db
24 self.use_empty_config = use_empty_config
2225
23 def setUp(self):26 def setUp(self):
24 super(MessagingTestEnvironment, self).setUp()27 super(MessagingTestEnvironment, self).setUp()
@@ -27,6 +30,11 @@
27 self.useFixture(FillCustomSmsHistory())30 self.useFixture(FillCustomSmsHistory())
28 else:31 else:
29 self.useFixture(UseEmptySmsHistory())32 self.useFixture(UseEmptySmsHistory())
33 # check for the configuration file
34 if self.use_empty_config:
35 self.useFixture(UseEmptyConfiguration())
36 else:
37 self.useFixture(UseDefaultConfiguration())
30 self.useFixture(RespawnService())38 self.useFixture(RespawnService())
3139
3240
@@ -84,6 +92,38 @@
84 self.database_path = ''92 self.database_path = ''
8593
8694
95class UseEmptyConfiguration(fixtures.Fixture):
96
97 def setUp(self):
98 super(UseEmptyConfiguration, self).setUp()
99 self.user_config_dir = tempfile.mkdtemp(
100 suffix='', prefix='messaging-app')
101 self.app_config_dir = (
102 self.user_config_dir + '/com.ubuntu.messaging-app/')
103 os.makedirs(self.app_config_dir)
104 self.useFixture(
105 fixtures.EnvironmentVariable(
106 'XDG_CONFIG_HOME', newvalue=self.user_config_dir)
107 )
108 self.useFixture(
109 fixture_setup.InitctlEnvironmentVariable(
110 XDG_CONFIG_HOME=self.user_config_dir)
111 )
112
113 def tearDown(self):
114 super(UseEmptyConfiguration, self).tearDown()
115 shutil.rmtree(self.user_config_dir)
116
117
118class UseDefaultConfiguration(UseEmptyConfiguration):
119
120 def setUp(self):
121 super(UseDefaultConfiguration, self).setUp()
122 config_file_path = (self.app_config_dir + '/MessagingApp.conf')
123 with open(config_file_path, 'w') as config_file:
124 config_file.write('[General]\nhintNecessary=false\n')
125
126
87class RespawnService(fixtures.Fixture):127class RespawnService(fixtures.Fixture):
88128
89 def setUp(self):129 def setUp(self):
90130
=== modified file 'tests/autopilot/messaging_app/tests/test_messaging.py'
--- tests/autopilot/messaging_app/tests/test_messaging.py 2015-02-18 12:21:08 +0000
+++ tests/autopilot/messaging_app/tests/test_messaging.py 2015-05-11 17:56:31 +0000
@@ -422,3 +422,57 @@
422 self.messages_view = self.main_view.select_single(422 self.messages_view = self.main_view.select_single(
423 emulators.Messages,423 emulators.Messages,
424 text='text message')424 text='text message')
425
426
427class MessagingTestSwipeToDeleteDemo(MessagingAppTestCase):
428
429 def setUp(self):
430 test_setup = fixture_setup.MessagingTestEnvironment(
431 use_empty_config=True)
432 self.useFixture(test_setup)
433
434 super(MessagingTestSwipeToDeleteDemo, self).setUp()
435
436 def test_write_new_message_with_tutorial(self):
437 """Verify if the tutorial appears after send a message"""
438 phone_num = '123'
439 message = 'hello from Ubuntu'
440 self.main_view.send_message(phone_num, message)
441 self.main_view.close_osk()
442
443 swipe_item_demo = self.main_view.get_swipe_item_demo()
444 self.assertThat(swipe_item_demo.enabled, Eventually(Equals(True)))
445 self.assertThat(swipe_item_demo.necessary, Eventually(Equals(True)))
446 got_it_button = swipe_item_demo.select_single(
447 'Button',
448 objectName='gotItButton')
449 self.pointing_device.click_object(got_it_button)
450 self.assertThat(swipe_item_demo.enabled, Eventually(Equals(False)))
451 self.assertThat(swipe_item_demo.necessary, Eventually(Equals(False)))
452
453 def test_receive_new_message_with_tutorial(self):
454 """Verify if the tutorial appears after receive a message"""
455 thread_list = self.app.select_single(objectName='threadList')
456 self.assertThat(thread_list.visible, Equals(True))
457 self.assertThat(thread_list.count, Equals(0))
458
459 number = '5555555678'
460 message = 'open me'
461 # receive message
462 helpers.receive_sms(number, message)
463 # verify that we got the message
464 self.assertThat(thread_list.count, Eventually(Equals(1)))
465
466 # click message thread
467 mess_thread = thread_list.wait_select_single('Label', text=number)
468 self.pointing_device.click_object(mess_thread)
469
470 swipe_item_demo = self.main_view.get_swipe_item_demo()
471 self.assertThat(swipe_item_demo.enabled, Eventually(Equals(True)))
472 self.assertThat(swipe_item_demo.necessary, Eventually(Equals(True)))
473 got_it_button = swipe_item_demo.select_single(
474 'Button',
475 objectName='gotItButton')
476 self.pointing_device.click_object(got_it_button)
477 self.assertThat(swipe_item_demo.enabled, Eventually(Equals(False)))
478 self.assertThat(swipe_item_demo.necessary, Eventually(Equals(False)))

Subscribers

People subscribed via source and target branches