2016-06-19 20:06:00 +02:00
|
|
|
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);
|
2016-06-26 11:43:26 +02:00
|
|
|
if (Config.APS)
|
|
|
|
addPreferencesFromResource(R.xml.pref_closedmode);
|
2016-06-19 20:06:00 +02:00
|
|
|
if (Config.OPENAPSMAENABLED)
|
|
|
|
addPreferencesFromResource(R.xml.pref_openapsma);
|
|
|
|
if (Config.LOWSUSPEDENABLED)
|
|
|
|
addPreferencesFromResource(R.xml.pref_lowsuspend);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|