Merge lp:~nik90/ubuntu-clock-app/2-fix-one-time-alarm into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 191
Merged at revision: 187
Proposed branch: lp:~nik90/ubuntu-clock-app/2-fix-one-time-alarm
Merge into: lp:ubuntu-clock-app
Prerequisite: lp:~nik90/ubuntu-clock-app/1-fix-trunk-tests
Diff against target: 42 lines (+21/-0)
2 files modified
app/alarm/AlarmDelegate.qml (+19/-0)
debian/changelog (+2/-0)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/2-fix-one-time-alarm
Reviewer Review Type Date Requested Status
Riccardo Padovani Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Review via email: mp+247081@code.launchpad.net

This proposal supersedes a proposal from 2015-01-21.

Commit message

Automatically calculate the new alarm time of a one-time alarm that has gone off and is re-enabled by the user. Fixes lp 1413027

Description of the change

Now when the user re-enables a one-time alarm that has gone off, clock app automatically calculates the correct alarm time and changes it correctly for the user instead of just saying that the alarm time has passed.

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)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Looks good! Thanks!

review: Approve
190. By Nekhelesh Ramananthan

Updated if logic to take into account another use case. Thnx riccardo!

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

Tried a different logic using getTime()

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
Riccardo Padovani (rpadovani) wrote :

Lgtm, thanks for this fix, I love it :D

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/AlarmDelegate.qml'
2--- app/alarm/AlarmDelegate.qml 2014-11-19 14:56:42 +0000
3+++ app/alarm/AlarmDelegate.qml 2015-01-21 18:43:53 +0000
4@@ -94,6 +94,25 @@
5 if (checked !== model.enabled) {
6 var alarmData = model
7 alarmData.enabled = checked
8+
9+ /*
10+ Calculate the new alarm time if it is a one-time alarm and has
11+ gone-off and the user is re-enabling the alarm. Repeating
12+ alarms do this automatically.
13+ */
14+ if(checked && type === Alarm.OneTime && alarmData.date < new Date()) {
15+ var currentTime = new Date()
16+
17+ var twentyfourHours = 86400000 // 1000 * 60 * 60 * 24
18+ var tomorrow = currentTime
19+ tomorrow.setDate(tomorrow.getDate() + 1)
20+ alarmData.daysOfWeek = alarmUtils.get_alarm_day(tomorrow.getDay())
21+
22+ if (alarmData.date.getTime() - currentTime.getTime() > twentyfourHours) {
23+ alarmData.daysOfWeek = alarmUtils.get_alarm_day(currentTime.getDay())
24+ }
25+ }
26+
27 alarmData.save()
28 }
29 }
30
31=== modified file 'debian/changelog'
32--- debian/changelog 2015-01-21 00:17:46 +0000
33+++ debian/changelog 2015-01-21 18:43:53 +0000
34@@ -30,6 +30,8 @@
35 * Fixed alarm string not being translatable (LP: #1380248)
36 * Fixed the incorrect overriding of alarm delegate model value.
37 * Fixed qml tests broken in vivid due to listitem behaviour change.
38+ * Fixed one-time alarms not being able to be re-enabled using the alarm switch
39+ after they have gone off once (LP: #1413027)
40
41 [Akiva Shammai Avraham]
42 * Improved the analog clock performance by updating the clock hands every second

Subscribers

People subscribed via source and target branches