android.preference.EditTextPreference Java Examples

The following examples show how to use android.preference.EditTextPreference. 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: BasicSettings.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void initPreferences() {
    Log.i(TAG, "initPreferences()");
    // Phone name
    // This doesn't always work
    String line1Number = ((TelephonyManager) getSystemService(
            Context.TELEPHONY_SERVICE))
            .getLine1Number();
    String deviceId = ((TelephonyManager) getSystemService(
            Context.TELEPHONY_SERVICE)).getDeviceId();
    Log.d(TAG, "...line1 number: " + line1Number);
    Log.d(TAG, "...device id: " + deviceId);
    String phoneNum = (!TextUtils.isEmpty(line1Number)) ? line1Number :
            (!TextUtils.isEmpty(deviceId)) ? deviceId : Constants
                    .DEFAULT_PHONE_NUMBER;
    EditTextPreference prefPhoneName = (EditTextPreference) findPreference(Constants.PREFERENCE_PHONE_NAME);
    if (TextUtils.isEmpty(prefPhoneName.getText())) {
        prefPhoneName.setText(phoneNum);
    }
    // Sana Dispatch Server URL
    EditTextPreference prefMdsUrl = (EditTextPreference) findPreference(Constants.PREFERENCE_MDS_URL);
    if (TextUtils.isEmpty(prefMdsUrl.getText())) {
        prefMdsUrl.setText(Constants.DEFAULT_DISPATCH_SERVER);
    }
}
 
Example #2
Source File: MapSettingsActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
/**
 * Configures the IME action done.
 * 
 * @param editTextPreference the edit text preference
 */
private void configImeActionDone(final EditTextPreference editTextPreference) {
  editTextPreference.getEditText()
      .setOnEditorActionListener(new TextView.OnEditorActionListener() {
          @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
          if (actionId == EditorInfo.IME_ACTION_DONE) {
            Dialog dialog = editTextPreference.getDialog();
            editTextPreference.onClick(dialog, Dialog.BUTTON_POSITIVE);
            dialog.dismiss();
            return true;
          }
          return false;
        }
      });
}
 
Example #3
Source File: DobroModule.java    From Overchan-Android with GNU General Public License v3.0 6 votes vote down vote up
private void addDomainPreferences(PreferenceGroup group) {
    Context context = group.getContext();
    Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) {
                domain = (String) newValue;
                if (domain.length() == 0) domain = DEFAULT_DOMAIN;
                loadHanabiraCookie();
                return true;
            }
            return false;
        }
    };
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    domainPref.setOnPreferenceChangeListener(updateDomainListener);
    group.addPreference(domainPref);
}
 
Example #4
Source File: PreferencesUtil.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else if (preference instanceof RingtonePreference) {
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example #5
Source File: PBServerPreferenceFragment.java    From client-android with GNU General Public License v2.0 6 votes vote down vote up
private void setSummaries() {
    final EditTextPreference urlPreference = (EditTextPreference) findPreference(PREF_SERVER_URL);
    urlPreference.setSummary(preferences.getString(PREF_SERVER_URL, this.getResources().getString(R.string.server_url_summary)));

    final String serverPassHash = preferences.getString(PREF_SERVER_PASS_HASH, "");
    final EditTextPreference serverPassTextPreference = (EditTextPreference) findPreference(PREF_SERVER_PASS);
    if (serverPassHash.isEmpty()) {
        serverPassTextPreference.setSummary(getResources().getString(R.string.server_password_summary));
    } else {
        serverPassTextPreference.setSummary(getResources().getString(R.string.server_password_summary_set));
    }

    final EditTextPreference httpLoginPreference = (EditTextPreference) findPreference(PREF_SERVER_HTTP_AUTH_LOGIN);
    httpLoginPreference.setSummary(preferences.getString(PREF_SERVER_HTTP_AUTH_LOGIN, ""));

    final String httpPass = preferences.getString(PREF_SERVER_HTTP_AUTH_PASS,"");
    if (!httpPass.isEmpty()) {
        final EditTextPreference httpPassPreference = (EditTextPreference) findPreference(PREF_SERVER_HTTP_AUTH_PASS);
        httpPassPreference.setSummary(getResources().getString(R.string.server_password_summary_set));
    }
}
 
Example #6
Source File: SettingsFragment.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.preferences);
    PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences,
            false);

    mSharedPrefs = PreferenceManager
            .getDefaultSharedPreferences(getActivity());
    mIntervalsListPreference = (ListPreference) getPreferenceScreen()
        .findPreference(Constants.KEY_INTERVALS_LIST_PREFERENCE);
    mInitialTabListPreference = (ListPreference) getPreferenceScreen()
        .findPreference(Constants.KEY_INITIAL_TAB_LIST_PREFERENCE);
    mSlideshowIntervalPreference = (EditTextPreference)
        getPreferenceScreen().findPreference(
                Constants.KEY_SLIDESHOW_INTERVAL);
    mHighQualityThumbsCbPreference = (CheckBoxPreference) getPreferenceScreen()
            .findPreference(Constants.KEY_HIGH_QUALITY_THUMBNAILS);

    if (Constants.PRO_VERSION) {
        mHighQualityThumbsCbPreference.setEnabled(true);
    }
}
 
Example #7
Source File: AbstractChanModule.java    From Overchan-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Добавить в группу параметров (на экран/в категорию) параметр задания пароля для удаления постов/файлов
 * @param group группа, на которую добавляется параметр
 */
protected void addPasswordPreference(PreferenceGroup group) {
    final Context context = group.getContext();
    EditTextPreference passwordPref = new EditTextPreference(context) {
        @Override
        protected void showDialog(Bundle state) {
            if (createPassword()) {
                setText(getDefaultPassword());
            }
            super.showDialog(state);
        }
    };
    passwordPref.setTitle(R.string.pref_password_title);
    passwordPref.setDialogTitle(R.string.pref_password_title);
    passwordPref.setSummary(R.string.pref_password_summary);
    passwordPref.setKey(getSharedKey(PREF_KEY_PASSWORD));
    passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    passwordPref.getEditText().setSingleLine();
    passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) });
    group.addPreference(passwordPref);
}
 
Example #8
Source File: BasePreferenceFragment.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
public void onPreferenceAfterChange(Preference preference) {
	if (summaryListenersEditText != null) {
		if (preference instanceof EditTextPreference && summaryListenersEditText.contains(preference)) {
			updateEditTextSummary((EditTextPreference) preference);
		}
	}
	if (summaryListenersMultipleEditText != null) {
		if (preference instanceof MultipleEditTextPreference && summaryListenersMultipleEditText
				.containsKey(preference)) {
			updateMultipleEditTextSummary((MultipleEditTextPreference) preference,
					summaryListenersMultipleEditText.get(preference));
		}
	}
	if (preference instanceof ListPreference) {
		updateListSummary((ListPreference) preference);
	}
	if (dependencies != null) {
		for (Dependency dependency : dependencies) {
			if (preference.getKey().equals(dependency.dependencyKey)) {
				updateDependency(dependency, preference);
			}
		}
	}
}
 
Example #9
Source File: SetupActivity.java    From trigger with GNU General Public License v2.0 6 votes vote down vote up
private void setText(String key, String value) {
    Preference p = findAnyPreference(key, null);
    if (p instanceof EditTextPreference) {
        EditTextPreference etp = (EditTextPreference) p;
        etp.setText(value);

        // show value as summary
        etp.setOnPreferenceChangeListener((Preference preference, Object newValue) -> {
            preference.setSummary(getSummaryValue(key, newValue.toString()));
            return true;
        });
        etp.setSummary(getSummaryValue(key, value));
    } else if (p instanceof ListPreference) {
        ListPreference lp = (ListPreference) p;
        lp.setValue(value);
        // set summary field to "%s" in xml
    } else {
        Log.w("SetupActivity.setText", "Cannot find EditTextPreference/ListPreference in PreferenceGroup with key: " + key);
    }
}
 
Example #10
Source File: PreferencesUtil.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else if (preference instanceof RingtonePreference) {
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example #11
Source File: PreferenceFragment.java    From habpanelviewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void validationAvailable(List<String> items) {
    mUiHandler.post(() -> {
        List<Preference> list = getPreferenceList(getPreferenceScreen(), new ArrayList<>());
        for (Preference p : list) {
            if (p.getKey().endsWith(Constants.PREF_SUFFIX_ITEM) && p instanceof EditTextPreference) {
                final EditText editText = ((EditTextPreference) p).getEditText();

                if (editText instanceof AutoCompleteTextView) {
                    AutoCompleteTextView t = (AutoCompleteTextView) editText;
                    t.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, items));
                    t.performValidation();
                }
            }
        }
    });
}
 
Example #12
Source File: SettingsActivity.java    From batteryhub with Apache License 2.0 6 votes vote down vote up
private void bindPreferenceSummaryToValue(Preference preference) {
    String stringValue = PreferenceManager
            .getDefaultSharedPreferences(preference.getContext())
            .getString(preference.getKey(), "");

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        stringValue = stringValue.replaceFirst("^0+(?!$)", "");

        editTextPreference.setText(stringValue);
        preference.setSummary(stringValue.replaceFirst("^0+(?!$)", ""));
    }
}
 
Example #13
Source File: PreferencesActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
private static void updatePrefSummary(Preference pref) {
    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        pref.setSummary(listPref.getEntry());
    }
    if (pref instanceof EditTextPreference) {
        EditTextPreference editTextPref = (EditTextPreference) pref;
        if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
            pref.setSummary("******");
        } else if (editTextPref.getText() != null) {
            ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
            pref.setSummary(editTextPref.getText());
        } else {
            for (PluginBase plugin : MainApp.getPluginsList()) {
                plugin.updatePreferenceSummary(pref);
            }
        }
    }
    if (pref != null)
        adjustUnitDependentPrefs(pref);
}
 
Example #14
Source File: DeviceAdminSample.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Retrieve the useful instance variables
    mActivity = (DeviceAdminSample) getActivity();
    mDPM = mActivity.mDPM;
    mDeviceAdminSample = mActivity.mDeviceAdminSample;
    mAdminActive = mActivity.isActiveAdmin();

    // Configure the shared UI elements (if they exist)
    mResetPassword = (EditTextPreference) findPreference(KEY_RESET_PASSWORD);
    mSetPassword = (PreferenceScreen) findPreference(KEY_SET_PASSWORD);

    if (mResetPassword != null) {
        mResetPassword.setOnPreferenceChangeListener(this);
    }
    if (mSetPassword != null) {
        mSetPassword.setOnPreferenceClickListener(this);
    }
}
 
Example #15
Source File: PreferencesUtil.java    From text_converter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else if (preference instanceof RingtonePreference) {
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example #16
Source File: Preferences.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private static void setSummary_static(AllPrefsFragment allPrefsFragment, String pref_name) {
    try {
        // is there a cleaner way to bind these values when setting programatically?
        final String pref_val = allPrefsFragment.prefs.getString(pref_name, "");
        allPrefsFragment.findPreference(pref_name).setSummary(pref_val);
        EditTextPreference thispref = (EditTextPreference) allPrefsFragment.findPreference(pref_name);
        thispref.setText(pref_val);
    } catch (Exception e) {
        Log.e(TAG, "Exception during setSummary: " + e.toString());
    }
}
 
Example #17
Source File: BasePreferenceFragment.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private void updateEditTextSummary(EditTextPreference preference) {
	String text = preference.getText();
	if (StringUtils.isEmpty(text)) {
		CharSequence hint = preference.getEditText().getHint();
		text = hint != null ? hint.toString() : null;
	}
	preference.setSummary(text);
}
 
Example #18
Source File: CastPreference.java    From CastVideos-android with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.application_preference);
    getPreferenceScreen().getSharedPreferences().
            registerOnSharedPreferenceChangeListener(this);

    EditTextPreference versionPref = (EditTextPreference) findPreference("app_version");
    versionPref.setTitle(getString(R.string.version, Utils.getAppVersionName(this)));
}
 
Example #19
Source File: SettingsActivity.java    From WhereAreTheEyes with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    final EditTextPreference username = (EditTextPreference) getPreferenceManager().findPreference("username_preference");

    // Set the title to include the username if there is one
    if( username.getText().length() > 0 )
        username.setTitle("Username (" + username.getText() + ")");

    // This big block of code is equivalent to s/[^A-Za-z0-9_]//g
    InputFilter usernameFilter = new InputFilter() {
        public CharSequence filter(CharSequence source, int start, int end,
                                   Spanned dest, int dstart, int dend) {
            for (int i = start; i < end; i++) {
                if (!Character.isLetterOrDigit(source.charAt(i)) && source.charAt(i) != '_' ) {
                    return "";
                }
            }
            return null;
        }
    };
    username.getEditText().setFilters(new InputFilter[] { usernameFilter });

    // Set a callback so we can update the username text when user changes it
    username.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if( newValue.toString().length() > 0 )
                preference.setTitle("Username (" + newValue.toString() + ")");
            else
                preference.setTitle("Username");
            Log.d("PREFERENCES", "Updated username to: " + newValue.toString());
            return true; // Returning true commits the change
        }
    });

    Log.d("Settings", "Starting settings.");
}
 
Example #20
Source File: Preferences.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void updateMibandPreferencesData(){
    EditTextPreference prefMac = (EditTextPreference) findPreference(MiBandEntry.PREF_MIBAND_MAC);
    if (prefMac != null ) {
        prefMac.setText(MiBand.getMac());
        sBindPreferenceTitleAppendToMacValueListener.onPreferenceChange(prefMac,
                PreferenceManager
                        .getDefaultSharedPreferences(prefMac.getContext())
                        .getString(prefMac.getKey(), ""));
    }
    EditTextPreference prefAuthKey = (EditTextPreference) findPreference(MiBandEntry.PREF_MIBAND_AUTH_KEY);
    if (prefAuthKey != null )prefAuthKey.setText(MiBand.getAuthKey());
}
 
Example #21
Source File: SettingsFragment.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
private static void dependBindPreference(PreferenceGroup pg) {
        int count = pg.getPreferenceCount();
        Preference preference;
        String key;
        Object value;

        Pref pref = Pref.getInstance(pg.getContext());

        for(int i = 0; i < count; i++) {
            preference = pg.getPreference(i);
            key = preference.getKey();

            if(preference instanceof PreferenceGroup) {
                dependBindPreference((PreferenceGroup) preference);
                continue;
            }

            Class<? extends Preference> cls = preference.getClass();
            if(cls.equals(Preference.class))
                continue;

            value = pref.getValue(key);

            if(preference instanceof JecListPreference) {
//                if("pref_font_size".equals(key)) {
//                    new FontSizePreference((JecListPreference)preference);
//                } else if("pref_cursor_width".equals(key)) {
//                    new CursorWidthPreference((JecListPreference)preference);
//                }
            } else if(preference instanceof EditTextPreference) {
                ((EditTextPreference)preference).setText(String.valueOf(value));
            } else if(preference instanceof CheckBoxPreference) {
                ((CheckBoxPreference)preference).setChecked((boolean)value);
            }

            if (!Pref.KEY_SYMBOL.equals(key))
                bindPreferenceSummaryToValue(preference);
        }
    }
 
Example #22
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 #23
Source File: WidgetPreferenceFragment.java    From zulip-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);
    findPreference(TITLE_PREFRENCE).setOnPreferenceChangeListener(this);
    findPreference(FROM_PREFERENCE).setOnPreferenceChangeListener(this);
    findPreference(INTERVAL_PREFERENCE).setOnPreferenceChangeListener(this);

    findPreference(TITLE_PREFRENCE).setSummary(((EditTextPreference) findPreference(TITLE_PREFRENCE)).getText());
    findPreference(FROM_PREFERENCE).setSummary(((ListPreference) findPreference(FROM_PREFERENCE)).getValue());
    findPreference(INTERVAL_PREFERENCE).setSummary(((ListPreference) findPreference(INTERVAL_PREFERENCE)).getValue());
}
 
Example #24
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 #25
Source File: IatSettings.java    From AirFree-Client with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState) {
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	super.onCreate(savedInstanceState);
	getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
	addPreferencesFromResource(R.xml.iat_setting);
	
	mVadbosPreference = (EditTextPreference)findPreference("iat_vadbos_preference");
	mVadbosPreference.getEditText().addTextChangedListener(new SettingTextWatcher(IatSettings.this,mVadbosPreference,0,10000));
	
	mVadeosPreference = (EditTextPreference)findPreference("iat_vadeos_preference");
	mVadeosPreference.getEditText().addTextChangedListener(new SettingTextWatcher(IatSettings.this,mVadeosPreference,0,10000));
}
 
Example #26
Source File: AccountSettingsActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set dummy name for preferences so that they don't mix with global ones.
    // FIXME we should not be writing these out to a file, since they are written to
    // the DB in onSharedPreferenceChanged().
    getPreferenceManager().setSharedPreferencesName("account");
    addPreferencesFromResource(R.xml.account_settings);

    Intent intent = getIntent();
    mProviderId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, -1);
    mAccountId = intent.getLongExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, -1);

    if (mProviderId < 0) {
        Log.e(ImApp.LOG_TAG, "AccountSettingsActivity intent requires provider id extra");
        throw new RuntimeException(
                "AccountSettingsActivity must be created with an provider id");
    }
    mXmppResource = (EditTextPreference) findPreference(("pref_account_xmpp_resource"));
    mXmppResourcePrio = (EditTextPreference) findPreference(("pref_account_xmpp_resource_prio"));
    mPort = (EditTextPreference) findPreference(("pref_account_port"));
    mServer = (EditTextPreference) findPreference(("pref_account_server"));
    mAllowPlainAuth = (CheckBoxPreference) findPreference(("pref_security_allow_plain_auth"));
    mRequireTls = (CheckBoxPreference) findPreference(("pref_security_require_tls"));
    mDoDnsSrv = (CheckBoxPreference) findPreference(("pref_security_do_dns_srv"));
    mUseProxy = (CheckBoxPreference) findPreference(("pref_security_use_proxy"));
    mProxyServer = (EditTextPreference) findPreference(("pref_security_proxy_host"));
    mProxyPort = (EditTextPreference) findPreference(("pref_security_proxy_port"));

}
 
Example #27
Source File: PreferencesConnection.java    From habpanelviewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.preferences_connection);

    EditTextPreference urlPreference = (EditTextPreference) findPreference(Constants.PREF_SERVER_URL);
    urlPreference.setOnPreferenceChangeListener(new URLValidatingListener());
}
 
Example #28
Source File: CirnoModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    final Context context = preferenceGroup.getContext();
    EditTextPreference passwordPref = new EditTextPreference(context);
    passwordPref.setTitle(R.string.iichan_prefs_report_thread);
    passwordPref.setDialogTitle(R.string.iichan_prefs_report_thread);
    passwordPref.setSummary(R.string.iichan_prefs_report_thread_summary);
    passwordPref.setKey(getSharedKey(PREF_KEY_REPORT_THREAD));
    passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    passwordPref.getEditText().setSingleLine();
    passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) });
    preferenceGroup.addPreference(passwordPref);
    
    super.addPreferencesOnScreen(preferenceGroup);
}
 
Example #29
Source File: PreferencesConnected.java    From habpanelviewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.preferences_connected);

    EditTextPreference connectedIntervalPreference =
            (EditTextPreference) findPreference(Constants.PREF_CONNECTED_INTERVAL);
    connectedIntervalPreference.setOnPreferenceChangeListener(new NumberValidatingListener(0, 6000));
}
 
Example #30
Source File: AbstractChanModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Добавить в группу параметров (на экран/в категорию) новую категорию настроек прокси-сервера
 * @param group группа, на которую добавляются параметры
 */
protected void addProxyPreferences(PreferenceGroup group) {
    final Context context = group.getContext();
    PreferenceCategory proxyCat = new PreferenceCategory(context); //категория настроек прокси
    proxyCat.setTitle(R.string.pref_cat_proxy);
    group.addPreference(proxyCat);
    CheckBoxPreference useProxyPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать ли прокси вообще"
    useProxyPref.setTitle(R.string.pref_use_proxy);
    useProxyPref.setSummary(R.string.pref_use_proxy_summary);
    useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY));
    useProxyPref.setDefaultValue(false);
    useProxyPref.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(useProxyPref);
    EditTextPreference proxyHostPref = new LazyPreferences.EditTextPreference(context); //поле ввода адреса прокси-сервера
    proxyHostPref.setTitle(R.string.pref_proxy_host);
    proxyHostPref.setDialogTitle(R.string.pref_proxy_host);
    proxyHostPref.setSummary(R.string.pref_proxy_host_summary);
    proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST));
    proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST);
    proxyHostPref.getEditText().setSingleLine();
    proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    proxyHostPref.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(proxyHostPref);
    proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
    EditTextPreference proxyHostPort = new LazyPreferences.EditTextPreference(context); //поле ввода порта прокси-сервера
    proxyHostPort.setTitle(R.string.pref_proxy_port);
    proxyHostPort.setDialogTitle(R.string.pref_proxy_port);
    proxyHostPort.setSummary(R.string.pref_proxy_port_summary);
    proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT));
    proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT);
    proxyHostPort.getEditText().setSingleLine();
    proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    proxyHostPort.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(proxyHostPort);
    proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
}