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
1=== modified file 'src/qml/Messages.qml'
2--- src/qml/Messages.qml 2015-04-13 13:11:46 +0000
3+++ src/qml/Messages.qml 2015-05-11 17:56:31 +0000
4@@ -185,7 +185,12 @@
5 if (multipleAccounts && !telepathyHelper.defaultMessagingAccount && !settings.messagesDontAsk) {
6 Qt.inputMethod.hide()
7 PopupUtils.open(Qt.createComponent("Dialogs/SetDefaultSIMCardDialog.qml").createObject(messages))
8+ } else {
9+ // FIXME: We only show the swipe tutorial after select the default sim card to avoid problems with the dialog
10+ // Since the dialog will be removed soon we do not expend time refactoring the code to make it visible after the dialog
11+ swipeItemDemo.enable()
12 }
13+
14 return true
15 }
16
17@@ -264,6 +269,12 @@
18 addAttachmentsToModel(sharedAttachmentsTransfer)
19 }
20
21+ onActiveChanged: {
22+ if (active && (eventModel.count > 0)){
23+ swipeItemDemo.enable()
24+ }
25+ }
26+
27 function updateFilters() {
28 if (participants.length == 0) {
29 eventModel.filter = null
30@@ -1005,7 +1016,7 @@
31 for (var i = 0; i < attachments.count; i++) {
32 var attachment = []
33 var item = attachments.get(i)
34- // we dont include smil files. they will be auto generated
35+ // we dont include smil files. they will be auto generated
36 if (item.contentType.toLowerCase() === "application/smil") {
37 continue
38 }
39@@ -1033,4 +1044,19 @@
40 MessageInfoDialog {
41 id: messageInfoDialog
42 }
43+
44+ SwipeItemDemo {
45+ id: swipeItemDemo
46+ objectName: "swipeItemDemo"
47+
48+ property bool parentActive: messages.active
49+
50+ parent: QuickUtils.rootItem(this)
51+ anchors.fill: parent
52+ onStatusChanged: {
53+ if (status === Loader.Ready) {
54+ Qt.inputMethod.hide()
55+ }
56+ }
57+ }
58 }
59
60=== added file 'src/qml/SwipeItemDemo.qml'
61--- src/qml/SwipeItemDemo.qml 1970-01-01 00:00:00 +0000
62+++ src/qml/SwipeItemDemo.qml 2015-05-11 17:56:31 +0000
63@@ -0,0 +1,326 @@
64+/*
65+ * Copyright 2012-2015 Canonical Ltd.
66+ *
67+ * This file is part of dialer-app.
68+ *
69+ * dialer-app is free software; you can redistribute it and/or modify
70+ * it under the terms of the GNU General Public License as published by
71+ * the Free Software Foundation; version 3.
72+ *
73+ * dialer-app is distributed in the hope that it will be useful,
74+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
75+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76+ * GNU General Public License for more details.
77+ *
78+ * You should have received a copy of the GNU General Public License
79+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
80+ */
81+
82+import QtQuick 2.0
83+import QtQuick.Layouts 1.1
84+import Qt.labs.settings 1.0
85+
86+import Ubuntu.Components 1.1
87+import Ubuntu.Contacts 0.1
88+
89+
90+Loader {
91+ id: root
92+
93+ property bool necessary: true
94+ property bool enabled: false
95+
96+
97+ function enable() {
98+ root.enabled = true;
99+ }
100+
101+ function disable() {
102+ if (root.enabled) {
103+ root.necessary = false;
104+ root.enabled = false;
105+ }
106+ }
107+
108+ sourceComponent: necessary && enabled ? listItemDemoComponent : null
109+
110+ Settings {
111+ property alias hintNecessary: root.necessary
112+ }
113+
114+ Component {
115+ id: listItemDemoComponent
116+
117+ Rectangle {
118+ id: rectangleContents
119+
120+ color: "black"
121+ opacity: 0.0
122+ anchors.fill: parent
123+
124+ Behavior on opacity {
125+ UbuntuNumberAnimation {
126+ duration: UbuntuAnimation.SlowDuration
127+ }
128+ }
129+
130+ Button {
131+ id: gotItButton
132+ objectName: "gotItButton"
133+
134+ anchors {
135+ bottom: dragTitle.top
136+ horizontalCenter: parent.horizontalCenter
137+ bottomMargin: units.gu(19)
138+ }
139+ width: units.gu(17)
140+ strokeColor: UbuntuColors.green
141+ text: i18n.tr("Got it")
142+ enabled: !dismissAnimation.running
143+ onClicked: dismissAnimation.start()
144+
145+ InverseMouseArea {
146+ anchors.fill: parent
147+ topmostItem: true
148+ }
149+ }
150+
151+ RowLayout {
152+ id: dragTitle
153+
154+ anchors {
155+ left: parent.left
156+ right: parent.right
157+ bottom: listItem.top
158+ margins: units.gu(1)
159+ }
160+ height: units.gu(3)
161+ spacing: units.gu(2)
162+
163+ Image {
164+ visible: listItem.swipeState === "RightToLeft"
165+ source: Qt.resolvedUrl("./assets/swipe_arrow.svg")
166+ rotation: 180
167+ Layout.preferredWidth: sourceSize.width
168+ height: parent.height
169+ verticalAlignment: Image.AlignVCenter
170+ fillMode: Image.Pad
171+ sourceSize {
172+ width: units.gu(7)
173+ height: units.gu(2)
174+ }
175+ }
176+
177+ Label {
178+ id: dragMessage
179+
180+ Layout.fillWidth: true
181+ height: parent.height
182+ verticalAlignment: Image.AlignVCenter
183+ wrapMode: Text.Wrap
184+ fontSize: "large"
185+ color: "#ffffff"
186+ }
187+
188+ Image {
189+ visible: listItem.swipeState === "LeftToRight"
190+ source: Qt.resolvedUrl("./assets/swipe_arrow.svg")
191+ Layout.preferredWidth: sourceSize.width
192+ height: parent.height
193+ verticalAlignment: Image.AlignVCenter
194+ fillMode: Image.Pad
195+ sourceSize {
196+ width: units.gu(7)
197+ height: units.gu(2)
198+ }
199+ }
200+ }
201+
202+ MessageDelegateFactory {
203+ id: listItem
204+
205+ property int xPos: 0
206+ // message data
207+ property int index: 10
208+ property int textMessageStatus: 1
209+ property var textMessageAttachments: []
210+ property var messageData: null
211+
212+ incoming: true
213+ accountLabel: ""
214+
215+ anchors {
216+ bottom: parent.bottom
217+ bottomMargin: units.gu(8)
218+ left: parent.left
219+ right: parent.right
220+ }
221+
222+ Component.onCompleted: {
223+ messageData = {
224+ "textMessage": i18n.tr("Welcome to your Ubuntu messaging app."),
225+ "timestamp": new Date(),
226+ "textMessageStatus": 1,
227+ "senderId": "self",
228+ "textReadTimestamp": new Date(),
229+ "textMessageAttachments": [],
230+ "newEvent": false,
231+ "accountId": "",
232+ "accountLabel" : ""}
233+ }
234+
235+ rightSideActions: [
236+ Action {
237+ id: infoAction
238+
239+ iconName: "info"
240+ text: i18n.tr("Info")
241+ },
242+ Action {
243+ iconName: "reload"
244+ text: i18n.tr("Retry")
245+ },
246+ Action {
247+ iconName: "edit-copy"
248+ text: i18n.tr("Copy")
249+ }
250+ ]
251+
252+ animated: false
253+ onXPosChanged: listItem.updatePosition(xPos)
254+
255+ }
256+
257+ SequentialAnimation {
258+ id: slideAnimation
259+
260+ readonly property real leftToRightXpos: (-3 * (listItem.actionWidth + units.gu(2)))
261+ readonly property real rightToLeftXpos: listItem.leftActionWidth
262+
263+ loops: Animation.Infinite
264+ running: root.enabled
265+
266+ PropertyAction {
267+ target: dragMessage
268+ property: "text"
269+ value: i18n.tr("Swipe to reveal actions")
270+ }
271+
272+ PropertyAction {
273+ target: dragMessage
274+ property: "horizontalAlignment"
275+ value: Text.AlignLeft
276+ }
277+
278+ ParallelAnimation {
279+ PropertyAnimation {
280+ target: listItem
281+ property: "xPos"
282+ from: 0
283+ to: slideAnimation.leftToRightXpos
284+ duration: 2000
285+ }
286+ PropertyAnimation {
287+ target: dragTitle
288+ property: "opacity"
289+ from: 0
290+ to: 1
291+ duration: UbuntuAnimation.SleepyDuration
292+ }
293+ }
294+
295+ PauseAnimation {
296+ duration: UbuntuAnimation.SleepyDuration
297+ }
298+
299+ ParallelAnimation {
300+ PropertyAnimation {
301+ target: dragTitle
302+ property: "opacity"
303+ to: 0
304+ duration: UbuntuAnimation.SlowDuration
305+ }
306+
307+ PropertyAnimation {
308+ target: listItem
309+ property: "xPos"
310+ from: slideAnimation.leftToRightXpos
311+ to: 0
312+ duration: UbuntuAnimation.SleepyDuration
313+ }
314+ }
315+
316+ PropertyAction {
317+ target: dragMessage
318+ property: "text"
319+ value: i18n.tr("Swipe to delete")
320+ }
321+
322+ PropertyAction {
323+ target: dragMessage
324+ property: "horizontalAlignment"
325+ value: Text.AlignRight
326+ }
327+
328+ ParallelAnimation {
329+ PropertyAnimation {
330+ target: listItem
331+ property: "xPos"
332+ from: 0
333+ to: slideAnimation.rightToLeftXpos
334+ duration: UbuntuAnimation.SleepyDuration
335+ }
336+ PropertyAnimation {
337+ target: dragTitle
338+ property: "opacity"
339+ from: 0
340+ to: 1
341+ duration: UbuntuAnimation.SlowDuration
342+ }
343+ }
344+
345+ PauseAnimation {
346+ duration: UbuntuAnimation.SleepyDuration
347+ }
348+
349+ ParallelAnimation {
350+ PropertyAnimation {
351+ target: dragTitle
352+ property: "opacity"
353+ to: 0
354+ duration: UbuntuAnimation.SlowDuration
355+ }
356+
357+ PropertyAnimation {
358+ target: listItem
359+ property: "xPos"
360+ from: slideAnimation.rightToLeftXpos
361+ to: 0
362+ duration: UbuntuAnimation.SleepyDuration
363+ }
364+ }
365+ }
366+
367+ SequentialAnimation {
368+ id: dismissAnimation
369+
370+ alwaysRunToEnd: true
371+ running: false
372+
373+ UbuntuNumberAnimation {
374+ target: rectangleContents
375+ property: "opacity"
376+ to: 0.0
377+ duration: UbuntuAnimation.SlowDuration
378+ }
379+ ScriptAction {
380+ script: root.disable()
381+ }
382+ }
383+
384+ Component.onCompleted: {
385+ opacity = 0.85
386+ }
387+ }
388+ }
389+}
390
391=== added file 'src/qml/assets/swipe_arrow.svg'
392--- src/qml/assets/swipe_arrow.svg 1970-01-01 00:00:00 +0000
393+++ src/qml/assets/swipe_arrow.svg 2015-05-11 17:56:31 +0000
394@@ -0,0 +1,17 @@
395+<?xml version="1.0" encoding="utf-8"?>
396+<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
397+<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"
398+ viewBox="0 0 96.6 36.7" enable-background="new 0 0 96.6 36.7" xml:space="preserve">
399+<g>
400+
401+ <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="
402+ M96,18.7c-10.5-7.3-21.3-12-21.3-12l0,24"/>
403+ <circle id="circle4146" fill="#DC4B26" cx="69.2" cy="18.3" r="2.4"/>
404+ <circle id="circle4148" fill="#DC4B26" cx="58.5" cy="18.3" r="2.4"/>
405+ <circle id="circle4150" fill="#DC4B26" cx="47.8" cy="18.3" r="2.4"/>
406+ <circle id="circle4152" fill="#DC4B26" cx="37.1" cy="18.3" r="2.4"/>
407+ <circle id="circle4154" fill="#DC4B26" cx="26.4" cy="18.3" r="2.4"/>
408+ <circle id="circle4156" fill="#DC4B26" cx="15.7" cy="18.3" r="2.4"/>
409+</g>
410+<circle id="circle4156_1_" fill="#DC4B26" cx="4.9" cy="18.3" r="2.4"/>
411+</svg>
412
413=== modified file 'tests/autopilot/messaging_app/emulators.py'
414--- tests/autopilot/messaging_app/emulators.py 2015-02-17 16:02:59 +0000
415+++ tests/autopilot/messaging_app/emulators.py 2015-05-11 17:56:31 +0000
416@@ -386,6 +386,10 @@
417
418 return thread_bubble
419
420+ def get_swipe_item_demo(self):
421+ return self.wait_select_single(
422+ 'SwipeItemDemo', objectName='swipeItemDemo', parentActive=True)
423+
424
425 class PageWithBottomEdge(MainView):
426 """An emulator class that makes it easy to interact with the bottom edge
427
428=== modified file 'tests/autopilot/messaging_app/fixture_setup.py'
429--- tests/autopilot/messaging_app/fixture_setup.py 2015-02-18 12:05:36 +0000
430+++ tests/autopilot/messaging_app/fixture_setup.py 2015-05-11 17:56:31 +0000
431@@ -11,14 +11,17 @@
432 import os
433 import subprocess
434 import shutil
435+import tempfile
436
437 import fixtures
438+from ubuntuuitoolkit import fixture_setup
439
440
441 class MessagingTestEnvironment(fixtures.Fixture):
442
443- def __init__(self, use_testdata_db=False):
444+ def __init__(self, use_testdata_db=False, use_empty_config=False):
445 self.use_testdata_db = use_testdata_db
446+ self.use_empty_config = use_empty_config
447
448 def setUp(self):
449 super(MessagingTestEnvironment, self).setUp()
450@@ -27,6 +30,11 @@
451 self.useFixture(FillCustomSmsHistory())
452 else:
453 self.useFixture(UseEmptySmsHistory())
454+ # check for the configuration file
455+ if self.use_empty_config:
456+ self.useFixture(UseEmptyConfiguration())
457+ else:
458+ self.useFixture(UseDefaultConfiguration())
459 self.useFixture(RespawnService())
460
461
462@@ -84,6 +92,38 @@
463 self.database_path = ''
464
465
466+class UseEmptyConfiguration(fixtures.Fixture):
467+
468+ def setUp(self):
469+ super(UseEmptyConfiguration, self).setUp()
470+ self.user_config_dir = tempfile.mkdtemp(
471+ suffix='', prefix='messaging-app')
472+ self.app_config_dir = (
473+ self.user_config_dir + '/com.ubuntu.messaging-app/')
474+ os.makedirs(self.app_config_dir)
475+ self.useFixture(
476+ fixtures.EnvironmentVariable(
477+ 'XDG_CONFIG_HOME', newvalue=self.user_config_dir)
478+ )
479+ self.useFixture(
480+ fixture_setup.InitctlEnvironmentVariable(
481+ XDG_CONFIG_HOME=self.user_config_dir)
482+ )
483+
484+ def tearDown(self):
485+ super(UseEmptyConfiguration, self).tearDown()
486+ shutil.rmtree(self.user_config_dir)
487+
488+
489+class UseDefaultConfiguration(UseEmptyConfiguration):
490+
491+ def setUp(self):
492+ super(UseDefaultConfiguration, self).setUp()
493+ config_file_path = (self.app_config_dir + '/MessagingApp.conf')
494+ with open(config_file_path, 'w') as config_file:
495+ config_file.write('[General]\nhintNecessary=false\n')
496+
497+
498 class RespawnService(fixtures.Fixture):
499
500 def setUp(self):
501
502=== modified file 'tests/autopilot/messaging_app/tests/test_messaging.py'
503--- tests/autopilot/messaging_app/tests/test_messaging.py 2015-02-18 12:21:08 +0000
504+++ tests/autopilot/messaging_app/tests/test_messaging.py 2015-05-11 17:56:31 +0000
505@@ -422,3 +422,57 @@
506 self.messages_view = self.main_view.select_single(
507 emulators.Messages,
508 text='text message')
509+
510+
511+class MessagingTestSwipeToDeleteDemo(MessagingAppTestCase):
512+
513+ def setUp(self):
514+ test_setup = fixture_setup.MessagingTestEnvironment(
515+ use_empty_config=True)
516+ self.useFixture(test_setup)
517+
518+ super(MessagingTestSwipeToDeleteDemo, self).setUp()
519+
520+ def test_write_new_message_with_tutorial(self):
521+ """Verify if the tutorial appears after send a message"""
522+ phone_num = '123'
523+ message = 'hello from Ubuntu'
524+ self.main_view.send_message(phone_num, message)
525+ self.main_view.close_osk()
526+
527+ swipe_item_demo = self.main_view.get_swipe_item_demo()
528+ self.assertThat(swipe_item_demo.enabled, Eventually(Equals(True)))
529+ self.assertThat(swipe_item_demo.necessary, Eventually(Equals(True)))
530+ got_it_button = swipe_item_demo.select_single(
531+ 'Button',
532+ objectName='gotItButton')
533+ self.pointing_device.click_object(got_it_button)
534+ self.assertThat(swipe_item_demo.enabled, Eventually(Equals(False)))
535+ self.assertThat(swipe_item_demo.necessary, Eventually(Equals(False)))
536+
537+ def test_receive_new_message_with_tutorial(self):
538+ """Verify if the tutorial appears after receive a message"""
539+ thread_list = self.app.select_single(objectName='threadList')
540+ self.assertThat(thread_list.visible, Equals(True))
541+ self.assertThat(thread_list.count, Equals(0))
542+
543+ number = '5555555678'
544+ message = 'open me'
545+ # receive message
546+ helpers.receive_sms(number, message)
547+ # verify that we got the message
548+ self.assertThat(thread_list.count, Eventually(Equals(1)))
549+
550+ # click message thread
551+ mess_thread = thread_list.wait_select_single('Label', text=number)
552+ self.pointing_device.click_object(mess_thread)
553+
554+ swipe_item_demo = self.main_view.get_swipe_item_demo()
555+ self.assertThat(swipe_item_demo.enabled, Eventually(Equals(True)))
556+ self.assertThat(swipe_item_demo.necessary, Eventually(Equals(True)))
557+ got_it_button = swipe_item_demo.select_single(
558+ 'Button',
559+ objectName='gotItButton')
560+ self.pointing_device.click_object(got_it_button)
561+ self.assertThat(swipe_item_demo.enabled, Eventually(Equals(False)))
562+ self.assertThat(swipe_item_demo.necessary, Eventually(Equals(False)))

Subscribers

People subscribed via source and target branches