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

Proposed by Raúl Yeguas
Status: Merged
Approved by: Martin Borho
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 Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
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.
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
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
=== modified file 'components/CurrentWeather.qml'
--- components/CurrentWeather.qml 2013-07-27 16:02:29 +0000
+++ components/CurrentWeather.qml 2013-08-05 18:56:25 +0000
@@ -13,109 +13,329 @@
13 property int minTemp13 property int minTemp
14 property int maxTemp14 property int maxTemp
15 property bool showMaxTemp15 property bool showMaxTemp
16 property string scale: (mainView.settings["units"] === "imperial") ? "F" : "C"16 property int windSpeed
17 property string windDir
18 property int humidity
19 property real precipitation
20 property string tempScale: (mainView.settings["units"] === "imperial") ? "F" : "C"
21 property string speedScale: (mainView.settings["units"] === "imperial") ? "mph" : "km/h"
22 property string precipScale: (mainView.settings["units"] === "imperial") ? "in" : "mm"
1723
18 width: parent.width24 width: parent.width
19 height: childrenRect.height+units.gu(10)25 height: units.gu(40)
20 anchors.horizontalCenter: parent.horizontalCenter26 anchors.horizontalCenter: parent.horizontalCenter
2127
22 Components.WeatherConditionIconComponent {28 Flipable {
23 id: currentCondition29 id: flipable
24 width: units.gu(30)30 anchors.fill: parent
25 height: units.gu(30)31
26 anchors.horizontalCenter: parent.horizontalCenter32 property bool flipped: false
27 condition: currentWeather.icon33
2834 MouseArea {anchors.fill: parent; onClicked: flipable.flipped = !flipable.flipped}
29 NumberAnimation on opacity {35
30 id: createAnimation36 back:
31 easing.type: Easing.Linear37 Rectangle {
32 from: 038 anchors.fill: parent
33 to: 139 color: "transparent"
34 duration: 100040
35 }41 Components.WeatherConditionIconComponent {
3642 id: currentCondition2
37 Component.onCompleted: {43 width: units.gu(20)
38 createAnimation.start()44 height: units.gu(20)
39 }45 anchors.horizontalCenter: parent.horizontalCenter
40 }46 anchors.horizontalCenterOffset: units.gu(-6)
4147 condition: currentWeather.icon
42 Rectangle {48
43 id: rectangle149 NumberAnimation on opacity {
44 width: units.gu(50)50 id: createAnimation2
45 height: units.gu(10)51 easing.type: Easing.Linear
46 anchors.horizontalCenter: parent.horizontalCenter52 from: 0
47 anchors.top: currentCondition.bottom53 to: 1
48 anchors.topMargin: 054 duration: 1000
49 color: "transparent"55 }
5056
51 Column {57 Component.onCompleted: {
52 id: column158 createAnimation2.start()
53 width: units.gu(5)59 }
54 height: units.gu(5)60 }
55 anchors.rightMargin: units.gu(2)61
56 anchors.verticalCenter: parent.verticalCenter62 Rectangle {
57 anchors.right: tempCurrent.left63 id: rectangle12
58 visible: showMaxTemp64 width: units.gu(50)
5965 height: units.gu(10)
60 Label {66 anchors.horizontalCenter: parent.horizontalCenter
61 text: i18n.tr("Max.")67 anchors.top: currentCondition2.bottom
62 anchors.horizontalCenter: parent.horizontalCenter68 anchors.topMargin: 0
63 font.pixelSize: FontUtils.sizeToPixels("small")69 color: "transparent"
64 horizontalAlignment: Text.AlignHCenter70
65 }71 Column {
6672 id: column12
67 Label {73 width: units.gu(5)
68 id: tempMax74 height: units.gu(5)
69 text: maxTemp+"°"+currentWeather.scale75 anchors.rightMargin: units.gu(2)
70 anchors.horizontalCenter: parent.horizontalCenter76 anchors.verticalCenter: parent.verticalCenter
71 font.pixelSize: FontUtils.sizeToPixels("large")77 anchors.right: tempCurrent2.left
72 horizontalAlignment: Text.AlignHCenter78 visible: showMaxTemp
73 color: Theme.palette.normal.baseText79
74 }80 Label {
75 }81 text: i18n.tr("Max.")
7682 anchors.horizontalCenter: parent.horizontalCenter
77 Text {83 font.pixelSize: FontUtils.sizeToPixels("small")
78 width: units.gu(17)84 horizontalAlignment: Text.AlignHCenter
79 height: units.gu(10)85 }
80 id: tempCurrent86
81 objectName: "CurrentTempText"87 Label {
82 text: currentTemp+String("°")+currentWeather.scale88 id: tempMax2
83 style: Text.Normal89 text: maxTemp+"°"+currentWeather.tempScale
84 font.bold: false90 anchors.horizontalCenter: parent.horizontalCenter
85 font.family: "Ubuntu"91 font.pixelSize: FontUtils.sizeToPixels("large")
86 verticalAlignment: Text.AlignVCenter92 horizontalAlignment: Text.AlignHCenter
87 anchors.horizontalCenter: parent.horizontalCenter93 color: Theme.palette.normal.baseText
88 anchors.horizontalCenterOffset: (showMaxTemp) ? 0 : -units.gu(4)94 }
89 anchors.verticalCenter: parent.verticalCenter95 }
90 font.pointSize: 5296
91 horizontalAlignment: Text.AlignHCenter97 Text {
92 color: Theme.palette.normal.baseText98 width: units.gu(17)
93 }99 height: units.gu(10)
94100 id: tempCurrent2
95 Column {101 objectName: "CurrentTempText"
96 id: column2102 text: currentTemp+String("°")+currentWeather.tempScale
97 width: units.gu(5)103 style: Text.Normal
98 height: units.gu(5)104 font.bold: false
99 anchors.leftMargin: (showMaxTemp) ? units.gu(2) : units.gu(4)105 font.family: "Ubuntu"
100 anchors.verticalCenter: parent.verticalCenter106 verticalAlignment: Text.AlignVCenter
101 anchors.left: tempCurrent.right107 anchors.horizontalCenter: parent.horizontalCenter
102108 anchors.horizontalCenterOffset: (showMaxTemp) ? 0 : -units.gu(4)
103 Label {109 anchors.verticalCenter: parent.verticalCenter
104 text: i18n.tr("Min.")110 font.pointSize: 52
105 horizontalAlignment: Text.AlignHCenter111 horizontalAlignment: Text.AlignHCenter
106 anchors.horizontalCenter: parent.horizontalCenter112 color: Theme.palette.normal.baseText
107 font.pixelSize: FontUtils.sizeToPixels("small")113 }
108 color: Theme.palette.normal.baseText114
109 }115 Column {
110116 id: column22
111 Label {117 width: units.gu(5)
112 id: tempMin118 height: units.gu(5)
113 text: minTemp+"°"+currentWeather.scale119 anchors.leftMargin: (showMaxTemp) ? units.gu(2) : units.gu(4)
114 horizontalAlignment: Text.AlignHCenter120 anchors.verticalCenter: parent.verticalCenter
115 anchors.horizontalCenter: parent.horizontalCenter121 anchors.left: tempCurrent2.right
116 font.pixelSize: FontUtils.sizeToPixels("large")122
117 color: Theme.palette.normal.baseText123 Label {
118 }124 text: i18n.tr("Min.")
119 }125 horizontalAlignment: Text.AlignHCenter
120 }126 anchors.horizontalCenter: parent.horizontalCenter
121}127 font.pixelSize: FontUtils.sizeToPixels("small")
128 color: Theme.palette.normal.baseText
129 }
130
131 Label {
132 id: tempMin2
133 text: minTemp+"°"+currentWeather.tempScale
134 horizontalAlignment: Text.AlignHCenter
135 anchors.horizontalCenter: parent.horizontalCenter
136 font.pixelSize: FontUtils.sizeToPixels("large")
137 color: Theme.palette.normal.baseText
138 }
139 }
140 }
141
142 Column {
143 id: windColumn
144 anchors.left: currentCondition2.right
145 anchors.leftMargin: units.gu(3)
146 height: childrenRect.height
147 width: childrenRect.width
148
149 Label {
150 id: windLabel
151 text: i18n.tr("Wind")
152 horizontalAlignment: Text.AlignLeft
153 font.pixelSize: FontUtils.sizeToPixels("small")
154 color: Theme.palette.normal.baseText
155 }
156 Label {
157 id: windValue
158 text: currentWeather.windSpeed+" "+currentWeather.speedScale+" "+currentWeather.windDir
159 horizontalAlignment: Text.AlignLeft
160 font.pixelSize: FontUtils.sizeToPixels("large")
161 color: Theme.palette.normal.baseText
162 }
163 }
164
165 Column {
166 id: humidityColumn
167 anchors.left: currentCondition2.right
168 anchors.leftMargin: units.gu(3)
169 anchors.top: windColumn.bottom
170 anchors.topMargin: units.gu(2)
171 height: childrenRect.height
172 width: childrenRect.width
173
174 Label {
175 id: humidityLabel
176 text: i18n.tr("Humidity")
177 horizontalAlignment: Text.AlignLeft
178 font.pixelSize: FontUtils.sizeToPixels("small")
179 color: Theme.palette.normal.baseText
180 }
181 Label {
182 id: humidityValue
183 text: currentWeather.humidity+"%"
184 horizontalAlignment: Text.AlignLeft
185 font.pixelSize: FontUtils.sizeToPixels("large")
186 color: Theme.palette.normal.baseText
187 }
188 }
189
190 Column {
191 id: precipitationColumn
192 anchors.left: currentCondition2.right
193 anchors.leftMargin: units.gu(3)
194 anchors.top: humidityColumn.bottom
195 anchors.topMargin: units.gu(2)
196 height: childrenRect.height
197 width: childrenRect.width
198
199 Label {
200 id: precipitationLabel
201 text: i18n.tr("Precipitation")
202 horizontalAlignment: Text.AlignLeft
203 font.pixelSize: FontUtils.sizeToPixels("small")
204 color: Theme.palette.normal.baseText
205 }
206 Label {
207 id: precipitationValue
208 text: currentWeather.precipitation.toFixed(1)+" "+currentWeather.precipScale
209 horizontalAlignment: Text.AlignLeft
210 font.pixelSize: FontUtils.sizeToPixels("large")
211 color: Theme.palette.normal.baseText
212 }
213 }
214 }
215
216 front:
217 Rectangle {
218 anchors.fill: parent
219 color: "transparent"
220
221 Components.WeatherConditionIconComponent {
222 id: currentCondition
223 width: units.gu(30)
224 height: units.gu(30)
225 anchors.horizontalCenter: parent.horizontalCenter
226 condition: currentWeather.icon
227
228 NumberAnimation on opacity {
229 id: createAnimation
230 easing.type: Easing.Linear
231 from: 0
232 to: 1
233 duration: 1000
234 }
235
236 Component.onCompleted: {
237 createAnimation.start()
238 }
239 }
240
241 Rectangle {
242 id: rectangle1
243 width: units.gu(50)
244 height: units.gu(10)
245 anchors.horizontalCenter: parent.horizontalCenter
246 anchors.top: currentCondition.bottom
247 anchors.topMargin: 0
248 color: "transparent"
249
250 Column {
251 id: column1
252 width: units.gu(5)
253 height: units.gu(5)
254 anchors.rightMargin: units.gu(2)
255 anchors.verticalCenter: parent.verticalCenter
256 anchors.right: tempCurrent.left
257 visible: showMaxTemp
258
259 Label {
260 text: i18n.tr("Max.")
261 anchors.horizontalCenter: parent.horizontalCenter
262 font.pixelSize: FontUtils.sizeToPixels("small")
263 horizontalAlignment: Text.AlignHCenter
264 }
265
266 Label {
267 id: tempMax
268 text: maxTemp+"°"+currentWeather.tempScale
269 anchors.horizontalCenter: parent.horizontalCenter
270 font.pixelSize: FontUtils.sizeToPixels("large")
271 horizontalAlignment: Text.AlignHCenter
272 color: Theme.palette.normal.baseText
273 }
274 }
275
276 Text {
277 width: units.gu(17)
278 height: units.gu(10)
279 id: tempCurrent
280 objectName: "CurrentTempText"
281 text: currentTemp+String("°")+currentWeather.tempScale
282 style: Text.Normal
283 font.bold: false
284 font.family: "Ubuntu"
285 verticalAlignment: Text.AlignVCenter
286 anchors.horizontalCenter: parent.horizontalCenter
287 anchors.horizontalCenterOffset: (showMaxTemp) ? 0 : -units.gu(4)
288 anchors.verticalCenter: parent.verticalCenter
289 font.pointSize: 52
290 horizontalAlignment: Text.AlignHCenter
291 color: Theme.palette.normal.baseText
292 }
293
294 Column {
295 id: column2
296 width: units.gu(5)
297 height: units.gu(5)
298 anchors.leftMargin: (showMaxTemp) ? units.gu(2) : units.gu(4)
299 anchors.verticalCenter: parent.verticalCenter
300 anchors.left: tempCurrent.right
301
302 Label {
303 text: i18n.tr("Min.")
304 horizontalAlignment: Text.AlignHCenter
305 anchors.horizontalCenter: parent.horizontalCenter
306 font.pixelSize: FontUtils.sizeToPixels("small")
307 color: Theme.palette.normal.baseText
308 }
309
310 Label {
311 id: tempMin
312 text: minTemp+"°"+currentWeather.tempScale
313 horizontalAlignment: Text.AlignHCenter
314 anchors.horizontalCenter: parent.horizontalCenter
315 font.pixelSize: FontUtils.sizeToPixels("large")
316 color: Theme.palette.normal.baseText
317 }
318 }
319 }
320 }
321
322 transform: Rotation {
323 id: rotation
324 origin.x: flipable.width/2
325 origin.y: flipable.height/2
326 axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis
327 angle: 0 // the default angle
328 }
329
330 states: State {
331 name: "back"
332 PropertyChanges { target: rotation; angle: 180 }
333 when: flipable.flipped
334 }
335
336 transitions: Transition {
337 NumberAnimation { target: rotation; property: "angle"; duration: 500 }
338 }
339 }
340 }
341
122342
=== modified file 'components/LocationTab.qml'
--- components/LocationTab.qml 2013-07-27 16:02:29 +0000
+++ components/LocationTab.qml 2013-08-05 18:56:25 +0000
@@ -51,6 +51,27 @@
5151
52 // set daily forecasts52 // set daily forecasts
53 for(var x=0;x<dailyLength;x++) {53 for(var x=0;x<dailyLength;x++) {
54 var direction = "?";
55 var degrees = dailyForecasts[x].windDeg;
56 if(degrees >=0 && degrees <= 30){
57 direction = "N";
58 } else if(degrees >30 && degrees <= 60){
59 direction = "NE";
60 } else if(degrees >60 && degrees <= 120){
61 direction = "E";
62 } else if(degrees >120 && degrees <= 150){
63 direction = "SE";
64 } else if(degrees >150 && degrees <= 210){
65 direction = "S";
66 } else if(degrees >210 && degrees <= 240){
67 direction = "SW";
68 } else if(degrees >240 && degrees <= 300){
69 direction = "W";
70 } else if(degrees >300 && degrees <= 330){
71 direction = "NW";
72 }else if(degrees >330 && degrees <= 360){
73 direction = "N";
74 }
54 dayForecastModel.append({75 dayForecastModel.append({
55 dateRel: "",//Tomorrow",76 dateRel: "",//Tomorrow",
56 date: formatTimestamp(dailyForecasts[x].timestamp, 'dddd, dd MMMM yyyy'),77 date: formatTimestamp(dailyForecasts[x].timestamp, 'dddd, dd MMMM yyyy'),
@@ -60,7 +81,11 @@
60 tempMax: (dailyForecasts[x]["current"] !== undefined) ? dailyForecasts[x][units].tempMax :81 tempMax: (dailyForecasts[x]["current"] !== undefined) ? dailyForecasts[x][units].tempMax :
61 null,82 null,
62 cond: dailyForecasts[x].condition.id,83 cond: dailyForecasts[x].condition.id,
63 condIcon: dailyForecasts[x].condition.icon84 condIcon: dailyForecasts[x].condition.icon,
85 wind_speed: dailyForecasts[x][units].windSpeed,
86 wind_dir: direction,
87 humid: dailyForecasts[x].humidity,
88 precip: (dailyForecasts[x][units].rain !== null && dailyForecasts[x][units].rain !== undefined) ? dailyForecasts[x][units].rain : 0
64 });89 });
65 }90 }
66 }91 }
@@ -111,6 +136,10 @@
111 maxTemp: tempMax136 maxTemp: tempMax
112 icon: condIcon137 icon: condIcon
113 condition: cond138 condition: cond
139 windSpeed: wind_speed
140 windDir: wind_dir
141 humidity: humid
142 precipitation: precip
114 anchors.top: dateComponent.bottom143 anchors.top: dateComponent.bottom
115 showMaxTemp: (index === 0)144 showMaxTemp: (index === 0)
116 }145 }
117146
=== modified file 'components/SettingsSheet.qml'
--- components/SettingsSheet.qml 2013-07-23 21:20:11 +0000
+++ components/SettingsSheet.qml 2013-08-05 18:56:25 +0000
@@ -31,8 +31,8 @@
31 container: ListItem.ValueSelector {31 container: ListItem.ValueSelector {
32 id: unitsSelector32 id: unitsSelector
33 objectName: "UnitsSelector"33 objectName: "UnitsSelector"
34 text: i18n.tr("Temperature unit")34 text: i18n.tr("Units")
35 values: [i18n.tr("°C"), i18n.tr("°F")]35 values: [i18n.tr("Metric"), i18n.tr("Imperial")]
36 selectedIndex: (settings["units"] === "imperial") ? 1 : 0;36 selectedIndex: (settings["units"] === "imperial") ? 1 : 0;
37 }37 }
3838
3939
=== modified file 'components/WeatherApi.js'
--- components/WeatherApi.js 2013-07-27 16:01:13 +0000
+++ components/WeatherApi.js 2013-08-05 18:56:25 +0000
@@ -3,7 +3,7 @@
3* Version of the response data format.3* Version of the response data format.
4* Increase this number to force a refresh.4* Increase this number to force a refresh.
5*/5*/
6var RESPONSE_DATA_VERSION = 20130727;6var RESPONSE_DATA_VERSION = 20130801;
77
8/**8/**
9* Helper functions9* Helper functions
@@ -11,8 +11,14 @@
11function calcFahrenheit(celsius) {11function calcFahrenheit(celsius) {
12 return celsius * 1.8 + 32;12 return celsius * 1.8 + 32;
13}13}
14function calcMph(kmh) {14function calcMph(ms) {
15 return kmh*0.62137;15 return ms*2.24;
16}
17function calcInch(mm) {
18 return mm/25.4;
19}
20function calcKmh(ms) {
21 return ms*3.6;
16}22}
1723
18var OpenWeatherMapApi = (function() {24var OpenWeatherMapApi = (function() {
@@ -42,13 +48,11 @@
42 var result = {48 var result = {
43 timestamp: data.dt,49 timestamp: data.dt,
44 date: Qt.formatDateTime(new Date(data.dt*1000), "yyyy-MM-dd hh:mm"),50 date: Qt.formatDateTime(new Date(data.dt*1000), "yyyy-MM-dd hh:mm"),
45 metric: { temp:data.main.temp },51 metric: { temp:data.main.temp, windSpeed: calcKmh(data.main.speed), rain: data.main.rain},
46 imperial: { temp: calcFahrenheit(data.main.temp) },52 imperial: { temp: calcFahrenheit(data.main.temp), windSpeed: calcMph(data.main.speed), rain: calcInch(data.main.rain)},
47 humidity: data.main.humidity,53 humidity: data.main.humidity,
48 pressure: data.main.pressure,54 pressure: data.main.pressure,
49 wind_speed_kmh: data.wind.speed,55 windDeg: data.main.deg,
50 wind_speed_mph: calcMph(data.wind.speed),
51 wind_deg: data.wind.deg,
52 condition: data.weather[0]56 condition: data.weather[0]
53 };57 };
54 if(data.id !== undefined) {58 if(data.id !== undefined) {
@@ -64,17 +68,20 @@
64 timestamp: data.dt,68 timestamp: data.dt,
65 metric: {69 metric: {
66 tempMin: data.temp.min,70 tempMin: data.temp.min,
67 tempMax: data.temp.max71 tempMax: data.temp.max,
72 windSpeed: calcKmh(data.speed),
73 rain: data.rain
68 },74 },
69 imperial: {75 imperial: {
70 tempMin: calcFahrenheit(data.temp.min),76 tempMin: calcFahrenheit(data.temp.min),
71 tempMax: calcFahrenheit(data.temp.max)77 tempMax: calcFahrenheit(data.temp.max),
78 windSpeed: calcMph(data.speed),
79 rain: calcInch(data.rain)
72 },80 },
73 pressure: data.pressure,81 pressure: data.pressure,
74 humidity: data.humidity,82 humidity: data.humidity,
75 condition: data.weather[0],83 condition: data.weather[0],
76 wind_speed: data.speed,84 windDeg: data.deg,
77 wind_deg: data.deg,
78 hourly: []85 hourly: []
79 }86 }
80 return result;87 return result;

Subscribers

People subscribed via source and target branches