package info.nightscout.androidaps; import android.content.SharedPreferences; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import info.nightscout.androidaps.events.EventPreferenceChange; public class PreferencesActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit(); PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { MainApp.bus().post(new EventPreferenceChange()); } public static class MyPreferenceFragment extends PreferenceFragment { @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_treatments); if (Config.APS) addPreferencesFromResource(R.xml.pref_closedmode); if (Config.OPENAPSMAENABLED) addPreferencesFromResource(R.xml.pref_openapsma); if (Config.LOWSUSPEDENABLED) addPreferencesFromResource(R.xml.pref_lowsuspend); } } }