Merge lp:~gary-wzl77/ubuntu-weather-app/fix_1518888 into lp:ubuntu-weather-app

Proposed by Gary.Wang on 2016-01-06
Status: Merged
Approved by: Andrew Hayzen on 2016-12-17
Approved revision: 222
Merged at revision: 251
Proposed branch: lp:~gary-wzl77/ubuntu-weather-app/fix_1518888
Merge into: lp:ubuntu-weather-app
Diff against target: 470 lines (+210/-34)
13 files modified
AUTHORS (+2/-0)
CMakeLists.txt (+5/-1)
app/components/CurrentLocation.qml (+5/-22)
app/components/HomeHourly.qml (+1/-1)
app/data/WeatherApi.js (+2/-1)
app/data/keys.js (+1/-1)
app/ubuntu-weather-app.qml (+170/-4)
app/ui/HomePage.qml (+3/-0)
app/ui/LocationPane.qml (+3/-1)
debian/changelog (+3/-0)
manifest.json.in (+2/-1)
po/com.ubuntu.weather.pot (+8/-2)
ubuntu-weather-app.url-dispatcher (+5/-0)
To merge this branch: bzr merge lp:~gary-wzl77/ubuntu-weather-app/fix_1518888
Reviewer Review Type Date Requested Status
Andrew Hayzen Approve on 2016-11-24
Jenkins Bot continuous-integration Approve on 2016-08-31
Victor Thompson 2016-01-06 Pending
Review via email: mp+281719@code.launchpad.net

Commit message

1.Add url-dispatcher to enable user to navigate weather app from weather scope
2.Add argument(display) to show hourly view when its value is "hourly" on startup

Description of the change

1.Add url-dispatcher to enable user to navigate weather app from weather scope.
2.Add argument(display) to show hourly view when its value is "hourly" on startup.

To post a comment you must log in.
review: Approve (continuous-integration)
194. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-01-06

Launchpad automatic translations update.

Andrew Hayzen (ahayzen) wrote :

Thanks for starting this :-)

I've found a few issues while looking at the code:
1) You are using Arguments not Connections { target: UriHandler; onOpened: { ... } } which means that the UrlHandler only works when the app is first started, not if the application was already running. Please refer to the docs [0] or music app [1] for how this works.
2) The idea is that this will be run from the scope, however you can search for any location in the scope and you can have any set of locations loaded in the weather app. So I could be on London in the scope, then click to open the weather-app and the weather-app could be at Berlin, this would not be very useful.

I suggest that you provide the latitude and longitude into the UriHandler so use something such as weather://latitiude/longitude/days for example for London hourly this could be weather://51.50853/0.12574/1 or for a 5 day forecast you could then use weather://51.50853/0.12574/5

The weather could the detect if the location exists and switch to the relevant page, or if it doesn't show a temporary view that allows them to view the info, but also save that as a location in their list.

It's probably best that a mail thread is started between the weather app devs, if we want to discuss the protocol design further.

Furthermore could you add yourself to the AUTHORS file and add an entry into the debian/changelog (use the tool $ dch ).

0 - https://developer.ubuntu.com/api/apps/qml/sdk-15.04.1/Ubuntu.Components.UriHandler/
1 - http://bazaar.launchpad.net/~music-app-dev/music-app/trunk/view/head:/app/components/Helpers/UriHandlerHelper.qml#L29

review: Needs Fixing
Gary.Wang (gary-wzl77) wrote :
Download full text (3.6 KiB)

Thanks for your reply.

1) You are using Arguments not Connections { target: UriHandler; onOpened:
{ ... } } which means that the UrlHandler only works when the app is first
started, not if the application was already running. Please refer to the
docs [0] or music app [1] for how this works.
A: Good suggestion, will fix in next MR update.

2) The idea is that this will be run from the scope, however you can search
for any location in the scope and you can have any set of locations loaded
in the weather app. So I could be on London in the scope, then click to
open the weather-app and the weather-app could be at Berlin, this would not
be very useful.
A: That's also an idea from David who reviews weather scope. will fix in
weather scope at first.

I suggest that you provide the latitude and longitude into the UriHandler
so use something such as weather://latitude/longitude/days for example for
London hourly this could be weather://51.50853/0.12574/1 or for a 5 day
forecast you could then use weather://51.50853/0.12574/5
A: weather://51.50853/0.12574/5 format is not that reasonable. I prefer
to keep current implementation(url parameters) by appending geo
information. E.g.
weather://?display=hourly&city=London&lat=51.50853&lng=-0.12574
weather://?display=default&city=London&lat=51.50853&lng=-0.12574

The weather could the detect if the location exists and switch to the
relevant page, or if it doesn't show a temporary view that allows them to
view the info, but also save that as a location in their list.
A: That's my general idea for this as well. if location exists, switch to
the relevant page. if not, searching location info based on lat&lng at
firstly, and switch to the regarding page then.

Thanks. Will update the MR later on.

On Wed, Jan 6, 2016 at 8:40 PM, Andrew Hayzen <email address hidden> wrote:

> Review: Needs Fixing
>
> Thanks for starting this :-)
>
> I've found a few issues while looking at the code:
> 1) You are using Arguments not Connections { target: UriHandler; onOpened:
> { ... } } which means that the UrlHandler only works when the app is first
> started, not if the application was already running. Please refer to the
> docs [0] or music app [1] for how this works.
> 2) The idea is that this will be run from the scope, however you can
> search for any location in the scope and you can have any set of locations
> loaded in the weather app. So I could be on London in the scope, then click
> to open the weather-app and the weather-app could be at Berlin, this would
> not be very useful.
>
> I suggest that you provide the latitude and longitude into the UriHandler
> so use something such as weather://latitiude/longitude/days for example for
> London hourly this could be weather://51.50853/0.12574/1 or for a 5 day
> forecast you could then use weather://51.50853/0.12574/5
>
> The weather could the detect if the location exists and switch to the
> relevant page, or if it doesn't show a temporary view that allows them to
> view the info, but also save that as a location in their list.
>
> It's probably best that a mail thread is started between the weather app
> devs, if we want to discuss the protocol design further.
>
>
> Furtherm...

Read more...

review: Needs Fixing (continuous-integration)
Gary.Wang (gary-wzl77) wrote :

Hi Andrew
1. Does the missing API key cause test run failed?
2. Is there any access limits for following API, at times I didn't get respond from it for a long time
http://api.geonames.org/findNearbyPlaceNameJSON?style=full&username=uweatherdev&lat=51.5047&lng=-0.1283&maxRows=25&featureClass=P

Thanks.

195. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-01-09

Launchpad automatic translations update.

Andrew Hayzen (ahayzen) wrote :

1) Yup, you will require the API keys to OWM/TWC to run the tests, please message me privately if you require them
2) geonames does have a limit and there is a bug 1326918 to migrate to the ubuntu one.

196. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-01-13

Launchpad automatic translations update.

197. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-01-14

Launchpad automatic translations update.

198. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-01-28

Launchpad automatic translations update.

199. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-01-29

Launchpad automatic translations update.

200. By Andrew Hayzen on 2016-01-29

* Use sidestage so that tablets don't go into portrait mode.

Approved by Jenkins Bot, Alan Pope .

201. By Victor Thompson on 2016-01-29

* Change translatable string from "rain" to "precipitation". Fixes: https://bugs.launchpad.net/bugs/1521701.

Approved by Jenkins Bot, Bartosz Kosiorek.

202. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-01-30

Launchpad automatic translations update.

203. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-01-31

Launchpad automatic translations update.

204. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-01

Launchpad automatic translations update.

205. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-02

Launchpad automatic translations update.

206. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-03

Launchpad automatic translations update.

207. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-04

Launchpad automatic translations update.

208. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-05

Launchpad automatic translations update.

209. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-06

Launchpad automatic translations update.

210. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-07

Launchpad automatic translations update.

211. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-08

Launchpad automatic translations update.

212. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-09

Launchpad automatic translations update.

213. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-10

Launchpad automatic translations update.

214. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-11

Launchpad automatic translations update.

215. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-13

Launchpad automatic translations update.

216. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-16

Launchpad automatic translations update.

217. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-17

Launchpad automatic translations update.

218. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-23

Launchpad automatic translations update.

219. By Launchpad Translations on behalf of ubuntu-weather-dev on 2016-02-26

Launchpad automatic translations update.

220. By Gary.Wang on 2016-02-29

Add url-dispatcher to support for app launching from weather scope

review: Needs Fixing (continuous-integration)
Andrew Hayzen (ahayzen) wrote :

This looks to be progressing well, is there a silo or debs for the scope so that we can test this? Or are you manually running a the URI-handler from a command? If so do you mind sharing to assist in the testing of the branch?

review: Needs Information
221. By Gary.Wang on 2016-08-25

merge from trunk.

Gary.Wang (gary-wzl77) wrote :

Hi Andrew
   Sorry for the late response,
   I've been cleaning up the bugs on my hand, The following link you can find a armhf-based test scope, which allows you to open weather app from the scope and check the current temperature for three different locations.
   London(belvedere)
   Berlin(mitte)
   Roma(trevi)

   https://drive.google.com/open?id=0B2H9ECPSSfqIc2xybjlxc0F4SGc
   Please playing around it and verify it on the device.

   Thanks.
   Sorry again for the delay.

P.S due to the API count limitation, sometimes main view didn't navigate to specific location page as we didn't get current temperature information.

review: Approve (continuous-integration)
Andrew Hayzen (ahayzen) wrote :

I've installed the scope and this branch on my device.

I've noticed a few functional issues to discuss first:
1) When I open via the scope, it causes all of the views (swiping across) to change to have the hourly view already shown, is this a design decision or an issue? (I wasn't expecting *all* the locations to change to hourly view, maybe only the location I had clicked in the scope)
2) I know you said there were API limitations, but I have not yet been able to select one of the locations in the scopes and then receive the respective location in the app. It always jumps to my 2nd non-location detected location.

Could you describe the expected scenarios here? For example
- if you click on a location and you already have the location, I assume it would jump to it?
- if you click on a location and you don't already have the location, I assume it will add a section - but will this be temporary? or remain in the saved list?

Also are you expecting this to work with both OpenWeatherMap and TheWeatherChannel.

If you want to discuss any of these issues with me, feel free to ping me (ahayzen) on IRC. I'm around in London daytime.

review: Needs Fixing
222. By Gary.Wang on 2016-10-08

refresh data even if location exists, which allows to show respective location's weather info if it can be found in db.

Gary.Wang (gary-wzl77) wrote :

Sorry for the late reply(Just got back from vacation).

Basically, regarding the issue you have that
" It always jumps to my 2nd non-location detected location."
I guess you got the problem by checking the location from scope that app has recorded in db.
Indeed, i can reproduce it and fixed it in the latest commit.

Could you describe the expected scenarios here? For example
- if you click on a location and you already have the location, I assume it would jump to it?
A: Yes
- if you click on a location and you don't already have the location, I assume it will add a section - but will this be temporary? or remain in the saved list?
A:It will add a new location and save it in the location list and navigate to hourlyView to show the location's weather info.

I record a video to show how it works under the scenarios you mentioned above.
https://drive.google.com/open?id=0B2H9ECPSSfqIak42YmU4MGducGs

Pre-condition:
    App only records my current location(Chengdu)

1. Click 'London' in scope to add a new location(Belvedere) in weather app(scenario 2)
2. Click 'Berlin' in scope to add a new location(Mitte) in weather app(scenario 2)
3. Click 'London' again from scope to jump to respective location(Belvedere) in weather app (scenario 1)
4. Click 'Roma' from scope to add a new location(Trevi) in weather app (scenario 2)

P.S:
1.if weather information is not able to be fetched via lat&lng due to api limits, the expected result is "Just open the app and stays at hourly view"
2.During my testing, new feature works fine with two providers(open weather map/the weather channel). In general, as long as backend APIs support to retrieve weather info via latitude and longitude, there would be no problem to add new provider in the future.

Andrew Hayzen (ahayzen) wrote :

As discussed, it seems my issues occur when a manual location (London) has been added via the search functionality in the app.

Otherwise, when I don't have and manual search locations added, this functions as expected :-)

Gary.Wang (gary-wzl77) wrote :

OKay, after taking a closer look, basically it's a bug of the scope, not weather app. I hardcoded the location name("London") for each item in scope. That's why it always jumps to the detected location(London) during your testing.

After the following change was made in scope, it should be working well.
- std::string openUri = "weather://?display=hourly&city=London&lat=" + lat + "&lng=" + lng;
+std::string openUri = "weather://?display=hourly&city=" + loc + "&lat=" + lat + "&lng=" + lng;

I attached the latest scope. Could you please have a check again?
https://drive.google.com/open?id=0B2H9ECPSSfqIZkY4UzhnWGJydzA

Sorry for the noise.
Thanks. :)

Andrew Hayzen (ahayzen) wrote :

OK this is looking better, the only thing i've noticed is that if I have London as a location, when I click London it still jumps to London rather than Belvedere. But I'm thinking that is expected as it is coming from the &city=" + loc + " part of the uri.

So functionally I think this is pretty much there, I'll work on doing a code review next :-)

Andrew Hayzen (ahayzen) wrote :

So testing this I’ve found that the restoration of which index you had previously selected is broken (but it also appears to be in trunk as well?)

Also in the code you have stated "NOTE: potential minor issue: cities with the same name in different countries", I think the best thing todo is report a bug with low priority stating the scenario in which this could happen.

Therefore I'm going to approve this branch, and we can fix the other issues separately.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'AUTHORS'
--- AUTHORS 2016-01-18 22:47:05 +0000
+++ AUTHORS 2016-10-08 08:45:35 +0000
@@ -9,3 +9,5 @@
9Nekhelesh Ramananthan <krnekhelesh@gmail.com>9Nekhelesh Ramananthan <krnekhelesh@gmail.com>
10Vamshi Balanaga <vamrocks602@gmail.com>10Vamshi Balanaga <vamrocks602@gmail.com>
11Victor Thompson <victor.thompson@gmail.com>11Victor Thompson <victor.thompson@gmail.com>
12Carla Sella <carla.sella@gmail.com>
13Gary Wang <Gary.Wang@canonical.com>
1214
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-11-01 18:35:08 +0000
+++ CMakeLists.txt 2016-10-08 08:45:35 +0000
@@ -32,6 +32,7 @@
32set(APP_HARDCODE ubuntu-weather-app)32set(APP_HARDCODE ubuntu-weather-app)
33set(MAIN_QML app/${APP_HARDCODE}.qml)33set(MAIN_QML app/${APP_HARDCODE}.qml)
34set(DESKTOP_FILE "${APP_HARDCODE}.desktop")34set(DESKTOP_FILE "${APP_HARDCODE}.desktop")
35set(URLS_FILE "${APP_HARDCODE}.url-dispatcher")
35set(ICON app/weather-app@30.png)36set(ICON app/weather-app@30.png)
36set(AUTOPILOT_DIR ubuntu_weather_app)37set(AUTOPILOT_DIR ubuntu_weather_app)
3738
@@ -41,8 +42,9 @@
41 set(UBUNTU-WEATHER_APP_DIR "${CMAKE_INSTALL_DATADIR}/qml")42 set(UBUNTU-WEATHER_APP_DIR "${CMAKE_INSTALL_DATADIR}/qml")
4243
43 set(QT_IMPORTS_DIR "${CMAKE_INSTALL_LIBDIR}")44 set(QT_IMPORTS_DIR "${CMAKE_INSTALL_LIBDIR}")
44 set(EXEC "qmlscene $@ ${MAIN_QML}")45 set(EXEC "qmlscene %u ${MAIN_QML}")
45 set(DATA_DIR /)46 set(DATA_DIR /)
47 set(URLS_DIR ${DATA_DIR})
4648
47 set(MODULE_PATH ${QT_IMPORTS_DIR})49 set(MODULE_PATH ${QT_IMPORTS_DIR})
48 if(NOT BZR_REVNO)50 if(NOT BZR_REVNO)
@@ -97,6 +99,8 @@
97install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE}99install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE}
98 DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)100 DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
99101
102install(FILES ${URLS_FILE} DESTINATION ${URLS_DIR})
103
100add_subdirectory(app)104add_subdirectory(app)
101add_subdirectory(po)105add_subdirectory(po)
102add_subdirectory(tests)106add_subdirectory(tests)
103107
=== modified file 'app/components/CurrentLocation.qml'
--- app/components/CurrentLocation.qml 2016-07-19 11:24:58 +0000
+++ app/components/CurrentLocation.qml 2016-10-08 08:45:35 +0000
@@ -28,26 +28,6 @@
2828
29 property string string: "Undefined"29 property string string: "Undefined"
3030
31 function searchForLocation(lat, lon) {
32 WeatherApi.sendRequest({
33 action: "searchByPoint",
34 params: {
35 coords: {
36 lat: lat,
37 lon: lon
38 }
39 }
40 }, searchResponseHandler)
41 }
42
43 function searchResponseHandler(msgObject) {
44 if (!msgObject.error && settings.detectCurrentLocation) {
45 console.log("Loc to add:", JSON.stringify(msgObject.result.locations[0]))
46 storage.updateCurrentLocation(msgObject.result.locations[0])
47 }
48 }
49
50
51 PositionSource {31 PositionSource {
52 id: currentPosition32 id: currentPosition
53 updateInterval: 100033 updateInterval: 1000
@@ -80,7 +60,10 @@
8060
81 onCountChanged: {61 onCountChanged: {
82 // Update the currentLocation if one is found and it does not match the stored location62 // Update the currentLocation if one is found and it does not match the stored location
83 if (count > 0 && currentLocation.string !== geocodeModel.get(0).address.city) {63 // if there is a location request from url on startup, we ignore this first a few times when signal is triggerd
64 // to avoid view position to current location. It works after requestLocationByUrl was set to undefined
65 if (weatherApp.requestLocationByUrl === undefined
66 && count > 0 && currentLocation.string !== geocodeModel.get(0).address.city) {
84 search();67 search();
85 }68 }
86 }69 }
@@ -88,7 +71,7 @@
88 function search() {71 function search() {
89 var loc = geocodeModel.get(0)72 var loc = geocodeModel.get(0)
90 currentLocation.string = loc.address.city73 currentLocation.string = loc.address.city
91 searchForLocation(loc.coordinate.latitude, loc.coordinate.longitude)74 searchForLocation("searchByPoint", loc.coordinate.latitude, loc.coordinate.longitude)
92 }75 }
93 }76 }
9477
9578
=== modified file 'app/components/HomeHourly.qml'
--- app/components/HomeHourly.qml 2015-11-02 21:28:34 +0000
+++ app/components/HomeHourly.qml 2016-10-08 08:45:35 +0000
@@ -39,7 +39,7 @@
39 MouseArea {39 MouseArea {
40 anchors.fill: parent40 anchors.fill: parent
41 onClicked: {41 onClicked: {
42 homeGraphic.visible = true42 graphicVisible = true
43 }43 }
44 }44 }
4545
4646
=== modified file 'app/data/WeatherApi.js'
--- app/data/WeatherApi.js 2016-06-04 21:02:30 +0000
+++ app/data/WeatherApi.js 2016-10-08 08:45:35 +0000
@@ -797,7 +797,8 @@
797 // perform the api calls797 // perform the api calls
798 if(message.action === "searchByName") {798 if(message.action === "searchByName") {
799 WeatherApi.search("name", message.params, finished, onError);799 WeatherApi.search("name", message.params, finished, onError);
800 } else if(message.action === "searchByPoint") {800 } else if(message.action === "searchByPoint"
801 || message.action === "searchByUrl") {
801 WeatherApi.search("point", message.params, finished, onError);802 WeatherApi.search("point", message.params, finished, onError);
802 } else if(message.action === "getGeoIp") {803 } else if(message.action === "getGeoIp") {
803 WeatherApi.geoLookup(message.params, finished, onError);804 WeatherApi.geoLookup(message.params, finished, onError);
804805
=== modified file 'app/data/keys.js'
--- app/data/keys.js 2015-11-09 10:37:47 +0000
+++ app/data/keys.js 2016-10-08 08:45:35 +0000
@@ -1,2 +1,2 @@
1var twcKey = "";1var twcKey = "";
2var owmKey = ""; // See README for details on how to obtain a personal API key2var owmKey = ""; // goto http://openweathermap.org/appid to get a personal API key
33
=== modified file 'app/ubuntu-weather-app.qml'
--- app/ubuntu-weather-app.qml 2015-11-02 21:28:34 +0000
+++ app/ubuntu-weather-app.qml 2016-10-08 08:45:35 +0000
@@ -64,11 +64,27 @@
64 property bool networkError: false64 property bool networkError: false
6565
66 /*66 /*
67 Indicates of the location info requested from Url
68 */
69 property var requestLocationByUrl;
70
71 /*
67 (re)load the pages on completion72 (re)load the pages on completion
68 */73 */
69 Component.onCompleted: {74 Component.onCompleted: {
75 var url = args.defaultArgument.at(0)
76 var argus = parseArguments(url);
77
78 mainPageStack.push(Qt.resolvedUrl("ui/HomePage.qml"), {"hourlyVisible": argus.hourlyVisible})
79
70 storage.getLocations(fillPages);80 storage.getLocations(fillPages);
71 refreshData();81 if (argus.city && argus.lat && argus.lng) {
82 if (positionViewAtCity(argus.city) === -1) {
83 searchForLocation("searchByUrl", argus.lat, argus.lng)
84 }
85 } else {
86 refreshData();
87 }
72 }88 }
7389
74 /*90 /*
@@ -86,6 +102,20 @@
86 });102 });
87 //print(JSON.stringify(messageObject.result));103 //print(JSON.stringify(messageObject.result));
88 fillPages(messageObject.result);104 fillPages(messageObject.result);
105
106 //1.Re-position current display index at requested location index
107 //2.Prevent index changed after reorder when geoChanged is triggered on startup
108 if (requestLocationByUrl) {
109 for (var i = 0; i < locationsList.length; i++) {
110 var loc = locationsList[i].location;
111 if (requestLocationByUrl !== undefined && loc.services.geonames !== undefined &&
112 requestLocationByUrl.services.geonames === loc.services.geonames) {
113 settings.current = i;
114 requestLocationByUrl = undefined
115 break;
116 }
117 }
118 }
89 }119 }
90 } else {120 } else {
91 console.log(messageObject.error.msg+" / "+messageObject.error.request.url)121 console.log(messageObject.error.msg+" / "+messageObject.error.request.url)
@@ -113,7 +143,7 @@
113 } else {143 } else {
114 storage.getLocations(function(locations) {144 storage.getLocations(function(locations) {
115 WeatherApi.sendRequest({145 WeatherApi.sendRequest({
116 action: "updateData",146 action: "updateData",
117 params: {147 params: {
118 locations: locations,148 locations: locations,
119 force: force_refresh,149 force: force_refresh,
@@ -127,6 +157,143 @@
127 }157 }
128 }158 }
129159
160 /*
161 parse arguments retrieved from url. The url format can be as following:
162 weather://?display=hourly&city=London&lat=51.50853&lng=-0.12574
163 */
164 function parseArguments(url) {
165 var arguments = url.substring(url.lastIndexOf('?') + 1).split('&');
166
167 var hourlyVisible = false;
168 var city, lat, lng;
169 var index = 0;
170 while(index < arguments.length) {
171 var params = arguments[index].split('=');
172 if (params[0] === "display")
173 hourlyVisible = params[1] === "hourly" ? true: false;
174 if (params[0] === "lng")
175 lng = params[1];
176 if (params[0] === "lat")
177 lat = params[1];
178 if (params[0] === "city")
179 city = params[1];
180
181 index++;
182 }
183
184 return {"hourlyVisible": hourlyVisible, "city": city, "lat": lat, "lng" : lng}
185 }
186
187 /*
188 Positions the view that with the specified cityName,
189 return pos index of the city if it can be found in locationlist
190 and return -1 if city is not found in locationlist.
191 NOTE: potential minor issue: cities with the same name in different countries
192 */
193 function positionViewAtCity(cityName) {
194 var index = -1;
195
196 for (var i = 0; i < locationsList.length; i++) {
197 var loc = locationsList[i].location;
198 if (cityName === loc.name) {
199 settings.current = i;
200 index = i;
201 break;
202 }
203 }
204
205 return index;
206 }
207
208 function searchForLocation(action, lat, lon) {
209 WeatherApi.sendRequest({
210 action: action,
211 params: {
212 coords: {
213 lat: lat,
214 lon: lon
215 }
216 }
217 }, searchResponseHandler)
218 }
219
220 function searchResponseHandler(msgObject) {
221 if (!msgObject.error ) {
222 console.log("Loc to add:", JSON.stringify(msgObject.result.locations[0]))
223 if (msgObject.action === "searchByUrl") {
224 requestLocationByUrl = msgObject.result.locations[0];
225 storage.addLocation(requestLocationByUrl)
226 } else if (settings.detectCurrentLocation) {
227 storage.updateCurrentLocation(msgObject.result.locations[0])
228 }
229 }
230 }
231
232 Arguments {
233 id: args;
234
235 defaultArgument.help: i18n.tr("One arguments for weather app: --display, --city, --lat, --lng They will be managed by system. See the source for a full comment about them");
236 defaultArgument.valueNames: ["URL"]
237
238 /* ARGUMENTS on startup
239 *
240 * Display hourly view when startup. This enable us to navigate weather app from weather scope
241 * Keyword: display
242 * Value: hourly or default
243 *
244 * Location information. This enable us to navigate relevant city weather view with geo information specified
245 * please pass all three basic geo parameters together when requesting specific city weather
246 * Keyword: city
247 * Value: city name
248 *
249 * Keyword: lat
250 * Value: latitude of city
251 *
252 * Keyword: lng
253 * Value: longitude of city
254 */
255
256 Argument {
257 name: "display"
258 required: false
259 valueNames: ["DISPLAY"]
260 }
261
262 Argument {
263 name: "city"
264 required: false
265 valueNames: ["CITY"]
266 }
267
268 Argument {
269 name: "lat"
270 required: false
271 valueNames: ["LATITUDE"]
272 }
273
274 Argument {
275 name: "lng"
276 required: false
277 valueNames: ["LONGITUDE"]
278 }
279 }
280
281 Connections {
282 target: UriHandler
283 onOpened: {
284 var argus = parseArguments(uris[0]);
285 if (argus.city && argus.lat && argus.lng) {
286 while (mainPageStack.depth > 1) {
287 mainPageStack.pop()
288 }
289
290 if (positionViewAtCity(argus.city) === -1) {
291 searchForLocation("searchByUrl", argus.lat, argus.lng)
292 }
293 }
294 }
295 }
296
130 CurrentLocation {297 CurrentLocation {
131 id: currentLocation298 id: currentLocation
132 }299 }
@@ -204,8 +371,8 @@
204 if(location.dbId === undefined || location.dbId === 0) {371 if(location.dbId === undefined || location.dbId === 0) {
205 storage.insertLocation({location: location});372 storage.insertLocation({location: location});
206 }373 }
207 refreshData();
208 }374 }
375 refreshData();
209376
210 return !exists;377 return !exists;
211 }378 }
@@ -294,6 +461,5 @@
294461
295 PageStack {462 PageStack {
296 id: mainPageStack463 id: mainPageStack
297 Component.onCompleted: mainPageStack.push(Qt.resolvedUrl("ui/HomePage.qml"))
298 }464 }
299}465}
300466
=== modified file 'app/ui/HomePage.qml'
--- app/ui/HomePage.qml 2016-02-28 22:53:13 +0000
+++ app/ui/HomePage.qml 2016-10-08 08:45:35 +0000
@@ -33,6 +33,8 @@
33 tipColor: UbuntuColors.orange33 tipColor: UbuntuColors.orange
34 tipLabelColor: "#FFF"34 tipLabelColor: "#FFF"
3535
36 property bool hourlyVisible : false
37
36 property var iconMap: {38 property var iconMap: {
37 "sun": "weather-clear-symbolic",39 "sun": "weather-clear-symbolic",
38 "moon": "weather-clear-night-symbolic",40 "moon": "weather-clear-night-symbolic",
@@ -109,6 +111,7 @@
109 currentIndex: settings.current111 currentIndex: settings.current
110 delegate: LocationPane {112 delegate: LocationPane {
111 objectName: "locationPane" + index113 objectName: "locationPane" + index
114 graphicVisible: !hourlyVisible
112 }115 }
113 highlightRangeMode: ListView.StrictlyEnforceRange116 highlightRangeMode: ListView.StrictlyEnforceRange
114 model: weatherApp.locationsList.length117 model: weatherApp.locationsList.length
115118
=== modified file 'app/ui/LocationPane.qml'
--- app/ui/LocationPane.qml 2016-06-04 21:12:07 +0000
+++ app/ui/LocationPane.qml 2016-10-08 08:45:35 +0000
@@ -43,6 +43,7 @@
43 property string hourlyTempUnits43 property string hourlyTempUnits
4444
45 property var todayData45 property var todayData
46 property bool graphicVisible : false
4647
47 delegate: DayDelegate {48 delegate: DayDelegate {
48 day: model.day49 day: model.day
@@ -75,10 +76,11 @@
75 HomeGraphic {76 HomeGraphic {
76 id: homeGraphic77 id: homeGraphic
77 icon: mainPageWeekdayListView.icon78 icon: mainPageWeekdayListView.icon
79 visible: graphicVisible;
78 MouseArea {80 MouseArea {
79 anchors.fill: parent81 anchors.fill: parent
80 onClicked: {82 onClicked: {
81 homeGraphic.visible = false;83 graphicVisible = false;
82 }84 }
83 }85 }
84 }86 }
8587
=== modified file 'debian/changelog'
--- debian/changelog 2016-07-19 11:24:58 +0000
+++ debian/changelog 2016-10-08 08:45:35 +0000
@@ -4,6 +4,9 @@
4 * Set useragent in geocode so that osm can uniquely identify our requests4 * Set useragent in geocode so that osm can uniquely identify our requests
5 * Release 3.3 and bump version to 3.45 * Release 3.3 and bump version to 3.4
66
7 [ Gary Wang ]
8 * Add url-dispatcher to support for app launching from weather scope (LP: #1518888)
9
7 -- Andrew Hayzen <ahayzen@gmail.com> Tue, 19 Jul 2016 12:22:57 +010010 -- Andrew Hayzen <ahayzen@gmail.com> Tue, 19 Jul 2016 12:22:57 +0100
811
9ubuntu-weather-app (3.3ubuntu1) xenial; urgency=medium12ubuntu-weather-app (3.3ubuntu1) xenial; urgency=medium
1013
=== modified file 'manifest.json.in'
--- manifest.json.in 2016-07-19 11:24:58 +0000
+++ manifest.json.in 2016-10-08 08:45:35 +0000
@@ -5,7 +5,8 @@
5 "hooks": {5 "hooks": {
6 "weather": {6 "weather": {
7 "apparmor": "ubuntu-weather-app.apparmor",7 "apparmor": "ubuntu-weather-app.apparmor",
8 "desktop": "@CMAKE_INSTALL_DATADIR@/applications/ubuntu-weather-app.desktop"8 "desktop": "@CMAKE_INSTALL_DATADIR@/applications/ubuntu-weather-app.desktop",
9 "urls": "@URLS_FILE@"
9 }10 }
10 },11 },
11 "icon": "@ICON@",12 "icon": "@ICON@",
1213
=== modified file 'po/com.ubuntu.weather.pot'
--- po/com.ubuntu.weather.pot 2016-03-26 16:48:16 +0000
+++ po/com.ubuntu.weather.pot 2016-10-08 08:45:35 +0000
@@ -1,6 +1,6 @@
1# SOME DESCRIPTIVE TITLE.1# SOME DESCRIPTIVE TITLE.
2# Copyright (C) YEAR Canonical Ltd.2# Copyright (C) YEAR Canonical Ltd.
3# This file is distributed under the same license as the ubuntu-weather-app package.3# This file is distributed under the same license as the PACKAGE package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5#5#
6#, fuzzy6#, fuzzy
@@ -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: 2016-03-26 11:43-0500\n"11"POT-Creation-Date: 2016-10-08 01:18-0700\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"
@@ -104,6 +104,12 @@
104"to obtain your own Open Weather Map API key."104"to obtain your own Open Weather Map API key."
105msgstr ""105msgstr ""
106106
107#: ../app/ubuntu-weather-app.qml:235
108msgid ""
109"One arguments for weather app: --display, --city, --lat, --lng They will be "
110"managed by system. See the source for a full comment about them"
111msgstr ""
112
107#: ../app/ui/AddLocationPage.qml:38113#: ../app/ui/AddLocationPage.qml:38
108msgid "Select a city"114msgid "Select a city"
109msgstr ""115msgstr ""
110116
=== added file 'ubuntu-weather-app.url-dispatcher'
--- ubuntu-weather-app.url-dispatcher 1970-01-01 00:00:00 +0000
+++ ubuntu-weather-app.url-dispatcher 2016-10-08 08:45:35 +0000
@@ -0,0 +1,5 @@
1[
2 {
3 "protocol": "weather"
4 }
5]

Subscribers

People subscribed via source and target branches

to all changes: