summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/src/main/AndroidManifest.xml8
-rw-r--r--app/src/main/java/org/cyanogenmod/yahooweatherprovider/ImagePreference.java29
-rw-r--r--app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooPreferenceActivity.java66
-rw-r--r--app/src/main/res/drawable/purple.pngbin0 -> 2485 bytes
-rw-r--r--app/src/main/res/layout/image_preference.xml14
-rw-r--r--app/src/main/res/values/strings.xml8
-rw-r--r--app/src/main/res/values/styles.xml2
-rw-r--r--app/src/main/res/xml/preferences.xml24
-rw-r--r--app/src/main/res/xml/weather_settings_service.xml15
9 files changed, 164 insertions, 2 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 48b4540..341c8ef 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -30,11 +30,19 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
+ <activity android:name=".YahooPreferenceActivity"
+ android:exported="true"
+ android:label="@string/app_name"/>
+
<service android:name=".YahooWeatherProviderService"
android:permission="cyanogenmod.permission.BIND_WEATHER_PROVIDER_SERVICE">
<intent-filter>
<action android:name="cyanogenmod.weatherservice.WeatherProviderService" />
</intent-filter>
+
+ <meta-data
+ android:name="cyanogenmod.weatherservice"
+ android:resource="@xml/weather_settings_service" />
</service>
</application>
diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ImagePreference.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ImagePreference.java
new file mode 100644
index 0000000..bac4822
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ImagePreference.java
@@ -0,0 +1,29 @@
+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/YahooPreferenceActivity.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooPreferenceActivity.java
new file mode 100644
index 0000000..58c9bb6
--- /dev/null
+++ b/app/src/main/java/org/cyanogenmod/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.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/res/drawable/purple.png b/app/src/main/res/drawable/purple.png
new file mode 100644
index 0000000..66cd058
--- /dev/null
+++ b/app/src/main/res/drawable/purple.png
Binary files differ
diff --git a/app/src/main/res/layout/image_preference.xml b/app/src/main/res/layout/image_preference.xml
new file mode 100644
index 0000000..09b449a
--- /dev/null
+++ b/app/src/main/res/layout/image_preference.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/widget_frame"
+ android:layout_width="match_parent"
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:orientation="vertical" >
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:src="@drawable/purple"
+ android:scaleType="centerInside"/>
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5f3269a..6b45a5d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,9 @@
<resources>
<string name="app_name">Yahoo Weather Provider</string>
-</resources>
+
+ <string name="about_preference_category_title">About</string>
+ <string name="about_preference">Copyright</string>
+ <string name="about_preference_summary">YAHOO! is a registered trademark of Yahoo! Inc. both in the United States and internationally.</string>
+
+ <string name="customization_preference_category_title">Customization</string>
+</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 3444a02..dc4204f 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,6 +1,6 @@
<resources>
<!-- Base application theme. -->
- <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
new file mode 100644
index 0000000..837a4a1
--- /dev/null
+++ b/app/src/main/res/xml/preferences.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory android:title="@string/about_preference_category_title">
+ <Preference
+ android:key="about_key"
+ android:title="@string/about_preference"
+ android:summary="@string/about_preference_summary" />
+ <org.cyanogenmod.yahooweatherprovider.ImagePreference
+ android:key="image_key"/>
+ </PreferenceCategory>
+
+</PreferenceScreen> \ No newline at end of file
diff --git a/app/src/main/res/xml/weather_settings_service.xml b/app/src/main/res/xml/weather_settings_service.xml
new file mode 100644
index 0000000..af5c23e
--- /dev/null
+++ b/app/src/main/res/xml/weather_settings_service.xml
@@ -0,0 +1,15 @@
+<?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.
+-->
+<weather-provider-service xmlns:android="http://schemas.android.com/apk/res/android"
+ android:settingsActivity="org.cyanogenmod.yahooweatherprovider.YahooPreferenceActivity" /> \ No newline at end of file