Merge lp:~nik90/ubuntu-clock-app/improve-header-confirmation-behavior into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 336
Merged at revision: 329
Proposed branch: lp:~nik90/ubuntu-clock-app/improve-header-confirmation-behavior
Merge into: lp:ubuntu-clock-app
Diff against target: 456 lines (+175/-32)
10 files modified
app/alarm/AlarmLabel.qml (+17/-6)
app/alarm/AlarmRepeat.qml (+36/-5)
app/alarm/AlarmSound.qml (+27/-1)
debian/changelog (+1/-0)
tests/unit/tst_alarm.qml (+1/-1)
tests/unit/tst_alarmLabel.qml (+47/-11)
tests/unit/tst_alarmRepeat.qml (+18/-1)
tests/unit/tst_alarmSound.qml (+26/-5)
tests/unit/tst_alarmUtils.qml (+1/-1)
tests/unit/tst_worldClock.qml (+1/-1)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/improve-header-confirmation-behavior
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Bartosz Kosiorek Approve
Nekhelesh Ramananthan Abstain
Review via email: mp+267839@code.launchpad.net

Commit message

Fixes the confusing back & save button behaviour in the alarm pages.

Description of the change

This MP fixes the confusing back & save button behaviour in the alarm pages.

Original issue was that the back button was sometimes used for "Saving" & "Going Back". This alternating behaviour was confusing to users as seen in the bug report attached. So according to UX Suggestion, the back button will now behave as "Go Back" or "Cancel" action. While the save button will be the save to confirm your changes.

To post a comment you must log in.
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Need to fix unit tests

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Fixed unit tests

review: Abstain
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

It works perfectly for me

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://91.189.93.70:8080/job/ubuntu-clock-app-autolanding/281/
Executed test runs:
    FAILURE: http://91.189.93.70:8080/job/ubuntu-clock-app-vivid-amd64-autolanding/38/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Autolanding.
Unapproved changes made after approval.
http://91.189.93.70:8080/job/ubuntu-clock-app-autolanding/283/
Executed test runs:
    SUCCESS: http://91.189.93.70:8080/job/ubuntu-clock-app-vivid-amd64-autolanding/40

review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/AlarmLabel.qml'
2--- app/alarm/AlarmLabel.qml 2015-05-27 16:03:23 +0000
3+++ app/alarm/AlarmLabel.qml 2015-08-12 21:01:35 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2014 Canonical Ltd
7+ * Copyright (C) 2014-2015 Canonical Ltd
8 *
9 * This file is part of Ubuntu Clock App
10 *
11@@ -26,6 +26,9 @@
12 // Property to set the alarm label in the edit alarm page
13 property var alarm
14
15+ // Property to store the old alarm label to detect if user changed it or not
16+ property string oldAlarmLabel: alarm.message
17+
18 visible: false
19 title: i18n.tr("Label")
20
21@@ -33,7 +36,19 @@
22 id: backAction
23 iconName: "back"
24 onTriggered: {
25- alarm.message = _labelEntry.text
26+ // Restore old alarm label if user presses the back button
27+ alarm.message = oldAlarmLabel
28+ pop()
29+ }
30+ }
31+
32+ head.actions: Action {
33+ id: saveAction
34+ objectName: "saveAction"
35+ iconName: "tick"
36+ enabled: oldAlarmLabel !== _labelEntry.text.trim() && _labelEntry.text.trim()
37+ onTriggered: {
38+ alarm.message = _labelEntry.text.trim()
39 pop()
40 }
41 }
42@@ -63,10 +78,6 @@
43 text: alarm.message
44 width: parent.width
45 inputMethodHints: Qt.ImhNoPredictiveText
46-
47- onTextChanged: {
48- backAction.enabled = !!text.trim()
49- }
50 }
51 }
52 }
53
54=== modified file 'app/alarm/AlarmRepeat.qml'
55--- app/alarm/AlarmRepeat.qml 2015-06-03 22:49:29 +0000
56+++ app/alarm/AlarmRepeat.qml 2015-08-12 21:01:35 +0000
57@@ -29,9 +29,31 @@
58 // Property to hold the alarm utils functions passed from edit alarm page
59 property var alarmUtils
60
61+ // Property to store the previously set alarm frequency to detect user changes
62+ property int oldAlarmDaysOfWeek
63+
64 visible: false
65 title: i18n.tr("Repeat")
66
67+ // Function to detect if alarm is OneTime or Repeating
68+ function detectAlarmType() {
69+ if (alarm.daysOfWeek > 0) {
70+ alarm.type = Alarm.Repeating
71+ } else {
72+ alarm.type = Alarm.OneTime
73+ }
74+ }
75+
76+ head.backAction: Action {
77+ iconName: "back"
78+ onTriggered: {
79+ // Restore alarm frequency and type if user presses the back button
80+ alarm.daysOfWeek = oldAlarmDaysOfWeek
81+ detectAlarmType()
82+ pop()
83+ }
84+ }
85+
86 head.actions: [
87 Action {
88 text: i18n.tr("Select All")
89@@ -56,6 +78,16 @@
90 }
91 }
92 }
93+ },
94+
95+ Action {
96+ id: saveAction
97+ objectName: "saveAction"
98+ iconName: "tick"
99+ enabled: oldAlarmDaysOfWeek !== alarm.daysOfWeek
100+ onTriggered: {
101+ pop()
102+ }
103 }
104 ]
105
106@@ -69,6 +101,9 @@
107 Component.onCompleted: {
108 if (alarm.type === Alarm.OneTime)
109 alarm.daysOfWeek = 0
110+
111+ // Record the current alarm repeat values (frequency)
112+ oldAlarmDaysOfWeek = alarm.daysOfWeek
113 }
114
115 Component.onDestruction: {
116@@ -147,11 +182,7 @@
117 alarm.daysOfWeek &= ~flag
118 }
119
120- if (alarm.daysOfWeek > 0) {
121- alarm.type = Alarm.Repeating
122- } else {
123- alarm.type = Alarm.OneTime
124- }
125+ detectAlarmType()
126 }
127 }
128
129
130=== modified file 'app/alarm/AlarmSound.qml'
131--- app/alarm/AlarmSound.qml 2015-06-03 22:49:29 +0000
132+++ app/alarm/AlarmSound.qml 2015-08-12 21:01:35 +0000
133@@ -1,5 +1,5 @@
134 /*
135- * Copyright (C) 2014 Canonical Ltd
136+ * Copyright (C) 2014-15 Canonical Ltd
137 *
138 * This file is part of Ubuntu Clock App
139 *
140@@ -37,9 +37,35 @@
141 // Property to set the alarm sound model in the edit alarm page
142 property var soundModel
143
144+ /*
145+ Properties to store the previously set alarm sound values to detect
146+ if the user changed the alarm sound or not
147+ */
148+ property url oldAlarmSoundUrl
149+ property string oldAlarmSoundName
150+
151+ Component.onCompleted: {
152+ // Record the current alarm sound values (url, name)
153+ oldAlarmSoundUrl = alarm.sound
154+ oldAlarmSoundName = alarmSound.subText
155+ }
156+
157 head.backAction: Action {
158 iconName: "back"
159 onTriggered: {
160+ // Restore alarm sound to old values (url, name) if the back button is pressed
161+ alarm.sound = oldAlarmSoundUrl
162+ alarmSound.subText = oldAlarmSoundName
163+ pop()
164+ }
165+ }
166+
167+ head.actions: Action {
168+ id: saveAction
169+ objectName: "saveAction"
170+ iconName: "tick"
171+ enabled: oldAlarmSoundUrl !== alarm.sound
172+ onTriggered: {
173 pop()
174 }
175 }
176
177=== modified file 'debian/changelog'
178--- debian/changelog 2015-08-12 20:45:23 +0000
179+++ debian/changelog 2015-08-12 21:01:35 +0000
180@@ -6,6 +6,7 @@
181
182 [Nekhelesh Ramananthan]
183 * Increase the height of times in the alarm screen (LP: #1365428)
184+ * Fixed the confusing behavior of the confirmation button (LP: #1408015)
185 * Added README.mergeproposal checklist to help with the review process.
186 * Fix alarm interval information being inconsistent (LP: #1466000)
187
188
189=== modified file 'tests/unit/tst_alarm.qml'
190--- tests/unit/tst_alarm.qml 2015-07-15 22:31:52 +0000
191+++ tests/unit/tst_alarm.qml 2015-08-12 21:01:35 +0000
192@@ -1,5 +1,5 @@
193 /*
194- * Copyright (C) 2014 Canonical Ltd
195+ * Copyright (C) 2014-2015 Canonical Ltd
196 *
197 * This file is part of Ubuntu Clock App
198 *
199
200=== modified file 'tests/unit/tst_alarmLabel.qml'
201--- tests/unit/tst_alarmLabel.qml 2015-06-04 21:46:37 +0000
202+++ tests/unit/tst_alarmLabel.qml 2015-08-12 21:01:35 +0000
203@@ -1,5 +1,5 @@
204 /*
205- * Copyright (C) 2014 Canonical Ltd
206+ * Copyright (C) 2014-2015 Canonical Ltd
207 *
208 * This file is part of Ubuntu Clock App
209 *
210@@ -44,12 +44,14 @@
211 property var header
212 property var alarmLabel
213 property var backButton
214+ property var saveButton
215
216 function initTestCase() {
217 alarmLabelPage.visible = true
218 header = findChild(mainView, "MainView_Header")
219 alarmLabel = findChild(alarmLabelPage, "labelEntry")
220 backButton = findChild(header, "customBackButton")
221+ saveButton = findChild(header, "saveAction_header_button")
222 }
223
224 /*
225@@ -60,29 +62,63 @@
226 compare(alarmLabel.focus, true, "Alarm Label does not have focus by default")
227 }
228
229- function test_backButtonEnabled_data() {
230+ function test_saveButtonEnabled_data() {
231 return [
232- {tag: "EmptyAlarmLabel", string: "", enableStatus: false},
233- {tag: "BlankSpacesAlarmLabel", string: " ", enableStatus: false},
234- {tag: "FilledAlarmLabel", string: "Test Label", enableStatus: true}
235+ {tag: "SameAlarmLabel", string: "Alarm", enableStatus: false, error: "Save button is enabled despite no alarm name change!"},
236+ {tag: "EmptyAlarmLabel", string: "", enableStatus: false, error: "Save button is enabled despite alarm name being empty!" },
237+ {tag: "BlankSpacesAlarmLabel", string: " ", enableStatus: false, error: "Save button is enabled despite alarm name being empty!" },
238+ {tag: "FilledAlarmLabel", string: "Test Label", enableStatus: true, error: "Save button is disabled despite alarm name being different!" }
239 ]
240 }
241
242 /*
243- Test to check if the back header button is enabled/disabled correctly
244+ Test to check if the save header button is enabled/disabled correctly
245 for different alarm label scenarios.
246 */
247- function test_backButtonEnabled(data) {
248+ function test_saveButtonEnabled(data) {
249 compare(alarmLabel.text, "Alarm", "Default alarm label is not Alarm")
250- compare(backButton.enabled, true, "Back header button is not enabled by default")
251+ compare(saveButton.enabled, false, "save header button is not disabled despite no alarm name change")
252
253 clearTextField(alarmLabel)
254 typeString(data.string)
255
256 compare(alarmLabel.text, data.string, "Alarm label is not what was type in the textfield")
257- compare(backButton.enabled, data.enableStatus, "Back Button enable status is not as expected")
258-
259- alarmLabel.text = _alarm.message
260+ compare(saveButton.enabled, data.enableStatus, data.error)
261+
262+ alarmLabel.text = _alarm.message
263+ }
264+
265+ /*
266+ Test to check if the back button correctly restores the alarm name to
267+ the old value when the back button is pressed
268+ */
269+
270+ function test_backButtonRestoresValues() {
271+ compare(alarmLabel.text, "Alarm", "Default alarm label is not Alarm")
272+
273+ clearTextField(alarmLabel)
274+ typeString("New Alarm Label")
275+ mouseClick(backButton, centerOf(backButton).x, centerOf(backButton).y)
276+
277+ compare(_alarm.message, "Alarm", "Alarm name is restored to the old value")
278+
279+ alarmLabel.text = _alarm.message
280+ }
281+
282+ /*
283+ Test to check if the save button correctly saves the new alarm name to
284+ the alarm object when the save button is pressed
285+ */
286+ function test_saveButtonSavesNewValues() {
287+ compare(alarmLabel.text, "Alarm", "Default alarm label is not Alarm")
288+ compare(_alarm.message, "Alarm", "Default alarm message is not Alarm")
289+
290+ clearTextField(alarmLabel)
291+ typeString("New Alarm Label")
292+ pressHeaderButton(header, "saveAction")
293+
294+ compare(_alarm.message, "New Alarm Label", "Alarm message has not changed despite pressing the save button")
295+ _alarm.reset()
296 }
297
298 /*
299
300=== modified file 'tests/unit/tst_alarmRepeat.qml'
301--- tests/unit/tst_alarmRepeat.qml 2015-06-04 21:46:37 +0000
302+++ tests/unit/tst_alarmRepeat.qml 2015-08-12 21:01:35 +0000
303@@ -16,7 +16,7 @@
304 * along with this program. If not, see <http://www.gnu.org/licenses/>.
305 */
306
307-import QtQuick 2.0
308+import QtQuick 2.4
309 import QtTest 1.0
310 import Ubuntu.Test 1.0
311 import Ubuntu.Components 1.2
312@@ -59,6 +59,7 @@
313
314 property var header
315 property var backButton
316+ property var saveButton
317 property var repeater
318 property var today: Qt.locale().standaloneDayName(
319 new Date().getDay(), Locale.LongFormat)
320@@ -69,6 +70,7 @@
321 spy.target = alarmRepeatPageLoader.item.Component
322 header = findChild(mainView, "MainView_Header")
323 backButton = findChild(header, "customBackButton")
324+ saveButton = findChild(header, "saveAction_header_button")
325 repeater = findChild(alarmRepeatPageLoader.item, "alarmDays")
326 }
327
328@@ -106,6 +108,21 @@
329 }
330
331 /*
332+ Test to check if the save button is disabled when no changes have been made
333+ and enabled when changes are made.
334+ */
335+ function test_saveButtonIsDisabledOnNoChanges() {
336+ waitForRendering(alarmRepeatPageLoader.item);
337+
338+ tryCompare(_alarm, "daysOfWeek", 0, 3000, "Alarm days of weeks is not 0 by default")
339+ compare(saveButton.enabled, false, "save header button is not disabled despite no alarm frequency change")
340+
341+ var randomDaySwitch = findChild(alarmRepeatPageLoader.item, "daySwitch"+3)
342+ mouseClick(randomDaySwitch, centerOf(randomDaySwitch).x, centerOf(randomDaySwitch).y)
343+ compare(saveButton.enabled, true, "save header button is not disabled despite no alarm frequency change")
344+ }
345+
346+ /*
347 Test to check if the alarm types are being correctly changed when
348 toggling some of the swtiches. So if a switch is toggle, the alarm
349 should become a repeating alarm. if no switches are enabled then
350
351=== modified file 'tests/unit/tst_alarmSound.qml'
352--- tests/unit/tst_alarmSound.qml 2015-06-04 21:46:37 +0000
353+++ tests/unit/tst_alarmSound.qml 2015-08-12 21:01:35 +0000
354@@ -1,5 +1,5 @@
355 /*
356- * Copyright (C) 2014 Canonical Ltd
357+ * Copyright (C) 2014-2015 Canonical Ltd
358 *
359 * This file is part of Ubuntu Clock App
360 *
361@@ -31,6 +31,7 @@
362
363 Alarm {
364 id: _alarm
365+ sound: "file:///usr/share/sounds/ubuntu/ringtones/Bliss.ogg"
366 }
367
368 FolderListModel {
369@@ -55,14 +56,17 @@
370 when: windowShown
371
372 property var repeater
373+ property var saveButton
374
375 function initTestCase() {
376 alarmSoundPage.visible = true
377 repeater = findChild(alarmSoundPage, "alarmSounds")
378+ saveButton = findChild(header, "saveAction_header_button")
379 }
380
381 function cleanup() {
382 alarmSoundPage.alarmSound.subText = "Bliss"
383+ _alarm.sound = "file:///usr/share/sounds/ubuntu/ringtones/Bliss.ogg"
384 for(var i=0; i<repeater.count; i++) {
385 var alarmSoundSwitch = findChild(alarmSoundPage, "soundStatus"+i)
386 var alarmSoundLabel = findChild(alarmSoundPage, "soundName"+i)
387@@ -99,20 +103,19 @@
388 Test to check if only one alarm sound is checked at all times
389 */
390 function test_onlyOneAlarmSoundIsSelected() {
391-
392 // Click on some random alarm sounds
393 var secondSwitch = findChild(alarmSoundPage, "soundStatus"+2)
394 mouseClick(secondSwitch, centerOf(secondSwitch).x, centerOf(secondSwitch).y)
395
396- var fourthSwitch = findChild(alarmSoundPage, "soundStatus"+2)
397- mouseClick(fourthSwitch, centerOf(fourthSwitch.width).x, centerOf(fourthSwitch.height).y)
398+ var fourthSwitch = findChild(alarmSoundPage, "soundStatus"+4)
399+ mouseClick(fourthSwitch, centerOf(fourthSwitch).x, centerOf(fourthSwitch).y)
400
401 // Check if only that alarm sound is check while the rest is disabled
402 for(var i=0; i<repeater.count; i++) {
403 var alarmSoundSwitch = findChild(alarmSoundPage, "soundStatus"+i)
404 var alarmSoundLabel = findChild(alarmSoundPage, "soundName"+i)
405
406- if(i !== 2) {
407+ if(i !== 4) {
408 compare(alarmSoundSwitch.checked, false, "More than one alarm sound selected")
409 }
410 }
411@@ -134,5 +137,23 @@
412 }
413 }
414 }
415+
416+ /*
417+ Test to check if the save button is disabled when no changes have been made
418+ and enabled when changes are made.
419+ */
420+ function test_saveButtonIsDisabledOnNoChanges() {
421+ compare(saveButton.enabled, false, "save header button is not disabled despite no alarm sound change")
422+
423+ // Change sound and check if save button is enabled
424+ var fifthSwitch = findChild(alarmSoundPage, "soundStatus"+5)
425+ mouseClick(fifthSwitch, centerOf(fifthSwitch).x, centerOf(fifthSwitch).y)
426+ compare(saveButton.enabled, true, "save header button is not enabled despite alarm sound change")
427+
428+ // Set sound to old value and check if save button is disabled
429+ var firstSwitch = findChild(alarmSoundPage, "soundStatus"+1)
430+ mouseClick(firstSwitch, centerOf(firstSwitch).x, centerOf(firstSwitch).y)
431+ compare(saveButton.enabled, false, "save header button is not disabled despite no alarm sound change")
432+ }
433 }
434 }
435
436=== modified file 'tests/unit/tst_alarmUtils.qml'
437--- tests/unit/tst_alarmUtils.qml 2015-08-05 13:13:05 +0000
438+++ tests/unit/tst_alarmUtils.qml 2015-08-12 21:01:35 +0000
439@@ -1,5 +1,5 @@
440 /*
441- * Copyright (C) 2014 Canonical Ltd
442+ * Copyright (C) 2014-2015 Canonical Ltd
443 *
444 * This file is part of Ubuntu Clock App
445 *
446
447=== modified file 'tests/unit/tst_worldClock.qml'
448--- tests/unit/tst_worldClock.qml 2015-07-15 22:31:52 +0000
449+++ tests/unit/tst_worldClock.qml 2015-08-12 21:01:35 +0000
450@@ -1,5 +1,5 @@
451 /*
452- * Copyright (C) 2014 Canonical Ltd
453+ * Copyright (C) 2014-2015 Canonical Ltd
454 *
455 * This file is part of Ubuntu Clock App
456 *

Subscribers

People subscribed via source and target branches