Merge lp:~neokore/ubuntu-weather-app/flippedInfo2 into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Raúl Yeguas on 2013-08-05
Status: Merged
Approved by: Martin Borho on 2013-08-06
Approved revision: 84
Merged at revision: 84
Proposed branch: lp:~neokore/ubuntu-weather-app/flippedInfo2
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 578 lines (+373/-117)
4 files modified
components/CurrentWeather.qml (+322/-102)
components/LocationTab.qml (+30/-1)
components/SettingsSheet.qml (+2/-2)
components/WeatherApi.js (+19/-12)
To merge this branch: bzr merge lp:~neokore/ubuntu-weather-app/flippedInfo2
Reviewer Review Type Date Requested Status
Martin Borho 2013-08-05 Approve on 2013-08-06
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2013-08-05
Review via email: mp+178622@code.launchpad.net

Commit message

Added wind speed, wind direction and rain to internal data and implemented flipped component for more forecast info.

Description of the change

Added wind speed, wind direction and rain to internal data and implemented flipped component for more forecast info.

To post a comment you must log in.
Martin Borho (martin-borho) wrote :

Excellent work, Raul!

I'll fix a litte issue on the device (double digit wind speed and double char wind direction is too wide) and the broken tests later. (I have already a branch with updated tests in the work)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/CurrentWeather.qml'
2--- components/CurrentWeather.qml 2013-07-27 16:02:29 +0000
3+++ components/CurrentWeather.qml 2013-08-05 18:56:25 +0000
4@@ -13,109 +13,329 @@
5 property int minTemp
6 property int maxTemp
7 property bool showMaxTemp
8- property string scale: (mainView.settings["units"] === "imperial") ? "F" : "C"
9+ property int windSpeed
10+ property string windDir
11+ property int humidity
12+ property real precipitation
13+ property string tempScale: (mainView.settings["units"] === "imperial") ? "F" : "C"
14+ property string speedScale: (mainView.settings["units"] === "imperial") ? "mph" : "km/h"
15+ property string precipScale: (mainView.settings["units"] === "imperial") ? "in" : "mm"
16
17 width: parent.width
18- height: childrenRect.height+units.gu(10)
19+ height: units.gu(40)
20 anchors.horizontalCenter: parent.horizontalCenter
21
22- Components.WeatherConditionIconComponent {
23- id: currentCondition
24- width: units.gu(30)
25- height: units.gu(30)
26- anchors.horizontalCenter: parent.horizontalCenter
27- condition: currentWeather.icon
28-
29- NumberAnimation on opacity {
30- id: createAnimation
31- easing.type: Easing.Linear
32- from: 0
33- to: 1
34- duration: 1000
35- }
36-
37- Component.onCompleted: {
38- createAnimation.start()
39- }
40- }
41-
42- Rectangle {
43- id: rectangle1
44- width: units.gu(50)
45- height: units.gu(10)
46- anchors.horizontalCenter: parent.horizontalCenter
47- anchors.top: currentCondition.bottom
48- anchors.topMargin: 0
49- color: "transparent"
50-
51- Column {
52- id: column1
53- width: units.gu(5)
54- height: units.gu(5)
55- anchors.rightMargin: units.gu(2)
56- anchors.verticalCenter: parent.verticalCenter
57- anchors.right: tempCurrent.left
58- visible: showMaxTemp
59-
60- Label {
61- text: i18n.tr("Max.")
62- anchors.horizontalCenter: parent.horizontalCenter
63- font.pixelSize: FontUtils.sizeToPixels("small")
64- horizontalAlignment: Text.AlignHCenter
65- }
66-
67- Label {
68- id: tempMax
69- text: maxTemp+"°"+currentWeather.scale
70- anchors.horizontalCenter: parent.horizontalCenter
71- font.pixelSize: FontUtils.sizeToPixels("large")
72- horizontalAlignment: Text.AlignHCenter
73- color: Theme.palette.normal.baseText
74- }
75- }
76-
77- Text {
78- width: units.gu(17)
79- height: units.gu(10)
80- id: tempCurrent
81- objectName: "CurrentTempText"
82- text: currentTemp+String("°")+currentWeather.scale
83- style: Text.Normal
84- font.bold: false
85- font.family: "Ubuntu"
86- verticalAlignment: Text.AlignVCenter
87- anchors.horizontalCenter: parent.horizontalCenter
88- anchors.horizontalCenterOffset: (showMaxTemp) ? 0 : -units.gu(4)
89- anchors.verticalCenter: parent.verticalCenter
90- font.pointSize: 52
91- horizontalAlignment: Text.AlignHCenter
92- color: Theme.palette.normal.baseText
93- }
94-
95- Column {
96- id: column2
97- width: units.gu(5)
98- height: units.gu(5)
99- anchors.leftMargin: (showMaxTemp) ? units.gu(2) : units.gu(4)
100- anchors.verticalCenter: parent.verticalCenter
101- anchors.left: tempCurrent.right
102-
103- Label {
104- text: i18n.tr("Min.")
105- horizontalAlignment: Text.AlignHCenter
106- anchors.horizontalCenter: parent.horizontalCenter
107- font.pixelSize: FontUtils.sizeToPixels("small")
108- color: Theme.palette.normal.baseText
109- }
110-
111- Label {
112- id: tempMin
113- text: minTemp+"°"+currentWeather.scale
114- horizontalAlignment: Text.AlignHCenter
115- anchors.horizontalCenter: parent.horizontalCenter
116- font.pixelSize: FontUtils.sizeToPixels("large")
117- color: Theme.palette.normal.baseText
118- }
119- }
120- }
121-}
122+ Flipable {
123+ id: flipable
124+ anchors.fill: parent
125+
126+ property bool flipped: false
127+
128+ MouseArea {anchors.fill: parent; onClicked: flipable.flipped = !flipable.flipped}
129+
130+ back:
131+ Rectangle {
132+ anchors.fill: parent
133+ color: "transparent"
134+
135+ Components.WeatherConditionIconComponent {
136+ id: currentCondition2
137+ width: units.gu(20)
138+ height: units.gu(20)
139+ anchors.horizontalCenter: parent.horizontalCenter
140+ anchors.horizontalCenterOffset: units.gu(-6)
141+ condition: currentWeather.icon
142+
143+ NumberAnimation on opacity {
144+ id: createAnimation2
145+ easing.type: Easing.Linear
146+ from: 0
147+ to: 1
148+ duration: 1000
149+ }
150+
151+ Component.onCompleted: {
152+ createAnimation2.start()
153+ }
154+ }
155+
156+ Rectangle {
157+ id: rectangle12
158+ width: units.gu(50)
159+ height: units.gu(10)
160+ anchors.horizontalCenter: parent.horizontalCenter
161+ anchors.top: currentCondition2.bottom
162+ anchors.topMargin: 0
163+ color: "transparent"
164+
165+ Column {
166+ id: column12
167+ width: units.gu(5)
168+ height: units.gu(5)
169+ anchors.rightMargin: units.gu(2)
170+ anchors.verticalCenter: parent.verticalCenter
171+ anchors.right: tempCurrent2.left
172+ visible: showMaxTemp
173+
174+ Label {
175+ text: i18n.tr("Max.")
176+ anchors.horizontalCenter: parent.horizontalCenter
177+ font.pixelSize: FontUtils.sizeToPixels("small")
178+ horizontalAlignment: Text.AlignHCenter
179+ }
180+
181+ Label {
182+ id: tempMax2
183+ text: maxTemp+"°"+currentWeather.tempScale
184+ anchors.horizontalCenter: parent.horizontalCenter
185+ font.pixelSize: FontUtils.sizeToPixels("large")
186+ horizontalAlignment: Text.AlignHCenter
187+ color: Theme.palette.normal.baseText
188+ }
189+ }
190+
191+ Text {
192+ width: units.gu(17)
193+ height: units.gu(10)
194+ id: tempCurrent2
195+ objectName: "CurrentTempText"
196+ text: currentTemp+String("°")+currentWeather.tempScale
197+ style: Text.Normal
198+ font.bold: false
199+ font.family: "Ubuntu"
200+ verticalAlignment: Text.AlignVCenter
201+ anchors.horizontalCenter: parent.horizontalCenter
202+ anchors.horizontalCenterOffset: (showMaxTemp) ? 0 : -units.gu(4)
203+ anchors.verticalCenter: parent.verticalCenter
204+ font.pointSize: 52
205+ horizontalAlignment: Text.AlignHCenter
206+ color: Theme.palette.normal.baseText
207+ }
208+
209+ Column {
210+ id: column22
211+ width: units.gu(5)
212+ height: units.gu(5)
213+ anchors.leftMargin: (showMaxTemp) ? units.gu(2) : units.gu(4)
214+ anchors.verticalCenter: parent.verticalCenter
215+ anchors.left: tempCurrent2.right
216+
217+ Label {
218+ text: i18n.tr("Min.")
219+ horizontalAlignment: Text.AlignHCenter
220+ anchors.horizontalCenter: parent.horizontalCenter
221+ font.pixelSize: FontUtils.sizeToPixels("small")
222+ color: Theme.palette.normal.baseText
223+ }
224+
225+ Label {
226+ id: tempMin2
227+ text: minTemp+"°"+currentWeather.tempScale
228+ horizontalAlignment: Text.AlignHCenter
229+ anchors.horizontalCenter: parent.horizontalCenter
230+ font.pixelSize: FontUtils.sizeToPixels("large")
231+ color: Theme.palette.normal.baseText
232+ }
233+ }
234+ }
235+
236+ Column {
237+ id: windColumn
238+ anchors.left: currentCondition2.right
239+ anchors.leftMargin: units.gu(3)
240+ height: childrenRect.height
241+ width: childrenRect.width
242+
243+ Label {
244+ id: windLabel
245+ text: i18n.tr("Wind")
246+ horizontalAlignment: Text.AlignLeft
247+ font.pixelSize: FontUtils.sizeToPixels("small")
248+ color: Theme.palette.normal.baseText
249+ }
250+ Label {
251+ id: windValue
252+ text: currentWeather.windSpeed+" "+currentWeather.speedScale+" "+currentWeather.windDir
253+ horizontalAlignment: Text.AlignLeft
254+ font.pixelSize: FontUtils.sizeToPixels("large")
255+ color: Theme.palette.normal.baseText
256+ }
257+ }
258+
259+ Column {
260+ id: humidityColumn
261+ anchors.left: currentCondition2.right
262+ anchors.leftMargin: units.gu(3)
263+ anchors.top: windColumn.bottom
264+ anchors.topMargin: units.gu(2)
265+ height: childrenRect.height
266+ width: childrenRect.width
267+
268+ Label {
269+ id: humidityLabel
270+ text: i18n.tr("Humidity")
271+ horizontalAlignment: Text.AlignLeft
272+ font.pixelSize: FontUtils.sizeToPixels("small")
273+ color: Theme.palette.normal.baseText
274+ }
275+ Label {
276+ id: humidityValue
277+ text: currentWeather.humidity+"%"
278+ horizontalAlignment: Text.AlignLeft
279+ font.pixelSize: FontUtils.sizeToPixels("large")
280+ color: Theme.palette.normal.baseText
281+ }
282+ }
283+
284+ Column {
285+ id: precipitationColumn
286+ anchors.left: currentCondition2.right
287+ anchors.leftMargin: units.gu(3)
288+ anchors.top: humidityColumn.bottom
289+ anchors.topMargin: units.gu(2)
290+ height: childrenRect.height
291+ width: childrenRect.width
292+
293+ Label {
294+ id: precipitationLabel
295+ text: i18n.tr("Precipitation")
296+ horizontalAlignment: Text.AlignLeft
297+ font.pixelSize: FontUtils.sizeToPixels("small")
298+ color: Theme.palette.normal.baseText
299+ }
300+ Label {
301+ id: precipitationValue
302+ text: currentWeather.precipitation.toFixed(1)+" "+currentWeather.precipScale
303+ horizontalAlignment: Text.AlignLeft
304+ font.pixelSize: FontUtils.sizeToPixels("large")
305+ color: Theme.palette.normal.baseText
306+ }
307+ }
308+ }
309+
310+ front:
311+ Rectangle {
312+ anchors.fill: parent
313+ color: "transparent"
314+
315+ Components.WeatherConditionIconComponent {
316+ id: currentCondition
317+ width: units.gu(30)
318+ height: units.gu(30)
319+ anchors.horizontalCenter: parent.horizontalCenter
320+ condition: currentWeather.icon
321+
322+ NumberAnimation on opacity {
323+ id: createAnimation
324+ easing.type: Easing.Linear
325+ from: 0
326+ to: 1
327+ duration: 1000
328+ }
329+
330+ Component.onCompleted: {
331+ createAnimation.start()
332+ }
333+ }
334+
335+ Rectangle {
336+ id: rectangle1
337+ width: units.gu(50)
338+ height: units.gu(10)
339+ anchors.horizontalCenter: parent.horizontalCenter
340+ anchors.top: currentCondition.bottom
341+ anchors.topMargin: 0
342+ color: "transparent"
343+
344+ Column {
345+ id: column1
346+ width: units.gu(5)
347+ height: units.gu(5)
348+ anchors.rightMargin: units.gu(2)
349+ anchors.verticalCenter: parent.verticalCenter
350+ anchors.right: tempCurrent.left
351+ visible: showMaxTemp
352+
353+ Label {
354+ text: i18n.tr("Max.")
355+ anchors.horizontalCenter: parent.horizontalCenter
356+ font.pixelSize: FontUtils.sizeToPixels("small")
357+ horizontalAlignment: Text.AlignHCenter
358+ }
359+
360+ Label {
361+ id: tempMax
362+ text: maxTemp+"°"+currentWeather.tempScale
363+ anchors.horizontalCenter: parent.horizontalCenter
364+ font.pixelSize: FontUtils.sizeToPixels("large")
365+ horizontalAlignment: Text.AlignHCenter
366+ color: Theme.palette.normal.baseText
367+ }
368+ }
369+
370+ Text {
371+ width: units.gu(17)
372+ height: units.gu(10)
373+ id: tempCurrent
374+ objectName: "CurrentTempText"
375+ text: currentTemp+String("°")+currentWeather.tempScale
376+ style: Text.Normal
377+ font.bold: false
378+ font.family: "Ubuntu"
379+ verticalAlignment: Text.AlignVCenter
380+ anchors.horizontalCenter: parent.horizontalCenter
381+ anchors.horizontalCenterOffset: (showMaxTemp) ? 0 : -units.gu(4)
382+ anchors.verticalCenter: parent.verticalCenter
383+ font.pointSize: 52
384+ horizontalAlignment: Text.AlignHCenter
385+ color: Theme.palette.normal.baseText
386+ }
387+
388+ Column {
389+ id: column2
390+ width: units.gu(5)
391+ height: units.gu(5)
392+ anchors.leftMargin: (showMaxTemp) ? units.gu(2) : units.gu(4)
393+ anchors.verticalCenter: parent.verticalCenter
394+ anchors.left: tempCurrent.right
395+
396+ Label {
397+ text: i18n.tr("Min.")
398+ horizontalAlignment: Text.AlignHCenter
399+ anchors.horizontalCenter: parent.horizontalCenter
400+ font.pixelSize: FontUtils.sizeToPixels("small")
401+ color: Theme.palette.normal.baseText
402+ }
403+
404+ Label {
405+ id: tempMin
406+ text: minTemp+"°"+currentWeather.tempScale
407+ horizontalAlignment: Text.AlignHCenter
408+ anchors.horizontalCenter: parent.horizontalCenter
409+ font.pixelSize: FontUtils.sizeToPixels("large")
410+ color: Theme.palette.normal.baseText
411+ }
412+ }
413+ }
414+ }
415+
416+ transform: Rotation {
417+ id: rotation
418+ origin.x: flipable.width/2
419+ origin.y: flipable.height/2
420+ axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis
421+ angle: 0 // the default angle
422+ }
423+
424+ states: State {
425+ name: "back"
426+ PropertyChanges { target: rotation; angle: 180 }
427+ when: flipable.flipped
428+ }
429+
430+ transitions: Transition {
431+ NumberAnimation { target: rotation; property: "angle"; duration: 500 }
432+ }
433+ }
434+ }
435+
436
437=== modified file 'components/LocationTab.qml'
438--- components/LocationTab.qml 2013-07-27 16:02:29 +0000
439+++ components/LocationTab.qml 2013-08-05 18:56:25 +0000
440@@ -51,6 +51,27 @@
441
442 // set daily forecasts
443 for(var x=0;x<dailyLength;x++) {
444+ var direction = "?";
445+ var degrees = dailyForecasts[x].windDeg;
446+ if(degrees >=0 && degrees <= 30){
447+ direction = "N";
448+ } else if(degrees >30 && degrees <= 60){
449+ direction = "NE";
450+ } else if(degrees >60 && degrees <= 120){
451+ direction = "E";
452+ } else if(degrees >120 && degrees <= 150){
453+ direction = "SE";
454+ } else if(degrees >150 && degrees <= 210){
455+ direction = "S";
456+ } else if(degrees >210 && degrees <= 240){
457+ direction = "SW";
458+ } else if(degrees >240 && degrees <= 300){
459+ direction = "W";
460+ } else if(degrees >300 && degrees <= 330){
461+ direction = "NW";
462+ }else if(degrees >330 && degrees <= 360){
463+ direction = "N";
464+ }
465 dayForecastModel.append({
466 dateRel: "",//Tomorrow",
467 date: formatTimestamp(dailyForecasts[x].timestamp, 'dddd, dd MMMM yyyy'),
468@@ -60,7 +81,11 @@
469 tempMax: (dailyForecasts[x]["current"] !== undefined) ? dailyForecasts[x][units].tempMax :
470 null,
471 cond: dailyForecasts[x].condition.id,
472- condIcon: dailyForecasts[x].condition.icon
473+ condIcon: dailyForecasts[x].condition.icon,
474+ wind_speed: dailyForecasts[x][units].windSpeed,
475+ wind_dir: direction,
476+ humid: dailyForecasts[x].humidity,
477+ precip: (dailyForecasts[x][units].rain !== null && dailyForecasts[x][units].rain !== undefined) ? dailyForecasts[x][units].rain : 0
478 });
479 }
480 }
481@@ -111,6 +136,10 @@
482 maxTemp: tempMax
483 icon: condIcon
484 condition: cond
485+ windSpeed: wind_speed
486+ windDir: wind_dir
487+ humidity: humid
488+ precipitation: precip
489 anchors.top: dateComponent.bottom
490 showMaxTemp: (index === 0)
491 }
492
493=== modified file 'components/SettingsSheet.qml'
494--- components/SettingsSheet.qml 2013-07-23 21:20:11 +0000
495+++ components/SettingsSheet.qml 2013-08-05 18:56:25 +0000
496@@ -31,8 +31,8 @@
497 container: ListItem.ValueSelector {
498 id: unitsSelector
499 objectName: "UnitsSelector"
500- text: i18n.tr("Temperature unit")
501- values: [i18n.tr("°C"), i18n.tr("°F")]
502+ text: i18n.tr("Units")
503+ values: [i18n.tr("Metric"), i18n.tr("Imperial")]
504 selectedIndex: (settings["units"] === "imperial") ? 1 : 0;
505 }
506
507
508=== modified file 'components/WeatherApi.js'
509--- components/WeatherApi.js 2013-07-27 16:01:13 +0000
510+++ components/WeatherApi.js 2013-08-05 18:56:25 +0000
511@@ -3,7 +3,7 @@
512 * Version of the response data format.
513 * Increase this number to force a refresh.
514 */
515-var RESPONSE_DATA_VERSION = 20130727;
516+var RESPONSE_DATA_VERSION = 20130801;
517
518 /**
519 * Helper functions
520@@ -11,8 +11,14 @@
521 function calcFahrenheit(celsius) {
522 return celsius * 1.8 + 32;
523 }
524-function calcMph(kmh) {
525- return kmh*0.62137;
526+function calcMph(ms) {
527+ return ms*2.24;
528+}
529+function calcInch(mm) {
530+ return mm/25.4;
531+}
532+function calcKmh(ms) {
533+ return ms*3.6;
534 }
535
536 var OpenWeatherMapApi = (function() {
537@@ -42,13 +48,11 @@
538 var result = {
539 timestamp: data.dt,
540 date: Qt.formatDateTime(new Date(data.dt*1000), "yyyy-MM-dd hh:mm"),
541- metric: { temp:data.main.temp },
542- imperial: { temp: calcFahrenheit(data.main.temp) },
543+ metric: { temp:data.main.temp, windSpeed: calcKmh(data.main.speed), rain: data.main.rain},
544+ imperial: { temp: calcFahrenheit(data.main.temp), windSpeed: calcMph(data.main.speed), rain: calcInch(data.main.rain)},
545 humidity: data.main.humidity,
546 pressure: data.main.pressure,
547- wind_speed_kmh: data.wind.speed,
548- wind_speed_mph: calcMph(data.wind.speed),
549- wind_deg: data.wind.deg,
550+ windDeg: data.main.deg,
551 condition: data.weather[0]
552 };
553 if(data.id !== undefined) {
554@@ -64,17 +68,20 @@
555 timestamp: data.dt,
556 metric: {
557 tempMin: data.temp.min,
558- tempMax: data.temp.max
559+ tempMax: data.temp.max,
560+ windSpeed: calcKmh(data.speed),
561+ rain: data.rain
562 },
563 imperial: {
564 tempMin: calcFahrenheit(data.temp.min),
565- tempMax: calcFahrenheit(data.temp.max)
566+ tempMax: calcFahrenheit(data.temp.max),
567+ windSpeed: calcMph(data.speed),
568+ rain: calcInch(data.rain)
569 },
570 pressure: data.pressure,
571 humidity: data.humidity,
572 condition: data.weather[0],
573- wind_speed: data.speed,
574- wind_deg: data.deg,
575+ windDeg: data.deg,
576 hourly: []
577 }
578 return result;

Subscribers

People subscribed via source and target branches