← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

Nekhelesh Ramananthan has proposed merging lp:~nik90/ubuntu-clock-app/fix-invalid-alarm-model into lp:ubuntu-clock-app.

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

Requested reviews:
  Ubuntu Clock Developers (ubuntu-clock-dev)
Related bugs:
  Bug #1487789 in Ubuntu Clock App: "Edited alarm cannot be saved if any point clock app loses focus"
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1487789

For more details, see:
https://code.launchpad.net/~nik90/ubuntu-clock-app/fix-invalid-alarm-model/+merge/268838

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 of one-time alarms that rang not appearing off after they were switched off by the user. 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. 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.
-- 
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~nik90/ubuntu-clock-app/fix-invalid-alarm-model into lp:ubuntu-clock-app.
=== modified file 'app/alarm/AlarmPage.qml'
--- app/alarm/AlarmPage.qml	2015-08-14 05:34:49 +0000
+++ app/alarm/AlarmPage.qml	2015-08-23 00:39:28 +0000
@@ -22,6 +22,8 @@
 Page {
     id: alarmPage
 
+    property bool isAlarmPage: true
+
     title: i18n.tr("Alarms")
     objectName: 'AlarmPage'
     flickable: null

=== modified file 'app/ubuntu-clock-app.qml'
--- app/ubuntu-clock-app.qml	2015-08-20 23:19:35 +0000
+++ app/ubuntu-clock-app.qml	2015-08-23 00:39:28 +0000
@@ -95,7 +95,9 @@
          Reload the alarm model when the clock app gains focus to refresh
          the alarm page UI in the case of alarm notifications.
         */
-        if(applicationState && !mainPage.isColdStart) {
+        if(applicationState && !mainPage.isColdStart && (mainStack.currentPage.isMainPage
+                || mainStack.currentPage.isAlarmPage)) {
+            console.log("[LOG]: Alarm Database unloaded")
             alarmModelLoader.source = ""
             alarmModelLoader.source = Qt.resolvedUrl("alarm/AlarmModelComponent.qml")
         }
@@ -109,6 +111,8 @@
         MainPage {
             id: mainPage
 
+            property bool isMainPage: true
+
             Loader {
                 id: alarmModelLoader
                 asynchronous: false

=== modified file 'debian/changelog'
--- debian/changelog	2015-08-22 13:42:20 +0000
+++ debian/changelog	2015-08-23 00:39:28 +0000
@@ -24,6 +24,8 @@
     alarm sound page not visible. (LP: #1487699)
   * Select the newly imported custom sound automatically (LP: #1487689)
   * Fixed alarm sound preview not playing when pressing on the checkbox (LP: #1487690)
+  * Fixed edited alarm not being saveable if at any point of editing the alarm
+    clock app loses focus (LP: #1487789)
 
   [Victor Thompson]
   * Show all README files in QtCreator 

=== modified file 'tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu'
--- tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu	2015-01-21 02:35:03 +0000
+++ tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu	2015-08-23 00:39:28 +0000
@@ -49,6 +49,35 @@
     9. Press "Ok" to dismiss the alarm.
         The alarm should be dismissed.
 
+id: alarm/edit-alarm-focus
+plugin: manual
+depends: alarm/trigger-alarm
+_summary: Edit Alarm focus test
+estimated_duration: 660
+_description:
+    This test check if an edited alarm is saveable even when clock app loses focus during the test.
+    1. Launch the clock app.
+        Clock app opens showing the current local time.
+    2. Swipe the bottom edge to open the alarms page.
+        Alarms page should appear showing a list of alarm. If empty then you should see a
+        message being displayed that "No saved alarms".
+    3. Press the plus icon to create a new alarm. Change the alarm time to ring in the next
+       minute. Do not change any other options. Save Alarm.
+        The saved alarm should be displayed in the alarms page.
+    4. Press the saved alarm to edit it.
+        The edit alarm page should be visible with the values set in the previous step.
+    5. Swipe from the right-edge briefly.
+        The Unity dash should be visible
+    6. Swipe again from the right-edge briefly.
+        The clock app should now be visible
+    7. Change the alarm time to ring in the next minute. Do not change any other options. Save Alarm.
+        The saved alarm should be displayed in the alarms page.
+    8. Wait for the alarm to ring.
+        The alarm should ring (with haptic feedback) at the time set in the previous step and 
+        should show a notification with the buttons "Snooze" and "Ok".
+    9. Press "Ok" to dismiss the alarm.
+        The alarm should be dismissed.
+
 id: alarm/silence-setting
 plugin: manual
 depends: alarm/trigger-alarm


References