Android Open Source - Snapshare Settings






From Project

Back to project page Snapshare.

License

The source code is released under:

GNU General Public License

If you think the Android project Snapshare 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

package com.amcgavin.snapshare;
/**/*www  .  j ava 2  s. c  o  m*/
Settings.java created on 22/12/13.

Copyright (C) 2013 Alec McGavin <alec.mcgavin@gmail.com>

This file is part of Snapshare.

Snapshare 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.

Snapshare 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
a gazillion times. If not, see <http://www.gnu.org/licenses/>.
 */

import net.cantab.stammler.snapshare.R;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;

/**
 * Class to hold all the preferences
 *
 */
public class Settings extends PreferenceFragment implements OnSharedPreferenceChangeListener{

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getPreferenceManager().setSharedPreferencesMode(1);
        addPreferencesFromResource(R.xml.prefs);
        updateSummary("pref_key_adjustment");
    }

    private void updateSummary(String key) {
        if(findPreference(key) instanceof ListPreference) {
            ListPreference lp = (ListPreference)findPreference(key);
            lp.setSummary(lp.getEntry());
        }
    }
    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
            String key) {
        updateSummary(key);

    }
    @Override
    public void onResume() {
        super.onResume();
        getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
    }

}




Java Source Code List

com.amcgavin.snapshare.Media.java
com.amcgavin.snapshare.Obfuscator.java
com.amcgavin.snapshare.SettingsActivity.java
com.amcgavin.snapshare.Settings.java
net.cantab.stammler.snapshare.ReceiveMediaActivity.java
net.cantab.stammler.snapshare.Snapshare.java