Android Open Source - RssReader Preference Activity






From Project

Back to project page RssReader.

License

The source code is released under:

GNU General Public License

If you think the Android project RssReader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * RssReader// w  ww  . java2  s .co  m
 *
 * Copyright (c) 2013-2014 teejoe
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.m2x.rssreader.activity;

import org.m2x.rssreader.util.PrefUtils;
import org.m2x.rssreader.util.UiUtils;
import org.m2x.rssreader.R;

import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;

import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.actionbarsherlock.view.MenuItem;

/**
 * The preference Activity.
 * @author teejoe(mtjm2x@gmail.com)
 *
 */
public class PreferenceActivity extends SherlockPreferenceActivity {
    
    @SuppressWarnings("deprecation")
  @Override
    protected void onCreate(Bundle savedInstanceState) {
      UiUtils.setPreferenceTheme(this);
        super.onCreate(savedInstanceState);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        
        addPreferencesFromResource(R.xml.preferences);
                
        /** Set the listener of the push notification preference. **/
        Preference preference = findPreference(PrefUtils.PUSH_NOTIFICATION);
        preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                if (Boolean.TRUE.equals(newValue)) {
                  PrefUtils.putBoolean(PrefUtils.PUSH_NOTIFICATION, false);
                }
                else {
                  PrefUtils.putBoolean(PrefUtils.PUSH_NOTIFICATION, true);
                }
                return true;
            }
        });

        /** Set the listener of the theme preference. **/
        preference = findPreference(PrefUtils.THEME);
        preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                PrefUtils.putString(PrefUtils.THEME, (String)newValue);
              android.os.Process.killProcess(android.os.Process.myPid());

                // this return statement will never be reached
                return true;
            }
        });
    }
    
  @Override
  public boolean onOptionsItemSelected(MenuItem menuItem) {
      switch (menuItem.getItemId()) {
      case android.R.id.home:
          finish();
          return true;
      }
      
      return (super.onOptionsItemSelected(menuItem));
  }
    
}




Java Source Code List

org.m2x.rssreader.Constants.java
org.m2x.rssreader.MainApplication.java
org.m2x.rssreader.activity.AddChannelActivity.java
org.m2x.rssreader.activity.EditChannelActivity.java
org.m2x.rssreader.activity.MainActivity.java
org.m2x.rssreader.activity.PreferenceActivity.java
org.m2x.rssreader.activity.RssArticleActivity.java
org.m2x.rssreader.activity.RssItemListActivity.java
org.m2x.rssreader.adapter.ChannelListAdapter.java
org.m2x.rssreader.adapter.RssArticlePagerAdapter.java
org.m2x.rssreader.adapter.RssItemListAdapter.java
org.m2x.rssreader.fragment.ChannelListFragment.java
org.m2x.rssreader.fragment.RssArticleFragment.java
org.m2x.rssreader.fragment.RssItemListFragment.java
org.m2x.rssreader.provider.DatabaseHelper.java
org.m2x.rssreader.provider.FeedDataProvider.java
org.m2x.rssreader.provider.FeedData.java
org.m2x.rssreader.service.FetcherService.java
org.m2x.rssreader.service.RefreshService.java
org.m2x.rssreader.util.HtmlUtils.java
org.m2x.rssreader.util.NetworkUtils.java
org.m2x.rssreader.util.OPML.java
org.m2x.rssreader.util.PrefUtils.java
org.m2x.rssreader.util.RssAtomParser.java
org.m2x.rssreader.util.StringUtils.java
org.m2x.rssreader.util.UiUtils.java
org.m2x.rssreader.view.RssArticleView.java