Back to project page simple-dash.
The source code is released under:
MIT License
If you think the Android project simple-dash listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.bmdtech.simpledash.activity; /*from w w w . j a v a2 s. com*/ import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.support.annotation.NonNull; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import org.bmdtech.simpledash.R; public class SettingsActivity extends ActionBarActivity { public static final String IP_ADDRESS = "pref_key_ip_address"; public static final String PORT = "pref_key_port"; public static final String REDLINE_FROM_IRACING = "pref_key_redline_iracing"; public static final String RPM_REDLINE = "pref_key_rpm_redline"; public static final String RPM_INCREMENT = "pref_key_rpm_increment"; public static final String SPEED_UNITS = "pref_key_speed_units"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Display the fragment as the main content. getFragmentManager().beginTransaction() .replace(android.R.id.content, new SettingsFragment()) .commit(); // for some reason without this call the settings page would be empty getSupportActionBar(); } public static class SettingsFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); toggleRPMRedlineVisibility(findPreference(REDLINE_FROM_IRACING)); } @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, @NonNull Preference preference) { toggleRPMRedlineVisibility(preference); return super.onPreferenceTreeClick(preferenceScreen, preference); } private void toggleRPMRedlineVisibility(Preference preference) { if (preference.getKey().equals(REDLINE_FROM_IRACING)) { CheckBoxPreference redlineFromIracing = (CheckBoxPreference) preference; findPreference(RPM_REDLINE).setEnabled(!redlineFromIracing.isChecked()); } } } }