Search in sources :

Example 1 with ControlCharacterFilter

use of org.odk.collect.android.preferences.filters.ControlCharacterFilter in project collect by opendatakit.

the class ServerPreferencesFragment method addGooglePreferences.

public void addGooglePreferences() {
    addPreferencesFromResource(R.xml.google_preferences);
    selectedGoogleAccountPreference = findPreference(PreferenceKeys.KEY_SELECTED_GOOGLE_ACCOUNT);
    EditTextPreference googleSheetsUrlPreference = (EditTextPreference) findPreference(PreferenceKeys.KEY_GOOGLE_SHEETS_URL);
    googleSheetsUrlPreference.setOnPreferenceChangeListener(createChangeListener());
    String currentGoogleSheetsURL = googleSheetsUrlPreference.getText();
    if (currentGoogleSheetsURL != null && currentGoogleSheetsURL.length() > 0) {
        googleSheetsUrlPreference.setSummary(currentGoogleSheetsURL + "\n\n" + getString(R.string.google_sheets_url_hint));
    }
    googleSheetsUrlPreference.getEditText().setFilters(new InputFilter[] { new ControlCharacterFilter(), new WhitespaceFilter() });
    initAccountPreferences();
}
Also used : WhitespaceFilter(org.odk.collect.android.preferences.filters.WhitespaceFilter) EditTextPreference(android.preference.EditTextPreference) ControlCharacterFilter(org.odk.collect.android.preferences.filters.ControlCharacterFilter)

Example 2 with ControlCharacterFilter

use of org.odk.collect.android.preferences.filters.ControlCharacterFilter in project collect by opendatakit.

the class ServerPreferencesFragment method addAggregatePreferences.

public void addAggregatePreferences() {
    addPreferencesFromResource(R.xml.aggregate_preferences);
    serverUrlPreference = (EditTextPreference) findPreference(PreferenceKeys.KEY_SERVER_URL);
    usernamePreference = (EditTextPreference) findPreference(PreferenceKeys.KEY_USERNAME);
    passwordPreference = (EditTextPreference) findPreference(PreferenceKeys.KEY_PASSWORD);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    String urlListString = prefs.getString(KNOWN_URL_LIST, "");
    if (urlListString.isEmpty()) {
        urlList = new ArrayList<>();
    } else {
        urlList = new Gson().fromJson(urlListString, new TypeToken<List<String>>() {
        }.getType());
    }
    if (urlList.size() == 0) {
        addUrlToPreferencesList(getString(R.string.default_server_url), prefs);
    }
    urlDropdownSetup();
    serverUrlPreference.getEditText().setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
    serverUrlPreference.getEditText().setOnTouchListener(this);
    serverUrlPreference.setOnPreferenceChangeListener(createChangeListener());
    serverUrlPreference.setSummary(serverUrlPreference.getText());
    serverUrlPreference.getEditText().setFilters(new InputFilter[] { new ControlCharacterFilter(), new WhitespaceFilter() });
    usernamePreference.setOnPreferenceChangeListener(createChangeListener());
    usernamePreference.setSummary(usernamePreference.getText());
    usernamePreference.getEditText().setFilters(new InputFilter[] { new ControlCharacterFilter() });
    passwordPreference.setOnPreferenceChangeListener(createChangeListener());
    maskPasswordSummary(passwordPreference.getText());
    passwordPreference.getEditText().setFilters(new InputFilter[] { new ControlCharacterFilter() });
}
Also used : WhitespaceFilter(org.odk.collect.android.preferences.filters.WhitespaceFilter) SharedPreferences(android.content.SharedPreferences) Gson(com.google.gson.Gson) ArrayList(java.util.ArrayList) List(java.util.List) ControlCharacterFilter(org.odk.collect.android.preferences.filters.ControlCharacterFilter)

Example 3 with ControlCharacterFilter

use of org.odk.collect.android.preferences.filters.ControlCharacterFilter in project collect by opendatakit.

the class ServerPreferencesFragment method addOtherPreferences.

public void addOtherPreferences() {
    addAggregatePreferences();
    addPreferencesFromResource(R.xml.other_preferences);
    formListUrlPreference = (EditTextPreference) findPreference(KEY_FORMLIST_URL);
    submissionUrlPreference = (EditTextPreference) findPreference(KEY_SUBMISSION_URL);
    InputFilter[] filters = { new ControlCharacterFilter(), new WhitespaceFilter() };
    serverUrlPreference.getEditText().setFilters(filters);
    formListUrlPreference.setOnPreferenceChangeListener(createChangeListener());
    formListUrlPreference.setSummary(formListUrlPreference.getText());
    formListUrlPreference.getEditText().setFilters(filters);
    submissionUrlPreference.setOnPreferenceChangeListener(createChangeListener());
    submissionUrlPreference.setSummary(submissionUrlPreference.getText());
    submissionUrlPreference.getEditText().setFilters(filters);
}
Also used : WhitespaceFilter(org.odk.collect.android.preferences.filters.WhitespaceFilter) InputFilter(android.text.InputFilter) ControlCharacterFilter(org.odk.collect.android.preferences.filters.ControlCharacterFilter)

Aggregations

ControlCharacterFilter (org.odk.collect.android.preferences.filters.ControlCharacterFilter)3 WhitespaceFilter (org.odk.collect.android.preferences.filters.WhitespaceFilter)3 SharedPreferences (android.content.SharedPreferences)1 EditTextPreference (android.preference.EditTextPreference)1 InputFilter (android.text.InputFilter)1 Gson (com.google.gson.Gson)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1