Search in sources :

Example 1 with EditTextPreference

use of androidx.preference.EditTextPreference in project kcanotify by antest1.

the class MainPreferenceFragment method onSharedPreferenceChanged.

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (sHandler != null) {
        JsonObject dmpData = new JsonObject();
        String kca_url = "";
        Bundle bundle = new Bundle();
        switch(key) {
            case PREF_KCA_SEEK_CN:
                kca_url = KCA_API_PREF_CN_CHANGED;
                break;
            case PREF_KCA_EXP_VIEW:
                kca_url = KCA_API_PREF_EXPVIEW_CHANGED;
                break;
            case PREF_KCA_SET_PRIORITY:
                kca_url = KCA_API_PREF_PRIORITY_CHANGED;
                break;
            case PREF_FAIRY_SIZE:
                kca_url = KCA_API_PREF_FAIRYSIZE_CHANGED;
                break;
            default:
                break;
        }
        if (kca_url.length() > 0) {
            bundle.putString("url", kca_url);
            bundle.putString("data", gson.toJson(dmpData));
            Message sMsg = sHandler.obtainMessage();
            sMsg.setData(bundle);
            sHandler.sendMessage(sMsg);
        }
    }
    Preference preference = findPreference(key);
    if (preference instanceof ListPreference) {
        ListPreference lp = (ListPreference) preference;
        if (!preference.getKey().equals(PREF_KCA_HP_FORMAT)) {
            // PREF_KCA_HP_FORMAT already has a summary
            preference.setSummary(lp.getEntry());
        }
    }
    if (preference instanceof EditTextPreference) {
        EditTextPreference etp = (EditTextPreference) preference;
        preference.setSummary(getEditTextSummary(key, etp.getText()));
    }
}
Also used : Message(android.os.Message) EditTextPreference(androidx.preference.EditTextPreference) Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) Bundle(android.os.Bundle) JsonObject(com.google.gson.JsonObject) ListPreference(androidx.preference.ListPreference) EditTextPreference(androidx.preference.EditTextPreference)

Example 2 with EditTextPreference

use of androidx.preference.EditTextPreference in project Gadgetbridge by Freeyourgadget.

the class SonyHeadphonesSettingsCustomizer method onPreferenceChange.

@Override
public void onPreferenceChange(final Preference preference, final DeviceSpecificSettingsHandler handler) {
    // TODO: Should the coordinator be responsible for this compatibility check?
    if (preference.getKey().equals(PREF_SONY_AUDIO_CODEC) && device.getType().equals(DeviceType.SONY_WH_1000XM3)) {
        final boolean isSbcCodec = ((EditTextPreference) preference).getText().equalsIgnoreCase("sbc");
        final List<Preference> prefsToDisable = Arrays.asList(handler.findPreference(PREF_SONY_EQUALIZER), handler.findPreference(PREF_SONY_EQUALIZER_MODE), handler.findPreference(PREF_SONY_EQUALIZER_BAND_400), handler.findPreference(PREF_SONY_EQUALIZER_BAND_1000), handler.findPreference(PREF_SONY_EQUALIZER_BAND_2500), handler.findPreference(PREF_SONY_EQUALIZER_BAND_6300), handler.findPreference(PREF_SONY_EQUALIZER_BAND_16000), handler.findPreference(PREF_SONY_EQUALIZER_BASS), handler.findPreference(PREF_SONY_SOUND_POSITION), handler.findPreference(PREF_SONY_SURROUND_MODE));
        for (Preference pref : prefsToDisable) {
            if (pref != null) {
                pref.setEnabled(isSbcCodec);
            }
        }
    }
    // Handle ANC Optimizer status
    if (preference.getKey().equals(PREF_SONY_NOISE_OPTIMIZER_STATUS)) {
        final EditTextPreference optimizerStatusPreference = (EditTextPreference) preference;
        final NoiseCancellingOptimizerStatus optimizerStatus = NoiseCancellingOptimizerStatus.valueOf(optimizerStatusPreference.getText().toUpperCase(Locale.ROOT));
        if (ancOptimizerProgressDialog != null) {
            switch(optimizerStatus) {
                case FINISHED:
                case NOT_RUNNING:
                    ancOptimizerProgressDialog.dismiss();
                    ancOptimizerProgressDialog = null;
                    break;
                default:
                    ancOptimizerProgressDialog.setMessage(optimizerStatus.i18n(preference.getContext()));
            }
        }
    }
}
Also used : EditTextPreference(androidx.preference.EditTextPreference) Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) EditTextPreference(androidx.preference.EditTextPreference) NoiseCancellingOptimizerStatus(nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.NoiseCancellingOptimizerStatus)

Example 3 with EditTextPreference

use of androidx.preference.EditTextPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ApnEditorTest method setMockPreference.

private void setMockPreference(Context context) {
    mApnEditorUT.mName = new EditTextPreference(context);
    mApnEditorUT.mApn = new EditTextPreference(context);
    mApnEditorUT.mProxy = new EditTextPreference(context);
    mApnEditorUT.mPort = new EditTextPreference(context);
    mApnEditorUT.mUser = new EditTextPreference(context);
    mApnEditorUT.mServer = new EditTextPreference(context);
    mApnEditorUT.mPassword = new EditTextPreference(context);
    mApnEditorUT.mMmsc = new EditTextPreference(context);
    mApnEditorUT.mMcc = new EditTextPreference(context);
    mApnEditorUT.mMnc = new EditTextPreference(context);
    mApnEditorUT.mMmsProxy = new EditTextPreference(context);
    mApnEditorUT.mMmsPort = new EditTextPreference(context);
    mApnEditorUT.mAuthType = new ListPreference(context);
    mApnEditorUT.mApnType = new EditTextPreference(context);
    mApnEditorUT.mProtocol = new ListPreference(context);
    mApnEditorUT.mRoamingProtocol = new ListPreference(context);
    mApnEditorUT.mCarrierEnabled = new SwitchPreference(context);
    mApnEditorUT.mBearerMulti = new MultiSelectListPreference(context);
    mApnEditorUT.mMvnoType = new ListPreference(context);
    mApnEditorUT.mMvnoMatchData = new EditTextPreference(context);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) EditTextPreference(androidx.preference.EditTextPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) ListPreference(androidx.preference.ListPreference)

Example 4 with EditTextPreference

use of androidx.preference.EditTextPreference in project collect by opendatakit.

the class ServerPreferencesFragment method addGooglePreferences.

public void addGooglePreferences() {
    addPreferencesFromResource(R.xml.google_preferences);
    selectedGoogleAccountPreference = findPreference(KEY_SELECTED_GOOGLE_ACCOUNT);
    EditTextPreference googleSheetsUrlPreference = (EditTextPreference) findPreference(ProjectKeys.KEY_GOOGLE_SHEETS_URL);
    googleSheetsUrlPreference.setOnBindEditTextListener(editText -> editText.setFilters(new InputFilter[] { new ControlCharacterFilter(), new WhitespaceFilter() }));
    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));
    }
    initAccountPreferences();
}
Also used : WhitespaceFilter(org.odk.collect.android.preferences.filters.WhitespaceFilter) InputFilter(android.text.InputFilter) EditTextPreference(androidx.preference.EditTextPreference) ControlCharacterFilter(org.odk.collect.android.preferences.filters.ControlCharacterFilter)

Example 5 with EditTextPreference

use of androidx.preference.EditTextPreference in project fdroidclient by f-droid.

the class PreferencesFragment method updateSummary.

private void updateSummary(String key, boolean changing) {
    switch(key) {
        case Preferences.PREF_UPDATE_INTERVAL:
            updateIntervalSeekBar.setMax(Preferences.UPDATE_INTERVAL_VALUES.length - 1);
            int seekBarPosition = updateIntervalSeekBar.getValue();
            updateIntervalSeekBar.setSummary(UPDATE_INTERVAL_NAMES[seekBarPosition]);
            break;
        case Preferences.PREF_OVER_WIFI:
            overWifiSeekBar.setMax(Preferences.OVER_NETWORK_ALWAYS);
            setNetworkSeekBarSummary(overWifiSeekBar);
            enableUpdateInverval();
            break;
        case Preferences.PREF_OVER_DATA:
            overDataSeekBar.setMax(Preferences.OVER_NETWORK_ALWAYS);
            setNetworkSeekBarSummary(overDataSeekBar);
            enableUpdateInverval();
            break;
        case Preferences.PREF_UPDATE_NOTIFICATION_ENABLED:
            checkSummary(key, R.string.notify_on);
            break;
        case Preferences.PREF_THEME:
            entrySummary(key);
            if (changing) {
                AppCompatActivity activity = (AppCompatActivity) getActivity();
                FDroidApp fdroidApp = (FDroidApp) activity.getApplication();
                fdroidApp.applyTheme();
            }
            break;
        case Preferences.PREF_USE_PURE_BLACK_DARK_THEME:
            if (changing) {
                AppCompatActivity activity = (AppCompatActivity) getActivity();
                // Theme will be applied upon activity creation
                if (activity != null) {
                    ActivityCompat.recreate(activity);
                }
            }
            break;
        case Preferences.PREF_SHOW_INCOMPAT_VERSIONS:
            checkSummary(key, R.string.show_incompat_versions_on);
            break;
        case Preferences.PREF_SHOW_ANTI_FEATURES:
            checkSummary(key, R.string.show_anti_feature_apps_on);
            break;
        case Preferences.PREF_FORCE_TOUCH_APPS:
            checkSummary(key, R.string.force_touch_apps_on);
            break;
        case Preferences.PREF_LOCAL_REPO_NAME:
            textSummary(key, R.string.local_repo_name_summary);
            break;
        case Preferences.PREF_LOCAL_REPO_HTTPS:
            checkSummary(key, R.string.local_repo_https_on);
            break;
        case Preferences.PREF_LANGUAGE:
            entrySummary(key);
            if (changing) {
                AppCompatActivity activity = (AppCompatActivity) getActivity();
                Languages.setLanguage(activity);
                RepoProvider.Helper.clearEtags(getActivity());
                UpdateService.updateNow(getActivity());
                Languages.forceChangeLanguage(activity);
            }
            break;
        case Preferences.PREF_KEEP_CACHE_TIME:
            entrySummary(key);
            if (changing && currentKeepCacheTime != Preferences.get().getKeepCacheTime()) {
                CleanCacheWorker.schedule(requireContext());
            }
            break;
        case Preferences.PREF_EXPERT:
            checkSummary(key, R.string.expert_on);
            int expertPreferencesCount = 0;
            boolean isExpertMode = Preferences.get().expertMode();
            for (int i = 0; i < otherPrefGroup.getPreferenceCount(); i++) {
                Preference pref = otherPrefGroup.getPreference(i);
                if (TextUtils.equals(Preferences.PREF_EXPERT, pref.getDependency())) {
                    pref.setVisible(isExpertMode);
                    expertPreferencesCount++;
                }
            }
            if (changing) {
                RecyclerView recyclerView = getListView();
                int preferencesCount = recyclerView.getAdapter().getItemCount();
                if (!isExpertMode) {
                    expertPreferencesCount = 0;
                }
                topScroller.setTargetPosition(preferencesCount - expertPreferencesCount - 1);
                recyclerView.getLayoutManager().startSmoothScroll(topScroller);
            }
            break;
        case Preferences.PREF_PRIVILEGED_INSTALLER:
            // We may have removed this preference if it is not suitable to show the user.
            // So lets check it is here first.
            final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER);
            if (pref != null) {
                checkSummary(key, R.string.system_installer_on);
            }
            break;
        case Preferences.PREF_ENABLE_PROXY:
            SwitchPreferenceCompat checkPref = (SwitchPreferenceCompat) findPreference(key);
            checkPref.setSummary(R.string.enable_proxy_summary);
            break;
        case Preferences.PREF_PROXY_HOST:
            EditTextPreference textPref = (EditTextPreference) findPreference(key);
            String text = Preferences.get().getProxyHost();
            if (TextUtils.isEmpty(text) || text.equals(Preferences.DEFAULT_PROXY_HOST)) {
                textPref.setSummary(R.string.proxy_host_summary);
            } else {
                textPref.setSummary(text);
            }
            break;
        case Preferences.PREF_PROXY_PORT:
            EditTextPreference textPref2 = (EditTextPreference) findPreference(key);
            int port = Preferences.get().getProxyPort();
            if (port == Preferences.DEFAULT_PROXY_PORT) {
                textPref2.setSummary(R.string.proxy_port_summary);
            } else {
                textPref2.setSummary(String.valueOf(port));
            }
            break;
        case Preferences.PREF_KEEP_INSTALL_HISTORY:
            if (keepInstallHistoryPref.isChecked()) {
                InstallHistoryService.register(getActivity());
                installHistoryPref.setVisible(true);
                sendToFDroidMetricsPref.setEnabled(true);
            } else {
                InstallHistoryService.unregister(getActivity());
                installHistoryPref.setVisible(false);
                sendToFDroidMetricsPref.setEnabled(false);
            }
            setFDroidMetricsWorker();
            break;
        case Preferences.PREF_SEND_TO_FDROID_METRICS:
            setFDroidMetricsWorker();
            break;
    }
}
Also used : CheckBoxPreference(androidx.preference.CheckBoxPreference) SeekBarPreference(androidx.preference.SeekBarPreference) EditTextPreference(androidx.preference.EditTextPreference) Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) CheckBoxPreference(androidx.preference.CheckBoxPreference) SwitchPreferenceCompat(androidx.preference.SwitchPreferenceCompat) FDroidApp(org.fdroid.fdroid.FDroidApp) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) RecyclerView(androidx.recyclerview.widget.RecyclerView) EditTextPreference(androidx.preference.EditTextPreference)

Aggregations

EditTextPreference (androidx.preference.EditTextPreference)13 ListPreference (androidx.preference.ListPreference)10 Preference (androidx.preference.Preference)8 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)2 PreferenceScreen (androidx.preference.PreferenceScreen)2 SwitchPreference (androidx.preference.SwitchPreference)2 SwitchPreferenceCompat (androidx.preference.SwitchPreferenceCompat)2 ControlCharacterFilter (org.odk.collect.android.preferences.filters.ControlCharacterFilter)2 Activity (android.app.Activity)1 RESULT_OK (android.app.Activity.RESULT_OK)1 Context (android.content.Context)1 Uri (android.net.Uri)1 Message (android.os.Message)1 InputFilter (android.text.InputFilter)1 Toast (android.widget.Toast)1 Nullable (androidx.annotation.Nullable)1 AlertDialog (androidx.appcompat.app.AlertDialog)1