// Path: Demo/src/main/java/com/braintreepayments/demo/views/SummaryEditTestPreference.java
// public class SummaryEditTestPreference extends EditTextPreference {
// 
//     private String summaryString;
// 
//     public SummaryEditTestPreference(Context context) {
//         super(context);
//         init();
//     }
// 
//     public SummaryEditTestPreference(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         init();
//     }
// 
//     public SummaryEditTestPreference(Context context, AttributeSet attrs, int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//         init();
//     }
// 
//     @TargetApi(VERSION_CODES.LOLLIPOP)
//     public SummaryEditTestPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
//         super(context, attrs, defStyleAttr, defStyleRes);
//         init();
//     }
// 
//     private void init() {
//         summaryString = super.getSummary().toString();
//     }
// 
//     /**
//      * Returns the summary of this EditTextPreference. If the summary has a
//      * {@link java.lang.String#format String formatting} marker in it (i.e. "%s" or "%1$s"), then the current value
//      * will be substituted in its place.
//      *
//      * @return the summary with appropriate string substitution
//      */
//     @Override
//     public CharSequence getSummary() {
//         final CharSequence text = getText();
//         return String.format(summaryString, text == null ? "" : text);
//     }
// }


import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import com.braintreepayments.demo.R;
import com.braintreepayments.demo.views.SummaryEditTestPreference;
package com.braintreepayments.demo.fragments;



public class SettingsFragment extends PreferenceFragment
        implements OnSharedPreferenceChangeListener {

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

        SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
        onSharedPreferenceChanged(preferences, "paypal_payment_type");
        preferences.registerOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        Preference preference = findPreference(key);
        if (preference instanceof ListPreference) {
            preference.setSummary(((ListPreference) preference).getEntry());
// Path: Demo/src/main/java/com/braintreepayments/demo/views/SummaryEditTestPreference.java
// public class SummaryEditTestPreference extends EditTextPreference {
// 
//     private String summaryString;
// 
//     public SummaryEditTestPreference(Context context) {
//         super(context);
//         init();
//     }
// 
//     public SummaryEditTestPreference(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         init();
//     }
// 
//     public SummaryEditTestPreference(Context context, AttributeSet attrs, int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//         init();
//     }
// 
//     @TargetApi(VERSION_CODES.LOLLIPOP)
//     public SummaryEditTestPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
//         super(context, attrs, defStyleAttr, defStyleRes);
//         init();
//     }
// 
//     private void init() {
//         summaryString = super.getSummary().toString();
//     }
// 
//     /**
//      * Returns the summary of this EditTextPreference. If the summary has a
//      * {@link java.lang.String#format String formatting} marker in it (i.e. "%s" or "%1$s"), then the current value
//      * will be substituted in its place.
//      *
//      * @return the summary with appropriate string substitution
//      */
//     @Override
//     public CharSequence getSummary() {
//         final CharSequence text = getText();
//         return String.format(summaryString, text == null ? "" : text);
//     }
// }


// Path: Demo/src/main/java/com/braintreepayments/demo/fragments/SettingsFragment.java
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import com.braintreepayments.demo.R;
import com.braintreepayments.demo.views.SummaryEditTestPreference;

package com.braintreepayments.demo.fragments;



public class SettingsFragment extends PreferenceFragment
        implements OnSharedPreferenceChangeListener {

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

        SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
        onSharedPreferenceChanged(preferences, "paypal_payment_type");
        preferences.registerOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        Preference preference = findPreference(key);
        if (preference instanceof ListPreference) {
            preference.setSummary(((ListPreference) preference).getEntry());
        } else if (preference instanceof SummaryEditTestPreference) {