当前位置: 首页>>代码示例>>Java>>正文


Java SwitchPreferenceCompat.setEnabled方法代码示例

本文整理汇总了Java中android.support.v7.preference.SwitchPreferenceCompat.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchPreferenceCompat.setEnabled方法的具体用法?Java SwitchPreferenceCompat.setEnabled怎么用?Java SwitchPreferenceCompat.setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.preference.SwitchPreferenceCompat的用法示例。


在下文中一共展示了SwitchPreferenceCompat.setEnabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enableOrDisablePreferences

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void enableOrDisablePreferences(boolean enable)
{
    String keyAddress = getString(R.string.pref_key_proxy_address);
    EditTextPreference address = (EditTextPreference) findPreference(keyAddress);
    address.setEnabled(enable);

    String keyPort = getString(R.string.pref_key_proxy_port);
    EditTextPreference port = (EditTextPreference) findPreference(keyPort);
    port.setEnabled(enable);

    String keyProxyPeersToo = getString(R.string.pref_key_proxy_peers_too);
    SwitchPreferenceCompat proxyPeersToo = (SwitchPreferenceCompat) findPreference(keyProxyPeersToo);
    proxyPeersToo.setEnabled(enable);

    String keyForceProxy = getString(R.string.pref_key_force_proxy);
    SwitchPreferenceCompat forceProxy = (SwitchPreferenceCompat) findPreference(keyForceProxy);
    forceProxy.setEnabled(enable);

    String keyRequiresAuth = getString(R.string.pref_key_proxy_requires_auth);
    SwitchPreferenceCompat requiresAuth = (SwitchPreferenceCompat) findPreference(keyRequiresAuth);
    requiresAuth.setEnabled(enable);
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:23,代码来源:ProxySettingsFragment.java

示例2: onCreatePreferences

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    addPreferencesFromResource(R.xml.pref_global);
    mSnoozeDuration = (ListPreference)findPreference(getString(R.string.pref_snooze_duration_key));
    mRingDuration = (ListPreference)findPreference(getString(R.string.pref_ring_duration_key));
    mAlarmVolume = (VolumeSliderPreference)findPreference(getString(R.string.pref_ring_volume_key));
    mEnableNotifications = (SwitchPreferenceCompat)findPreference(getString(R.string.pref_enable_notifications_key));
    mEnableReliability = (SwitchPreferenceCompat)findPreference(getString(R.string.pref_enable_reliability_key));
    mEnableReliability.setEnabled(mEnableNotifications.isChecked());
    setDefaultSummaryValues();
}
 
开发者ID:Microsoft,项目名称:ProjectOxford-Apps-MimickerAlarm,代码行数:12,代码来源:AlarmGlobalSettingsActivity.java

示例3: onPreferenceChange

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
    SettingsManager pref = new SettingsManager(getActivity().getApplicationContext());

    if (preference instanceof SwitchPreferenceCompat) {
        pref.put(preference.getKey(), (boolean) newValue);
    } else if (preference.getKey().equals(getString(R.string.pref_key_port))) {
        int value = TorrentEngine.Settings.DEFAULT_PORT;
        if (!TextUtils.isEmpty((String) newValue)) {
            value = Integer.parseInt((String) newValue);
        }
        pref.put(preference.getKey(), value);
        preference.setSummary(Integer.toString(value));
    } else if (preference.getKey().equals(getString(R.string.pref_key_enc_mode))) {
        int type = Integer.parseInt((String) newValue);
        pref.put(preference.getKey(), type);
        String typesName[] = getResources().getStringArray(R.array.pref_enc_mode_entries);
        preference.setSummary(typesName[type]);

        boolean enableAdvancedEncryptSettings = type != Integer.parseInt(getString(R.string.pref_enc_mode_disable_value));

        String keyEncryptInConnections = getString(R.string.pref_key_enc_in_connections);
        SwitchPreferenceCompat encryptInConnections =
                (SwitchPreferenceCompat) findPreference(keyEncryptInConnections);
        encryptInConnections.setEnabled(enableAdvancedEncryptSettings);
        encryptInConnections.setChecked(enableAdvancedEncryptSettings);

        String keyEncryptOutConnections = getString(R.string.pref_key_enc_out_connections);
        SwitchPreferenceCompat encryptOutConnections =
                (SwitchPreferenceCompat) findPreference(keyEncryptOutConnections);
        encryptOutConnections.setEnabled(enableAdvancedEncryptSettings);
        encryptOutConnections.setChecked(enableAdvancedEncryptSettings);
    }

    return true;
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:38,代码来源:NetworkSettingsFragment.java

示例4: accountChanged

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void accountChanged(Account account) {
    if (account == null) {
        Log.d(TAG, "accountChanged: Null account");
        return;
    }

    setPreferenceDetails(account.getConfig());

    SwitchPreferenceCompat pref = (SwitchPreferenceCompat) findPreference("Account.status");
    if (account.isSip() && pref != null) {
        String status;
        pref.setTitle(account.getAlias());
        if (account.isEnabled()) {
            if (account.isTrying()) {
                status = getString(R.string.account_status_connecting);
            } else if (account.needsMigration()) {
                status = getString(R.string.account_update_needed);
            } else if (account.isInError()) {
                status = getString(R.string.account_status_connection_error);
            } else if (account.isRegistered()) {
                status = getString(R.string.account_status_online);
            } else {
                status = getString(R.string.account_status_unknown);
            }
        } else {
            status = getString(R.string.account_status_offline);
        }
        pref.setSummary(status);
        pref.setChecked(account.isEnabled());

        // An ip2ip account is always ready
        pref.setEnabled(!account.isIP2IP());

        pref.setOnPreferenceChangeListener(changeAccountStatusListener);
    }

    setPreferenceListener(account.getConfig(), changeBasicPreferenceListener);
}
 
开发者ID:savoirfairelinux,项目名称:ring-client-android,代码行数:40,代码来源:GeneralAccountFragment.java

示例5: onCreate

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    SettingsManager pref = new SettingsManager(getActivity().getApplicationContext());

    boolean enableAdvancedSettings;

    String keyProxyType = getString(R.string.pref_key_proxy_type);
    ListPreference proxyType = (ListPreference) findPreference(keyProxyType);
    int type = pref.getInt(keyProxyType, SettingsManager.Default.proxyType);
    proxyType.setValueIndex(type);
    String typesName[] = getResources().getStringArray(R.array.pref_proxy_type_entries);
    proxyType.setSummary(typesName[type]);
    enableAdvancedSettings = type != Integer.parseInt(getString(R.string.pref_proxy_type_none_value));
    bindOnPreferenceChangeListener(proxyType);

    String keyAddress = getString(R.string.pref_key_proxy_address);
    EditTextPreference address = (EditTextPreference) findPreference(keyAddress);
    address.setEnabled(enableAdvancedSettings);
    String addressValue = pref.getString(keyAddress, SettingsManager.Default.proxyAddress);
    address.setText(addressValue);
    address.setSummary(addressValue);
    bindOnPreferenceChangeListener(address);

    String keyPort = getString(R.string.pref_key_proxy_port);
    EditTextPreference port = (EditTextPreference) findPreference(keyPort);
    port.setEnabled(enableAdvancedSettings);
    InputFilter[] portFilter =
            new InputFilter[]{new InputFilterMinMax(0, 10000)};
    int portNumber = pref.getInt(keyPort, SettingsManager.Default.proxyPort);
    String portValue = Integer.toString(portNumber);
    port.getEditText().setFilters(portFilter);
    port.setSummary(portValue);
    port.setText(portValue);
    bindOnPreferenceChangeListener(port);

    String keyProxyPeersToo = getString(R.string.pref_key_proxy_peers_too);
    SwitchPreferenceCompat proxyPeersToo = (SwitchPreferenceCompat) findPreference(keyProxyPeersToo);
    proxyPeersToo.setEnabled(enableAdvancedSettings);
    proxyPeersToo.setChecked(pref.getBoolean(keyProxyPeersToo, SettingsManager.Default.proxyPeersToo));
    bindOnPreferenceChangeListener(proxyPeersToo);

    String keyForceProxy = getString(R.string.pref_key_force_proxy);
    SwitchPreferenceCompat forceProxy = (SwitchPreferenceCompat) findPreference(keyForceProxy);
    forceProxy.setEnabled(enableAdvancedSettings);
    forceProxy.setChecked(pref.getBoolean(keyForceProxy, SettingsManager.Default.forceProxy));
    bindOnPreferenceChangeListener(forceProxy);

    String keyRequiresAuth = getString(R.string.pref_key_proxy_requires_auth);
    SwitchPreferenceCompat requiresAuth = (SwitchPreferenceCompat) findPreference(keyRequiresAuth);
    requiresAuth.setEnabled(enableAdvancedSettings);
    requiresAuth.setChecked(pref.getBoolean(keyRequiresAuth, SettingsManager.Default.proxyRequiresAuth));
    bindOnPreferenceChangeListener(requiresAuth);

    String keyLogin = getString(R.string.pref_key_proxy_login);
    EditTextPreference login = (EditTextPreference) findPreference(keyLogin);
    String loginValue = pref.getString(keyLogin, SettingsManager.Default.proxyLogin);
    login.setText(loginValue);
    login.setSummary(loginValue);
    bindOnPreferenceChangeListener(login);

    String keyPassword = getString(R.string.pref_key_proxy_password);
    EditTextPreference password = (EditTextPreference) findPreference(keyPassword);
    String passwordValue = pref.getString(keyPassword, SettingsManager.Default.proxyPassword);
    password.setText(passwordValue);
    EditText edit = password.getEditText();
    password.setSummary(edit.getTransformationMethod().getTransformation(passwordValue, edit).toString());
    bindOnPreferenceChangeListener(password);
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:72,代码来源:ProxySettingsFragment.java

示例6: onCreatePreferences

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

    mActivity = super.getActivity();
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);
    // Set Default values from XML attribute
    PreferenceManager.setDefaultValues(mActivity, R.xml.preferences, false);
    // Set Summary
    initSummary(getPreferenceScreen());
    // Clear History
    Preference clearHistory = getPreferenceScreen().findPreference("clear_history");
    clearHistory.setOnPreferenceClickListener(this);
    // Clear Follow / Clear All Route Data
    Preference clearFollow = getPreferenceScreen().findPreference("clear_follow");
    clearFollow.setOnPreferenceClickListener(this);
    // Permission - Location
    locationPermission = (SwitchPreferenceCompat) getPreferenceScreen().findPreference("location_permission");
    if (locationPermission != null) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            locationPermission.setEnabled(false);
            locationPermission.setChecked(true);
        } else {
            locationPermission.setOnPreferenceClickListener(this);
            Boolean granted = ContextCompat.checkSelfPermission(getActivity(),
                    Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
            locationPermission.setChecked(granted);
        }
    }
    // App Name
    Preference appName = getPreferenceScreen().findPreference("app_name");
    appName.setTitle(getString(R.string.title_app_name, getString(R.string.app_name)));
    // App Version
    Preference appVersion = getPreferenceScreen().findPreference("app_version");
    final int versionCode = BuildConfig.VERSION_CODE;
    final String versionName = BuildConfig.VERSION_NAME;
    appVersion.setSummary(versionName);
    if (BuildConfig.DEBUG) {
        appVersion.setSummary(versionName + "(" + versionCode +")");
    }
    // Developer
    Preference developer = getPreferenceScreen().findPreference("developer");
    developer.setSummary(getString(R.string.summary_developer) + " (" + getString(R.string.url_developer) + ")");
    //
    Preference shareApp = getPreferenceScreen().findPreference("share_app");
    shareApp.setOnPreferenceClickListener(this);
    // hide ad
    SwitchPreferenceCompat hideAd = (SwitchPreferenceCompat) getPreferenceScreen().findPreference(C.PREF.AD_HIDE);
    if (hideAd != null) {
        hideAd.setVisible(false);
        hideAd.setOnPreferenceClickListener(preference -> {
            SwitchPreferenceCompat switchPref = (SwitchPreferenceCompat) preference;
            if (switchPref.isChecked()) {
                final Snackbar snackbar = Snackbar.make(mActivity.findViewById(android.R.id.content),
                        R.string.message_hide_ad, Snackbar.LENGTH_LONG);
                snackbar.show();
            }
            return true;
        });
    }
    //
    Preference checkAppUpdate = getPreferenceScreen().findPreference("check_app_update");
    checkAppUpdate.setOnPreferenceClickListener(this);

    // Set up a listener whenever a key changes
    PreferenceManager.getDefaultSharedPreferences(mActivity)
            .registerOnSharedPreferenceChangeListener(this);
}
 
开发者ID:alvinhkh,项目名称:buseta,代码行数:69,代码来源:SettingActivity.java

示例7: onAdPreferenceCreate

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void onAdPreferenceCreate() {
    SwitchPreferenceCompat switchPreferenceCompat = (SwitchPreferenceCompat) findPreference(getString(R.string.preference_key_disable_ad));
    switchPreferenceCompat.setIcon(getIcon(R.drawable.ic_settings_24dp));
    switchPreferenceCompat.setEnabled(false);
}
 
开发者ID:siarhei-luskanau,项目名称:siarhei.luskanau.gps.tracker.free,代码行数:6,代码来源:GeneralSettingsFragment.java


注:本文中的android.support.v7.preference.SwitchPreferenceCompat.setEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。