diff options
Diffstat (limited to 'app/src/main/java/org/lineageos/yahooweatherprovider/YahooPreferenceActivity.java')
-rw-r--r-- | app/src/main/java/org/lineageos/yahooweatherprovider/YahooPreferenceActivity.java | 66 |
1 files changed, 66 insertions, 0 deletions
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; + } +} |