Merge lp:~ahayzen/ubuntu-weather-app/reboot-settings-page into lp:ubuntu-weather-app

Proposed by Andrew Hayzen
Status: Merged
Approved by: Victor Thompson
Approved revision: 19
Merged at revision: 10
Proposed branch: lp:~ahayzen/ubuntu-weather-app/reboot-settings-page
Merge into: lp:ubuntu-weather-app
Prerequisite: lp:~ahayzen/ubuntu-weather-app/reboot-use-settings-api
Diff against target: 427 lines (+305/-6)
11 files modified
app/components/HeaderRow.qml (+2/-0)
app/data/WeatherApi.js (+2/-2)
app/ubuntu-weather-app.qml (+3/-1)
app/ui/CMakeLists.txt (+2/-0)
app/ui/HomePage.qml (+2/-2)
app/ui/Settings/CMakeLists.txt (+5/-0)
app/ui/Settings/DataProviderPage.qml (+53/-0)
app/ui/Settings/RefreshIntervalPage.qml (+56/-0)
app/ui/Settings/UnitsPage.qml (+77/-0)
app/ui/SettingsPage.qml (+62/-0)
po/com.ubuntu.weather.pot (+41/-1)
To merge this branch: bzr merge lp:~ahayzen/ubuntu-weather-app/reboot-settings-page
Reviewer Review Type Date Requested Status
Victor Thompson Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+249109@code.launchpad.net

Commit message

* Basic implementation of settings for Units, DataProvider and RefreshInterval

Description of the change

* Basic implementation of settings for Units, DataProvider and RefreshInterval

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
Victor Thompson (vthompson) wrote :

It doesn't appear as though making changes to the settings is persisting when the user leaves the page and goes back into settings.

review: Needs Fixing
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

Fixed, seems the selectedIndex changes *after* the delegate clicked signal, so now using the index from the signal itself.

16. By Andrew Hayzen

* Merge of upstream

17. By Andrew Hayzen

* Fix for options not being saved

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
Victor Thompson (vthompson) wrote :

I'm trying to debug now, but for some reason when I switch to metric for temperature units, the "tempMax" from the API does not show up in the HeadTempInfo.qml section. I don't see any errors in the console output.

The rest looks great though!

review: Needs Information
18. By Andrew Hayzen

* Fix for maxTemps <0 not appearing

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
19. By Andrew Hayzen

* Further fix for when tempMax is 0

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
Victor Thompson (vthompson) wrote :

This looks good to me. My above comment was reported as lp:1420609 and the fix for that has been introduced into this MP.

review: Approve
Revision history for this message
Victor Thompson (vthompson) wrote :

I'm going to top approve this, but we'll want to get some finalized visual's for the Settings page's sub-views. So far as I can tell, we don't have a spec for them.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/components/HeaderRow.qml'
2--- app/components/HeaderRow.qml 2015-02-03 21:26:09 +0000
3+++ app/components/HeaderRow.qml 2015-02-11 04:29:37 +0000
4@@ -42,6 +42,8 @@
5 height: width
6 width: units.gu(4)
7
8+ onClicked: mainPageStack.push(Qt.resolvedUrl("../ui/SettingsPage.qml"))
9+
10 Rectangle {
11 anchors {
12 fill: parent
13
14=== modified file 'app/data/WeatherApi.js'
15--- app/data/WeatherApi.js 2015-01-27 18:51:25 +0000
16+++ app/data/WeatherApi.js 2015-02-11 04:29:37 +0000
17@@ -480,7 +480,7 @@
18 },
19 imperial: {
20 tempMin: calcFahrenheit(data.minTemp),
21- tempMax: calcFahrenheit(data.maxTemp || data.minTemp),
22+ tempMax: calcFahrenheit(data.maxTemp !== undefined ? data.maxTemp : data.minTemp),
23 windSpeed: convertKmhToMph(partData.wSpeed)
24 },
25 precipType: partData.precip_type,
26@@ -728,7 +728,7 @@
27 api_key: message.params.api_key
28 },
29 secsFromLastFetch = (now-loc.updated)/1000;
30- if( message.params.force===true || loc.format !== RESPONSE_DATA_VERSION || secsFromLastFetch > 1800){
31+ if( message.params.force===true || loc.format !== RESPONSE_DATA_VERSION || secsFromLastFetch > params.interval){
32 // data older than 30min, location is new or data format is deprecated
33 WeatherApi.getLocationData(params, updatedHnd, onError);
34 } else {
35
36=== modified file 'app/ubuntu-weather-app.qml'
37--- app/ubuntu-weather-app.qml 2015-02-11 04:29:37 +0000
38+++ app/ubuntu-weather-app.qml 2015-02-11 04:29:37 +0000
39@@ -101,7 +101,8 @@
40 locations:locations,
41 force:force_refresh,
42 service:settings.service,
43- api_key: Key.twcKey
44+ api_key: Key.twcKey,
45+ interval: settings.refreshInterval
46 }
47 }, responseDataHandler)
48 });
49@@ -112,6 +113,7 @@
50 id: settings
51 category: "weatherSettings"
52
53+ property int refreshInterval: 1800
54 property string precipUnits
55 property string service
56 property string tempScale
57
58=== modified file 'app/ui/CMakeLists.txt'
59--- app/ui/CMakeLists.txt 2015-02-03 21:26:09 +0000
60+++ app/ui/CMakeLists.txt 2015-02-11 04:29:37 +0000
61@@ -1,3 +1,5 @@
62+add_subdirectory(Settings)
63+
64 file(GLOB UI_QML_JS_FILES *.qml *.js)
65
66 add_custom_target(ubuntu-weather-app_ui_QMlFiles ALL SOURCES ${UI_QML_JS_FILES})
67
68=== modified file 'app/ui/HomePage.qml'
69--- app/ui/HomePage.qml 2015-02-11 04:29:37 +0000
70+++ app/ui/HomePage.qml 2015-02-11 04:29:37 +0000
71@@ -35,7 +35,7 @@
72 /*
73 Data properties
74 */
75- property string name;
76+ property string name
77 property string conditionText
78 property string currentTemp
79 property string todayMaxTemp
80@@ -79,7 +79,7 @@
81 // set current temps and condition
82 iconName = (current.icon) ? current.icon : ""
83 conditionText = (current.condition.main) ? current.condition.main : current.condition; // difference TWC/OWM
84- todayMaxTemp = (today[tempUnits].tempMax) ? Math.round(today[tempUnits].tempMax).toString() + settings.tempScale: "";
85+ todayMaxTemp = (today[tempUnits].tempMax !== undefined) ? Math.round(today[tempUnits].tempMax).toString() + settings.tempScale: "";
86 todayMinTemp = Math.round(today[tempUnits].tempMin).toString() + settings.tempScale;
87 currentTemp = Math.round(current[tempUnits].temp).toString() + String("°");
88
89
90=== added directory 'app/ui/Settings'
91=== added file 'app/ui/Settings/CMakeLists.txt'
92--- app/ui/Settings/CMakeLists.txt 1970-01-01 00:00:00 +0000
93+++ app/ui/Settings/CMakeLists.txt 2015-02-11 04:29:37 +0000
94@@ -0,0 +1,5 @@
95+file(GLOB UI_SETTINGS_QML_JS_FILES *.qml *.js)
96+
97+add_custom_target(ubuntu-weather-app_ui_settings_QMlFiles ALL SOURCES ${UI_SETTINGS_QML_JS_FILES})
98+
99+install(FILES ${UI_SETTINGS_QML_JS_FILES} DESTINATION ${UBUNTU-WEATHER_APP_DIR}/ui/settings)
100
101=== added file 'app/ui/Settings/DataProviderPage.qml'
102--- app/ui/Settings/DataProviderPage.qml 1970-01-01 00:00:00 +0000
103+++ app/ui/Settings/DataProviderPage.qml 2015-02-11 04:29:37 +0000
104@@ -0,0 +1,53 @@
105+/*
106+ * Copyright (C) 2015 Canonical Ltd
107+ *
108+ * This file is part of Ubuntu Weather App
109+ *
110+ * Ubuntu Weather App is free software: you can redistribute it and/or modify
111+ * it under the terms of the GNU General Public License version 3 as
112+ * published by the Free Software Foundation.
113+ *
114+ * Ubuntu Weather App is distributed in the hope that it will be useful,
115+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
116+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117+ * GNU General Public License for more details.
118+ *
119+ * You should have received a copy of the GNU General Public License
120+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
121+ */
122+
123+import QtQuick 2.3
124+import Ubuntu.Components 1.1
125+import Ubuntu.Components.ListItems 0.1 as ListItem
126+
127+
128+Page {
129+ title: i18n.tr("Data Provider")
130+
131+ Flickable {
132+ anchors {
133+ fill: parent
134+ }
135+ height: parent.height
136+ contentHeight: unitsColumn.childrenRect.height
137+
138+ Column {
139+ id: unitsColumn
140+ anchors {
141+ fill: parent
142+ }
143+
144+ ListItem.ItemSelector {
145+ expanded: true
146+ model: ["openweathermap", "weatherchannel"] // "geonames", "geoip"]
147+ selectedIndex: model.indexOf(settings.service)
148+ text: i18n.tr("Provider")
149+
150+ onDelegateClicked: {
151+ settings.service = model[index]
152+ refreshData(false, true)
153+ }
154+ }
155+ }
156+ }
157+}
158
159=== added file 'app/ui/Settings/RefreshIntervalPage.qml'
160--- app/ui/Settings/RefreshIntervalPage.qml 1970-01-01 00:00:00 +0000
161+++ app/ui/Settings/RefreshIntervalPage.qml 2015-02-11 04:29:37 +0000
162@@ -0,0 +1,56 @@
163+/*
164+ * Copyright (C) 2015 Canonical Ltd
165+ *
166+ * This file is part of Ubuntu Weather App
167+ *
168+ * Ubuntu Weather App is free software: you can redistribute it and/or modify
169+ * it under the terms of the GNU General Public License version 3 as
170+ * published by the Free Software Foundation.
171+ *
172+ * Ubuntu Weather App is distributed in the hope that it will be useful,
173+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
174+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
175+ * GNU General Public License for more details.
176+ *
177+ * You should have received a copy of the GNU General Public License
178+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
179+ */
180+
181+import QtQuick 2.3
182+import Ubuntu.Components 1.1
183+import Ubuntu.Components.ListItems 0.1 as ListItem
184+
185+
186+Page {
187+ title: i18n.tr("Refresh Interval")
188+
189+ Flickable {
190+ anchors {
191+ fill: parent
192+ }
193+ height: parent.height
194+ contentHeight: unitsColumn.childrenRect.height
195+
196+ Column {
197+ id: unitsColumn
198+ anchors {
199+ fill: parent
200+ }
201+
202+ ListItem.ItemSelector {
203+ delegate: OptionSelectorDelegate {
204+ text: Math.floor(modelData / 60).toString() + " " + i18n.tr("minutes")
205+ }
206+ expanded: true
207+ model: [300, 600, 900, 1800]
208+ selectedIndex: model.indexOf(settings.refreshInterval)
209+ text: i18n.tr("Interval")
210+
211+ onDelegateClicked: {
212+ settings.refreshInterval = model[index]
213+ refreshData(false, true)
214+ }
215+ }
216+ }
217+ }
218+}
219
220=== added file 'app/ui/Settings/UnitsPage.qml'
221--- app/ui/Settings/UnitsPage.qml 1970-01-01 00:00:00 +0000
222+++ app/ui/Settings/UnitsPage.qml 2015-02-11 04:29:37 +0000
223@@ -0,0 +1,77 @@
224+/*
225+ * Copyright (C) 2015 Canonical Ltd
226+ *
227+ * This file is part of Ubuntu Weather App
228+ *
229+ * Ubuntu Weather App is free software: you can redistribute it and/or modify
230+ * it under the terms of the GNU General Public License version 3 as
231+ * published by the Free Software Foundation.
232+ *
233+ * Ubuntu Weather App is distributed in the hope that it will be useful,
234+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
235+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
236+ * GNU General Public License for more details.
237+ *
238+ * You should have received a copy of the GNU General Public License
239+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
240+ */
241+
242+import QtQuick 2.3
243+import Ubuntu.Components 1.1
244+import Ubuntu.Components.ListItems 0.1 as ListItem
245+
246+
247+Page {
248+ title: i18n.tr("Units")
249+
250+ Flickable {
251+ anchors {
252+ fill: parent
253+ }
254+ height: parent.height
255+ contentHeight: unitsColumn.childrenRect.height
256+
257+ Column {
258+ id: unitsColumn
259+ anchors {
260+ fill: parent
261+ }
262+
263+ ListItem.ItemSelector {
264+ expanded: true
265+ model: ["°C", "°F"]
266+ selectedIndex: model.indexOf(settings.tempScale)
267+ text: i18n.tr("Temperature")
268+
269+ onDelegateClicked: {
270+ settings.tempScale = model[index]
271+ refreshData()
272+ }
273+ }
274+
275+ ListItem.ItemSelector {
276+ expanded: true
277+ model: ["mm", "in"]
278+ selectedIndex: model.indexOf(settings.precipUnits)
279+ text: i18n.tr("Precipitation")
280+
281+ onDelegateClicked: {
282+ settings.precipUnits = model[index]
283+ refreshData()
284+ }
285+ }
286+
287+ ListItem.ItemSelector {
288+ expanded: true
289+ model: ["kmh", "mph"]
290+ text: i18n.tr("Wind Speed")
291+ selectedIndex: model.indexOf(settings.windUnits)
292+
293+ onDelegateClicked: {
294+ settings.windUnits = model[index]
295+ refreshData()
296+ }
297+ }
298+ }
299+ }
300+}
301
302=== added file 'app/ui/SettingsPage.qml'
303--- app/ui/SettingsPage.qml 1970-01-01 00:00:00 +0000
304+++ app/ui/SettingsPage.qml 2015-02-11 04:29:37 +0000
305@@ -0,0 +1,62 @@
306+/*
307+ * Copyright (C) 2015 Canonical Ltd
308+ *
309+ * This file is part of Ubuntu Weather App
310+ *
311+ * Ubuntu Weather App is free software: you can redistribute it and/or modify
312+ * it under the terms of the GNU General Public License version 3 as
313+ * published by the Free Software Foundation.
314+ *
315+ * Ubuntu Weather App is distributed in the hope that it will be useful,
316+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
317+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
318+ * GNU General Public License for more details.
319+ *
320+ * You should have received a copy of the GNU General Public License
321+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
322+ */
323+
324+import QtQuick 2.3
325+import Ubuntu.Components 1.1
326+import Ubuntu.Components.ListItems 0.1 as ListItem
327+
328+
329+Page {
330+ title: i18n.tr("Settings")
331+
332+ Flickable {
333+ anchors {
334+ fill: parent
335+ }
336+ height: parent.height
337+ contentHeight: settingsColumn.childrenRect.height
338+
339+ Column {
340+ id: settingsColumn
341+ anchors {
342+ fill: parent
343+ }
344+
345+ ListItem.SingleValue {
346+ progression: true
347+ text: i18n.tr("Units")
348+
349+ onClicked: mainPageStack.push(Qt.resolvedUrl("Settings/UnitsPage.qml"))
350+ }
351+
352+ ListItem.SingleValue {
353+ progression: true
354+ text: i18n.tr("Data Provider")
355+
356+ onClicked: mainPageStack.push(Qt.resolvedUrl("Settings/DataProviderPage.qml"))
357+ }
358+
359+ ListItem.SingleValue {
360+ progression: true
361+ text: i18n.tr("Refresh Interval")
362+
363+ onClicked: mainPageStack.push(Qt.resolvedUrl("Settings/RefreshIntervalPage.qml"))
364+ }
365+ }
366+ }
367+}
368
369=== modified file 'po/com.ubuntu.weather.pot'
370--- po/com.ubuntu.weather.pot 2015-02-11 04:29:37 +0000
371+++ po/com.ubuntu.weather.pot 2015-02-11 04:29:37 +0000
372@@ -8,7 +8,7 @@
373 msgstr ""
374 "Project-Id-Version: ubuntu-weather-app\n"
375 "Report-Msgid-Bugs-To: \n"
376-"POT-Creation-Date: 2015-02-09 19:09+0000\n"
377+"POT-Creation-Date: 2015-02-11 04:15+0000\n"
378 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
379 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
380 "Language-Team: LANGUAGE <LL@li.org>\n"
381@@ -25,6 +25,46 @@
382 msgid "Locations"
383 msgstr ""
384
385+#: ../app/ui/Settings/DataProviderPage.qml:25 ../app/ui/SettingsPage.qml:49
386+msgid "Data Provider"
387+msgstr ""
388+
389+#: ../app/ui/Settings/DataProviderPage.qml:44
390+msgid "Provider"
391+msgstr ""
392+
393+#: ../app/ui/Settings/RefreshIntervalPage.qml:25 ../app/ui/SettingsPage.qml:56
394+msgid "Refresh Interval"
395+msgstr ""
396+
397+#: ../app/ui/Settings/RefreshIntervalPage.qml:42
398+msgid "minutes"
399+msgstr ""
400+
401+#: ../app/ui/Settings/RefreshIntervalPage.qml:47
402+msgid "Interval"
403+msgstr ""
404+
405+#: ../app/ui/Settings/UnitsPage.qml:25 ../app/ui/SettingsPage.qml:42
406+msgid "Units"
407+msgstr ""
408+
409+#: ../app/ui/Settings/UnitsPage.qml:44
410+msgid "Temperature"
411+msgstr ""
412+
413+#: ../app/ui/Settings/UnitsPage.qml:56
414+msgid "Precipitation"
415+msgstr ""
416+
417+#: ../app/ui/Settings/UnitsPage.qml:67
418+msgid "Wind Speed"
419+msgstr ""
420+
421+#: ../app/ui/SettingsPage.qml:25
422+msgid "Settings"
423+msgstr ""
424+
425 #: ubuntu-weather-app.desktop.in.in.h:1
426 msgid "Weather"
427 msgstr ""

Subscribers

People subscribed via source and target branches

to all changes: