← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~etherpulse/ubuntu-clock-app/alarm_pause into lp:ubuntu-clock-app

 

Eran Uzan has proposed merging lp:~etherpulse/ubuntu-clock-app/alarm_pause into lp:ubuntu-clock-app.

Requested reviews:
  Ubuntu Clock Developers (ubuntu-clock-dev)
Related bugs:
  Bug #1438037 in Ubuntu Clock App: "[Feature] Skip next occurence of a repeating alarm"
  https://bugs.launchpad.net/ubuntu-clock-app/+bug/1438037

For more details, see:
https://code.launchpad.net/~etherpulse/ubuntu-clock-app/alarm_pause/+merge/308571

A workaround to allow for alarm pausing even though the back end  doesn't allow for adding  extra data to alarms.
This can only pause alarms that will fire tomorrow.

You can pasue/enable each alarm by left swiping it (trailing actions).
the alarm will be pause by moving the next alarm time one day forward.
the alarm will be unpaused by moving the next alarm time to tomorrow date

paused alarms  display a pause icon on them.

-- 
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~etherpulse/ubuntu-clock-app/alarm_pause into lp:ubuntu-clock-app.
=== modified file 'app/alarm/AlarmDelegate.qml'
--- app/alarm/AlarmDelegate.qml	2016-03-03 00:28:40 +0000
+++ app/alarm/AlarmDelegate.qml	2016-10-14 23:46:19 +0000
@@ -38,6 +38,7 @@
         textChangeAnimation.start()
     }
 
+
     height: mainLayout.height + divider.height
 
     SequentialAnimation {
@@ -63,6 +64,17 @@
         }
     }
 
+    Icon {
+        width: units.gu(2.5)
+        anchors.bottom: parent.bottom
+        anchors.bottomMargin: units.gu(2.5)
+        anchors.right: parent.right
+        anchors.rightMargin: units.gu(3.5)
+        name: "media-playback-pause"
+        visible: { return alarmUtils.isPaused(model) }
+        asynchronous: true
+    }
+
     ListItemLayout {
         id: mainLayout
 
@@ -125,6 +137,7 @@
                 }
             }
         }
+
     }
 
 }

=== modified file 'app/alarm/AlarmList.qml'
--- app/alarm/AlarmList.qml	2016-03-03 00:28:40 +0000
+++ app/alarm/AlarmList.qml	2016-10-14 23:46:19 +0000
@@ -69,6 +69,33 @@
             ]
         }
 
+        trailingActions: ListItemActions {
+            actions: [
+                Action {
+                    id: pauseAction
+                    objectName: "pauseAction"
+                    iconName: actionIcon()
+                    text: actionText()
+                    enabled : { return alarmUtils.isPausable(model) }
+                    visible: { return alarmUtils.isPausable(model) }
+                    onTriggered: {
+                        alarmUtils.pauseToggle( model );
+                    }
+
+
+                    function actionText() {
+                          return alarmUtils.isPaused( model ) ? i18n.tr("Unpause Alarm"): i18n.tr("Pause Alarm")
+                    }
+
+                    function actionIcon() {
+                        return alarmUtils.isPaused( model ) ? "media-playback-start" : "media-playback-pause" ;
+                    }
+                }
+            ]
+        }
+
+
+
         onClicked: {
             if (selectMode) {
                 selected = !selected

=== modified file 'app/alarm/AlarmUtils.qml'
--- app/alarm/AlarmUtils.qml	2016-02-29 16:20:29 +0000
+++ app/alarm/AlarmUtils.qml	2016-10-14 23:46:19 +0000
@@ -224,4 +224,44 @@
 
         return occurs;
     }
+
+
+
+    // Alarm pausing
+
+    function pauseToggle(alarm) {
+        var tomorrow = new Date();
+        tomorrow.setDate(tomorrow.getDate() + 1)
+        var newDate = alarm.date;
+        if(isPaused(alarm)) {
+           newDate.setDate(tomorrow.getDate());
+        } else {
+           newDate.setDate(alarm.date.getDate() + 1);
+        }
+
+        alarm.date = newDate;
+        alarm.save();
+    }
+
+    function getEOD(date) {
+        var eodDate = date;
+        eodDate.setHours(23);
+        eodDate.setSeconds(59);
+        eodDate.setMinutes(59);
+
+        return eodDate;
+    }
+
+    function isPausable(alarm) {
+        var tomorrow = getEOD(new Date());
+        tomorrow.setDate(tomorrow.getDate() + 1)
+        return alarm.type == Alarm.Repeating && alarm.daysOfWeek & get_alarm_day(tomorrow.getDay());
+    }
+
+    function isPaused(alarm) {
+        var tomorrow =  getEOD(new Date());
+        tomorrow.setDate(tomorrow.getDate() + 1)
+        return ( alarm.date > tomorrow && alarm.daysOfWeek & get_alarm_day(tomorrow.getDay()) );
+    }
+
 }

=== modified file 'app/alarm/EditAlarmPage.qml'
--- app/alarm/EditAlarmPage.qml	2016-03-03 00:28:40 +0000
+++ app/alarm/EditAlarmPage.qml	2016-10-14 23:46:19 +0000
@@ -276,13 +276,27 @@
             property string subText: alarmUtils.format_day_string(_alarm.daysOfWeek, _alarm.type)
             height: alarmRepeatLayout.height + divider.height
 
+            Icon {
+                anchors.top: parent.top
+                anchors.topMargin: units.gu(1)
+                anchors.right: parent.right
+                anchors.rightMargin: units.gu(1)
+                width: units.gu(2.5)
+                height: width
+                name: "media-playback-pause"
+                visible: { return alarmUtils.isPaused(_alarm) }
+                asynchronous: true
+            }
+
             ListItemLayout {
                 id: alarmRepeatLayout
 
                 title.text: i18n.tr("Repeat")
                 subtitle.text: _alarmRepeat.subText
                 subtitle.textSize: Label.Medium
+
             }
+
             onClicked: pageStack.push(Qt.resolvedUrl("AlarmRepeat.qml"),
                                       {"alarm": _alarm, "alarmUtils": alarmUtils})
         }


Follow ups