← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~nik90/ubuntu-clock-app/fix-alarm-sound-preview-playback into lp:ubuntu-clock-app

 

Nekhelesh Ramananthan has proposed merging lp:~nik90/ubuntu-clock-app/fix-alarm-sound-preview-playback into lp:ubuntu-clock-app.

Requested reviews:
  Ubuntu Clock Developers (ubuntu-clock-dev)
Related bugs:
  Bug #1487689 in Ubuntu Clock App: "[Custom sound] After add custom sound, newly added sound should be selected"
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1487689
  Bug #1487690 in Ubuntu Clock App: "[Custom sound] After selecting sound by clicking "checkbox" the preview sound should be played."
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1487690
  Bug #1487699 in Ubuntu Clock App: "[Custom sound] Preview sound is playing even if phone is locked or clock application is switched"
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1487699

For more details, see:
https://code.launchpad.net/~nik90/ubuntu-clock-app/fix-alarm-sound-preview-playback/+merge/268833

Fixes the above mentioned bugs
-- 
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~nik90/ubuntu-clock-app/fix-alarm-sound-preview-playback into lp:ubuntu-clock-app.
=== modified file 'app/alarm/AlarmSound.qml'
--- app/alarm/AlarmSound.qml	2015-08-21 14:14:21 +0000
+++ app/alarm/AlarmSound.qml	2015-08-22 13:43:05 +0000
@@ -96,7 +96,43 @@
                 console.log("[LOG] Original Custom Alarm Sound URL: " + _alarmSoundPage.importItems[0].url)
                 _alarmSoundPage.importItems[0].move(customSound.alarmSoundDirectory)
                 console.log("[LOG] Final Custom Alarm Sound URL: " + _alarmSoundPage.importItems[0].url)
-            }
+                // Wait for folder model to update and then select the imported sound
+                waitForCustomSoundModelToUpdate.start()
+            }
+        }
+    }
+
+    Timer {
+        id: waitForCustomSoundModelToUpdate
+        interval: 100
+        repeat: false
+        onTriggered: {
+            selectNewlyImportedCustomSound(_alarmSoundPage.importItems[0].url)
+        }
+    }
+
+    function selectNewlyImportedCustomSound(soundUrl) {
+        for (var i=0; i<customSoundModel.count; i++) {
+            if (soundUrl === customSoundModel.get(i, "fileURL")) {
+                alarmSound.subText = customSoundModel.get(i, "fileBaseName")
+                alarm.sound = soundUrl
+                previewAlarmSound.source = soundUrl
+                _customAlarmSounds.itemAt(i).isChecked = true
+                return
+            }
+        }
+    }
+
+    Connections {
+        target: clockApp
+        onApplicationStateChanged: {
+            previewAlarmSound.stop()
+        }
+    }
+
+    onVisibleChanged: {
+        if (!_alarmSoundPage.visible) {
+            previewAlarmSound.stop()
         }
     }
 
@@ -267,8 +303,6 @@
                         onClicked: {
                             if (!checked) {
                                 checked = true
-                            } else {
-                                previewAlarmSound.controlPlayback(fileURL)
                             }
                         }
                     }
@@ -347,8 +381,6 @@
                         onClicked: {
                             if (!checked) {
                                 checked = true
-                            } else {
-                                previewAlarmSound.controlPlayback(fileURL)
                             }
                         }
                     }

=== modified file 'debian/changelog'
--- debian/changelog	2015-08-21 16:05:48 +0000
+++ debian/changelog	2015-08-22 13:43:05 +0000
@@ -20,6 +20,10 @@
   * Added Clock Utility C++ plugin housing CustomAlarmSound type required
     for custom alarm sound feature
   * Added support for setting custom alarm sounds (LP: #1450640)
+  * Stop playing alarm sound preview if the application loses focus or
+    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)
 
   [Victor Thompson]
   * Show all README files in QtCreator 


Follow ups