Java Code Examples for android.preference.EditTextPreference#setEnabled()

The following examples show how to use android.preference.EditTextPreference#setEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsFragment.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
private void initNetworkSettings() {
	((CheckBoxPreference) findPreference(getString(R.string.pref_wifi_only_key))).setChecked(mPrefs.isWifiOnlyEnabled());

	// Disable UPnP if ICE si enabled, or disable ICE if UPnP is enabled
	CheckBoxPreference ice = (CheckBoxPreference) findPreference(getString(R.string.pref_ice_enable_key));
	CheckBoxPreference turn = (CheckBoxPreference) findPreference(getString(R.string.pref_turn_enable_key));
	ice.setChecked(mPrefs.isIceEnabled());
	turn.setEnabled(mPrefs.getStunServer() != null);
	turn.setChecked(mPrefs.isTurnEnabled());

	EditTextPreference turnUsername = (EditTextPreference) findPreference(getString(R.string.pref_turn_username_key));
	EditTextPreference turnPassword = (EditTextPreference) findPreference(getString(R.string.pref_turn_passwd_key));
	turnUsername.setEnabled(mPrefs.isTurnEnabled());
	turnUsername.setSummary(mPrefs.getTurnUsername());
	turnUsername.setText(mPrefs.getTurnUsername());
	turnPassword.setEnabled(mPrefs.isTurnEnabled());

	CheckBoxPreference randomPort = (CheckBoxPreference) findPreference(getString(R.string.pref_transport_use_random_ports_key));
	randomPort.setChecked(mPrefs.isUsingRandomPort());

	// Disable sip port choice if port is random
	EditTextPreference sipPort = (EditTextPreference) findPreference(getString(R.string.pref_sip_port_key));
	sipPort.setEnabled(!randomPort.isChecked());
	sipPort.setSummary(mPrefs.getSipPort());
	sipPort.setText(mPrefs.getSipPort());

	EditTextPreference stun = (EditTextPreference) findPreference(getString(R.string.pref_stun_server_key));
	stun.setSummary(mPrefs.getStunServer());
	stun.setText(mPrefs.getStunServer());

	((CheckBoxPreference) findPreference(getString(R.string.pref_push_notification_key))).setChecked(mPrefs.isPushNotificationEnabled());
	((CheckBoxPreference) findPreference(getString(R.string.pref_ipv6_key))).setChecked(mPrefs.isUsingIpv6());
}
 
Example 2
Source File: SettingsFragment.java    From MedtronicUploader with GNU General Public License v2.0 5 votes vote down vote up
private void addMedtronicOptionsListener(){
     final EditTextPreference med_id = (EditTextPreference)findPreference("medtronic_cgm_id");
     final EditTextPreference gluc_id = (EditTextPreference)findPreference("glucometer_cgm_id");
     final EditTextPreference sensor_id = (EditTextPreference)findPreference("sensor_cgm_id");
     final ListPreference calib_type = (ListPreference)findPreference("calibrationType");
     final ListPreference glucSrcType = (ListPreference)findPreference("glucSrcTypes");

     med_id.setEnabled(true);
     gluc_id.setEnabled(true);
     sensor_id.setEnabled(true);
     calib_type.setEnabled(true);
     glucSrcType.setEnabled(true);

}
 
Example 3
Source File: PreferenceMatchersTest.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Test
@UiThreadTest
public void isEnabledTest() {
  CheckBoxPreference pref = new CheckBoxPreference(getApplicationContext());
  pref.setEnabled(true);
  assertThat(pref, isEnabled());
  pref.setEnabled(false);
  assertThat(pref, not(isEnabled()));
  EditTextPreference pref2 = new EditTextPreference(getApplicationContext());
  pref2.setEnabled(true);
  assertThat(pref2, isEnabled());
  pref2.setEnabled(false);
  assertThat(pref2, not(isEnabled()));
}
 
Example 4
Source File: SettingsFragment.java    From NightWidget with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	/* set preferences */
	addPreferencesFromResource(R.xml.preferences);
	addMedtronicOptionsListener();
	PreferenceManager.setDefaultValues(context, R.xml.preferences, false);
	final ListPreference mon_type = (ListPreference) findPreference("monitor_type_widget");
	final EditTextPreference med_id = (EditTextPreference) findPreference("medtronic_cgm_id_widget");
	final ListPreference metric_type = (ListPreference) findPreference("metric_preference_widget");
	final CustomSwitchPreference mmolDecimals = (CustomSwitchPreference)findPreference("mmolDecimals_widget");
	int index = mon_type.findIndexOfValue(mon_type.getValue());

	if (index == 1) {
		med_id.setEnabled(true);
	} else {
		med_id.setEnabled(false);
	}
	int index_met = metric_type.findIndexOfValue(PreferenceManager.getDefaultSharedPreferences(context).getString("metric_preference_widget", "1"));

	if (index_met == 0){

		mmolDecimals.setEnabled(false);
	}else{ 
		mmolDecimals.setEnabled(true);
	}
	// iterate through all preferences and update to saved value
	for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
		initSummary(getPreferenceScreen().getPreference(i));
	}

}
 
Example 5
Source File: PriceHitAlarmSettingsFragment.java    From boilr with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void updateDependentOnPair() {
	super.updateDependentOnPair();
	EditTextPreference[] edits = { mUpperLimitPref, mLowerLimitPref };
	String text;
	for (EditTextPreference edit : edits) {
		edit.setEnabled(true);
		text = edit.getText();
		if(text != null && !text.equals(""))
			edit.setSummary(text + " " + alarm.getPair().getExchange());
	}
}
 
Example 6
Source File: AlarmPreferencesFragment.java    From boilr with GNU General Public License v3.0 5 votes vote down vote up
protected void disableDependentOnPairHitAlarm() {
	EditTextPreference[] edits = { mUpperLimitPref, mLowerLimitPref };
	for (EditTextPreference edit : edits) {
		edit.setEnabled(false);
		edit.setSummary(null);
	}
}
 
Example 7
Source File: Pref.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
public static EditTextPreference Edit(Context context, PreferenceCategory category, String caption, String summary, String dialogCaption, String key, Object defaultValue, boolean enabled, Integer type) {
	EditTextPreference retval = new EditTextPreference(context);
	retval.setTitle(caption);
	retval.setSummary(summary);
	retval.setEnabled(enabled);
	retval.setKey(key);
	retval.setDefaultValue(defaultValue);
	retval.setDialogTitle(dialogCaption);
	if (type != null) {
		retval.getEditText().setInputType(type);
	}
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 8
Source File: Pref.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
public static EditTextPreference Edit(Context context, PreferenceCategory category, int caption, int summary, int dialogCaption, String key, Object defaultValue, boolean enabled, Integer type) {
	EditTextPreference retval = new EditTextPreference(context);
	if (caption > 0) retval.setTitle(caption);
	if (summary > 0) retval.setSummary(summary);
	retval.setEnabled(enabled);
	retval.setKey(key);
	retval.setDefaultValue(defaultValue);
	if (dialogCaption > 0) retval.setDialogTitle(dialogCaption);
	if (type != null) {
		retval.getEditText().setInputType(type);
	}
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 9
Source File: Settings.java    From SMP with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d("Settings", "onCreate");
    super.onCreate(savedInstanceState);
    params = new ParametersImpl(this);
    // fixme: everything should be put in onResume?
    addPreferencesFromResource(R.xml.preferences);
    playIntent = new Intent(this, MusicService.class);
    bindService(playIntent, musicConnection, Context.BIND_AUTO_CREATE);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();

    String thresholdKeys = PrefKeys.SHAKE_THRESHOLD.name();
    EditTextPreference prefShakeThreshold = (EditTextPreference) findPreference(thresholdKeys);
    CheckBoxPreference prefEnableShake = (CheckBoxPreference) findPreference(PrefKeys.ENABLE_SHAKE.name());
    if(getPackageManager().hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER)) {
        prefShakeThreshold.setSummary(String.valueOf(params.getShakeThreshold()));
        prefEnableShake.setChecked(params.getEnableShake());
    }
    else {
        prefShakeThreshold.setEnabled(false);
        prefEnableShake.setEnabled(false);
        Toast.makeText(getApplicationContext(),
                getResources().getString(R.string.settings_no_accelerometer),
                Toast.LENGTH_LONG).show();
    }

    findPreference(PrefKeys.TEXT_SIZE_NORMAL.name()).setSummary(String.valueOf(params.getNormalTextSize()));
    findPreference(PrefKeys.TEXT_SIZE_BIG.name()).setSummary(String.valueOf(params.getBigTextSize()));
    findPreference(PrefKeys.TEXT_SIZE_RATIO.name()).setSummary(String.valueOf(params.getTextSizeRatio()));

    Preference rescan = findPreference(getResources().getString(R.string.settings_rescan_key));
    rescan.setOnPreferenceClickListener(this);

    Preference donate = findPreference(getResources().getString(R.string.settings_donate_key));
    donate.setOnPreferenceClickListener(this);

    setUnfoldSubgroup();
    setUnfoldThresholdSummary();

    String rootFoldersKey = PrefKeys.ROOT_FOLDERS.name();
    EditTextPreference prefRootFolders = (EditTextPreference) findPreference(rootFoldersKey);
    prefRootFolders.setSummary(params.getRootFolders());
    if(!sharedPreferences.contains(rootFoldersKey))
        prefRootFolders.setText(Path.getMusicStoragesStr(getBaseContext()));

    setFoldSummary();

    this.onContentChanged();
}
 
Example 10
Source File: Settings.java    From SMP with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d("Settings", "onCreate");
    super.onCreate(savedInstanceState);
    params = new ParametersImpl(this);
    // fixme: everything should be put in onResume?
    addPreferencesFromResource(R.xml.preferences);
    playIntent = new Intent(this, MusicService.class);
    bindService(playIntent, musicConnection, Context.BIND_AUTO_CREATE);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();

    String thresholdKeys = PrefKeys.SHAKE_THRESHOLD.name();
    EditTextPreference prefShakeThreshold = (EditTextPreference) findPreference(thresholdKeys);
    CheckBoxPreference prefEnableShake = (CheckBoxPreference) findPreference(PrefKeys.ENABLE_SHAKE.name());
    if(getPackageManager().hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER)) {
        prefShakeThreshold.setSummary(String.valueOf(params.getShakeThreshold()));
        prefEnableShake.setChecked(params.getEnableShake());
    }
    else {
        prefShakeThreshold.setEnabled(false);
        prefEnableShake.setEnabled(false);
        Toast.makeText(getApplicationContext(),
                getResources().getString(R.string.settings_no_accelerometer),
                Toast.LENGTH_LONG).show();
    }

    findPreference(PrefKeys.TEXT_SIZE_NORMAL.name()).setSummary(String.valueOf(params.getNormalTextSize()));
    findPreference(PrefKeys.TEXT_SIZE_BIG.name()).setSummary(String.valueOf(params.getBigTextSize()));
    findPreference(PrefKeys.TEXT_SIZE_RATIO.name()).setSummary(String.valueOf(params.getTextSizeRatio()));

    Preference rescan = findPreference(getResources().getString(R.string.settings_rescan_key));
    rescan.setOnPreferenceClickListener(this);

    Preference donate = findPreference(getResources().getString(R.string.settings_donate_key));
    donate.setOnPreferenceClickListener(this);

    setUnfoldSubgroup();
    setUnfoldThresholdSummary();

    String rootFoldersKey = PrefKeys.ROOT_FOLDERS.name();
    EditTextPreference prefRootFolders = (EditTextPreference) findPreference(rootFoldersKey);
    prefRootFolders.setSummary(params.getRootFolders());
    if(!sharedPreferences.contains(rootFoldersKey))
        prefRootFolders.setText(Path.getMusicStoragesStr(getBaseContext()));

    setFoldSummary();

    this.onContentChanged();
}