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

Commit 219142b4 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: I53c981383ea6836466ef854b1e2f1db17493e812
parent 487fa765
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);
    }