package com.example.android.quakereport;

import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

/**
 * Created by Lenovo on 7/10/2017.
 */

public class SettingsActivity extends AppCompatActivity
{
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings_activity);
    }

    public static class EarthquakePreferenceFragment extends PreferenceFragment
    {
        @Override
        public void onCreate(@Nullable Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            addPreferencesFromResource(R.xml.settings_main);
        }
    }
}

@@ -54,16 +54,96 @@
 oid.
-os.Bundl
+content.SharedPreferences;%0Aimport android.os.Bundle;%0Aimport android.preference.Preferenc
 e;%0Ai
@@ -187,16 +187,61 @@
 agment;%0A
+import android.preference.PreferenceManager;%0A
 import a
@@ -695,16 +695,65 @@
 Fragment
+ implements Preference.OnPreferenceChangeListener
 %0A    %7B%0A 
@@ -885,32 +885,32 @@
 InstanceState);%0A
-
             addP
@@ -954,16 +954,923 @@
 _main);%0A
+%0A%0A            //Update the preference summary when the settings activity is launched%0A            Preference minMagnitude = findPreference(getString(R.string.settings_min_magnitude_key));%0A            bindPreferenceSummaryToValue(minMagnitude);%0A        %7D%0A%0A        @Override%0A        public boolean onPreferenceChange(Preference preference, Object o)%0A        %7B%0A            String stringValue = o.toString();%0A            preference.setSummary(stringValue);%0A            return true;%0A        %7D%0A%0A        private void bindPreferenceSummaryToValue(Preference preference)%0A        %7B%0A            preference.setOnPreferenceChangeListener(this);%0A            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(preference.getContext());%0A            String preferenceString = sharedPreferences.getString(preference.getKey(), %22%22);%0A            onPreferenceChange(preference, preferenceString);%0A
         

Add preference summaries