Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6f77979 authored by Danesh Mondegarian's avatar Danesh Mondegarian Committed by Robert Burns
Browse files

Lock screen weather : Switch to new yahoo api

Use YQL since where.yahooapis.com seems to have been shutdown

Change-Id: Id5f3096f7bc80de6f4c97c3a76cb6d603fba073d
parent e1d208de
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -17,23 +17,25 @@
package com.android.internal.util.weather;

import android.content.Context;
import android.net.Uri;

public class YahooPlaceFinder {

    private static final String YAHOO_API_BASE_REV_URL = "http://where.yahooapis.com/geocode?appid=jYkTZp64&q=%1$s,+%2$s&gflags=R";
    private static final String YAHOO_API_BASE_URL = "http://where.yahooapis.com/geocode?appid=jYkTZp64&q=%1$s";
    private static final String YAHOO_API_BASE_URL = "http://query.yahooapis.com/v1/public/yql?q=" +
            Uri.encode("select woeid from geo.placefinder where text =");

    public static String reverseGeoCode(Context c, double latitude, double longitude) {

        String url = String.format(YAHOO_API_BASE_REV_URL, String.valueOf(latitude),
                String.valueOf(longitude));
        String formattedCoordinates = String.format("\"%s %s\" and gflags=\"R\"",
                String.valueOf(latitude), String.valueOf(longitude));
        String url = YAHOO_API_BASE_URL + Uri.encode(formattedCoordinates);
        String response = new HttpRetriever().retrieve(url);
        return new WeatherXmlParser(c).parsePlaceFinderResponse(response);

    }

    public static String GeoCode(Context c, String location) {
        String url = String.format(YAHOO_API_BASE_URL, location).replace(' ', '+');
        String url = YAHOO_API_BASE_URL + Uri.encode(String.format("\"%s\"",location));
        String response = new HttpRetriever().retrieve(url);
        return new WeatherXmlParser(c).parsePlaceFinderResponse(response);
    }