Merge lp:~chipaca/ubuntu-push/remove-duration into lp:ubuntu-push

Proposed by John Lenton
Status: Superseded
Proposed branch: lp:~chipaca/ubuntu-push/remove-duration
Merge into: lp:ubuntu-push
Prerequisite: lp:~chipaca/ubuntu-push/postal-setup-obj
Diff against target: 156 lines (+8/-48)
6 files modified
bus/haptic/haptic.go (+1/-4)
bus/haptic/haptic_test.go (+0/-30)
client/service/postal_test.go (+1/-1)
docs/highlevel.txt (+2/-5)
docs/lowlevel.txt (+2/-5)
launch_helper/helper_output.go (+2/-3)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/remove-duration
Reviewer Review Type Date Requested Status
Ubuntu Push Hackers Pending
Review via email: mp+230069@code.launchpad.net

Commit message

Remove Vibration's confusing and redundant Duration attribute.

Description of the change

Remove Vibration's confusing and redundant Duration attribute.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bus/haptic/haptic.go'
2--- bus/haptic/haptic.go 2014-07-25 10:25:59 +0000
3+++ bus/haptic/haptic.go 2014-08-08 09:06:25 +0000
4@@ -50,7 +50,7 @@
5 }
6
7 if notification.Vibrate == nil {
8- haptic.log.Debugf("[%s] notification has no Vibrate: %#v", nid, notification.Vibrate)
9+ haptic.log.Debugf("[%s] notification has no Vibrate.", nid)
10 return false
11 }
12 pattern := notification.Vibrate.Pattern
13@@ -58,9 +58,6 @@
14 if repeat == 0 {
15 repeat = 1
16 }
17- if notification.Vibrate.Duration != 0 {
18- pattern = []uint32{notification.Vibrate.Duration}
19- }
20 if len(pattern) == 0 {
21 haptic.log.Debugf("[%s] not enough information in the Vibrate to create a pattern", nid)
22 return false
23
24=== modified file 'bus/haptic/haptic_test.go'
25--- bus/haptic/haptic_test.go 2014-07-25 10:25:59 +0000
26+++ bus/haptic/haptic_test.go 2014-08-08 09:06:25 +0000
27@@ -71,36 +71,6 @@
28 c.Check(callArgs[0].Args, DeepEquals, []interface{}{[]uint32{200, 100}, uint32(1)})
29 }
30
31-// check that Present() makes a Pattern of [Duration] if Duration is given
32-func (hs *hapticSuite) TestPresentBuildsPatternWithDuration(c *C) {
33- endp := testibus.NewTestingEndpoint(nil, condition.Work(true))
34-
35- ec := New(endp, hs.log)
36- // note: no Repeat, no Pattern, just Duration:
37- notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200}}
38- c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)
39- callArgs := testibus.GetCallArgs(endp)
40- c.Assert(callArgs, HasLen, 1)
41- c.Check(callArgs[0].Member, Equals, "VibratePattern")
42- // note: Pattern of [Duration], Repeat of 1:
43- c.Check(callArgs[0].Args, DeepEquals, []interface{}{[]uint32{200}, uint32(1)})
44-}
45-
46-// check that Present() ignores Pattern and makes a Pattern of [Duration] if Duration is given
47-func (hs *hapticSuite) TestPresentOverrides(c *C) {
48- endp := testibus.NewTestingEndpoint(nil, condition.Work(true))
49-
50- ec := New(endp, hs.log)
51- // note: Duration given, as well as Pattern; Repeat given as 0:
52- notif := launch_helper.Notification{Vibrate: &launch_helper.Vibration{Duration: 200, Pattern: []uint32{500}, Repeat: 0}}
53- c.Check(ec.Present(hs.app, "nid", &notif), Equals, true)
54- callArgs := testibus.GetCallArgs(endp)
55- c.Assert(callArgs, HasLen, 1)
56- c.Check(callArgs[0].Member, Equals, "VibratePattern")
57- // note: Pattern of [Duration], Repeat of 1:
58- c.Check(callArgs[0].Args, DeepEquals, []interface{}{[]uint32{200}, uint32(1)})
59-}
60-
61 // check that Present() doesn't call VibratePattern if things are not right
62 func (hs *hapticSuite) TestSkipIfMissing(c *C) {
63 endp := testibus.NewTestingEndpoint(nil, condition.Work(true))
64
65=== modified file 'client/service/postal_test.go'
66--- client/service/postal_test.go 2014-08-08 09:06:25 +0000
67+++ client/service/postal_test.go 2014-08-08 09:06:25 +0000
68@@ -522,7 +522,7 @@
69
70 // Persist is false so we just check the log
71 card := &launch_helper.Card{Icon: "icon-value", Summary: "summary-value", Body: "body-value", Popup: true, Persist: false}
72- vib := &launch_helper.Vibration{Duration: 500}
73+ vib := &launch_helper.Vibration{Pattern: []uint32{1}}
74 emb := &launch_helper.EmblemCounter{Count: 2, Visible: true}
75 output := &launch_helper.HelperOutput{Notification: &launch_helper.Notification{Card: card, EmblemCounter: emb, Vibrate: vib}}
76 b := svc.messageHandler(&click.AppId{}, "", output)
77
78=== modified file 'docs/highlevel.txt'
79--- docs/highlevel.txt 2014-08-08 09:06:25 +0000
80+++ docs/highlevel.txt 2014-08-08 09:06:25 +0000
81@@ -208,7 +208,6 @@
82 "sound": "buzz.mp3",
83 "vibrate": {
84 "pattern": [200, 100],
85- "duration": 200,
86 "repeat": 2
87 }
88 "emblem-counter": {
89@@ -249,8 +248,7 @@
90
91 The notification can contain a **vibrate** field, causing haptic feedback, that has the following content:
92
93-:pattern: a list of integers describing a vibration pattern.
94-:duration: duration in milliseconds. Is equivalent to setting pattern to [duration], and overrides pattern.
95+:pattern: a list of integers describing a vibration pattern (duration of alternating vibration/no vibration times, in milliseconds).
96 :repeat: number of times the pattern has to be repeated (defaults to 1, 0 is the same as 1).
97
98 The notification can contain a **emblem-counter** field, with the following content:
99@@ -304,8 +302,7 @@
100 "sound": "buzz.mp3",
101 "tag": "foo",
102 "vibrate": {
103- "duration": 200,
104- "pattern": (200, 100),
105+ "pattern": [200, 100],
106 "repeat": 2
107 }
108 "emblem-counter": {
109
110=== modified file 'docs/lowlevel.txt'
111--- docs/lowlevel.txt 2014-08-08 09:06:25 +0000
112+++ docs/lowlevel.txt 2014-08-08 09:06:25 +0000
113@@ -302,7 +302,6 @@
114 "sound": "buzz.mp3",
115 "vibrate": {
116 "pattern": [200, 100],
117- "duration": 200,
118 "repeat": 2
119 }
120 "emblem-counter": {
121@@ -343,8 +342,7 @@
122
123 The notification can contain a **vibrate** field, causing haptic feedback, that has the following content:
124
125-:pattern: a list of integers describing a vibration pattern.
126-:duration: duration in milliseconds. Is equivalent to setting pattern to [duration], and overrides pattern.
127+:pattern: a list of integers describing a vibration pattern (duration of alternating vibration/no vibration times, in milliseconds).
128 :repeat: number of times the pattern has to be repeated (defaults to 1, 0 is the same as 1).
129
130 The notification can contain a **emblem-counter** field, with the following content:
131@@ -398,8 +396,7 @@
132 "sound": "buzz.mp3",
133 "tag": "foo",
134 "vibrate": {
135- "duration": 200,
136- "pattern": (200, 100),
137+ "pattern": [200, 100],
138 "repeat": 2
139 }
140 "emblem-counter": {
141
142=== modified file 'launch_helper/helper_output.go'
143--- launch_helper/helper_output.go 2014-08-08 09:06:25 +0000
144+++ launch_helper/helper_output.go 2014-08-08 09:06:25 +0000
145@@ -44,9 +44,8 @@
146 // a Vibration generates a vibration in the form of a Pattern set in
147 // duration a pattern of on off states, repeated a number of times
148 type Vibration struct {
149- Duration uint32 `json:"duration"` // if Duration is present and not 0, it's like a Pattern of [Duration]; otherwise, Pattern is used.
150- Pattern []uint32 `json:"pattern"`
151- Repeat uint32 `json:"repeat"` // defaults to 1. A value of zero is ignored (so it's like 1).
152+ Pattern []uint32 `json:"pattern"`
153+ Repeat uint32 `json:"repeat"` // defaults to 1. A value of zero is ignored (so it's like 1).
154 }
155
156 // a Notification can be any of the above

Subscribers

People subscribed via source and target branches