package com.meerkat.laura.fakescannerapp;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;

public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
    public final static String PSC_URL = "psc_url";
    public final static String PSC_NONCE = "psc_nonce";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        Preference pref = findPreference(key);
        if (pref == null)
            return;
        switch(key) {
            case SettingsFragment.PSC_URL:
                pref.setSummary(sharedPreferences.getString(key, ""));
                break;
            case SettingsFragment.PSC_NONCE:
                pref.setSummary(sharedPreferences.getString(key, ""));
                break;
        }
    }
}