aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2016-04-05 14:15:15 -0700
committerAdnan Begovic <adnan@cyngn.com>2016-04-06 10:01:48 -0700
commitdda60c79896d803d944abfa022c779982f9ad88a (patch)
tree88ec448c2be1dbbbe3269127a16a92c72b02a07a
parent2ea0462f88e69c67f55ca1f8dc35bf90f0e982f2 (diff)
downloadandroid_packages_apps_WundergroundWeatherProvider-dda60c79896d803d944abfa022c779982f9ad88a.tar.gz
android_packages_apps_WundergroundWeatherProvider-dda60c79896d803d944abfa022c779982f9ad88a.tar.bz2
android_packages_apps_WundergroundWeatherProvider-dda60c79896d803d944abfa022c779982f9ad88a.zip
WundergroundCM: Initial checking of WG weather provider service.
Change-Id: If2f638889578180d3b7bf7c8bebe1caee69fec52
-rw-r--r--.gitignore44
-rw-r--r--app/.gitignore1
-rw-r--r--app/build.gradle34
-rw-r--r--app/proguard-rules.pro17
-rw-r--r--app/src/androidTest/java/org/cyanogenmod/wundergroundcmweatherprovider/ApplicationTest.java29
-rw-r--r--app/src/main/AndroidManifest.xml47
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/DebugActivity.java237
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUBaseActivity.java27
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUBasePreferenceActivity.java27
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUSettingsPreferenceFragment.java27
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WeakReferenceHandler.java40
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundCMApplication.java40
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundModule.java46
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundWeatherProviderService.java224
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java45
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/Feature.java27
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/FeatureParam.java20
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/WundergroundServiceInterface.java35
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/WundergroundServiceManager.java69
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/CurrentObservationResponse.java111
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/DisplayLocationResponse.java31
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/ForecastResponse.java36
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/WundergroundReponse.java53
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/ForecastDayResponse.java50
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/SimpleForecastResponse.java35
-rw-r--r--app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/TemperatureForecastResponse.java40
-rw-r--r--app/src/main/res/layout/activity_main.xml36
-rw-r--r--app/src/main/res/menu/menu_main.xml22
-rw-r--r--app/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 3418 bytes
-rw-r--r--app/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 2206 bytes
-rw-r--r--app/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 4842 bytes
-rw-r--r--app/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 7718 bytes
-rw-r--r--app/src/main/res/values-v21/styles.xml17
-rw-r--r--app/src/main/res/values-w820dp/dimens.xml18
-rw-r--r--app/src/main/res/values/dimens.xml18
-rw-r--r--app/src/main/res/values/strings.xml16
-rw-r--r--app/src/main/res/values/styles.xml20
-rw-r--r--build.gradle22
-rw-r--r--gradle.properties18
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin0 -> 49896 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xgradlew164
-rw-r--r--gradlew.bat90
-rw-r--r--settings.gradle1
44 files changed, 1840 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..067f8c1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,44 @@
+# built application files
+*.apk
+*.ap_
+
+# files for the dex VM
+*.dex
+
+# Java class files
+*.class
+
+# generated files
+bin/
+gen/
+out/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Eclipse project files
+.classpath
+.project
+
+# Windows thumbnail db
+.DS_Store
+
+# IDEA/Android Studio project files, because
+# the project can be imported from settings.gradle
+.idea
+*.iml
+
+# Old-style IDEA project files
+*.ipr
+*.iws
+
+# Local IDEA workspace
+.idea/workspace.xml
+
+# Gradle cache
+.gradle
+
+# Sandbox stuff
+_sandbox
+
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..d28efab
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,34 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 21
+ buildToolsVersion "23.0.1"
+
+ defaultConfig {
+ applicationId "org.cyanogenmod.wundergroundcmweatherprovider"
+ minSdkVersion 21
+ targetSdkVersion 21
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+ packagingOptions {
+ exclude 'META-INF/LICENSE.txt'
+ exclude 'META-INF/NOTICE.txt'
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile 'com.squareup.retrofit2:retrofit:2.0.1'
+ compile 'com.squareup.retrofit2:converter-gson:2.0.1'
+ compile 'org.cyanogenmod:platform.sdk:5.0-SNAPSHOT'
+ compile 'com.squareup.okhttp3:okhttp:3.2.0'
+ compile 'com.squareup.dagger:dagger-compiler:1.2.2'
+ compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..1f8e664
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /usr/local/var/lib/android-sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/app/src/androidTest/java/org/cyanogenmod/wundergroundcmweatherprovider/ApplicationTest.java b/app/src/androidTest/java/org/cyanogenmod/wundergroundcmweatherprovider/ApplicationTest.java
new file mode 100644
index 0000000..a66c369
--- /dev/null
+++ b/app/src/androidTest/java/org/cyanogenmod/wundergroundcmweatherprovider/ApplicationTest.java
@@ -0,0 +1,29 @@
+/**
+ * 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.wundergroundcmweatherprovider;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+/**
+ * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
+ */
+public class ApplicationTest extends ApplicationTestCase<Application> {
+ 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
new file mode 100644
index 0000000..2375ced
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.cyanogenmod.wundergroundcmweatherprovider" >
+
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.INTERNET" />
+
+ <uses-permission android:name="cyanogenmod.permission.ACCESS_WEATHER_MANAGER" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme"
+ android:name=".WundergroundCMApplication">
+
+ <activity
+ android:name=".DebugActivity"
+ android:enabled="false"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
+ <service android:name=".WundergroundWeatherProviderService"
+ android:permission="cyanogenmod.permission.BIND_WEATHER_PROVIDER_SERVICE">
+ <intent-filter>
+ <action android:name="cyanogenmod.weatherservice.WeatherProviderService" />
+ </intent-filter>
+ </service>
+ </application>
+
+</manifest>
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/DebugActivity.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/DebugActivity.java
new file mode 100644
index 0000000..d4be2bd
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/DebugActivity.java
@@ -0,0 +1,237 @@
+/**
+ * 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.wundergroundcmweatherprovider;
+
+import android.content.Context;
+import android.location.Criteria;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.os.Looper;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.ConverterUtils;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.Feature;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.WundergroundServiceManager;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.CurrentObservationResponse;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.DisplayLocationResponse;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.ForecastResponse;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.WundergroundReponse;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.forecast.SimpleForecastResponse;
+
+import java.util.ArrayList;
+
+import javax.inject.Inject;
+
+import cyanogenmod.providers.WeatherContract;
+import cyanogenmod.weather.CMWeatherManager;
+import cyanogenmod.weather.WeatherInfo;
+
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+
+public class DebugActivity extends WUBaseActivity implements
+ CMWeatherManager.WeatherServiceProviderChangeListener,
+ CMWeatherManager.WeatherUpdateRequestListener,
+ LocationListener {
+
+ private static final String TAG = DebugActivity.class.getSimpleName();
+
+ @Inject
+ WundergroundServiceManager mWundergroundServiceManager;
+
+ private CMWeatherManager mWeatherManager;
+ private LocationManager mLocationManager;
+
+ private boolean mDirectRequest = false;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ mWeatherManager = CMWeatherManager.getInstance(this);
+ mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
+ mWeatherManager.registerWeatherServiceProviderChangeListener(this);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ public void requestWeatherInfo(View v) {
+ mDirectRequest = false;
+ requestWeatherInfo();
+ }
+
+ public void requestWeatherInfoDirectly(View v) {
+ mDirectRequest = true;
+ requestWeatherInfo();
+ }
+
+ private void requestWeatherInfo() {
+ Log.d(TAG, "Requesting weather!");
+ Criteria criteria = new Criteria();
+ criteria.setAccuracy(Criteria.ACCURACY_FINE);
+ mLocationManager.requestSingleUpdate(criteria, this, Looper.getMainLooper());
+ }
+
+ @Override
+ public void onWeatherServiceProviderChanged(String s) {
+
+ }
+
+ @Override
+ public void onWeatherRequestCompleted(int i, WeatherInfo weatherInfo) {
+ switch (i) {
+ case CMWeatherManager.WEATHER_REQUEST_COMPLETED:
+ Log.d(TAG, "Weather request completed: " + weatherInfo.toString());
+ break;
+ case CMWeatherManager.WEATHER_REQUEST_FAILED:
+ Log.d(TAG, "Weather request failed!");
+ break;
+ case CMWeatherManager.WEATHER_REQUEST_ALREADY_IN_PROGRESS:
+ Log.d(TAG, "Weather request already in progress");
+ break;
+ case CMWeatherManager.WEATHER_REQUEST_SUBMITTED_TOO_SOON:
+ Log.d(TAG, "Weather request submitted too soon");
+ break;
+ }
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (mDirectRequest) {
+ Call<WundergroundReponse> wundergroundCall =
+ mWundergroundServiceManager.query(location.getLatitude(),
+ location.getLongitude(), Feature.conditions, Feature.forecast);
+
+ wundergroundCall.enqueue(new Callback<WundergroundReponse>() {
+ @Override
+ public void onResponse(Call<WundergroundReponse> call, Response<WundergroundReponse> response) {
+ if (response.isSuccessful()) {
+ Log.d(TAG, "Received response:\n" + response.body().toString());
+ WundergroundReponse wundergroundReponse = response.body();
+
+ if (wundergroundReponse == null) {
+ Log.d(TAG, "Null wu reponse, return");
+ return;
+ }
+
+ CurrentObservationResponse currentObservationResponse =
+ wundergroundReponse.getCurrentObservation();
+
+ if (currentObservationResponse == null) {
+ Log.d(TAG, "Null co reponse, return");
+ return;
+ }
+
+ WeatherInfo.Builder weatherInfoBuilder =
+ new WeatherInfo.Builder(System.currentTimeMillis());
+
+ weatherInfoBuilder.setTemperature(currentObservationResponse.getTempF()
+ .floatValue(),
+ WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT);
+
+ weatherInfoBuilder.setWeatherCondition(
+ WeatherContract.WeatherColumns.WeatherCode.CLOUDY);
+
+ DisplayLocationResponse displayLocationResponse =
+ currentObservationResponse.getDisplayLocation();
+
+ if (displayLocationResponse == null) {
+ Log.d(TAG, "Null dl reponse, return");
+ return;
+ }
+
+ weatherInfoBuilder.setCity(displayLocationResponse.getCity(),
+ displayLocationResponse.getCity());
+
+ ForecastResponse forecastResponse =
+ wundergroundReponse.getForecast();
+
+ if (forecastResponse == null) {
+ Log.d(TAG, "Null fc reponse, return");
+ return;
+ }
+
+ SimpleForecastResponse simpleForecastResponse =
+ forecastResponse.getSimpleForecast();
+
+ if (simpleForecastResponse == null) {
+ Log.d(TAG, "Null sf reponse, return");
+ return;
+ }
+
+ ArrayList<WeatherInfo.DayForecast> dayForecasts =
+ ConverterUtils.convertSimpleFCToDayForcast(
+ simpleForecastResponse.getForecastDay());
+ weatherInfoBuilder.setForecast(dayForecasts);
+
+ Log.d(TAG, "Weather info " + weatherInfoBuilder.build().toString());
+ } else {
+ Log.d(TAG, "Response " + response.toString());
+ }
+ }
+
+ @Override
+ public void onFailure(Call<WundergroundReponse> call, Throwable t) {
+ Log.d(TAG, "Failure " + t.toString());
+ }
+ });
+ } else {
+ mWeatherManager.requestWeatherUpdate(location, this);
+ }
+ }
+
+ @Override
+ public void onStatusChanged(String s, int i, Bundle bundle) {
+
+ }
+
+ @Override
+ public void onProviderEnabled(String s) {
+
+ }
+
+ @Override
+ public void onProviderDisabled(String s) {
+
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUBaseActivity.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUBaseActivity.java
new file mode 100644
index 0000000..2ac412e
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUBaseActivity.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.cyanogenmod.wundergroundcmweatherprovider;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class WUBaseActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ WundergroundCMApplication.get(this).inject(this);
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUBasePreferenceActivity.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUBasePreferenceActivity.java
new file mode 100644
index 0000000..31fdacc
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUBasePreferenceActivity.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.cyanogenmod.wundergroundcmweatherprovider;
+
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+public class WUBasePreferenceActivity extends PreferenceActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ WundergroundCMApplication.get(this).inject(this);
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUSettingsPreferenceFragment.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUSettingsPreferenceFragment.java
new file mode 100644
index 0000000..b6c855a
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WUSettingsPreferenceFragment.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.cyanogenmod.wundergroundcmweatherprovider;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+public class WUSettingsPreferenceFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ //TODO: Implement
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WeakReferenceHandler.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WeakReferenceHandler.java
new file mode 100644
index 0000000..d65a7c5
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/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.cyanogenmod.wundergroundcmweatherprovider;
+
+import android.os.Handler;
+import android.os.Message;
+
+import java.lang.ref.WeakReference;
+
+public abstract class WeakReferenceHandler<T> extends Handler {
+ private WeakReference<T> mReference;
+
+ public WeakReferenceHandler(T reference) {
+ mReference = new WeakReference<T>(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/wundergroundcmweatherprovider/WundergroundCMApplication.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundCMApplication.java
new file mode 100644
index 0000000..7de4717
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundCMApplication.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.cyanogenmod.wundergroundcmweatherprovider;
+
+import android.app.Application;
+import android.content.Context;
+
+import dagger.ObjectGraph;
+
+public class WundergroundCMApplication extends Application {
+ private ObjectGraph mObjectGraph;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ mObjectGraph = ObjectGraph.create(new WundergroundModule(this));
+ }
+
+ public static WundergroundCMApplication get(Context context) {
+ return (WundergroundCMApplication) context.getApplicationContext();
+ }
+
+ public final void inject(Object object) {
+ mObjectGraph.inject(object);
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundModule.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundModule.java
new file mode 100644
index 0000000..c07de64
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundModule.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.cyanogenmod.wundergroundcmweatherprovider;
+
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.WundergroundServiceManager;
+
+import javax.inject.Singleton;
+
+import dagger.Module;
+import dagger.Provides;
+
+@Module(
+ injects = {
+ DebugActivity.class,
+ WundergroundWeatherProviderService.class
+ }
+)
+public class WundergroundModule {
+
+ private static final String API_KEY = "API_KEY";
+ private WundergroundCMApplication mWeatherviewApplication;
+
+ public WundergroundModule(WundergroundCMApplication weatherviewApplication) {
+ mWeatherviewApplication = weatherviewApplication;
+ }
+
+ @Provides
+ @Singleton
+ public WundergroundServiceManager providesWundergroundServiceManager() {
+ return new WundergroundServiceManager(API_KEY);
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundWeatherProviderService.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundWeatherProviderService.java
new file mode 100644
index 0000000..d9351ad
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/WundergroundWeatherProviderService.java
@@ -0,0 +1,224 @@
+/**
+ * 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.wundergroundcmweatherprovider;
+
+import android.content.Context;
+import android.location.Criteria;
+import android.location.Location;
+import android.location.LocationManager;
+import android.os.Message;
+import android.util.Log;
+
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.ConverterUtils;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.Feature;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.WundergroundServiceManager;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.CurrentObservationResponse;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.DisplayLocationResponse;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.ForecastResponse;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.WundergroundReponse;
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.forecast.SimpleForecastResponse;
+
+import cyanogenmod.providers.WeatherContract;
+import cyanogenmod.weather.RequestInfo;
+import cyanogenmod.weather.WeatherInfo;
+import cyanogenmod.weatherservice.ServiceRequest;
+import cyanogenmod.weatherservice.ServiceRequestResult;
+import cyanogenmod.weatherservice.WeatherProviderService;
+
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+
+import java.util.ArrayList;
+
+import javax.inject.Inject;
+
+public class WundergroundWeatherProviderService extends WeatherProviderService {
+ private static final String TAG = WundergroundWeatherProviderService.class.getSimpleName();
+ private static final int SERVICE_REQUEST_CANCELLED = -1;
+ private static final int SERVICE_REQUEST_SUBMITTED = 0;
+
+ @Inject
+ public WundergroundServiceManager mWundergroundServiceManager;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ WundergroundCMApplication.get(this).inject(this);
+ }
+
+ @Override
+ protected void onRequestSubmitted(final 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<WundergroundWeatherProviderService> {
+ public NonLeakyMessageHandler(WundergroundWeatherProviderService reference) {
+ super(reference);
+ }
+
+ @Override
+ protected void handleMessage(WundergroundWeatherProviderService 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_LOCATION_REQ:
+ reference.processWeatherLocationRequest(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 processWeatherLocationRequest(final ServiceRequest serviceRequest) {
+ final RequestInfo requestInfo = serviceRequest.getRequestInfo();
+ Log.d(TAG, "Received weather request info: " + requestInfo.toString());
+
+ 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));
+ }
+
+ Call<WundergroundReponse> wundergroundCall =
+ mWundergroundServiceManager.query(location.getLatitude(),
+ location.getLongitude(), Feature.conditions, Feature.forecast);
+
+ wundergroundCall.enqueue(new Callback<WundergroundReponse>() {
+ @Override
+ public void onResponse(Call<WundergroundReponse> call, Response<WundergroundReponse> response) {
+ if (response.isSuccessful()) {
+ Log.d(TAG, "Received response:\n" + response.body().toString());
+
+ WundergroundReponse wundergroundReponse = response.body();
+
+ if (wundergroundReponse == null) {
+ Log.d(TAG, "Null wu reponse, return");
+ serviceRequest.fail();
+ return;
+ }
+
+ CurrentObservationResponse currentObservationResponse =
+ wundergroundReponse.getCurrentObservation();
+
+ if (currentObservationResponse == null) {
+ Log.d(TAG, "Null co reponse, return");
+ serviceRequest.fail();
+ return;
+ }
+
+ WeatherInfo.Builder weatherInfoBuilder =
+ new WeatherInfo.Builder(System.currentTimeMillis());
+
+ weatherInfoBuilder.setTemperature(currentObservationResponse.getTempF()
+ .floatValue(),
+ WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT);
+
+ weatherInfoBuilder.setWeatherCondition(
+ WeatherContract.WeatherColumns.WeatherCode.CLOUDY);
+
+ DisplayLocationResponse displayLocationResponse =
+ currentObservationResponse.getDisplayLocation();
+
+ if (displayLocationResponse == null) {
+ Log.d(TAG, "Null dl reponse, return");
+ return;
+ }
+
+ weatherInfoBuilder.setCity(displayLocationResponse.getCity(),
+ displayLocationResponse.getCity());
+
+ ForecastResponse forecastResponse =
+ wundergroundReponse.getForecast();
+
+ if (forecastResponse == null) {
+ Log.d(TAG, "Null fc reponse, return");
+ serviceRequest.fail();
+ return;
+ }
+
+ SimpleForecastResponse simpleForecastResponse =
+ forecastResponse.getSimpleForecast();
+
+ if (simpleForecastResponse == null) {
+ Log.d(TAG, "Null sf reponse, return");
+ serviceRequest.fail();
+ return;
+ }
+
+ ArrayList<WeatherInfo.DayForecast> dayForecasts =
+ ConverterUtils.convertSimpleFCToDayForcast(
+ simpleForecastResponse.getForecastDay());
+ weatherInfoBuilder.setForecast(dayForecasts);
+
+ ServiceRequestResult serviceRequestResult =
+ new ServiceRequestResult.Builder()
+ .setWeatherInfo(weatherInfoBuilder.build()).build();
+ serviceRequest.complete(serviceRequestResult);
+ } else {
+ Log.d(TAG, "Response " + response.toString());
+ }
+ }
+
+ @Override
+ public void onFailure(Call<WundergroundReponse> call, Throwable t) {
+ Log.d(TAG, "Failure " + t.toString());
+ serviceRequest.fail();
+ }
+ });
+ }
+
+ //TODO IMPLEMENT
+ private void processCityNameLookupRequest(final ServiceRequest serviceRequest) {
+ final RequestInfo requestInfo = serviceRequest.getRequestInfo();
+ Log.d(TAG, "Received city lookup request info: " + requestInfo.toString());
+
+
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java
new file mode 100644
index 0000000..41ea613
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.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.cyanogenmod.wundergroundcmweatherprovider.wunderground;
+
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.forecast.ForecastDayResponse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cyanogenmod.providers.WeatherContract;
+import cyanogenmod.weather.WeatherInfo;
+
+public class ConverterUtils {
+
+ private ConverterUtils() {
+ }
+
+ public static ArrayList<WeatherInfo.DayForecast> convertSimpleFCToDayForcast(
+ List<ForecastDayResponse> forecastDayResponses) {
+ ArrayList<WeatherInfo.DayForecast> dayForecasts = new ArrayList<>();
+ for (ForecastDayResponse forecastDayResponse : forecastDayResponses) {
+ WeatherInfo.DayForecast dayForecast = new WeatherInfo.DayForecast.Builder()
+ .setHigh(forecastDayResponse.getHigh().getFahrenheit())
+ .setLow(forecastDayResponse.getLow().getFahrenheit())
+ .setWeatherCondition(WeatherContract.WeatherColumns.WeatherCode.SUNNY)
+ .build();
+ dayForecasts.add(dayForecast);
+ }
+ return dayForecasts;
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/Feature.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/Feature.java
new file mode 100644
index 0000000..d072a09
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/Feature.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.cyanogenmod.wundergroundcmweatherprovider.wunderground;
+
+public enum Feature implements FeatureParam {
+ conditions,
+ forecast;
+
+ @Override
+ public String toString() {
+ return name();
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/FeatureParam.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/FeatureParam.java
new file mode 100644
index 0000000..e8fe214
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/FeatureParam.java
@@ -0,0 +1,20 @@
+/**
+ * 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.wundergroundcmweatherprovider.wunderground;
+
+public interface FeatureParam {
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/WundergroundServiceInterface.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/WundergroundServiceInterface.java
new file mode 100644
index 0000000..1d544e5
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/WundergroundServiceInterface.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.cyanogenmod.wundergroundcmweatherprovider.wunderground;
+
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.WundergroundReponse;
+
+import retrofit2.Call;
+import retrofit2.http.GET;
+import retrofit2.http.Path;
+
+public interface WundergroundServiceInterface {
+ @GET("{features}/q/{state}/{city}.json")
+ public Call<WundergroundReponse> query(@Path("state") String state,
+ @Path("city") String city, @Path(value ="features",
+ encoded = true) String features);
+
+ @GET("{features}/q/{latitude},{longitude}.json")
+ public Call<WundergroundReponse> query(@Path("latitude") double latitude,
+ @Path("longitude") double longitude, @Path(value ="features",
+ encoded = true) String features);
+} \ No newline at end of file
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/WundergroundServiceManager.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/WundergroundServiceManager.java
new file mode 100644
index 0000000..5dbe3f4
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/WundergroundServiceManager.java
@@ -0,0 +1,69 @@
+/**
+ * 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.wundergroundcmweatherprovider.wunderground;
+
+import android.util.Log;
+
+import com.google.common.base.Joiner;
+
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.WundergroundReponse;
+
+import okhttp3.OkHttpClient;
+import okhttp3.logging.HttpLoggingInterceptor;
+import retrofit2.Call;
+import retrofit2.Retrofit;
+import retrofit2.converter.gson.GsonConverterFactory;
+
+public class WundergroundServiceManager {
+ private final static String TAG = WundergroundServiceManager.class.getSimpleName();
+ private final WundergroundServiceInterface mWundergroundServiceInterface;
+
+ public WundergroundServiceManager(String apiKey) {
+ Retrofit baseAdapter = buildRestAdapter(apiKey);
+ mWundergroundServiceInterface = baseAdapter.create(WundergroundServiceInterface.class);
+ }
+
+ public Call<WundergroundReponse> query(String state, String city,
+ FeatureParam... features) {
+ return mWundergroundServiceInterface.query(state, city,
+ coerceVarArgFeaturesToDelimitedString(features));
+ }
+
+ public Call<WundergroundReponse> query(double latitude, double longitude,
+ FeatureParam... features) {
+ return mWundergroundServiceInterface.query(latitude, longitude,
+ coerceVarArgFeaturesToDelimitedString(features));
+ }
+
+ private String coerceVarArgFeaturesToDelimitedString(FeatureParam... featureParams) {
+ return Joiner.on('/').join(featureParams);
+ }
+
+ private Retrofit buildRestAdapter(String apiKey) {
+ //TODO: Wrap this in debug flag
+ //HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
+ //interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
+ //OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
+
+ return new Retrofit.Builder()
+ .baseUrl("http://api.wunderground.com/api/" + apiKey + "/")
+ //.client(client)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build();
+ }
+}
+
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/CurrentObservationResponse.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/CurrentObservationResponse.java
new file mode 100644
index 0000000..d496a6c
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/CurrentObservationResponse.java
@@ -0,0 +1,111 @@
+/**
+ * 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.wundergroundcmweatherprovider.wunderground.responses;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.io.Serializable;
+
+public class CurrentObservationResponse implements Serializable {
+
+ @SerializedName("display_location")
+ private DisplayLocationResponse displayLocationResponse;
+
+ private String weather;
+
+ @SerializedName("temperature_string")
+ private String temperatureString;
+
+ @SerializedName("temp_f")
+ private Double tempF;
+
+ @SerializedName("temp_c")
+ private Double tempC;
+
+ @SerializedName("wind_dir")
+ private String windDir;
+
+ @SerializedName("wind_degrees")
+ private Double windDegrees;
+
+ @SerializedName("wind_mph")
+ private Double windMph;
+
+ public DisplayLocationResponse getDisplayLocation() {
+ return displayLocationResponse;
+ }
+
+ public void setDisplayLocation(DisplayLocationResponse city) {
+ this.displayLocationResponse = city;
+ }
+
+ public String getWeather() {
+ return weather;
+ }
+
+ public void setWeather(String weather) {
+ this.weather = weather;
+ }
+
+ public String getTemperatureString() {
+ return temperatureString;
+ }
+
+ public void setTemperatureString(String temperatureString) {
+ this.temperatureString = temperatureString;
+ }
+
+ public Double getTempF() {
+ return tempF;
+ }
+
+ public void setTempF(Double tempF) {
+ this.tempF = tempF;
+ }
+
+ public Double getTempC() {
+ return tempC;
+ }
+
+ public void setTempC(Double tempC) {
+ this.tempC = tempC;
+ }
+
+ public String getWindDir() {
+ return windDir;
+ }
+
+ public void setWindDir(String windDir) {
+ this.windDir = windDir;
+ }
+
+ public Double getWindDegrees() {
+ return windDegrees;
+ }
+
+ public void setWindDegrees(Double windDegrees) {
+ this.windDegrees = windDegrees;
+ }
+
+ public Double getWindMph() {
+ return windMph;
+ }
+
+ public void setWindMph(Double windMph) {
+ this.windMph = windMph;
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/DisplayLocationResponse.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/DisplayLocationResponse.java
new file mode 100644
index 0000000..c0f6372
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/DisplayLocationResponse.java
@@ -0,0 +1,31 @@
+/**
+ * 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.wundergroundcmweatherprovider.wunderground.responses;
+
+import java.io.Serializable;
+
+public class DisplayLocationResponse implements Serializable {
+ private String city;
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/ForecastResponse.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/ForecastResponse.java
new file mode 100644
index 0000000..f647575
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/ForecastResponse.java
@@ -0,0 +1,36 @@
+/**
+ * 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.wundergroundcmweatherprovider.wunderground.responses;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.forecast.SimpleForecastResponse;
+
+import java.io.Serializable;
+
+public class ForecastResponse implements Serializable {
+ @SerializedName("simpleforecast")
+ private SimpleForecastResponse simpleForecast;
+
+ public SimpleForecastResponse getSimpleForecast() {
+ return simpleForecast;
+ }
+
+ public void setSimpleForecastResponse(SimpleForecastResponse simpleForecast) {
+ this.simpleForecast = simpleForecast;
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/WundergroundReponse.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/WundergroundReponse.java
new file mode 100644
index 0000000..40a5587
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/WundergroundReponse.java
@@ -0,0 +1,53 @@
+/**
+ * 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.wundergroundcmweatherprovider.wunderground.responses;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.io.Serializable;
+
+public class WundergroundReponse implements Serializable {
+ @SerializedName("current_observation")
+ private CurrentObservationResponse currentObservationResponse;
+
+ @SerializedName("forecast")
+ private ForecastResponse forecastResponse;
+
+ public CurrentObservationResponse getCurrentObservation() {
+ return currentObservationResponse;
+ }
+
+ public void setCurrentObservationResponse(CurrentObservationResponse
+ currentObservationResponse) {
+ this.currentObservationResponse = currentObservationResponse;
+ }
+
+ public ForecastResponse getForecast() {
+ return forecastResponse;
+ }
+
+ public void setForecastResponse(ForecastResponse forecastResponse) {
+ this.forecastResponse = forecastResponse;
+ }
+
+ @Override
+ public String toString() {
+ return "WundergroundResponse:\n"
+ + "Forecast: " + forecastResponse.toString() + "\n"
+ + "Current Observation: " + currentObservationResponse.toString();
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/ForecastDayResponse.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/ForecastDayResponse.java
new file mode 100644
index 0000000..8aec0f6
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/ForecastDayResponse.java
@@ -0,0 +1,50 @@
+/**
+ * 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.wundergroundcmweatherprovider.wunderground.responses.forecast;
+
+import java.io.Serializable;
+
+public class ForecastDayResponse implements Serializable {
+ private TemperatureForecastResponse high;
+ private TemperatureForecastResponse low;
+
+ private String conditions;
+
+ public TemperatureForecastResponse getHigh() {
+ return high;
+ }
+
+ public void setHigh(TemperatureForecastResponse high) {
+ this.high = high;
+ }
+
+ public TemperatureForecastResponse getLow() {
+ return low;
+ }
+
+ public void setLow(TemperatureForecastResponse low) {
+ this.low = low;
+ }
+
+ public String getConditions() {
+ return conditions;
+ }
+
+ public void setConditions(String conditions) {
+ this.conditions = conditions;
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/SimpleForecastResponse.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/SimpleForecastResponse.java
new file mode 100644
index 0000000..dcef37a
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/SimpleForecastResponse.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.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.forecast;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class SimpleForecastResponse implements Serializable {
+ @SerializedName("forecastday")
+ private List<ForecastDayResponse> forecastDay;
+
+ public List<ForecastDayResponse> getForecastDay() {
+ return forecastDay;
+ }
+
+ public void setForecastDay(List<ForecastDayResponse> forecastDay) {
+ this.forecastDay = forecastDay;
+ }
+}
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/TemperatureForecastResponse.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/TemperatureForecastResponse.java
new file mode 100644
index 0000000..3379cfd
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/responses/forecast/TemperatureForecastResponse.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.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.forecast;
+
+import java.io.Serializable;
+
+public class TemperatureForecastResponse implements Serializable {
+ private int fahrenheit;
+ private int celsius;
+
+ public int getFahrenheit() {
+ return fahrenheit;
+ }
+
+ public void setFahrenheit(int fahrenheit) {
+ this.fahrenheit = fahrenheit;
+ }
+
+ public int getCelsius() {
+ return celsius;
+ }
+
+ public void setCelsius(int celsius) {
+ this.celsius = celsius;
+ }
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..6729e8c
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,36 @@
+<!--
+ 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
+
+ <Button
+ android:layout_marginTop="5dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Request WeatherInfo"
+ android:onClick="requestWeatherInfo"/>
+
+ <Button
+ android:layout_marginTop="5dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Request WeatherInfo Directly"
+ android:onClick="requestWeatherInfoDirectly"/>
+
+</LinearLayout>
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
new file mode 100644
index 0000000..76816a4
--- /dev/null
+++ b/app/src/main/res/menu/menu_main.xml
@@ -0,0 +1,22 @@
+<!--
+ 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.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context=".MainActivity">
+
+ <item
+ android:id="@+id/action_settings"
+ android:title="@string/action_settings"
+ android:orderInCategory="100"
+ android:showAsAction="never" />
+</menu>
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
--- /dev/null
+++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
--- /dev/null
+++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
new file mode 100644
index 0000000..ba5d926
--- /dev/null
+++ b/app/src/main/res/values-v21/styles.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<resources>
+ <style name="AppTheme" parent="android:Theme.Material.Light">
+ </style>
+</resources>
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..325b9b8
--- /dev/null
+++ b/app/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,18 @@
+<!--
+ 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.
+-->
+<resources>
+ <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..1b44413
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,18 @@
+<!--
+ 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.
+-->
+
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..1de629b
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,16 @@
+<!--
+ 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.
+-->
+<resources>
+ <string name="app_name">Wunderground CM WeatherProvider</string>
+ <string name="action_settings">Settings</string>
+</resources>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..83d8e9d
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,20 @@
+<!--
+ 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.
+-->
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- Customize your theme here. -->
+ </style>
+
+</resources>
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..24daa26
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,22 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:1.2.3'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ maven {
+ url "https://oss.sonatype.org/content/repositories/snapshots/"
+ }
+ }
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..1d3591c
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true \ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..a407c95
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Thu Mar 24 13:52:54 PDT 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app'