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


Java SwitchPreferenceCompat.setSummary方法代码示例

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


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

示例1: 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

示例2: init

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void init() {
        addPreferencesFromResource(R.xml.settings);

        if (Utils.DONATED) {
            getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
        }

        SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
        if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
            getPreferenceScreen().removePreference(forceEnglish);
        } else {
            forceEnglish.setOnPreferenceChangeListener(this);
        }
/*
        if (Utils.hideStartActivity()) {
            ((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
                    .removePreference(findPreference(KEY_MATERIAL_ICON));
        } else {
            findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
        }
*/
        findPreference(KEY_RESET_DATA).setOnPreferenceClickListener(this);
        findPreference(KEY_UPDATE_NOTIFICATION).setOnPreferenceChangeListener(this);
        findPreference(KEY_CHECK_UPDATE).setOnPreferenceClickListener(this);
        findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
        findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
        findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
        findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
        findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
        findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
        findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);

        if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
            findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
        } else {
            ((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
                    findPreference(KEY_LAST_KMSG));
        }

        findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
        findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
        findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
                || !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
            ((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
                    findPreference(KEY_FINGERPRINT));
        } else {
            mFingerprint = findPreference(KEY_FINGERPRINT);
            mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
        }

        PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
        for (NavigationActivity.NavigationFragment navigationFragment : NavigationActivity.sFragments) {
            Fragment fragment = navigationFragment.mFragment;
            int id = navigationFragment.mId;

            if (fragment != null && fragment.getClass() != SettingsFragment.class) {
                SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
                        new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
                switchPreference.setSummary(getString(id));
                switchPreference.setKey(fragment.getClass().getSimpleName() + "_enabled");
                switchPreference.setChecked(Prefs.getBoolean(fragment.getClass().getSimpleName()
                        + "_enabled", true, getActivity()));
                switchPreference.setOnPreferenceChangeListener(this);
                switchPreference.setPersistent(false);
                sectionsCategory.addPreference(switchPreference);
            }
        }
    }
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:71,代码来源:SettingsFragment.java

示例3: init

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void init() {
    addPreferencesFromResource(R.xml.settings);

    if (Utils.DONATED) {
        getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
    }

    SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
    if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
        getPreferenceScreen().removePreference(forceEnglish);
    } else {
        forceEnglish.setOnPreferenceChangeListener(this);
    }

    if (Utils.hideStartActivity()) {
        ((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
                .removePreference(findPreference(KEY_MATERIAL_ICON));
    } else {
        findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
    }

    findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
    findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
    findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
    findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
    findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
    findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
    findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);

    if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
        findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
    } else {
        ((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
                findPreference(KEY_LAST_KMSG));
    }

    findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
    findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
    findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            || !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
        ((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
                findPreference(KEY_FINGERPRINT));
    } else {
        mFingerprint = findPreference(KEY_FINGERPRINT);
        mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
    }

    PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
    for (NavigationActivity.NavigationFragment navigationFragment : NavigationActivity.sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        if (fragment != null && fragment.getClass() != SettingsFragment.class) {
            SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
                    new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
            switchPreference.setSummary(getString(id));
            switchPreference.setKey(fragment.getClass().getSimpleName() + "_enabled");
            switchPreference.setChecked(Prefs.getBoolean(fragment.getClass().getSimpleName()
                    + "_enabled", true, getActivity()));
            switchPreference.setOnPreferenceChangeListener(this);
            switchPreference.setPersistent(false);
            sectionsCategory.addPreference(switchPreference);
        }
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:68,代码来源:SettingsFragment.java

示例4: onCreate

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

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

    String keyAutostart = getString(R.string.pref_key_autostart);
    SwitchPreferenceCompat autostart = (SwitchPreferenceCompat) findPreference(keyAutostart);
    autostart.setChecked(pref.getBoolean(keyAutostart, SettingsManager.Default.autostart));
    bindOnPreferenceChangeListener(autostart);

    String keyKeepAlive = getString(R.string.pref_key_keep_alive);
    SwitchPreferenceCompat keepAlive = (SwitchPreferenceCompat) findPreference(keyKeepAlive);
    keepAlive.setChecked(pref.getBoolean(keyKeepAlive, SettingsManager.Default.keepAlive));
    bindOnPreferenceChangeListener(keepAlive);

    String keyShutdownComplete = getString(R.string.pref_key_shutdown_downloads_complete);
    SwitchPreferenceCompat shutdownComplete = (SwitchPreferenceCompat) findPreference(keyShutdownComplete);
    shutdownComplete.setChecked(pref.getBoolean(keyShutdownComplete, SettingsManager.Default.shutdownDownloadsComplete));
    bindOnPreferenceChangeListener(shutdownComplete);

    String keyCpuSleep = getString(R.string.pref_key_cpu_do_not_sleep);
    SwitchPreferenceCompat cpuSleep = (SwitchPreferenceCompat) findPreference(keyCpuSleep);
    cpuSleep.setChecked(pref.getBoolean(keyCpuSleep, SettingsManager.Default.cpuDoNotSleep));
    bindOnPreferenceChangeListener(cpuSleep);

    String keyOnlyCharging = getString(R.string.pref_key_download_and_upload_only_when_charging);
    SwitchPreferenceCompat onlyCharging = (SwitchPreferenceCompat) findPreference(keyOnlyCharging);
    onlyCharging.setChecked(pref.getBoolean(keyOnlyCharging, SettingsManager.Default.onlyCharging));
    bindOnPreferenceChangeListener(onlyCharging);

    String keyBatteryControl = getString(R.string.pref_key_battery_control);
    SwitchPreferenceCompat batteryControl = (SwitchPreferenceCompat) findPreference(keyBatteryControl);
    batteryControl.setSummary(String.format(getString(R.string.pref_battery_control_summary),
                              Utils.getDefaultBatteryLowLevel()));
    batteryControl.setChecked(pref.getBoolean(keyBatteryControl, SettingsManager.Default.batteryControl));
    bindOnPreferenceChangeListener(batteryControl);

    String keyCustomBatteryControl = getString(R.string.pref_key_custom_battery_control);
    SwitchPreferenceCompat customBatteryControl = (SwitchPreferenceCompat) findPreference(keyCustomBatteryControl);
    customBatteryControl.setSummary(String.format(getString(R.string.pref_custom_battery_control_summary),
            Utils.getDefaultBatteryLowLevel()));
    customBatteryControl.setChecked(pref.getBoolean(keyCustomBatteryControl, SettingsManager.Default.customBatteryControl));
    bindOnPreferenceChangeListener(customBatteryControl);

    String keyCustomBatteryControlValue = getString(R.string.pref_key_custom_battery_control_value);
    SeekBarPreference customBatteryControlValue = (SeekBarPreference) findPreference(keyCustomBatteryControlValue);
    customBatteryControlValue.setValue(pref.getInt(keyCustomBatteryControlValue, Utils.getDefaultBatteryLowLevel()));
    customBatteryControlValue.setMin(10);
    customBatteryControlValue.setMax(90);
    bindOnPreferenceChangeListener(customBatteryControlValue);

    String keyWifiOnly = getString(R.string.pref_key_wifi_only);
    SwitchPreferenceCompat wifiOnly = (SwitchPreferenceCompat) findPreference(keyWifiOnly);
    wifiOnly.setChecked(pref.getBoolean(keyWifiOnly, SettingsManager.Default.wifiOnly));
    bindOnPreferenceChangeListener(wifiOnly);
}
 
开发者ID:proninyaroslav,项目名称:libretorrent,代码行数:59,代码来源:BehaviorSettingsFragment.java

示例5: onCreatePreferences

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    addPreferencesFromResource(R.xml.settings);

    if (Utils.DONATED) {
        getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
    }

    SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
    if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
        getPreferenceScreen().removePreference(forceEnglish);
    } else {
        forceEnglish.setOnPreferenceChangeListener(this);
    }

    if (Utils.hideStartActivity()) {
        ((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
                .removePreference(findPreference(KEY_MATERIAL_ICON));
    } else {
        findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
    }

    findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
    findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
    findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
    findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
    findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
    findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
    findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);

    if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
        findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
    } else {
        ((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
                findPreference(KEY_LAST_KMSG));
    }

    findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
    findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
    findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            || !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
        ((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
                findPreference(KEY_FINGERPRINT));
    } else {
        mFingerprint = findPreference(KEY_FINGERPRINT);
        mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
    }

    NavigationActivity activity = (NavigationActivity) getActivity();
    PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
    for (NavigationActivity.NavigationFragment navigationFragment : activity.getFragments()) {
        Class<? extends Fragment> fragmentClass = navigationFragment.mFragmentClass;
        int id = navigationFragment.mId;

        if (fragmentClass != null && fragmentClass != SettingsFragment.class) {
            SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
                    new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
            switchPreference.setSummary(getString(id));
            switchPreference.setKey(fragmentClass.getSimpleName() + "_enabled");
            switchPreference.setChecked(Prefs.getBoolean(fragmentClass.getSimpleName()
                    + "_enabled", true, getActivity()));
            switchPreference.setOnPreferenceChangeListener(this);
            switchPreference.setPersistent(false);
            sectionsCategory.addPreference(switchPreference);
        }
    }
}
 
开发者ID:Grarak,项目名称:KernelAdiutor,代码行数:70,代码来源:SettingsFragment.java


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