From fd3221f8699973f3fba64453a8efe88fb98f3708 Mon Sep 17 00:00:00 2001 From: Joey Rizzoli Date: Mon, 5 Jun 2017 21:04:24 +0200 Subject: Refactor cyanogemod -> lineageos Change-Id: I6aa88e034e6c7642aff6277489bd758e479b2e89 Signed-off-by: Joey Rizzoli --- .../yahooweatherprovider/ApplicationTest.java | 13 - .../yahooweatherprovider/ApplicationTest.java | 13 + app/src/main/AndroidManifest.xml | 8 +- .../yahooweatherprovider/ConverterUtils.java | 125 --------- .../yahooweatherprovider/ImagePreference.java | 29 -- .../YahooCMWeatherApplication.java | 42 --- .../yahooweatherprovider/YahooModule.java | 45 --- .../YahooPreferenceActivity.java | 66 ----- .../YahooWeatherProviderService.java | 304 --------------------- .../yahoo/WeakReferenceHandler.java | 40 --- .../yahoo/YQLQueryCreator.java | 43 --- .../yahoo/YahooServiceInterface.java | 28 -- .../yahoo/YahooWeatherRequestCallback.java | 61 ----- .../yahoo/YahooWeatherResponseListener.java | 27 -- .../yahoo/YahooWeatherServiceManager.java | 66 ----- .../yahoo/response/Admin1.java | 64 ----- .../yahoo/response/Admin2.java | 64 ----- .../yahoo/response/Admin3.java | 64 ----- .../yahoo/response/Astronomy.java | 44 --- .../yahoo/response/Atmosphere.java | 64 ----- .../yahoo/response/Channel.java | 154 ----------- .../yahoo/response/Condition.java | 64 ----- .../yahoo/response/Country.java | 65 ----- .../yahoo/response/Forecast.java | 84 ------ .../yahooweatherprovider/yahoo/response/Guid.java | 35 --- .../yahooweatherprovider/yahoo/response/Image.java | 74 ----- .../yahooweatherprovider/yahoo/response/Item.java | 117 -------- .../yahoo/response/Locality1.java | 54 ---- .../yahoo/response/Location.java | 54 ---- .../yahooweatherprovider/yahoo/response/Place.java | 89 ------ .../yahoo/response/Postal.java | 54 ---- .../yahooweatherprovider/yahoo/response/Query.java | 64 ----- .../yahoo/response/Results.java | 46 ---- .../yahooweatherprovider/yahoo/response/Units.java | 65 ----- .../yahooweatherprovider/yahoo/response/Wind.java | 54 ---- .../yahoo/response/YQLResponse.java | 34 --- .../yahooweatherprovider/ConverterUtils.java | 125 +++++++++ .../yahooweatherprovider/ImagePreference.java | 29 ++ .../YahooCMWeatherApplication.java | 42 +++ .../yahooweatherprovider/YahooModule.java | 45 +++ .../YahooPreferenceActivity.java | 66 +++++ .../YahooWeatherProviderService.java | 304 +++++++++++++++++++++ .../yahoo/WeakReferenceHandler.java | 40 +++ .../yahoo/YQLQueryCreator.java | 43 +++ .../yahoo/YahooServiceInterface.java | 28 ++ .../yahoo/YahooWeatherRequestCallback.java | 61 +++++ .../yahoo/YahooWeatherResponseListener.java | 27 ++ .../yahoo/YahooWeatherServiceManager.java | 66 +++++ .../yahoo/response/Admin1.java | 64 +++++ .../yahoo/response/Admin2.java | 64 +++++ .../yahoo/response/Admin3.java | 64 +++++ .../yahoo/response/Astronomy.java | 44 +++ .../yahoo/response/Atmosphere.java | 64 +++++ .../yahoo/response/Channel.java | 154 +++++++++++ .../yahoo/response/Condition.java | 64 +++++ .../yahoo/response/Country.java | 65 +++++ .../yahoo/response/Forecast.java | 84 ++++++ .../yahooweatherprovider/yahoo/response/Guid.java | 35 +++ .../yahooweatherprovider/yahoo/response/Image.java | 74 +++++ .../yahooweatherprovider/yahoo/response/Item.java | 117 ++++++++ .../yahoo/response/Locality1.java | 54 ++++ .../yahoo/response/Location.java | 54 ++++ .../yahooweatherprovider/yahoo/response/Place.java | 89 ++++++ .../yahoo/response/Postal.java | 54 ++++ .../yahooweatherprovider/yahoo/response/Query.java | 64 +++++ .../yahoo/response/Results.java | 46 ++++ .../yahooweatherprovider/yahoo/response/Units.java | 65 +++++ .../yahooweatherprovider/yahoo/response/Wind.java | 54 ++++ .../yahoo/response/YQLResponse.java | 34 +++ app/src/main/res/xml/preferences.xml | 2 +- app/src/main/res/xml/weather_settings_service.xml | 2 +- 71 files changed, 2302 insertions(+), 2302 deletions(-) delete mode 100644 app/src/androidTest/java/org/cyanogenmod/yahooweatherprovider/ApplicationTest.java create mode 100644 app/src/androidTest/java/org/lineageos/yahooweatherprovider/ApplicationTest.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/ImagePreference.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooCMWeatherApplication.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooModule.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooPreferenceActivity.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/WeakReferenceHandler.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YQLQueryCreator.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooServiceInterface.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherRequestCallback.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherResponseListener.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherServiceManager.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin1.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin2.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin3.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Astronomy.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Atmosphere.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Channel.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Condition.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Country.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Forecast.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Guid.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Image.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Item.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Locality1.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Location.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Place.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Postal.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Query.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Results.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Units.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Wind.java delete mode 100644 app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/YQLResponse.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/ConverterUtils.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/ImagePreference.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/YahooCMWeatherApplication.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/YahooModule.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/YahooPreferenceActivity.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/YahooWeatherProviderService.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/WeakReferenceHandler.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YQLQueryCreator.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooServiceInterface.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherRequestCallback.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherResponseListener.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherServiceManager.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin1.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin2.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin3.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Astronomy.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Atmosphere.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Channel.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Condition.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Country.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Forecast.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Guid.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Image.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Item.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Locality1.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Location.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Place.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Postal.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Query.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Results.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Units.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Wind.java create mode 100644 app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/YQLResponse.java (limited to 'app/src') diff --git a/app/src/androidTest/java/org/cyanogenmod/yahooweatherprovider/ApplicationTest.java b/app/src/androidTest/java/org/cyanogenmod/yahooweatherprovider/ApplicationTest.java deleted file mode 100644 index 5e3e664..0000000 --- a/app/src/androidTest/java/org/cyanogenmod/yahooweatherprovider/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.cyanogenmod.yahooweatherprovider; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/org/lineageos/yahooweatherprovider/ApplicationTest.java b/app/src/androidTest/java/org/lineageos/yahooweatherprovider/ApplicationTest.java new file mode 100644 index 0000000..2602d41 --- /dev/null +++ b/app/src/androidTest/java/org/lineageos/yahooweatherprovider/ApplicationTest.java @@ -0,0 +1,13 @@ +package org.lineageos.yahooweatherprovider; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 341c8ef..39426d0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,7 +12,7 @@ limitations under the License. --> + package="org.lineageos.yahooweatherprovider"> @@ -23,18 +23,18 @@ - - diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java deleted file mode 100644 index 635b5b7..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider; - -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Admin1; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Admin2; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Admin3; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Forecast; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Locality1; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Place; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Postal; - -import java.util.ArrayList; -import java.util.List; - -import cyanogenmod.providers.WeatherContract; -import cyanogenmod.weather.WeatherInfo; -import cyanogenmod.weather.WeatherLocation; - -import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.ISOLATED_THUNDERSHOWERS; -import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.NOT_AVAILABLE; -import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_SNOW_SHOWERS; -import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_THUNDERSTORMS; - -public class ConverterUtils { - - public static ArrayList convertForecastsToDayForecasts( - List forecasts, int max) { - ArrayList ret = new ArrayList<>(); - int i = 0; - for (Forecast forecast : forecasts) { - if (i > max) { - break; - } - WeatherInfo.DayForecast dayForecast = new WeatherInfo.DayForecast.Builder(offset( - Integer.parseInt(forecast.getCode()))) - .setHigh(Double.parseDouble(forecast.getHigh())) - .setLow(Double.parseDouble(forecast.getLow())) - .build(); - ret.add(dayForecast); - i++; - } - return ret; - } - - public static List convertPlacesToWeatherLocations(List places) { - List ret = new ArrayList<>(); - for (Place place : places) { - Postal postal = place.getPostal(); - Admin1 admin1 = place.getAdmin1(); - if (admin1 != null && admin1.getContent() != null) { - WeatherLocation weatherLocation = new WeatherLocation.Builder(admin1.getWoeid(), - admin1.getContent()) - .setCountry(place.getCountry().getContent()) - .setCountryId(place.getCountry().getCode()) - .setPostalCode(postal == null ? "" : postal.getContent()) - .build(); - ret.add(weatherLocation); - } - - Admin2 admin2 = place.getAdmin2(); - if (admin2 != null && admin2.getContent() != null) { - WeatherLocation weatherLocation = new WeatherLocation.Builder(admin2.getWoeid(), - admin2.getContent()) - .setCountry(place.getCountry().getContent()) - .setCountryId(place.getCountry().getCode()) - .setPostalCode(postal == null ? "" : postal.getContent()) - .build(); - ret.add(weatherLocation); - } - - Admin3 admin3 = place.getAdmin3(); - if (admin3 != null && admin3.getContent() != null) { - WeatherLocation weatherLocation = new WeatherLocation.Builder(admin3.getWoeid(), - admin3.getContent()) - .setCountry(place.getCountry().getContent()) - .setCountryId(place.getCountry().getCode()) - .setPostalCode(postal == null ? "" : postal.getContent()) - .build(); - ret.add(weatherLocation); - } - - Locality1 locality1 = place.getLocality1(); - if (locality1 != null && locality1.getContent() != null) { - WeatherLocation weatherLocation = new WeatherLocation.Builder( - locality1.getWoeid(), - locality1.getContent()) - .setCountry(place.getCountry().getContent()) - .setCountryId(place.getCountry().getCode()) - .setPostalCode(postal == null ? "" : postal.getContent()) - .build(); - ret.add(weatherLocation); - } - } - return ret; - } - - public static int offset(int conditionCode) { - if (conditionCode <= WeatherContract.WeatherColumns.WeatherCode.SHOWERS) { - return conditionCode; - } else if (conditionCode <= SCATTERED_THUNDERSTORMS) { - return conditionCode - 1; - } else if (conditionCode <= SCATTERED_SNOW_SHOWERS) { - return conditionCode - 2; - } else if (conditionCode <= ISOLATED_THUNDERSHOWERS) { - return conditionCode - 3; - } else { - return NOT_AVAILABLE; - } - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ImagePreference.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ImagePreference.java deleted file mode 100644 index bac4822..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ImagePreference.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.cyanogenmod.yahooweatherprovider; - -import android.content.Context; -import android.preference.Preference; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -public class ImagePreference extends Preference { - public ImagePreference(Context context) { - super(context); - } - - public ImagePreference(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ImagePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } - - @Override - protected View onCreateView(ViewGroup parent) { - LayoutInflater li = (LayoutInflater) - getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE ); - return li.inflate(R.layout.image_preference, parent, false); - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooCMWeatherApplication.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooCMWeatherApplication.java deleted file mode 100644 index 51265a2..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooCMWeatherApplication.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider; - -import android.app.Application; -import android.content.Context; - -import dagger.ObjectGraph; - -public class YahooCMWeatherApplication extends Application { - - private ObjectGraph mObjectGraph; - - @Override - public void onCreate() { - super.onCreate(); - mObjectGraph = ObjectGraph.create(new YahooModule(this)); - } - - public static YahooCMWeatherApplication get(Context context) { - return (YahooCMWeatherApplication) context.getApplicationContext(); - } - - public final void inject(Object object) { - mObjectGraph.inject(object); - } - -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooModule.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooModule.java deleted file mode 100644 index 6bc1176..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooModule.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider; - -import org.cyanogenmod.yahooweatherprovider.yahoo.YahooWeatherServiceManager; - -import javax.inject.Singleton; - -import dagger.Module; -import dagger.Provides; - -@Module( - injects = { - YahooWeatherProviderService.class, - } -) -public class YahooModule { - - private YahooCMWeatherApplication mWeatherApplication; - - public YahooModule(YahooCMWeatherApplication weatherApplication) { - mWeatherApplication = weatherApplication; - } - - @Provides - @Singleton - public YahooWeatherServiceManager providesYahooWeatherServiceManager() { - return new YahooWeatherServiceManager(); - } - -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooPreferenceActivity.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooPreferenceActivity.java deleted file mode 100644 index 58c9bb6..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooPreferenceActivity.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider; - -import android.app.ActionBar; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.preference.Preference; -import android.preference.PreferenceActivity; -import android.view.MenuItem; - -public class YahooPreferenceActivity extends PreferenceActivity - implements Preference.OnPreferenceClickListener { - private static final String IMAGE_KEY = "image_key"; - private static final String YAHOO_URL = "https://www.yahoo.com/?ilc=401"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.preferences); - - final Preference imagePreference = findPreference(IMAGE_KEY); - imagePreference.setOnPreferenceClickListener(this); - ActionBar actionBar = getActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - break; - } - return super.onOptionsItemSelected(item); - } - - @Override - public boolean onPreferenceClick(Preference preference) { - switch (preference.getKey()) { - case IMAGE_KEY: - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(YAHOO_URL)); - startActivity(intent); - return true; - } - return false; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java deleted file mode 100644 index 92fb895..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java +++ /dev/null @@ -1,304 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider; - -import android.content.Context; -import android.location.Address; -import android.location.Criteria; -import android.location.Geocoder; -import android.location.LocationManager; -import android.os.Message; -import android.text.TextUtils; -import android.util.Log; - -import org.cyanogenmod.yahooweatherprovider.yahoo.WeakReferenceHandler; -import org.cyanogenmod.yahooweatherprovider.yahoo.YahooWeatherRequestCallback; -import org.cyanogenmod.yahooweatherprovider.yahoo.YahooWeatherResponseListener; -import org.cyanogenmod.yahooweatherprovider.yahoo.YahooWeatherServiceManager; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Atmosphere; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Channel; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Condition; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Forecast; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Location; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Place; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Query; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Results; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.Wind; -import org.cyanogenmod.yahooweatherprovider.yahoo.response.YQLResponse; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -import javax.inject.Inject; - -import cyanogenmod.providers.WeatherContract; -import cyanogenmod.weather.RequestInfo; -import cyanogenmod.weather.WeatherInfo; -import cyanogenmod.weather.WeatherLocation; -import cyanogenmod.weatherservice.ServiceRequest; -import cyanogenmod.weatherservice.ServiceRequestResult; -import cyanogenmod.weatherservice.WeatherProviderService; -import retrofit2.Call; - -public class YahooWeatherProviderService extends WeatherProviderService - implements YahooWeatherResponseListener { - - private static final String TAG = YahooWeatherProviderService.class.getSimpleName(); - private static final int SERVICE_REQUEST_CANCELLED = -1; - private static final int SERVICE_REQUEST_SUBMITTED = 0; - - //TODO, add a setting for this - private static final int MAX_FORECAST_DAYS = 5; - - @Inject - public YahooWeatherServiceManager mYahooWeatherServiceManager; - - @Override - public void onCreate() { - super.onCreate(); - YahooCMWeatherApplication.get(this).inject(this); - } - - @Override - protected void onRequestSubmitted(ServiceRequest serviceRequest) { - Log.d(TAG, "Received service request: " + serviceRequest.toString()); - Message request = mHandler.obtainMessage(SERVICE_REQUEST_SUBMITTED, serviceRequest); - request.sendToTarget(); - } - - @Override - protected void onRequestCancelled(ServiceRequest serviceRequest) { - Log.d(TAG, "Received service request cancelled: " + serviceRequest.toString()); - Message request = mHandler.obtainMessage(SERVICE_REQUEST_CANCELLED, serviceRequest); - request.sendToTarget(); - } - - private final NonLeakyMessageHandler mHandler = new NonLeakyMessageHandler(this); - - private static class NonLeakyMessageHandler - extends WeakReferenceHandler { - public NonLeakyMessageHandler(YahooWeatherProviderService reference) { - super(reference); - } - - @Override - protected void handleMessage(YahooWeatherProviderService reference, - Message inputMessage) { - ServiceRequest serviceRequest = (ServiceRequest)inputMessage.obj; - switch (inputMessage.what) { - case SERVICE_REQUEST_SUBMITTED: - RequestInfo requestInfo = serviceRequest.getRequestInfo(); - switch (requestInfo.getRequestType()) { - case RequestInfo.TYPE_WEATHER_BY_WEATHER_LOCATION_REQ: - case RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ: - reference.handleWeatherRequest(serviceRequest); - break; - case RequestInfo.TYPE_LOOKUP_CITY_NAME_REQ: - reference.handleLookupRequest(serviceRequest); - break; - default: - //Don't support anything else, fail. - serviceRequest.fail(); - break; - } - break; - case SERVICE_REQUEST_CANCELLED: - //TODO; Implement - break; - default: - //Don't support anything else, fail. - if (serviceRequest != null) { - serviceRequest.fail(); - } - } - } - } - - private void handleLookupRequest(ServiceRequest serviceRequest) { - final RequestInfo requestInfo = serviceRequest.getRequestInfo(); - - String cityName = requestInfo.getCityName(); - - if (TextUtils.isEmpty(cityName)) { - Log.d(TAG, "Null citname return"); - serviceRequest.fail(); - return; - } - - Call wundergroundCall = mYahooWeatherServiceManager.lookupCity(cityName); - wundergroundCall.enqueue(new YahooWeatherRequestCallback(serviceRequest, this)); - } - - - private void handleWeatherRequest(final ServiceRequest serviceRequest) { - final RequestInfo requestInfo = serviceRequest.getRequestInfo(); - Log.d(TAG, "Received weather request info: " + requestInfo.toString()); - - if (requestInfo.getRequestType() == RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ) { - android.location.Location location = requestInfo.getLocation(); - if (location == null) { - LocationManager locationManager = (LocationManager) - getSystemService(Context.LOCATION_SERVICE); - Criteria criteria = new Criteria(); - criteria.setAccuracy(Criteria.ACCURACY_HIGH); - location = locationManager.getLastKnownLocation(locationManager.getBestProvider( - criteria, false)); - } - handleRequestByGeoLocation(location, serviceRequest); - } else { - WeatherLocation weatherLocation = requestInfo.getWeatherLocation(); - handleRequestByWeatherLocation(weatherLocation, serviceRequest); - } - } - - /** - * Enqueue request by geolocation (lat/long) - */ - private void handleRequestByGeoLocation(android.location.Location location, - final ServiceRequest serviceRequest) { - Geocoder gcd = new Geocoder(this, Locale.getDefault()); - try { - List

addresses = gcd.getFromLocation(location.getLatitude(), - location.getLongitude(), 1); - Address address = addresses.get(0); - Call wundergroundCall = - mYahooWeatherServiceManager.query(address.getCountryName(), - address.getLocality()); - wundergroundCall.enqueue(new YahooWeatherRequestCallback(serviceRequest, this)); - } catch (IOException e) { - Log.d(TAG, "Failed to get addresses"); - serviceRequest.fail(); - } - } - - /** - * Enqueue request by weatherlocation - */ - private void handleRequestByWeatherLocation(WeatherLocation weatherLocation, - final ServiceRequest serviceRequest) { - - Call wundergroundCall = null; - if (weatherLocation.getCity() != null) { - wundergroundCall = - mYahooWeatherServiceManager.query(weatherLocation.getState(), - weatherLocation.getCity()); - } - //TODO: Add postal code support - //else if (weatherLocation.getPostalCode() != null) { - // wundergroundCall = - // mYahooWeatherServiceManager.query(weatherLocation.getPostalCode()); - //} - else { - Log.e(TAG, "Unable to handle service request"); - serviceRequest.fail(); - return; - } - - wundergroundCall.enqueue(new YahooWeatherRequestCallback(serviceRequest, this)); - } - - @Override - public void processYahooWeatherResponse(YQLResponse yqlResponse, ServiceRequest serviceRequest) { - switch (serviceRequest.getRequestInfo().getRequestType()) { - case RequestInfo.TYPE_WEATHER_BY_WEATHER_LOCATION_REQ: - case RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ: - processWeatherRequest(yqlResponse, serviceRequest); - break; - case RequestInfo.TYPE_LOOKUP_CITY_NAME_REQ: - processCityLookupRequest(yqlResponse, serviceRequest); - break; - default: - //Don't support anything else, fail. - serviceRequest.fail(); - } - } - - private void processWeatherRequest(YQLResponse yqlResponse, ServiceRequest serviceRequest) { - final Query queryResponse = yqlResponse.getQuery(); - final Results results = queryResponse.getResults(); - - if (results == null) { - Log.d(TAG, "Null query results, return"); - serviceRequest.fail(); - return; - } - final Channel channel = results.getChannel(); - final Location location = channel.getLocation(); - final Condition condition = channel.getItem().getCondition(); - final Atmosphere atmosphere = channel.getAtmosphere(); - final Wind wind = channel.getWind(); - final Forecast[] forecasts = channel.getItem().getForecast(); - - final WeatherInfo.Builder weatherInfoBuilder = new WeatherInfo.Builder(location.getCity(), - Double.parseDouble(condition.getTemp()), - WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT); - - // Set current weather condition code - weatherInfoBuilder.setWeatherCondition( - ConverterUtils.offset(Integer.parseInt(condition.getCode()))); - - // Set humidity - weatherInfoBuilder.setHumidity(Double.parseDouble(atmosphere.getHumidity())); - - // Set wind arguments - weatherInfoBuilder.setWind(Double.parseDouble(wind.getSpeed()), - Double.parseDouble(wind.getDirection()), - WeatherContract.WeatherColumns.WindSpeedUnit.MPH); - - // Set high and low for today from the simple forecast days - weatherInfoBuilder.setTodaysHigh(Double.parseDouble(forecasts[0].getHigh())); - weatherInfoBuilder.setTodaysLow(Double.parseDouble(forecasts[0].getLow())); - - ArrayList forecastList = - ConverterUtils.convertForecastsToDayForecasts( - Arrays.asList(forecasts), MAX_FORECAST_DAYS); - - weatherInfoBuilder.setForecast(forecastList); - - ServiceRequestResult serviceRequestResult = - new ServiceRequestResult.Builder(weatherInfoBuilder.build()) - .build(); - serviceRequest.complete(serviceRequestResult); - } - - private void processCityLookupRequest(YQLResponse yqlResponse, ServiceRequest serviceRequest) { - final Query queryResponse = yqlResponse.getQuery(); - final Results results = queryResponse.getResults(); - - if (results == null) { - Log.d(TAG, "Null query results, return"); - serviceRequest.fail(); - return; - } - - final Place[] places = results.getPlace(); - - if (places == null) { - Log.d(TAG, "Null places, return"); - serviceRequest.fail(); - return; - } - - ServiceRequestResult serviceRequestResult = - new ServiceRequestResult.Builder(ConverterUtils.convertPlacesToWeatherLocations( - Arrays.asList(places))).build(); - serviceRequest.complete(serviceRequestResult); - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/WeakReferenceHandler.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/WeakReferenceHandler.java deleted file mode 100644 index 0711b45..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/WeakReferenceHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo; - -import android.os.Handler; -import android.os.Message; - -import java.lang.ref.WeakReference; - -public abstract class WeakReferenceHandler extends Handler { - private WeakReference mReference; - - public WeakReferenceHandler(T reference) { - mReference = new WeakReference(reference); - } - - @Override - public void handleMessage(Message msg) { - T reference = mReference.get(); - if (reference == null) - return; - handleMessage(reference, msg); - } - - protected abstract void handleMessage(T reference, Message msg); -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YQLQueryCreator.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YQLQueryCreator.java deleted file mode 100644 index b8153af..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YQLQueryCreator.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo; - -import android.net.Uri; - -public class YQLQueryCreator { - private final static String YQL_FORECAST_QUERY = - Uri.encode("select * from weather.forecast where woeid in"); - private final static String YQL_LOCATION_QUERY = - Uri.encode("select woeid, postal, admin1, admin2, admin3, " + - "locality1, locality2, country from geo.places where " + - "(placetype = 7 or placetype = 8 or placetype = 9 " + - "or placetype = 10 or placetype = 11 or placetype = 20) and text = "); - - private YQLQueryCreator(){ - } - - public static String getForecastQuery(String state, String city) { - String params = "(select woeid from geo.places(1) where text=\"" + city + "," + state - + "\") and u='f'"; - return YQL_FORECAST_QUERY + Uri.encode(params); - } - - public static String getLocationQuery(String input) { - String params = "\"" + input + "\""; - return YQL_LOCATION_QUERY + Uri.encode(params); - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooServiceInterface.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooServiceInterface.java deleted file mode 100644 index 06beda9..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooServiceInterface.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo; - -import org.cyanogenmod.yahooweatherprovider.yahoo.response.YQLResponse; - -import retrofit2.Call; -import retrofit2.http.GET; -import retrofit2.http.Query; - -public interface YahooServiceInterface { - @GET("/v1/public/yql?format=json&env=store://datatables.org/alltableswithkeys") - Call query(@Query(value = "q", encoded = true) String query); -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherRequestCallback.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherRequestCallback.java deleted file mode 100644 index 33753b8..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherRequestCallback.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo; - -import android.util.Log; - -import org.cyanogenmod.yahooweatherprovider.yahoo.response.YQLResponse; - -import cyanogenmod.weatherservice.ServiceRequest; -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; - -public class YahooWeatherRequestCallback implements Callback { - private static final String TAG = YahooWeatherRequestCallback.class.getSimpleName(); - private ServiceRequest mServiceRequest; - private YahooWeatherResponseListener mYahooWeatherResponseListener; - - public YahooWeatherRequestCallback(ServiceRequest serviceRequest, - YahooWeatherResponseListener yahooWeatherdResponseListener) { - mServiceRequest = serviceRequest; - mYahooWeatherResponseListener = yahooWeatherdResponseListener; - } - - @Override - public void onResponse(Call call, Response response) { - if (response.isSuccessful()) { - Log.d(TAG, "Received response:\n" + response.body().toString()); - YQLResponse wundergroundReponse = response.body(); - if (wundergroundReponse == null) { - Log.d(TAG, "Null wu reponse, return"); - mServiceRequest.fail(); - return; - } - mYahooWeatherResponseListener.processYahooWeatherResponse( - wundergroundReponse, mServiceRequest); - } else { - Log.d(TAG, "Response " + response.toString()); - } - } - - @Override - public void onFailure(Call call, Throwable t) { - Log.d(TAG, "Failure " + t.toString()); - mServiceRequest.fail(); - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherResponseListener.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherResponseListener.java deleted file mode 100644 index 2e4f468..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherResponseListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo; - -import org.cyanogenmod.yahooweatherprovider.yahoo.response.YQLResponse; - -import cyanogenmod.weatherservice.ServiceRequest; - - -public interface YahooWeatherResponseListener { - void processYahooWeatherResponse(YQLResponse yqlResponse, - ServiceRequest serviceRequest); -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherServiceManager.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherServiceManager.java deleted file mode 100644 index 19c33a3..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/YahooWeatherServiceManager.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo; - -import android.util.Log; - -import org.cyanogenmod.yahooweatherprovider.yahoo.response.YQLResponse; - -import okhttp3.OkHttpClient; -import okhttp3.logging.HttpLoggingInterceptor; -import retrofit2.Call; -import retrofit2.Retrofit; -import retrofit2.converter.gson.GsonConverterFactory; - -public class YahooWeatherServiceManager { - private final static String TAG = "YahooServiceManager"; - private final static boolean DEBUG = Log.isLoggable(TAG, Log.VERBOSE); - - private final YahooServiceInterface mYahooServiceInterface; - - public YahooWeatherServiceManager() { - Retrofit baseAdapter = buildRestAdapter(); - mYahooServiceInterface = baseAdapter.create(YahooServiceInterface.class); - } - - public Call query(String state, String city) { - String forecastQuery = YQLQueryCreator.getForecastQuery(state, city); - return mYahooServiceInterface.query(forecastQuery); - } - - public Call lookupCity(String city) { - String locationQuery = YQLQueryCreator.getLocationQuery(city); - return mYahooServiceInterface.query(locationQuery); - } - - private Retrofit buildRestAdapter() { - final OkHttpClient.Builder builder = new OkHttpClient().newBuilder(); - if (DEBUG) { - final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); - loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); - builder.addInterceptor(loggingInterceptor); - } - final OkHttpClient client = builder.build(); - - final String baseUrl = "https://query.yahooapis.com"; - return new Retrofit.Builder() - .baseUrl(baseUrl) - .client(client) - .addConverterFactory(GsonConverterFactory.create()) - .build(); - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin1.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin1.java deleted file mode 100644 index 67ba44d..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin1.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Admin1 { - private String content; - - private String woeid; - - private String code; - - private String type; - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getWoeid() { - return woeid; - } - - public void setWoeid(String woeid) { - this.woeid = woeid; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "[content = " + content + ", woeid = " + woeid + ", code = " + code + ", type = " + type + "]"; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin2.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin2.java deleted file mode 100644 index 436073a..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin2.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Admin2 { - private String content; - - private String woeid; - - private String code; - - private String type; - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getWoeid() { - return woeid; - } - - public void setWoeid(String woeid) { - this.woeid = woeid; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "[content = " + content + ", woeid = " + woeid + ", code = " + code + ", type = " + type + "]"; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin3.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin3.java deleted file mode 100644 index 8bcc005..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Admin3.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Admin3 { - private String content; - - private String woeid; - - private String code; - - private String type; - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getWoeid() { - return woeid; - } - - public void setWoeid(String woeid) { - this.woeid = woeid; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "[content = " + content + ", woeid = " + woeid + ", code = " + code + ", type = " + type + "]"; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Astronomy.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Astronomy.java deleted file mode 100644 index be9304f..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Astronomy.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Astronomy { - private String sunset; - - private String sunrise; - - public String getSunset() { - return sunset; - } - - public void setSunset(String sunset) { - this.sunset = sunset; - } - - public String getSunrise() { - return sunrise; - } - - public void setSunrise(String sunrise) { - this.sunrise = sunrise; - } - - @Override - public String toString() { - return "[sunset = " + sunset + ", sunrise = " + sunrise + "]"; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Atmosphere.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Atmosphere.java deleted file mode 100644 index 4fea93d..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Atmosphere.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Atmosphere { - private String rising; - - private String humidity; - - private String pressure; - - private String visibility; - - public String getRising() { - return rising; - } - - public void setRising(String rising) { - this.rising = rising; - } - - public String getHumidity() { - return humidity; - } - - public void setHumidity(String humidity) { - this.humidity = humidity; - } - - public String getPressure() { - return pressure; - } - - public void setPressure(String pressure) { - this.pressure = pressure; - } - - public String getVisibility() { - return visibility; - } - - public void setVisibility(String visibility) { - this.visibility = visibility; - } - - @Override - public String toString() { - return "[rising = " + rising + ", humidity = " + humidity + ", pressure = " + pressure + ", visibility = " + visibility + "]"; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Channel.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Channel.java deleted file mode 100644 index 35f1320..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Channel.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Channel { - private Wind wind; - - private Location location; - - private String link; - - private Atmosphere atmosphere; - - private Image image; - - private String ttl; - - private Astronomy astronomy; - - private Units units; - - private String title; - - private String description; - - private Item item; - - private String lastBuildDate; - - private String language; - - public Wind getWind() { - return wind; - } - - public void setWind(Wind wind) { - this.wind = wind; - } - - public Location getLocation() { - return location; - } - - public void setLocation(Location location) { - this.location = location; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public Atmosphere getAtmosphere() { - return atmosphere; - } - - public void setAtmosphere(Atmosphere atmosphere) { - this.atmosphere = atmosphere; - } - - public Image getImage() { - return image; - } - - public void setImage(Image image) { - this.image = image; - } - - public String getTtl() { - return ttl; - } - - public void setTtl(String ttl) { - this.ttl = ttl; - } - - public Astronomy getAstronomy() { - return astronomy; - } - - public void setAstronomy(Astronomy astronomy) { - this.astronomy = astronomy; - } - - public Units getUnits() { - return units; - } - - public void setUnits(Units units) { - this.units = units; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Item getItem() { - return item; - } - - public void setItem(Item item) { - this.item = item; - } - - public String getLastBuildDate() { - return lastBuildDate; - } - - public void setLastBuildDate(String lastBuildDate) { - this.lastBuildDate = lastBuildDate; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - @Override - public String toString() { - return "[wind = " + wind + ", location = " + location + ", link = " + link + ", atmosphere = " + atmosphere + ", image = " + image + ", ttl = " + ttl + ", astronomy = " + astronomy + ", units = " + units + ", title = " + title + ", description = " + description + ", item = " + item + ", lastBuildDate = " + lastBuildDate + ", language = " + language + "]"; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Condition.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Condition.java deleted file mode 100644 index 304e665..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Condition.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Condition { - private String text; - - private String temp; - - private String code; - - private String date; - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getTemp() { - return temp; - } - - public void setTemp(String temp) { - this.temp = temp; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getDate() { - return date; - } - - public void setDate(String date) { - this.date = date; - } - - @Override - public String toString() { - return "[text = " + text + ", temp = " + temp + ", code = " + code + ", date = " + date + "]"; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Country.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Country.java deleted file mode 100644 index 4c1daaf..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Country.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Country { - private String content; - - private String woeid; - - private String code; - - private String type; - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getWoeid() { - return woeid; - } - - public void setWoeid(String woeid) { - this.woeid = woeid; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "[content = " + content + ", woeid = " + woeid + ", code = " + code + ", type = " + type + "]"; - } -} - diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Forecast.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Forecast.java deleted file mode 100644 index eb9b7d9..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Forecast.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Forecast { - private String text; - - private String high; - - private String day; - - private String code; - - private String low; - - private String date; - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getHigh() { - return high; - } - - public void setHigh(String high) { - this.high = high; - } - - public String getDay() { - return day; - } - - public void setDay(String day) { - this.day = day; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getLow() { - return low; - } - - public void setLow(String low) { - this.low = low; - } - - public String getDate() { - return date; - } - - public void setDate(String date) { - this.date = date; - } - - @Override - public String toString() { - return "[text = " + text + ", high = " + high + ", day = " + day + ", code = " + code + ", low = " + low + ", date = " + date + "]"; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Guid.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Guid.java deleted file mode 100644 index aea9589..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Guid.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Guid { - private String isPermaLink; - - public String getIsPermaLink() { - return isPermaLink; - } - - public void setIsPermaLink(String isPermaLink) { - this.isPermaLink = isPermaLink; - } - - @Override - public String toString() { - return "[isPermaLink = " + isPermaLink + "]"; - } -} - diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Image.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Image.java deleted file mode 100644 index 6357098..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Image.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Image { - private String title; - - private String height; - - private String link; - - private String width; - - private String url; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getHeight() { - return height; - } - - public void setHeight(String height) { - this.height = height; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public String getWidth() { - return width; - } - - public void setWidth(String width) { - this.width = width; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - @Override - public String toString() { - return "[title = " + title + ", height = " + height + ", link = " + link + ", width = " + width + ", url = " + url + "]"; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Item.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Item.java deleted file mode 100644 index 528e4b1..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Item.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -import java.util.Arrays; - -public class Item { - private Guid guid; - - private String pubDate; - - private String title; - - private Forecast[] forecast; - - private Condition condition; - - private String description; - - private String link; - - private String longz; - - private String lat; - - public Guid getGuid() { - return guid; - } - - public void setGuid(Guid guid) { - this.guid = guid; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public Forecast[] getForecast() { - return forecast; - } - - public void setForecast(Forecast[] forecast) { - this.forecast = forecast; - } - - public Condition getCondition() { - return condition; - } - - public void setCondition(Condition condition) { - this.condition = condition; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - public String getLong() { - return longz; - } - - public void setLong(String longz) { - this.longz = longz; - } - - public String getLat() { - return lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - @Override - public String toString() { - return "[guid = " + guid + ", pubDate = " + pubDate + ", title = " + title + ", forecast = " + Arrays.asList(forecast) + ", condition = " + condition + ", description = " + description + ", link = " + link + ", long = " + longz - + ", lat = " + lat + "]"; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Locality1.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Locality1.java deleted file mode 100644 index 901090b..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Locality1.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Locality1 { - private String content; - - private String woeid; - - private String type; - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getWoeid() { - return woeid; - } - - public void setWoeid(String woeid) { - this.woeid = woeid; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "[content = " + content + ", woeid = " + woeid + ", type = " + type + "]"; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Location.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Location.java deleted file mode 100644 index fa3ba9d..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Location.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Location { - private String region; - - private String country; - - private String city; - - public String getRegion() { - return region; - } - - public void setRegion(String region) { - this.region = region; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - @Override - public String toString() { - return "[region = " + region + ", country = " + country + ", city = " + city + "]"; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Place.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Place.java deleted file mode 100644 index 03c9011..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Place.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Place { - private String woeid; - - private Country country; - - private Admin1 admin1; - private Admin2 admin2; - private Admin3 admin3; - - private Postal postal; - - private Locality1 locality1; - - public String getWoeid() { - return woeid; - } - - public void setWoeid(String woeid) { - this.woeid = woeid; - } - - public Country getCountry() { - return country; - } - - public void setCountry(Country country) { - this.country = country; - } - - public Admin1 getAdmin1() { - return admin1; - } - - public void setAdmin1(Admin1 admin1) { - this.admin1 = admin1; - } - - public Admin2 getAdmin2() { - return admin2; - } - - public void setAdmin2(Admin2 admin2) { - this.admin2 = admin2; - } - - public Admin3 getAdmin3() { - return admin3; - } - - public void setAdmin3(Admin3 admin3) { - this.admin3 = admin3; - } - - public Postal getPostal() { - return postal; - } - - public void setPostal(Postal postal) { - this.postal = postal; - } - - public Locality1 getLocality1() { - return locality1; - } - - @Override - public String toString() { - return "[woeid = " + woeid + ", country = " + country + "]"; - } -} - diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Postal.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Postal.java deleted file mode 100644 index d3e1db1..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Postal.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Postal { - private String content; - - private String woeid; - - private String type; - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getWoeid() { - return woeid; - } - - public void setWoeid(String woeid) { - this.woeid = woeid; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "ClassPojo [content = " + content + ", woeid = " + woeid + ", type = " + type + "]"; - } -} \ No newline at end of file diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Query.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Query.java deleted file mode 100644 index 2bc7816..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Query.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Query { - private Results results; - - private String count; - - private String created; - - private String lang; - - public Results getResults() { - return results; - } - - public void setResults(Results results) { - this.results = results; - } - - public String getCount() { - return count; - } - - public void setCount(String count) { - this.count = count; - } - - public String getCreated() { - return created; - } - - public void setCreated(String created) { - this.created = created; - } - - public String getLang() { - return lang; - } - - public void setLang(String lang) { - this.lang = lang; - } - - @Override - public String toString() { - return "[results = " + results + ", count = " + count + ", created = " + created + ", lang = " + lang + "]"; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Results.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Results.java deleted file mode 100644 index 8b6a45d..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Results.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -import java.util.Arrays; - -public class Results { - private Channel channel; - - private Place[] place; - - public Channel getChannel() { - return channel; - } - - public void setChannel(Channel channel) { - this.channel = channel; - } - - public Place[] getPlace() { - return place; - } - - public void setPlace(Place[] place) { - this.place = place; - } - - @Override - public String toString() { - return "[channel = " + channel + ", place + " + Arrays.toString(place) + "]"; - } -} diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Units.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Units.java deleted file mode 100644 index 00923df..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Units.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Units { - private String distance; - - private String pressure; - - private String speed; - - private String temperature; - - public String getDistance() { - return distance; - } - - public void setDistance(String distance) { - this.distance = distance; - } - - public String getPressure() { - return pressure; - } - - public void setPressure(String pressure) { - this.pressure = pressure; - } - - public String getSpeed() { - return speed; - } - - public void setSpeed(String speed) { - this.speed = speed; - } - - public String getTemperature() { - return temperature; - } - - public void setTemperature(String temperature) { - this.temperature = temperature; - } - - @Override - public String toString() { - return "[distance = " + distance + ", pressure = " + pressure + ", speed = " + speed + ", temperature = " + temperature + "]"; - } -} - diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Wind.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Wind.java deleted file mode 100644 index 70fa91e..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/Wind.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class Wind { - private String speed; - - private String direction; - - private String chill; - - public String getSpeed() { - return speed; - } - - public void setSpeed(String speed) { - this.speed = speed; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public String getChill() { - return chill; - } - - public void setChill(String chill) { - this.chill = chill; - } - - @Override - public String toString() { - return "[speed = " + speed + ", direction = " + direction + ", chill = " + chill + "]"; - } -} - diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/YQLResponse.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/YQLResponse.java deleted file mode 100644 index bf47436..0000000 --- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/yahoo/response/YQLResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (C) 2016 The CyanogenMod Project - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.yahooweatherprovider.yahoo.response; - -public class YQLResponse { - private Query query; - - public Query getQuery() { - return query; - } - - public void setQuery(Query query) { - this.query = query; - } - - @Override - public String toString() { - return "[query = " + query + "]"; - } -} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/ConverterUtils.java b/app/src/main/java/org/lineageos/yahooweatherprovider/ConverterUtils.java new file mode 100644 index 0000000..650aca4 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/ConverterUtils.java @@ -0,0 +1,125 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider; + +import org.lineageos.yahooweatherprovider.yahoo.response.Admin1; +import org.lineageos.yahooweatherprovider.yahoo.response.Admin2; +import org.lineageos.yahooweatherprovider.yahoo.response.Admin3; +import org.lineageos.yahooweatherprovider.yahoo.response.Forecast; +import org.lineageos.yahooweatherprovider.yahoo.response.Locality1; +import org.lineageos.yahooweatherprovider.yahoo.response.Place; +import org.lineageos.yahooweatherprovider.yahoo.response.Postal; + +import java.util.ArrayList; +import java.util.List; + +import cyanogenmod.providers.WeatherContract; +import cyanogenmod.weather.WeatherInfo; +import cyanogenmod.weather.WeatherLocation; + +import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.ISOLATED_THUNDERSHOWERS; +import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.NOT_AVAILABLE; +import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_SNOW_SHOWERS; +import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_THUNDERSTORMS; + +public class ConverterUtils { + + public static ArrayList convertForecastsToDayForecasts( + List forecasts, int max) { + ArrayList ret = new ArrayList<>(); + int i = 0; + for (Forecast forecast : forecasts) { + if (i > max) { + break; + } + WeatherInfo.DayForecast dayForecast = new WeatherInfo.DayForecast.Builder(offset( + Integer.parseInt(forecast.getCode()))) + .setHigh(Double.parseDouble(forecast.getHigh())) + .setLow(Double.parseDouble(forecast.getLow())) + .build(); + ret.add(dayForecast); + i++; + } + return ret; + } + + public static List convertPlacesToWeatherLocations(List places) { + List ret = new ArrayList<>(); + for (Place place : places) { + Postal postal = place.getPostal(); + Admin1 admin1 = place.getAdmin1(); + if (admin1 != null && admin1.getContent() != null) { + WeatherLocation weatherLocation = new WeatherLocation.Builder(admin1.getWoeid(), + admin1.getContent()) + .setCountry(place.getCountry().getContent()) + .setCountryId(place.getCountry().getCode()) + .setPostalCode(postal == null ? "" : postal.getContent()) + .build(); + ret.add(weatherLocation); + } + + Admin2 admin2 = place.getAdmin2(); + if (admin2 != null && admin2.getContent() != null) { + WeatherLocation weatherLocation = new WeatherLocation.Builder(admin2.getWoeid(), + admin2.getContent()) + .setCountry(place.getCountry().getContent()) + .setCountryId(place.getCountry().getCode()) + .setPostalCode(postal == null ? "" : postal.getContent()) + .build(); + ret.add(weatherLocation); + } + + Admin3 admin3 = place.getAdmin3(); + if (admin3 != null && admin3.getContent() != null) { + WeatherLocation weatherLocation = new WeatherLocation.Builder(admin3.getWoeid(), + admin3.getContent()) + .setCountry(place.getCountry().getContent()) + .setCountryId(place.getCountry().getCode()) + .setPostalCode(postal == null ? "" : postal.getContent()) + .build(); + ret.add(weatherLocation); + } + + Locality1 locality1 = place.getLocality1(); + if (locality1 != null && locality1.getContent() != null) { + WeatherLocation weatherLocation = new WeatherLocation.Builder( + locality1.getWoeid(), + locality1.getContent()) + .setCountry(place.getCountry().getContent()) + .setCountryId(place.getCountry().getCode()) + .setPostalCode(postal == null ? "" : postal.getContent()) + .build(); + ret.add(weatherLocation); + } + } + return ret; + } + + public static int offset(int conditionCode) { + if (conditionCode <= WeatherContract.WeatherColumns.WeatherCode.SHOWERS) { + return conditionCode; + } else if (conditionCode <= SCATTERED_THUNDERSTORMS) { + return conditionCode - 1; + } else if (conditionCode <= SCATTERED_SNOW_SHOWERS) { + return conditionCode - 2; + } else if (conditionCode <= ISOLATED_THUNDERSHOWERS) { + return conditionCode - 3; + } else { + return NOT_AVAILABLE; + } + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/ImagePreference.java b/app/src/main/java/org/lineageos/yahooweatherprovider/ImagePreference.java new file mode 100644 index 0000000..b42ff62 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/ImagePreference.java @@ -0,0 +1,29 @@ +package org.lineageos.yahooweatherprovider; + +import android.content.Context; +import android.preference.Preference; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class ImagePreference extends Preference { + public ImagePreference(Context context) { + super(context); + } + + public ImagePreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public ImagePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + @Override + protected View onCreateView(ViewGroup parent) { + LayoutInflater li = (LayoutInflater) + getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE ); + return li.inflate(R.layout.image_preference, parent, false); + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/YahooCMWeatherApplication.java b/app/src/main/java/org/lineageos/yahooweatherprovider/YahooCMWeatherApplication.java new file mode 100644 index 0000000..6012dc8 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/YahooCMWeatherApplication.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider; + +import android.app.Application; +import android.content.Context; + +import dagger.ObjectGraph; + +public class YahooCMWeatherApplication extends Application { + + private ObjectGraph mObjectGraph; + + @Override + public void onCreate() { + super.onCreate(); + mObjectGraph = ObjectGraph.create(new YahooModule(this)); + } + + public static YahooCMWeatherApplication get(Context context) { + return (YahooCMWeatherApplication) context.getApplicationContext(); + } + + public final void inject(Object object) { + mObjectGraph.inject(object); + } + +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/YahooModule.java b/app/src/main/java/org/lineageos/yahooweatherprovider/YahooModule.java new file mode 100644 index 0000000..857c6ed --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/YahooModule.java @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider; + +import org.lineageos.yahooweatherprovider.yahoo.YahooWeatherServiceManager; + +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; + +@Module( + injects = { + YahooWeatherProviderService.class, + } +) +public class YahooModule { + + private YahooCMWeatherApplication mWeatherApplication; + + public YahooModule(YahooCMWeatherApplication weatherApplication) { + mWeatherApplication = weatherApplication; + } + + @Provides + @Singleton + public YahooWeatherServiceManager providesYahooWeatherServiceManager() { + return new YahooWeatherServiceManager(); + } + +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/YahooPreferenceActivity.java b/app/src/main/java/org/lineageos/yahooweatherprovider/YahooPreferenceActivity.java new file mode 100644 index 0000000..7b7f71e --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/YahooPreferenceActivity.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider; + +import android.app.ActionBar; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.view.MenuItem; + +public class YahooPreferenceActivity extends PreferenceActivity + implements Preference.OnPreferenceClickListener { + private static final String IMAGE_KEY = "image_key"; + private static final String YAHOO_URL = "https://www.yahoo.com/?ilc=401"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.preferences); + + final Preference imagePreference = findPreference(IMAGE_KEY); + imagePreference.setOnPreferenceClickListener(this); + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + break; + } + return super.onOptionsItemSelected(item); + } + + @Override + public boolean onPreferenceClick(Preference preference) { + switch (preference.getKey()) { + case IMAGE_KEY: + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(YAHOO_URL)); + startActivity(intent); + return true; + } + return false; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/YahooWeatherProviderService.java b/app/src/main/java/org/lineageos/yahooweatherprovider/YahooWeatherProviderService.java new file mode 100644 index 0000000..11e46f8 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/YahooWeatherProviderService.java @@ -0,0 +1,304 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider; + +import android.content.Context; +import android.location.Address; +import android.location.Criteria; +import android.location.Geocoder; +import android.location.LocationManager; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; + +import org.lineageos.yahooweatherprovider.yahoo.WeakReferenceHandler; +import org.lineageos.yahooweatherprovider.yahoo.YahooWeatherRequestCallback; +import org.lineageos.yahooweatherprovider.yahoo.YahooWeatherResponseListener; +import org.lineageos.yahooweatherprovider.yahoo.YahooWeatherServiceManager; +import org.lineageos.yahooweatherprovider.yahoo.response.Atmosphere; +import org.lineageos.yahooweatherprovider.yahoo.response.Channel; +import org.lineageos.yahooweatherprovider.yahoo.response.Condition; +import org.lineageos.yahooweatherprovider.yahoo.response.Forecast; +import org.lineageos.yahooweatherprovider.yahoo.response.Location; +import org.lineageos.yahooweatherprovider.yahoo.response.Place; +import org.lineageos.yahooweatherprovider.yahoo.response.Query; +import org.lineageos.yahooweatherprovider.yahoo.response.Results; +import org.lineageos.yahooweatherprovider.yahoo.response.Wind; +import org.lineageos.yahooweatherprovider.yahoo.response.YQLResponse; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +import javax.inject.Inject; + +import cyanogenmod.providers.WeatherContract; +import cyanogenmod.weather.RequestInfo; +import cyanogenmod.weather.WeatherInfo; +import cyanogenmod.weather.WeatherLocation; +import cyanogenmod.weatherservice.ServiceRequest; +import cyanogenmod.weatherservice.ServiceRequestResult; +import cyanogenmod.weatherservice.WeatherProviderService; +import retrofit2.Call; + +public class YahooWeatherProviderService extends WeatherProviderService + implements YahooWeatherResponseListener { + + private static final String TAG = YahooWeatherProviderService.class.getSimpleName(); + private static final int SERVICE_REQUEST_CANCELLED = -1; + private static final int SERVICE_REQUEST_SUBMITTED = 0; + + //TODO, add a setting for this + private static final int MAX_FORECAST_DAYS = 5; + + @Inject + public YahooWeatherServiceManager mYahooWeatherServiceManager; + + @Override + public void onCreate() { + super.onCreate(); + YahooCMWeatherApplication.get(this).inject(this); + } + + @Override + protected void onRequestSubmitted(ServiceRequest serviceRequest) { + Log.d(TAG, "Received service request: " + serviceRequest.toString()); + Message request = mHandler.obtainMessage(SERVICE_REQUEST_SUBMITTED, serviceRequest); + request.sendToTarget(); + } + + @Override + protected void onRequestCancelled(ServiceRequest serviceRequest) { + Log.d(TAG, "Received service request cancelled: " + serviceRequest.toString()); + Message request = mHandler.obtainMessage(SERVICE_REQUEST_CANCELLED, serviceRequest); + request.sendToTarget(); + } + + private final NonLeakyMessageHandler mHandler = new NonLeakyMessageHandler(this); + + private static class NonLeakyMessageHandler + extends WeakReferenceHandler { + public NonLeakyMessageHandler(YahooWeatherProviderService reference) { + super(reference); + } + + @Override + protected void handleMessage(YahooWeatherProviderService reference, + Message inputMessage) { + ServiceRequest serviceRequest = (ServiceRequest)inputMessage.obj; + switch (inputMessage.what) { + case SERVICE_REQUEST_SUBMITTED: + RequestInfo requestInfo = serviceRequest.getRequestInfo(); + switch (requestInfo.getRequestType()) { + case RequestInfo.TYPE_WEATHER_BY_WEATHER_LOCATION_REQ: + case RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ: + reference.handleWeatherRequest(serviceRequest); + break; + case RequestInfo.TYPE_LOOKUP_CITY_NAME_REQ: + reference.handleLookupRequest(serviceRequest); + break; + default: + //Don't support anything else, fail. + serviceRequest.fail(); + break; + } + break; + case SERVICE_REQUEST_CANCELLED: + //TODO; Implement + break; + default: + //Don't support anything else, fail. + if (serviceRequest != null) { + serviceRequest.fail(); + } + } + } + } + + private void handleLookupRequest(ServiceRequest serviceRequest) { + final RequestInfo requestInfo = serviceRequest.getRequestInfo(); + + String cityName = requestInfo.getCityName(); + + if (TextUtils.isEmpty(cityName)) { + Log.d(TAG, "Null citname return"); + serviceRequest.fail(); + return; + } + + Call wundergroundCall = mYahooWeatherServiceManager.lookupCity(cityName); + wundergroundCall.enqueue(new YahooWeatherRequestCallback(serviceRequest, this)); + } + + + private void handleWeatherRequest(final ServiceRequest serviceRequest) { + final RequestInfo requestInfo = serviceRequest.getRequestInfo(); + Log.d(TAG, "Received weather request info: " + requestInfo.toString()); + + if (requestInfo.getRequestType() == RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ) { + android.location.Location location = requestInfo.getLocation(); + if (location == null) { + LocationManager locationManager = (LocationManager) + getSystemService(Context.LOCATION_SERVICE); + Criteria criteria = new Criteria(); + criteria.setAccuracy(Criteria.ACCURACY_HIGH); + location = locationManager.getLastKnownLocation(locationManager.getBestProvider( + criteria, false)); + } + handleRequestByGeoLocation(location, serviceRequest); + } else { + WeatherLocation weatherLocation = requestInfo.getWeatherLocation(); + handleRequestByWeatherLocation(weatherLocation, serviceRequest); + } + } + + /** + * Enqueue request by geolocation (lat/long) + */ + private void handleRequestByGeoLocation(android.location.Location location, + final ServiceRequest serviceRequest) { + Geocoder gcd = new Geocoder(this, Locale.getDefault()); + try { + List

addresses = gcd.getFromLocation(location.getLatitude(), + location.getLongitude(), 1); + Address address = addresses.get(0); + Call wundergroundCall = + mYahooWeatherServiceManager.query(address.getCountryName(), + address.getLocality()); + wundergroundCall.enqueue(new YahooWeatherRequestCallback(serviceRequest, this)); + } catch (IOException e) { + Log.d(TAG, "Failed to get addresses"); + serviceRequest.fail(); + } + } + + /** + * Enqueue request by weatherlocation + */ + private void handleRequestByWeatherLocation(WeatherLocation weatherLocation, + final ServiceRequest serviceRequest) { + + Call wundergroundCall = null; + if (weatherLocation.getCity() != null) { + wundergroundCall = + mYahooWeatherServiceManager.query(weatherLocation.getState(), + weatherLocation.getCity()); + } + //TODO: Add postal code support + //else if (weatherLocation.getPostalCode() != null) { + // wundergroundCall = + // mYahooWeatherServiceManager.query(weatherLocation.getPostalCode()); + //} + else { + Log.e(TAG, "Unable to handle service request"); + serviceRequest.fail(); + return; + } + + wundergroundCall.enqueue(new YahooWeatherRequestCallback(serviceRequest, this)); + } + + @Override + public void processYahooWeatherResponse(YQLResponse yqlResponse, ServiceRequest serviceRequest) { + switch (serviceRequest.getRequestInfo().getRequestType()) { + case RequestInfo.TYPE_WEATHER_BY_WEATHER_LOCATION_REQ: + case RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ: + processWeatherRequest(yqlResponse, serviceRequest); + break; + case RequestInfo.TYPE_LOOKUP_CITY_NAME_REQ: + processCityLookupRequest(yqlResponse, serviceRequest); + break; + default: + //Don't support anything else, fail. + serviceRequest.fail(); + } + } + + private void processWeatherRequest(YQLResponse yqlResponse, ServiceRequest serviceRequest) { + final Query queryResponse = yqlResponse.getQuery(); + final Results results = queryResponse.getResults(); + + if (results == null) { + Log.d(TAG, "Null query results, return"); + serviceRequest.fail(); + return; + } + final Channel channel = results.getChannel(); + final Location location = channel.getLocation(); + final Condition condition = channel.getItem().getCondition(); + final Atmosphere atmosphere = channel.getAtmosphere(); + final Wind wind = channel.getWind(); + final Forecast[] forecasts = channel.getItem().getForecast(); + + final WeatherInfo.Builder weatherInfoBuilder = new WeatherInfo.Builder(location.getCity(), + Double.parseDouble(condition.getTemp()), + WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT); + + // Set current weather condition code + weatherInfoBuilder.setWeatherCondition( + ConverterUtils.offset(Integer.parseInt(condition.getCode()))); + + // Set humidity + weatherInfoBuilder.setHumidity(Double.parseDouble(atmosphere.getHumidity())); + + // Set wind arguments + weatherInfoBuilder.setWind(Double.parseDouble(wind.getSpeed()), + Double.parseDouble(wind.getDirection()), + WeatherContract.WeatherColumns.WindSpeedUnit.MPH); + + // Set high and low for today from the simple forecast days + weatherInfoBuilder.setTodaysHigh(Double.parseDouble(forecasts[0].getHigh())); + weatherInfoBuilder.setTodaysLow(Double.parseDouble(forecasts[0].getLow())); + + ArrayList forecastList = + ConverterUtils.convertForecastsToDayForecasts( + Arrays.asList(forecasts), MAX_FORECAST_DAYS); + + weatherInfoBuilder.setForecast(forecastList); + + ServiceRequestResult serviceRequestResult = + new ServiceRequestResult.Builder(weatherInfoBuilder.build()) + .build(); + serviceRequest.complete(serviceRequestResult); + } + + private void processCityLookupRequest(YQLResponse yqlResponse, ServiceRequest serviceRequest) { + final Query queryResponse = yqlResponse.getQuery(); + final Results results = queryResponse.getResults(); + + if (results == null) { + Log.d(TAG, "Null query results, return"); + serviceRequest.fail(); + return; + } + + final Place[] places = results.getPlace(); + + if (places == null) { + Log.d(TAG, "Null places, return"); + serviceRequest.fail(); + return; + } + + ServiceRequestResult serviceRequestResult = + new ServiceRequestResult.Builder(ConverterUtils.convertPlacesToWeatherLocations( + Arrays.asList(places))).build(); + serviceRequest.complete(serviceRequestResult); + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/WeakReferenceHandler.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/WeakReferenceHandler.java new file mode 100644 index 0000000..88302c5 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/WeakReferenceHandler.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo; + +import android.os.Handler; +import android.os.Message; + +import java.lang.ref.WeakReference; + +public abstract class WeakReferenceHandler extends Handler { + private WeakReference mReference; + + public WeakReferenceHandler(T reference) { + mReference = new WeakReference(reference); + } + + @Override + public void handleMessage(Message msg) { + T reference = mReference.get(); + if (reference == null) + return; + handleMessage(reference, msg); + } + + protected abstract void handleMessage(T reference, Message msg); +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YQLQueryCreator.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YQLQueryCreator.java new file mode 100644 index 0000000..da97a4e --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YQLQueryCreator.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo; + +import android.net.Uri; + +public class YQLQueryCreator { + private final static String YQL_FORECAST_QUERY = + Uri.encode("select * from weather.forecast where woeid in"); + private final static String YQL_LOCATION_QUERY = + Uri.encode("select woeid, postal, admin1, admin2, admin3, " + + "locality1, locality2, country from geo.places where " + + "(placetype = 7 or placetype = 8 or placetype = 9 " + + "or placetype = 10 or placetype = 11 or placetype = 20) and text = "); + + private YQLQueryCreator(){ + } + + public static String getForecastQuery(String state, String city) { + String params = "(select woeid from geo.places(1) where text=\"" + city + "," + state + + "\") and u='f'"; + return YQL_FORECAST_QUERY + Uri.encode(params); + } + + public static String getLocationQuery(String input) { + String params = "\"" + input + "\""; + return YQL_LOCATION_QUERY + Uri.encode(params); + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooServiceInterface.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooServiceInterface.java new file mode 100644 index 0000000..3590625 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooServiceInterface.java @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo; + +import org.lineageos.yahooweatherprovider.yahoo.response.YQLResponse; + +import retrofit2.Call; +import retrofit2.http.GET; +import retrofit2.http.Query; + +public interface YahooServiceInterface { + @GET("/v1/public/yql?format=json&env=store://datatables.org/alltableswithkeys") + Call query(@Query(value = "q", encoded = true) String query); +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherRequestCallback.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherRequestCallback.java new file mode 100644 index 0000000..4e82aaf --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherRequestCallback.java @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo; + +import android.util.Log; + +import org.lineageos.yahooweatherprovider.yahoo.response.YQLResponse; + +import cyanogenmod.weatherservice.ServiceRequest; +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +public class YahooWeatherRequestCallback implements Callback { + private static final String TAG = YahooWeatherRequestCallback.class.getSimpleName(); + private ServiceRequest mServiceRequest; + private YahooWeatherResponseListener mYahooWeatherResponseListener; + + public YahooWeatherRequestCallback(ServiceRequest serviceRequest, + YahooWeatherResponseListener yahooWeatherdResponseListener) { + mServiceRequest = serviceRequest; + mYahooWeatherResponseListener = yahooWeatherdResponseListener; + } + + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()) { + Log.d(TAG, "Received response:\n" + response.body().toString()); + YQLResponse wundergroundReponse = response.body(); + if (wundergroundReponse == null) { + Log.d(TAG, "Null wu reponse, return"); + mServiceRequest.fail(); + return; + } + mYahooWeatherResponseListener.processYahooWeatherResponse( + wundergroundReponse, mServiceRequest); + } else { + Log.d(TAG, "Response " + response.toString()); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + Log.d(TAG, "Failure " + t.toString()); + mServiceRequest.fail(); + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherResponseListener.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherResponseListener.java new file mode 100644 index 0000000..657ae6e --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherResponseListener.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo; + +import org.lineageos.yahooweatherprovider.yahoo.response.YQLResponse; + +import cyanogenmod.weatherservice.ServiceRequest; + + +public interface YahooWeatherResponseListener { + void processYahooWeatherResponse(YQLResponse yqlResponse, + ServiceRequest serviceRequest); +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherServiceManager.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherServiceManager.java new file mode 100644 index 0000000..0424680 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/YahooWeatherServiceManager.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo; + +import android.util.Log; + +import org.lineageos.yahooweatherprovider.yahoo.response.YQLResponse; + +import okhttp3.OkHttpClient; +import okhttp3.logging.HttpLoggingInterceptor; +import retrofit2.Call; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class YahooWeatherServiceManager { + private final static String TAG = "YahooServiceManager"; + private final static boolean DEBUG = Log.isLoggable(TAG, Log.VERBOSE); + + private final YahooServiceInterface mYahooServiceInterface; + + public YahooWeatherServiceManager() { + Retrofit baseAdapter = buildRestAdapter(); + mYahooServiceInterface = baseAdapter.create(YahooServiceInterface.class); + } + + public Call query(String state, String city) { + String forecastQuery = YQLQueryCreator.getForecastQuery(state, city); + return mYahooServiceInterface.query(forecastQuery); + } + + public Call lookupCity(String city) { + String locationQuery = YQLQueryCreator.getLocationQuery(city); + return mYahooServiceInterface.query(locationQuery); + } + + private Retrofit buildRestAdapter() { + final OkHttpClient.Builder builder = new OkHttpClient().newBuilder(); + if (DEBUG) { + final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); + builder.addInterceptor(loggingInterceptor); + } + final OkHttpClient client = builder.build(); + + final String baseUrl = "https://query.yahooapis.com"; + return new Retrofit.Builder() + .baseUrl(baseUrl) + .client(client) + .addConverterFactory(GsonConverterFactory.create()) + .build(); + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin1.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin1.java new file mode 100644 index 0000000..a775b03 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin1.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Admin1 { + private String content; + + private String woeid; + + private String code; + + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getWoeid() { + return woeid; + } + + public void setWoeid(String woeid) { + this.woeid = woeid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "[content = " + content + ", woeid = " + woeid + ", code = " + code + ", type = " + type + "]"; + } +} \ No newline at end of file diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin2.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin2.java new file mode 100644 index 0000000..5d06e3d --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin2.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Admin2 { + private String content; + + private String woeid; + + private String code; + + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getWoeid() { + return woeid; + } + + public void setWoeid(String woeid) { + this.woeid = woeid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "[content = " + content + ", woeid = " + woeid + ", code = " + code + ", type = " + type + "]"; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin3.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin3.java new file mode 100644 index 0000000..a03bbf2 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Admin3.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Admin3 { + private String content; + + private String woeid; + + private String code; + + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getWoeid() { + return woeid; + } + + public void setWoeid(String woeid) { + this.woeid = woeid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "[content = " + content + ", woeid = " + woeid + ", code = " + code + ", type = " + type + "]"; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Astronomy.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Astronomy.java new file mode 100644 index 0000000..9d292f1 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Astronomy.java @@ -0,0 +1,44 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Astronomy { + private String sunset; + + private String sunrise; + + public String getSunset() { + return sunset; + } + + public void setSunset(String sunset) { + this.sunset = sunset; + } + + public String getSunrise() { + return sunrise; + } + + public void setSunrise(String sunrise) { + this.sunrise = sunrise; + } + + @Override + public String toString() { + return "[sunset = " + sunset + ", sunrise = " + sunrise + "]"; + } +} \ No newline at end of file diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Atmosphere.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Atmosphere.java new file mode 100644 index 0000000..7cb496d --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Atmosphere.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Atmosphere { + private String rising; + + private String humidity; + + private String pressure; + + private String visibility; + + public String getRising() { + return rising; + } + + public void setRising(String rising) { + this.rising = rising; + } + + public String getHumidity() { + return humidity; + } + + public void setHumidity(String humidity) { + this.humidity = humidity; + } + + public String getPressure() { + return pressure; + } + + public void setPressure(String pressure) { + this.pressure = pressure; + } + + public String getVisibility() { + return visibility; + } + + public void setVisibility(String visibility) { + this.visibility = visibility; + } + + @Override + public String toString() { + return "[rising = " + rising + ", humidity = " + humidity + ", pressure = " + pressure + ", visibility = " + visibility + "]"; + } +} \ No newline at end of file diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Channel.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Channel.java new file mode 100644 index 0000000..1c7a978 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Channel.java @@ -0,0 +1,154 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Channel { + private Wind wind; + + private Location location; + + private String link; + + private Atmosphere atmosphere; + + private Image image; + + private String ttl; + + private Astronomy astronomy; + + private Units units; + + private String title; + + private String description; + + private Item item; + + private String lastBuildDate; + + private String language; + + public Wind getWind() { + return wind; + } + + public void setWind(Wind wind) { + this.wind = wind; + } + + public Location getLocation() { + return location; + } + + public void setLocation(Location location) { + this.location = location; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public Atmosphere getAtmosphere() { + return atmosphere; + } + + public void setAtmosphere(Atmosphere atmosphere) { + this.atmosphere = atmosphere; + } + + public Image getImage() { + return image; + } + + public void setImage(Image image) { + this.image = image; + } + + public String getTtl() { + return ttl; + } + + public void setTtl(String ttl) { + this.ttl = ttl; + } + + public Astronomy getAstronomy() { + return astronomy; + } + + public void setAstronomy(Astronomy astronomy) { + this.astronomy = astronomy; + } + + public Units getUnits() { + return units; + } + + public void setUnits(Units units) { + this.units = units; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Item getItem() { + return item; + } + + public void setItem(Item item) { + this.item = item; + } + + public String getLastBuildDate() { + return lastBuildDate; + } + + public void setLastBuildDate(String lastBuildDate) { + this.lastBuildDate = lastBuildDate; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + @Override + public String toString() { + return "[wind = " + wind + ", location = " + location + ", link = " + link + ", atmosphere = " + atmosphere + ", image = " + image + ", ttl = " + ttl + ", astronomy = " + astronomy + ", units = " + units + ", title = " + title + ", description = " + description + ", item = " + item + ", lastBuildDate = " + lastBuildDate + ", language = " + language + "]"; + } +} \ No newline at end of file diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Condition.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Condition.java new file mode 100644 index 0000000..f6d4931 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Condition.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Condition { + private String text; + + private String temp; + + private String code; + + private String date; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getTemp() { + return temp; + } + + public void setTemp(String temp) { + this.temp = temp; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + @Override + public String toString() { + return "[text = " + text + ", temp = " + temp + ", code = " + code + ", date = " + date + "]"; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Country.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Country.java new file mode 100644 index 0000000..553c883 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Country.java @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Country { + private String content; + + private String woeid; + + private String code; + + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getWoeid() { + return woeid; + } + + public void setWoeid(String woeid) { + this.woeid = woeid; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "[content = " + content + ", woeid = " + woeid + ", code = " + code + ", type = " + type + "]"; + } +} + diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Forecast.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Forecast.java new file mode 100644 index 0000000..e21f812 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Forecast.java @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Forecast { + private String text; + + private String high; + + private String day; + + private String code; + + private String low; + + private String date; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getHigh() { + return high; + } + + public void setHigh(String high) { + this.high = high; + } + + public String getDay() { + return day; + } + + public void setDay(String day) { + this.day = day; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getLow() { + return low; + } + + public void setLow(String low) { + this.low = low; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + @Override + public String toString() { + return "[text = " + text + ", high = " + high + ", day = " + day + ", code = " + code + ", low = " + low + ", date = " + date + "]"; + } +} \ No newline at end of file diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Guid.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Guid.java new file mode 100644 index 0000000..04ce1bf --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Guid.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Guid { + private String isPermaLink; + + public String getIsPermaLink() { + return isPermaLink; + } + + public void setIsPermaLink(String isPermaLink) { + this.isPermaLink = isPermaLink; + } + + @Override + public String toString() { + return "[isPermaLink = " + isPermaLink + "]"; + } +} + diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Image.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Image.java new file mode 100644 index 0000000..aa22836 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Image.java @@ -0,0 +1,74 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Image { + private String title; + + private String height; + + private String link; + + private String width; + + private String url; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getHeight() { + return height; + } + + public void setHeight(String height) { + this.height = height; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public String getWidth() { + return width; + } + + public void setWidth(String width) { + this.width = width; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public String toString() { + return "[title = " + title + ", height = " + height + ", link = " + link + ", width = " + width + ", url = " + url + "]"; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Item.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Item.java new file mode 100644 index 0000000..b511c12 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Item.java @@ -0,0 +1,117 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +import java.util.Arrays; + +public class Item { + private Guid guid; + + private String pubDate; + + private String title; + + private Forecast[] forecast; + + private Condition condition; + + private String description; + + private String link; + + private String longz; + + private String lat; + + public Guid getGuid() { + return guid; + } + + public void setGuid(Guid guid) { + this.guid = guid; + } + + public String getPubDate() { + return pubDate; + } + + public void setPubDate(String pubDate) { + this.pubDate = pubDate; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Forecast[] getForecast() { + return forecast; + } + + public void setForecast(Forecast[] forecast) { + this.forecast = forecast; + } + + public Condition getCondition() { + return condition; + } + + public void setCondition(Condition condition) { + this.condition = condition; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public String getLong() { + return longz; + } + + public void setLong(String longz) { + this.longz = longz; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + @Override + public String toString() { + return "[guid = " + guid + ", pubDate = " + pubDate + ", title = " + title + ", forecast = " + Arrays.asList(forecast) + ", condition = " + condition + ", description = " + description + ", link = " + link + ", long = " + longz + + ", lat = " + lat + "]"; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Locality1.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Locality1.java new file mode 100644 index 0000000..9fe89ce --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Locality1.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Locality1 { + private String content; + + private String woeid; + + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getWoeid() { + return woeid; + } + + public void setWoeid(String woeid) { + this.woeid = woeid; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "[content = " + content + ", woeid = " + woeid + ", type = " + type + "]"; + } +} \ No newline at end of file diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Location.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Location.java new file mode 100644 index 0000000..d775441 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Location.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Location { + private String region; + + private String country; + + private String city; + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Override + public String toString() { + return "[region = " + region + ", country = " + country + ", city = " + city + "]"; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Place.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Place.java new file mode 100644 index 0000000..b2763e8 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Place.java @@ -0,0 +1,89 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Place { + private String woeid; + + private Country country; + + private Admin1 admin1; + private Admin2 admin2; + private Admin3 admin3; + + private Postal postal; + + private Locality1 locality1; + + public String getWoeid() { + return woeid; + } + + public void setWoeid(String woeid) { + this.woeid = woeid; + } + + public Country getCountry() { + return country; + } + + public void setCountry(Country country) { + this.country = country; + } + + public Admin1 getAdmin1() { + return admin1; + } + + public void setAdmin1(Admin1 admin1) { + this.admin1 = admin1; + } + + public Admin2 getAdmin2() { + return admin2; + } + + public void setAdmin2(Admin2 admin2) { + this.admin2 = admin2; + } + + public Admin3 getAdmin3() { + return admin3; + } + + public void setAdmin3(Admin3 admin3) { + this.admin3 = admin3; + } + + public Postal getPostal() { + return postal; + } + + public void setPostal(Postal postal) { + this.postal = postal; + } + + public Locality1 getLocality1() { + return locality1; + } + + @Override + public String toString() { + return "[woeid = " + woeid + ", country = " + country + "]"; + } +} + diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Postal.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Postal.java new file mode 100644 index 0000000..65b0cfa --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Postal.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Postal { + private String content; + + private String woeid; + + private String type; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getWoeid() { + return woeid; + } + + public void setWoeid(String woeid) { + this.woeid = woeid; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "ClassPojo [content = " + content + ", woeid = " + woeid + ", type = " + type + "]"; + } +} \ No newline at end of file diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Query.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Query.java new file mode 100644 index 0000000..1d18e38 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Query.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Query { + private Results results; + + private String count; + + private String created; + + private String lang; + + public Results getResults() { + return results; + } + + public void setResults(Results results) { + this.results = results; + } + + public String getCount() { + return count; + } + + public void setCount(String count) { + this.count = count; + } + + public String getCreated() { + return created; + } + + public void setCreated(String created) { + this.created = created; + } + + public String getLang() { + return lang; + } + + public void setLang(String lang) { + this.lang = lang; + } + + @Override + public String toString() { + return "[results = " + results + ", count = " + count + ", created = " + created + ", lang = " + lang + "]"; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Results.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Results.java new file mode 100644 index 0000000..701b083 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Results.java @@ -0,0 +1,46 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +import java.util.Arrays; + +public class Results { + private Channel channel; + + private Place[] place; + + public Channel getChannel() { + return channel; + } + + public void setChannel(Channel channel) { + this.channel = channel; + } + + public Place[] getPlace() { + return place; + } + + public void setPlace(Place[] place) { + this.place = place; + } + + @Override + public String toString() { + return "[channel = " + channel + ", place + " + Arrays.toString(place) + "]"; + } +} diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Units.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Units.java new file mode 100644 index 0000000..643435b --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Units.java @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Units { + private String distance; + + private String pressure; + + private String speed; + + private String temperature; + + public String getDistance() { + return distance; + } + + public void setDistance(String distance) { + this.distance = distance; + } + + public String getPressure() { + return pressure; + } + + public void setPressure(String pressure) { + this.pressure = pressure; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getTemperature() { + return temperature; + } + + public void setTemperature(String temperature) { + this.temperature = temperature; + } + + @Override + public String toString() { + return "[distance = " + distance + ", pressure = " + pressure + ", speed = " + speed + ", temperature = " + temperature + "]"; + } +} + diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Wind.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Wind.java new file mode 100644 index 0000000..071598c --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/Wind.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class Wind { + private String speed; + + private String direction; + + private String chill; + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getChill() { + return chill; + } + + public void setChill(String chill) { + this.chill = chill; + } + + @Override + public String toString() { + return "[speed = " + speed + ", direction = " + direction + ", chill = " + chill + "]"; + } +} + diff --git a/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/YQLResponse.java b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/YQLResponse.java new file mode 100644 index 0000000..765ee60 --- /dev/null +++ b/app/src/main/java/org/lineageos/yahooweatherprovider/yahoo/response/YQLResponse.java @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2016 The CyanogenMod Project + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.lineageos.yahooweatherprovider.yahoo.response; + +public class YQLResponse { + private Query query; + + public Query getQuery() { + return query; + } + + public void setQuery(Query query) { + this.query = query; + } + + @Override + public String toString() { + return "[query = " + query + "]"; + } +} diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 837a4a1..9785836 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -17,7 +17,7 @@ android:key="about_key" android:title="@string/about_preference" android:summary="@string/about_preference_summary" /> - diff --git a/app/src/main/res/xml/weather_settings_service.xml b/app/src/main/res/xml/weather_settings_service.xml index af5c23e..74cc96b 100644 --- a/app/src/main/res/xml/weather_settings_service.xml +++ b/app/src/main/res/xml/weather_settings_service.xml @@ -12,4 +12,4 @@ limitations under the License. --> \ No newline at end of file + android:settingsActivity="org.lineageos.yahooweatherprovider.YahooPreferenceActivity" /> \ No newline at end of file -- cgit v1.2.3