Merge lp:~nik90/ubuntu-clock-app/fix-invalid-alarm-model into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 354
Merged at revision: 354
Proposed branch: lp:~nik90/ubuntu-clock-app/fix-invalid-alarm-model
Merge into: lp:ubuntu-clock-app
Diff against target: 89 lines (+38/-1)
4 files modified
app/alarm/AlarmPage.qml (+2/-0)
app/ubuntu-clock-app.qml (+5/-1)
debian/changelog (+2/-0)
tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu (+29/-0)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/fix-invalid-alarm-model
Reviewer Review Type Date Requested Status
Bartosz Kosiorek Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+268838@code.launchpad.net

Commit message

Fixes the issue where an edited alarm is not saveable after importing a new custom sound from the music app.

Description of the change

This MP fixes the issue where an edited alarm is not saveable after importing a new custom sound from the music app.

Background Info
---------------
We reload the Alarms Model whenever the clock app loses focus. This was done a long time ago to fix the issue of one-time alarms that rang not appearing switched off after they were switched off by indicator-datetime.

That's when an idea struck us that clock app loses focus when the user proceed to dismiss the one-time alarm notification and we can use that signal (losing focus) to quickly reload the alarms model.

Reloading the Alarms Model causes the UI to refresh, which thereby then shows the correct alarm switch value.

Current Situation
-----------------
However it turns out that when in the EditAlarmPage, if clock app loses focus due to switching to the music app, the tempAlarm variable loses track of the alarm we were editing since the Alarms Model reloaded silently in the background. As a result, saving an edited alarm after importing a new custom sound from music-app results in an error that tempAlarm is undefined :-)

Solution
--------
I have made the Alarms Model to reload *only* when in the MainPage or the AlarmsPage (basically when the alarms list is visible in the UI and requires refreshing). This thereby fixes the critical bug for good.

I have also added a manual test to ensure that this bug is never introduced accidentally in future versions of the clock app.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
353. By Nekhelesh Ramananthan

Made the isAlarmPage and isMainPage properties readonly for good measure

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

Merged lp:ubuntu-clock-app

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
Bartosz Kosiorek (gang65) wrote :

It is working for me correctly.

Unfortunately time needed to run is very high.
You did everything what was needed according to checklist.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/AlarmPage.qml'
2--- app/alarm/AlarmPage.qml 2015-08-14 05:34:49 +0000
3+++ app/alarm/AlarmPage.qml 2015-08-23 09:02:04 +0000
4@@ -22,6 +22,8 @@
5 Page {
6 id: alarmPage
7
8+ readonly property bool isAlarmPage: true
9+
10 title: i18n.tr("Alarms")
11 objectName: 'AlarmPage'
12 flickable: null
13
14=== modified file 'app/ubuntu-clock-app.qml'
15--- app/ubuntu-clock-app.qml 2015-08-20 23:19:35 +0000
16+++ app/ubuntu-clock-app.qml 2015-08-23 09:02:04 +0000
17@@ -95,7 +95,9 @@
18 Reload the alarm model when the clock app gains focus to refresh
19 the alarm page UI in the case of alarm notifications.
20 */
21- if(applicationState && !mainPage.isColdStart) {
22+ if(applicationState && !mainPage.isColdStart && (mainStack.currentPage.isMainPage
23+ || mainStack.currentPage.isAlarmPage)) {
24+ console.log("[LOG]: Alarm Database unloaded")
25 alarmModelLoader.source = ""
26 alarmModelLoader.source = Qt.resolvedUrl("alarm/AlarmModelComponent.qml")
27 }
28@@ -109,6 +111,8 @@
29 MainPage {
30 id: mainPage
31
32+ readonly property bool isMainPage: true
33+
34 Loader {
35 id: alarmModelLoader
36 asynchronous: false
37
38=== modified file 'debian/changelog'
39--- debian/changelog 2015-08-22 21:19:54 +0000
40+++ debian/changelog 2015-08-23 09:02:04 +0000
41@@ -25,6 +25,8 @@
42 alarm sound page not visible. (LP: #1487699)
43 * Select the newly imported custom sound automatically (LP: #1487689)
44 * Fixed alarm sound preview not playing when pressing on the checkbox (LP: #1487690)
45+ * Fixed edited alarm not being saveable if at any point of editing the alarm
46+ clock app loses focus (LP: #1487789)
47
48 [Victor Thompson]
49 * Show all README files in QtCreator
50
51=== modified file 'tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu'
52--- tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu 2015-01-21 02:35:03 +0000
53+++ tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu 2015-08-23 09:02:04 +0000
54@@ -49,6 +49,35 @@
55 9. Press "Ok" to dismiss the alarm.
56 The alarm should be dismissed.
57
58+id: alarm/edit-alarm-focus
59+plugin: manual
60+depends: alarm/trigger-alarm
61+_summary: Edit Alarm focus test
62+estimated_duration: 660
63+_description:
64+ This test check if an edited alarm is saveable even when clock app loses focus during the test.
65+ 1. Launch the clock app.
66+ Clock app opens showing the current local time.
67+ 2. Swipe the bottom edge to open the alarms page.
68+ Alarms page should appear showing a list of alarm. If empty then you should see a
69+ message being displayed that "No saved alarms".
70+ 3. Press the plus icon to create a new alarm. Change the alarm time to ring in the next
71+ minute. Do not change any other options. Save Alarm.
72+ The saved alarm should be displayed in the alarms page.
73+ 4. Press the saved alarm to edit it.
74+ The edit alarm page should be visible with the values set in the previous step.
75+ 5. Swipe from the right-edge briefly.
76+ The Unity dash should be visible
77+ 6. Swipe again from the right-edge briefly.
78+ The clock app should now be visible
79+ 7. Change the alarm time to ring in the next minute. Do not change any other options. Save Alarm.
80+ The saved alarm should be displayed in the alarms page.
81+ 8. Wait for the alarm to ring.
82+ The alarm should ring (with haptic feedback) at the time set in the previous step and
83+ should show a notification with the buttons "Snooze" and "Ok".
84+ 9. Press "Ok" to dismiss the alarm.
85+ The alarm should be dismissed.
86+
87 id: alarm/silence-setting
88 plugin: manual
89 depends: alarm/trigger-alarm

Subscribers

People subscribed via source and target branches