Merge lp:~martin-borho/ubuntu-weather-app/reboot-real-weather-data into lp:ubuntu-weather-app

Proposed by Martin Borho
Status: Superseded
Proposed branch: lp:~martin-borho/ubuntu-weather-app/reboot-real-weather-data
Merge into: lp:ubuntu-weather-app
Diff against target: 323 lines (+169/-47)
4 files modified
app/components/HomeGraphic.qml (+3/-1)
app/ubuntu-weather-app.qml (+84/-11)
app/ui/HomePage.qml (+81/-30)
po/com.ubuntu.weather.pot (+1/-5)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/reboot-real-weather-data
Reviewer Review Type Date Requested Status
Ubuntu Weather Developers Pending
Review via email: mp+249001@code.launchpad.net

This proposal supersedes a proposal from 2015-02-07.

Description of the change

Filled static prototype components with real weather data.

To post a comment you must log in.
7. By Martin Borho

Filled static prototype components with real weather data.

Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.

8. By Andrew Hayzen

* Add bottom edge page listing the locations.

Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.

9. By Andrew Hayzen

* Use Settings API, with migration of data - deletion of old data not enabled yet.

Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.

10. By Andrew Hayzen

* Basic implementation of settings for Units, DataProvider and RefreshInterval. Fixes: https://bugs.launchpad.net/bugs/1420609.

Approved by Victor Thompson, Ubuntu Phone Apps Jenkins Bot.

11. By Martin Borho

Put locations in a Listview and all in a Flickable

12. By Martin Borho

removed snapMode for LocatioonPanes due to error

13. By Martin Borho

minor comments changes

14. By Martin Borho

added current property to settings

15. By Martin Borho

removed highlightMoveDuration

16. By Martin Borho

currentIndex gets set from settings.current

17. By Martin Borho

formatting

18. By Martin Borho

pushing HomePage.qml directly to pagestack

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/components/HomeGraphic.qml'
--- app/components/HomeGraphic.qml 2015-02-03 21:26:09 +0000
+++ app/components/HomeGraphic.qml 2015-02-07 17:40:43 +0000
@@ -23,6 +23,8 @@
23 height: units.gu(32)23 height: units.gu(32)
24 width: parent.width24 width: parent.width
2525
26 property alias icon: iconLabel.text
27
26 // TODO: will be on 'rails' (horizontal listview?) to reveal hourly forecast28 // TODO: will be on 'rails' (horizontal listview?) to reveal hourly forecast
27 Image {29 Image {
28 anchors {30 anchors {
@@ -36,10 +38,10 @@
36 color: "#F00"38 color: "#F00"
3739
38 Label {40 Label {
41 id: iconLabel
39 anchors {42 anchors {
40 centerIn: parent43 centerIn: parent
41 }44 }
42 text: "IMAGE HERE!"
43 }45 }
44 }46 }
45 }47 }
4648
=== modified file 'app/ubuntu-weather-app.qml'
--- app/ubuntu-weather-app.qml 2015-02-06 15:35:49 +0000
+++ app/ubuntu-weather-app.qml 2015-02-07 17:40:43 +0000
@@ -41,20 +41,64 @@
41 useDeprecatedToolbar: false41 useDeprecatedToolbar: false
42 anchorToKeyboard: true42 anchorToKeyboard: true
4343
44 /*
45 List of locations and their data, accessible through index
46 */
47 property var locationsList: []
48
49 /*
50 Index of Location before a refresh, to go back after
51 */
52 property int indexAtRefresh: -1
53
54 /*
55 Set default values for settings here
56 */
57 property var settings: {
58 "units": Qt.locale().measurementSystem === Locale.MetricSystem ? "metric" : "imperial",
59 "wind_units": Qt.locale().measurementSystem === Locale.MetricSystem ? "kmh" : "mph",
60 "precip_units": Qt.locale().measurementSystem === Locale.MetricSystem ? "mm" : "in",
61 "service": "weatherchannel"
62 }
63
64 /*
65 Scale symbols and labels.
66 */
67 property string tempScale
68 property string speedScale
69 property string precipScale
70 property string tempUnits
71 property string windUnits
72 property string precipUnits
73
74 /*
75 After reading the settings from storage and updating the default
76 settings with the user selected ones, (re)load pages!
77 */
44 Component.onCompleted: {78 Component.onCompleted: {
45 storage.getLocations(function(locations) {79 storage.getSettings(function(storedSettings) {
46 WeatherApi.sendRequest({80 for(var settingName in storedSettings) {
47 action: "updateData",81 settings[settingName] = storedSettings[settingName];
48 params: {82 }
49 locations:locations,83 setScalesAndLabels();
50 force:false,84 refreshData();
51 service: "weatherchannel",
52 api_key: Key.twcKey
53 }
54 }, responseDataHandler)
55 })85 })
56 }86 }
5787
88 function setScalesAndLabels() {
89 // set scales
90 tempScale = String("°") + ((settings["units"] === "imperial") ? "F" : "C")
91 speedScale = ((settings["wind_units"] === "mph") ? "mph" : "km/h")
92 precipScale = ((settings["precip_units"] === "in") ? "in" : "mm")
93 tempUnits = ((settings["units"] === 'imperial') ? 'imperial' : 'metric')
94 windUnits = ((settings["wind_units"] === 'mph') ? 'imperial' : 'metric')
95 precipUnits = ((settings["precip_units"] === 'in') ? 'imperial' : 'metric')
96 }
97
98 /*
99 Handle response data from data backend. Checks if a location
100 was updated and has to be stored again.
101 */
58 function responseDataHandler(messageObject) {102 function responseDataHandler(messageObject) {
59 if(!messageObject.error) {103 if(!messageObject.error) {
60 if(messageObject.action === "updateData") {104 if(messageObject.action === "updateData") {
@@ -65,7 +109,7 @@
65 }109 }
66 });110 });
67 //print(JSON.stringify(messageObject.result));111 //print(JSON.stringify(messageObject.result));
68 //buildTabs(messageObject.result);112 fillPages(messageObject.result);
69 }113 }
70 } else {114 } else {
71 console.log(messageObject.error.msg+" / "+messageObject.error.request.url)115 console.log(messageObject.error.msg+" / "+messageObject.error.request.url)
@@ -73,6 +117,35 @@
73 }117 }
74 }118 }
75119
120 /* Fill the location pages with their data. */
121 function fillPages(locations) {
122 locationsList = locations;
123 // refactor this when Location are in a ListView!
124 homePage.renderData();
125 }
126
127 /*
128 Refresh data, either directly from storage or by checking against
129 API instead.
130 */
131 function refreshData(from_storage, force_refresh) {
132 if(from_storage === true && force_refresh !== true) {
133 storage.getLocations(fillPages);
134 } else {
135 storage.getLocations(function(locations) {
136 WeatherApi.sendRequest({
137 action: "updateData",
138 params: {
139 locations:locations,
140 force:force_refresh,
141 service:settings["service"],
142 api_key: Key.twcKey
143 }
144 }, responseDataHandler)
145 });
146 }
147 }
148
76 Data.Storage {149 Data.Storage {
77 id: storage150 id: storage
78 }151 }
79152
=== modified file 'app/ui/HomePage.qml'
--- app/ui/HomePage.qml 2015-02-03 21:26:09 +0000
+++ app/ui/HomePage.qml 2015-02-07 17:40:43 +0000
@@ -24,14 +24,85 @@
2424
25Page {25Page {
26 // Set to null otherwise the header is shown (but blank) over the top of the listview26 // Set to null otherwise the header is shown (but blank) over the top of the listview
27 id: locationPage
27 flickable: null28 flickable: null
2829
30 /*
31 Data properties
32 */
33 property string name;
34 property string conditionText
35 property int currentTemp
36 property string todayMaxTemp
37 property string todayMinTemp
38 property string iconName
39
40 // TODO map iconnames to source image names
41 property var iconMap: {
42 "moon": "moon.svg"
43 // etc pp
44 }
45
46 /*
47 Format date object by given format.
48 */
49 function formatTimestamp(dateData, format) {
50 var date = new Date(dateData.year, dateData.month, dateData.date, dateData.hours, dateData.minutes)
51 return Qt.formatDate(date, i18n.tr(format))
52 }
53
54 /*
55 Extracts values from the location weather data and puts them into the appropriate components
56 to display them.
57
58 Attention: Data access happens through "weatherApp.locationList[]" by index, since complex
59 data in models will lead to type problems.
60 */
61 function renderData() {
62 var index = Math.floor(Math.random()*weatherApp.locationsList.length), // TODO get this value from ListView.currentIndex later!
63 data = weatherApp.locationsList[index],
64 current = data.data[0].current,
65 forecasts = data.data,
66 forecastsLength = forecasts.length,
67 today = forecasts[0],
68 tempUnits = weatherApp.tempUnits,
69 tempScale = weatherApp.tempScale;
70
71 // set general location data
72 name = data.location.adminName1;
73
74 // set current temps and condition
75 iconName = (current.icon) ? current.icon : ""
76 conditionText = (current.condition.main) ? current.condition.main : current.condition; // difference TWC/OWM
77 todayMaxTemp = (today[tempUnits].tempMax) ? Math.round(today[tempUnits].tempMax).toString() + tempScale: "";
78 todayMinTemp = Math.round(today[tempUnits].tempMin.toString()) + tempScale;
79 currentTemp = Math.round(current[tempUnits].temp);
80
81 // reset days list
82 mainPageWeekdayListView.model.clear()
83
84 // set daily forecasts
85 if(forecastsLength > 0) {
86 for(var x=1;x<forecastsLength;x++) {
87 // print(JSON.stringify(forecasts[x][units]))
88 var dayData = {
89 day: formatTimestamp(forecasts[x].date, 'dddd'),
90 low: Math.round(forecasts[x][tempUnits].tempMin).toString() + tempScale,
91 high: (forecasts[x][tempUnits].tempMax !== undefined) ? Math.round(forecasts[x][tempUnits].tempMax).toString() + tempScale : "",
92 image: (forecasts[x].icon !== undefined && iconMap[forecasts[x].icon] !== undefined) ? iconMap[forecasts[x].icon] + tempScale : ""
93 }
94 mainPageWeekdayListView.model.append(dayData);
95 }
96 }
97 }
98
29 ListView {99 ListView {
30 id: mainPageWeekdayListView100 id: mainPageWeekdayListView
31 anchors {101 anchors {
32 fill: parent102 fill: parent
33 margins: units.gu(2)103 margins: units.gu(2)
34 }104 }
105
35 header: Column {106 header: Column {
36 anchors {107 anchors {
37 left: parent.left108 left: parent.left
@@ -40,50 +111,30 @@
40 spacing: units.gu(1)111 spacing: units.gu(1)
41112
42 HeaderRow {113 HeaderRow {
43 locationName: "Hackney" // TODO: non static114 locationName: locationPage.name
44 }115 }
45116
46 HomeGraphic {117 HomeGraphic {
47118 icon: locationPage.iconName
48 }119 }
49120
50 HomeTempInfo {121 HomeTempInfo {
51 description: i18n.tr("Rainy & windy") // TODO: non static122 description: locationPage.conditionText
52 high: "13°C"123 high: locationPage.todayMaxTemp
53 low: "10°C"124 low: locationPage.todayMinTemp
54 now: "13°" // TODO: non static125 now: locationPage.currentTemp
55 }126 }
56127
57 ListItem.ThinDivider {128 ListItem.ThinDivider {
58129
59 }130 }
60 }131 }
61 model: ListModel { // TODO: non static132 model: ListModel {}
62 ListElement {133
63 day: "Saturday"
64 low: 12
65 high: 15
66 }
67 ListElement {
68 day: "Sunday"
69 low: 14
70 high: 18
71 }
72 ListElement {
73 day: "Monday"
74 low: 10
75 high: 11
76 }
77 ListElement {
78 day: "Tuesday"
79 low: -7
80 high: 0
81 }
82 }
83 delegate: DayDelegate {134 delegate: DayDelegate {
84 day: model.day135 day: model.day
85 high: model.high + "°C" // TODO: non static136 high: model.high
86 low: model.low + "°C"137 low: model.low
87 }138 }
88 }139 }
89}140}
90141
=== modified file 'po/com.ubuntu.weather.pot'
--- po/com.ubuntu.weather.pot 2015-02-03 21:26:09 +0000
+++ po/com.ubuntu.weather.pot 2015-02-07 17:40:43 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: ubuntu-weather-app\n"9"Project-Id-Version: ubuntu-weather-app\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2015-02-03 21:25+0000\n"11"POT-Creation-Date: 2015-02-07 18:30+0100\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,10 +21,6 @@
21msgid "Today"21msgid "Today"
22msgstr ""22msgstr ""
2323
24#: ../app/ui/HomePage.qml:51
25msgid "Rainy & windy"
26msgstr ""
27
28#: ubuntu-weather-app.desktop.in.in.h:124#: ubuntu-weather-app.desktop.in.in.h:1
29msgid "Weather"25msgid "Weather"
30msgstr ""26msgstr ""

Subscribers

People subscribed via source and target branches

to all changes: