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


Java CheckBoxPreference.setEnabled方法代码示例

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


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

示例1: setupGaplessControlSettingsV14

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void setupGaplessControlSettingsV14() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        PreferenceCategory playbackControlSettings =
                (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_PLAYBACK_CONTROL_SETTINGS);
        CheckBoxPreference gaplessPlaybackEnabled =
                (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_GAPLESS_PLAYBACK);

        if (gaplessPlaybackEnabled != null) {
            gaplessPlaybackEnabled.setChecked(false);
            gaplessPlaybackEnabled.setEnabled(false);

            if (playbackControlSettings != null) {
                playbackControlSettings.removePreference(gaplessPlaybackEnabled);
            }
        }
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:18,代码来源:SettingsFragment.java

示例2: disableLastCheckedPref

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void disableLastCheckedPref() {
  Collection<CheckBoxPreference> checked = new ArrayList<CheckBoxPreference>(3);
  if (decode1D.isChecked()) {
    checked.add(decode1D);
  }
  if (decodeQR.isChecked()) {
    checked.add(decodeQR);
  }
  if (decodeDataMatrix.isChecked()) {
    checked.add(decodeDataMatrix);
  }
  boolean disable = checked.size() < 2;
  CheckBoxPreference[] checkBoxPreferences = {decode1D, decodeQR, decodeDataMatrix};
  for (CheckBoxPreference pref : checkBoxPreferences) {
    pref.setEnabled(!(disable && checked.contains(pref)));
  }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:18,代码来源:PreferencesFragment.java

示例3: disableLastCheckedPref

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void disableLastCheckedPref()
{
	Collection<CheckBoxPreference> checked = new ArrayList<CheckBoxPreference>(3);
	if (decode1D.isChecked())
	{
		checked.add(decode1D);
	}
	if (decodeQR.isChecked())
	{
		checked.add(decodeQR);
	}
	if (decodeDataMatrix.isChecked())
	{
		checked.add(decodeDataMatrix);
	}
	boolean disable = checked.size() < 2;
	for (CheckBoxPreference pref : new CheckBoxPreference[]
	{ decode1D, decodeQR, decodeDataMatrix })
	{
		pref.setEnabled(!(disable && checked.contains(pref)));
	}
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:23,代码来源:PreferencesActivity.java

示例4: initNetworkSettings

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void initNetworkSettings() {
	((CheckBoxPreference) findPreference(getString(R.string.pref_wifi_only_key))).setChecked(mPrefs.isWifiOnlyEnabled());

	// Disable UPnP if ICE si enabled, or disable ICE if UPnP is enabled
	CheckBoxPreference ice = (CheckBoxPreference) findPreference(getString(R.string.pref_ice_enable_key));
	CheckBoxPreference turn = (CheckBoxPreference) findPreference(getString(R.string.pref_turn_enable_key));
	ice.setChecked(mPrefs.isIceEnabled());
	turn.setEnabled(mPrefs.getStunServer() != null);
	turn.setChecked(mPrefs.isTurnEnabled());

	EditTextPreference turnUsername = (EditTextPreference) findPreference(getString(R.string.pref_turn_username_key));
	EditTextPreference turnPassword = (EditTextPreference) findPreference(getString(R.string.pref_turn_passwd_key));
	turnUsername.setEnabled(mPrefs.isTurnEnabled());
	turnUsername.setSummary(mPrefs.getTurnUsername());
	turnUsername.setText(mPrefs.getTurnUsername());
	turnPassword.setEnabled(mPrefs.isTurnEnabled());

	CheckBoxPreference randomPort = (CheckBoxPreference) findPreference(getString(R.string.pref_transport_use_random_ports_key));
	randomPort.setChecked(mPrefs.isUsingRandomPort());

	// Disable sip port choice if port is random
	EditTextPreference sipPort = (EditTextPreference) findPreference(getString(R.string.pref_sip_port_key));
	sipPort.setEnabled(!randomPort.isChecked());
	sipPort.setSummary(mPrefs.getSipPort());
	sipPort.setText(mPrefs.getSipPort());

	EditTextPreference stun = (EditTextPreference) findPreference(getString(R.string.pref_stun_server_key));
	stun.setSummary(mPrefs.getStunServer());
	stun.setText(mPrefs.getStunServer());

	((CheckBoxPreference) findPreference(getString(R.string.pref_push_notification_key))).setChecked(mPrefs.isPushNotificationEnabled());
	((CheckBoxPreference) findPreference(getString(R.string.pref_ipv6_key))).setChecked(mPrefs.isUsingIpv6());
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:34,代码来源:SettingsFragment.java

示例5: updateDataTypeState

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
/**
 * Update the data type switch state.
 *
 * If sync is on, load the prefs from native. Otherwise, all data types are disabled and
 * checked. Note that the Password data type will be shown as disabled and unchecked between
 * sync being turned on and the backend initialization completing.
 */
private void updateDataTypeState() {
    boolean isSyncEnabled = mSyncSwitchPreference.isChecked();
    boolean syncEverything = mSyncEverything.isChecked();
    boolean passwordSyncConfigurable = mProfileSyncService.isBackendInitialized()
            && mProfileSyncService.isCryptographerReady();
    Set<Integer> syncTypes = mProfileSyncService.getPreferredDataTypes();
    boolean syncAutofill = syncTypes.contains(ModelType.AUTOFILL);
    for (CheckBoxPreference pref : mAllTypes) {
        boolean canSyncType = true;
        if (pref == mSyncPasswords) canSyncType = passwordSyncConfigurable;
        if (pref == mPaymentsIntegration) {
            canSyncType = syncAutofill || syncEverything;
        }

        if (!isSyncEnabled) {
            pref.setChecked(true);
        } else if (syncEverything) {
            pref.setChecked(canSyncType);
        }

        pref.setEnabled(isSyncEnabled && !syncEverything && canSyncType);
    }
    if (isSyncEnabled && !syncEverything) {
        mSyncAutofill.setChecked(syncAutofill);
        mSyncBookmarks.setChecked(syncTypes.contains(ModelType.BOOKMARKS));
        mSyncOmnibox.setChecked(syncTypes.contains(ModelType.TYPED_URLS));
        mSyncPasswords.setChecked(passwordSyncConfigurable
                && syncTypes.contains(ModelType.PASSWORDS));
        mSyncRecentTabs.setChecked(syncTypes.contains(ModelType.PROXY_TABS));
        // TODO(zea): Switch this to PREFERENCE once that datatype is
        // supported on Android.
        mSyncSettings.setChecked(syncTypes.contains(ModelType.PRIORITY_PREFERENCES));
        mPaymentsIntegration.setChecked(
                syncAutofill && PersonalDataManager.isPaymentsIntegrationEnabled());
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:44,代码来源:SyncCustomizationFragment.java

示例6: onCreate

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

    mPrefs = SharedPreferencesUtils.getSharedPreferences(getPreferenceManager(), "ledcontrol");
    addPreferencesFromResource(R.xml.led_control_active_screen_settings);

    mPrefPocketMode = (CheckBoxPreference) findPreference(
            LedSettings.PREF_KEY_ACTIVE_SCREEN_POCKET_MODE);

    if (LedSettings.isProximityWakeUpEnabled(getActivity())) {
        mPrefPocketMode.setSummary(R.string.pref_unc_as_pocket_mode_summary_overriden);
        mPrefPocketMode.setEnabled(false);
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:16,代码来源:ActiveScreenActivity.java

示例7: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.setting);
    mSharedPreferenceUtil = SharedPreferenceUtil.getInstance();

    mChangeIcons = findPreference(SharedPreferenceUtil.CHANGE_ICONS);
    mChangeUpdate = findPreference(SharedPreferenceUtil.AUTO_UPDATE);
    mClearCache = findPreference(SharedPreferenceUtil.CLEAR_CACHE);

    mAnimationOnOff = (CheckBoxPreference) findPreference(SharedPreferenceUtil.ANIM_START);
    mNotificationType = (CheckBoxPreference) findPreference(SharedPreferenceUtil.NOTIFICATION_MODEL);
    mWatcherSwitch = (CheckBoxPreference) findPreference(SharedPreferenceUtil.WATCHER);

    mNotificationType.setChecked(
        SharedPreferenceUtil.getInstance().getNotificationModel() == Notification.FLAG_ONGOING_EVENT);
    mAnimationOnOff.setChecked(SharedPreferenceUtil.getInstance().getMainAnim());
    mWatcherSwitch.setChecked(SharedPreferenceUtil.getInstance().getWatcherSwitch());
    if (Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(getContext())) {
        mWatcherSwitch.setEnabled(false);
    }
    mChangeIcons.setSummary(getResources().getStringArray(R.array.icons)[mSharedPreferenceUtil.getIconType()]);

    mChangeUpdate.setSummary(
        mSharedPreferenceUtil.getAutoUpdate() == 0 ? "禁止刷新" : "每" + mSharedPreferenceUtil.getAutoUpdate() + "小时更新");
    mClearCache.setSummary(FileSizeUtil.getAutoFileOrFilesSize(C.NET_CACHE));

    mChangeIcons.setOnPreferenceClickListener(this);
    mChangeUpdate.setOnPreferenceClickListener(this);
    mClearCache.setOnPreferenceClickListener(this);
    mNotificationType.setOnPreferenceChangeListener(this);
    mAnimationOnOff.setOnPreferenceChangeListener(this);
    mWatcherSwitch.setOnPreferenceChangeListener(this);
}
 
开发者ID:xcc3641,项目名称:SeeWeather,代码行数:35,代码来源:SettingFragment.java

示例8: updateDataTypeState

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
/**
 * Update the data type switch state.
 *
 * If sync is on, load the prefs from native. Otherwise, all data types are disabled and
 * checked. Note that the Password data type will be shown as disabled and unchecked between
 * sync being turned on and the backend initialization completing.
 */
private void updateDataTypeState() {
    boolean isSyncEnabled = mSyncSwitchPreference.isChecked();
    boolean syncEverything = mSyncEverything.isChecked();
    boolean passwordSyncConfigurable = mProfileSyncService.isSyncInitialized()
            && mProfileSyncService.isCryptographerReady();
    for (CheckBoxPreference pref : mAllTypes) {
        boolean canSyncType = pref != mSyncPasswords || passwordSyncConfigurable;

        if (!isSyncEnabled) {
            pref.setChecked(true);
        } else if (syncEverything) {
            pref.setChecked(canSyncType);
        }

        pref.setEnabled(isSyncEnabled && !syncEverything && canSyncType);
    }
    if (isSyncEnabled && !syncEverything) {
        Set<Integer> syncTypes = mProfileSyncService.getPreferredDataTypes();
        mSyncAutofill.setChecked(syncTypes.contains(ModelType.AUTOFILL));
        mSyncBookmarks.setChecked(syncTypes.contains(ModelType.BOOKMARKS));
        mSyncOmnibox.setChecked(syncTypes.contains(ModelType.TYPED_URLS));
        mSyncPasswords.setChecked(passwordSyncConfigurable
                && syncTypes.contains(ModelType.PASSWORDS));
        mSyncRecentTabs.setChecked(syncTypes.contains(ModelType.PROXY_TABS));
        // TODO(zea): Switch this to PREFERENCE once that datatype is
        // supported on Android.
        mSyncSettings.setChecked(syncTypes.contains(ModelType.PRIORITY_PREFERENCES));
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:37,代码来源:SyncCustomizationFragment.java

示例9: initPrivilegedInstallerPreference

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
/**
 * Initializes SystemInstaller preference, which can only be enabled when F-Droid is installed as a system-app
 */
private void initPrivilegedInstallerPreference() {
    final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER);

    // This code will be run each time the activity is resumed, and so we may have already removed
    // this preference.
    if (pref == null) {
        return;
    }

    Preferences p = Preferences.get();
    boolean enabled = p.isPrivilegedInstallerEnabled();
    boolean installed = PrivilegedInstaller.isExtensionInstalledCorrectly(getActivity())
            == PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES;

    // On later versions of Android the privileged installer needs to be installed
    // via flashing an update.zip or building into a rom. As such, if it isn't installed
    // by the time the user boots, opens F-Droid, and views this settings page, then there
    // is no benefit showing it to them (it will only be disabled and we can't offer any
    // way to easily install from here.
    if (Build.VERSION.SDK_INT > 19 && !installed) {
        PreferenceCategory other = (PreferenceCategory) findPreference("pref_category_other");
        if (pref != null) {
            other.removePreference(pref);
        }
    } else {
        pref.setEnabled(installed);
        pref.setDefaultValue(installed);
        pref.setChecked(enabled && installed);

        pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
                if (pref.isChecked()) {
                    editor.remove(Preferences.PREF_PRIVILEGED_INSTALLER);
                } else {
                    editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, false);
                }
                editor.apply();
                return true;
            }
        });
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:48,代码来源:PreferencesFragment.java

示例10: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.app_selector_screen);

    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("apps");
    sharedPreferencesPackageNames = getActivity().getSharedPreferences("myPackageNames", MODE_PRIVATE);


    Set<String> all = sharedPreferencesPackageNames.getStringSet(getString(R.string.shared_pref_key_package_name_all), null);
    Set<String> selected = sharedPreferencesPackageNames.getStringSet(getString(R.string.shared_pref_key_package_name_selected), null);

    CheckBoxPreference a = new CheckBoxPreference(getContext());
    a.setKey(getContext().getString(R.string.string_all_key));
    a.setTitle(R.string.string_all_apps);
    if (selected != null){
        if (selected.contains(getContext().getString(R.string.string_all_key))){
            a.setChecked(true);
        }
    }
    a.setOnPreferenceClickListener(this);
    preferenceCategory.addPreference(a);

    if (all != null){
        for(String s: all){
            CheckBoxPreference p = new CheckBoxPreference(getContext());
            p.setKey(s);
            p.setSummary(s);
            p.setEnabled(!a.isChecked());

            if (selected != null){
                if (selected.contains(s)){
                    p.setChecked(true);
                }
            }

            p.setTitle(Utils.getAppName(getContext(), s));
            p.setOnPreferenceClickListener(this);
            preferenceCategory.addPreference(p);
        }
    }

    String title = preferenceCategory.getTitle().toString();

    // all devices with android 8.1 and Pixel 2 (XL) on 8.0 and onward are using "using battery" instead of "running in the background"
    if (Build.VERSION.SDK_INT >= 27 || Build.MODEL.equals("Pixel 2") || Build.MODEL.equals("Pixel 2 XL")){
        title = title.replace("%s", "\"" + getString(R.string.string_app_name_replace_using_battery) + "\"");
    }else{
        title = title.replace("%s", "\"" + getString(R.string.string_app_name_replace_running_in_the_background) + "\"");
    }

    preferenceCategory.setTitle(title);

}
 
开发者ID:iboalali,项目名称:sysnotifsnooze,代码行数:55,代码来源:AppSelectorActivity.java

示例11: initPrefs

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void initPrefs() {
    Preference clearcache = findPreference(SETTINGS_CLEARCACHE);
    Preference clearhistory = findPreference(SETTINGS_CLEARHISTORY);
    Preference clearcookies = findPreference(SETTINGS_CLEARCOOKIES);
    Preference clearwebstorage = findPreference(SETTINGS_CLEARWEBSTORAGE);

    CheckBoxPreference cblocation = (CheckBoxPreference) findPreference(SETTINGS_LOCATION);
    CheckBoxPreference cb3cookies = (CheckBoxPreference) findPreference(SETTINGS_THIRDPCOOKIES);
    CheckBoxPreference cbsavepasswords = (CheckBoxPreference) findPreference(SETTINGS_SAVEPASSWORD);
    CheckBoxPreference cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT);
    CheckBoxPreference cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT);
    CheckBoxPreference cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT);
    CheckBoxPreference cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT);
    CheckBoxPreference cbDoNotTrack = (CheckBoxPreference) findPreference(SETTINGS_DONOTTRACK);
    CheckBoxPreference cbIdentifyingHeaders = (CheckBoxPreference) findPreference(SETTINGS_IDENTIFYINGHEADERS);

    clearcache.setOnPreferenceClickListener(this);
    clearhistory.setOnPreferenceClickListener(this);
    clearcookies.setOnPreferenceClickListener(this);
    clearwebstorage.setOnPreferenceClickListener(this);

    cblocation.setOnPreferenceChangeListener(this);
    cb3cookies.setOnPreferenceChangeListener(this);
    cbsavepasswords.setOnPreferenceChangeListener(this);
    cbcacheexit.setOnPreferenceChangeListener(this);
    cbhistoryexit.setOnPreferenceChangeListener(this);
    cbcookiesexit.setOnPreferenceChangeListener(this);
    cbwebstorageexit.setOnPreferenceChangeListener(this);
    cbDoNotTrack.setOnPreferenceChangeListener(this);
    cbIdentifyingHeaders.setOnPreferenceChangeListener(this);

    cblocation.setChecked(mPreferenceManager.getLocationEnabled());
    cbsavepasswords.setChecked(mPreferenceManager.getSavePasswordsEnabled());
    cbcacheexit.setChecked(mPreferenceManager.getClearCacheExit());
    cbhistoryexit.setChecked(mPreferenceManager.getClearHistoryExitEnabled());
    cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled());
    cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled());
    cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled());
    cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled() && Utils.doesSupportHeaders());
    cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled() && Utils.doesSupportHeaders());

    cbDoNotTrack.setEnabled(Utils.doesSupportHeaders());
    cbIdentifyingHeaders.setEnabled(Utils.doesSupportHeaders());

    String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE;
    cbIdentifyingHeaders.setSummary(identifyingHeadersSummary);

    cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);

}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:51,代码来源:PrivacySettingsFragment.java

示例12: setUseRestBasePreference

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void setUseRestBasePreference(boolean manualMode) {
    RbSwitch.INSTANCE.update();
    CheckBoxPreference useRestBasePref = getUseRestBasePreference();
    useRestBasePref.setEnabled(manualMode);
    useRestBasePref.setChecked(RbSwitch.INSTANCE.isRestBaseEnabled());
}
 
开发者ID:gnosygnu,项目名称:xowa_android,代码行数:7,代码来源:DeveloperSettingsPreferenceLoader.java

示例13: initBasicPart

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void initBasicPart(SharedPreferences sharedPreferences) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        CheckBoxPreference backgroundFree = (CheckBoxPreference) findPreference(getString(R.string.key_background_free));
        backgroundFree.setChecked(true);
        backgroundFree.setEnabled(false);
    }

    Preference uiStyle = findPreference(getString(R.string.key_ui_style));
    uiStyle.setSummary(
            ValueUtils.getUIStyle(
                    getActivity(),
                    PreferenceManager.getDefaultSharedPreferences(getActivity())
                            .getString(
                                    getString(R.string.key_ui_style),
                                    "material")));
    uiStyle.setOnPreferenceChangeListener(this);

    Preference cardOrder = findPreference(getString(R.string.key_card_order));
    cardOrder.setSummary(
            ValueUtils.getCardOrder(
                    getActivity(),
                    PreferenceManager.getDefaultSharedPreferences(getActivity())
                            .getString(
                                    getString(R.string.key_card_order),
                                    "daily_first")));
    cardOrder.setOnPreferenceChangeListener(this);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        findPreference(getString(R.string.key_navigationBar_color)).setEnabled(false);
    } else {
        findPreference(getString(R.string.key_navigationBar_color)).setEnabled(true);
    }

    Preference fahrenheit = findPreference(getString(R.string.key_fahrenheit));
    fahrenheit.setOnPreferenceChangeListener(this);

    Preference imperial = findPreference(getString(R.string.key_imperial));
    imperial.setOnPreferenceChangeListener(this);

    Preference refreshRate = findPreference(getString(R.string.key_refresh_rate));
    refreshRate.setSummary(
            PreferenceManager.getDefaultSharedPreferences(getActivity())
                    .getString(
                            getString(R.string.key_refresh_rate),
                            "1:30"));
    refreshRate.setOnPreferenceChangeListener(this);

    Preference language = findPreference(getString(R.string.key_language));
    language.setSummary(
            ValueUtils.getLanguage(
                    getActivity(),
                    sharedPreferences.getString(getString(R.string.key_language), "follow_system")));
    language.setOnPreferenceChangeListener(this);
}
 
开发者ID:WangDaYeeeeee,项目名称:GeometricWeather,代码行数:55,代码来源:SettingsFragment.java

示例14: initNotificationPart

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void initNotificationPart(SharedPreferences sharedPreferences) {
    // widget icon style.
    ListPreference notificationIconStyle = (ListPreference) findPreference(getString(R.string.key_notification_icon_style));
    notificationIconStyle.setSummary(
            ValueUtils.getIconStyle(
                    getActivity(),
                    sharedPreferences.getString(getString(R.string.key_notification_icon_style), "material")));
    notificationIconStyle.setOnPreferenceChangeListener(this);

    // notification temp icon.
    CheckBoxPreference notificationTempIcon = (CheckBoxPreference) findPreference(getString(R.string.key_notification_temp_icon));

    // notification text color.
    ListPreference notificationTextColor = (ListPreference) findPreference(getString(R.string.key_notification_text_color));
    notificationTextColor.setSummary(
            ValueUtils.getNotificationTextColor(
                    getActivity(),
                    sharedPreferences.getString(getString(R.string.key_notification_text_color), "grey")));
    notificationTextColor.setOnPreferenceChangeListener(this);

    // notification background.
    CheckBoxPreference notificationBackground = (CheckBoxPreference) findPreference(getString(R.string.key_notification_background));

    // notification can be cleared.
    CheckBoxPreference notificationClearFlag = (CheckBoxPreference) findPreference(getString(R.string.key_notification_can_be_cleared));

    // notification hide icon.
    CheckBoxPreference notificationIconBehavior = (CheckBoxPreference) findPreference(getString(R.string.key_notification_hide_icon));

    // notification hide in lock screen.
    CheckBoxPreference notificationHideBehavior = (CheckBoxPreference) findPreference(getString(R.string.key_notification_hide_in_lockScreen));

    // notification hide big view.
    CheckBoxPreference notificationHideBigView = (CheckBoxPreference) findPreference(getString(R.string.key_notification_hide_big_view));

    if(sharedPreferences.getBoolean(getString(R.string.key_notification), false)) {
        // open notification.
        notificationIconStyle.setEnabled(true);
        notificationTempIcon.setEnabled(true);
        notificationTextColor.setEnabled(true);
        notificationBackground.setEnabled(true);
        notificationClearFlag.setEnabled(true);
        notificationIconBehavior.setEnabled(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            notificationHideBehavior.setEnabled(true);
        } else {
            notificationHideBehavior.setEnabled(false);
        }
        notificationHideBigView.setEnabled(true);
    } else {
        // close notification.
        notificationIconStyle.setEnabled(false);
        notificationTempIcon.setEnabled(false);
        notificationTextColor.setEnabled(false);
        notificationBackground.setEnabled(false);
        notificationClearFlag.setEnabled(false);
        notificationIconBehavior.setEnabled(false);
        notificationHideBehavior.setEnabled(false);
        notificationHideBigView.setEnabled(false);
    }
}
 
开发者ID:WangDaYeeeeee,项目名称:GeometricWeather,代码行数:62,代码来源:SettingsFragment.java

示例15: setSortAscendingEnabled

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void setSortAscendingEnabled(boolean enabled) {
	CheckBoxPreference sortAscendingPreference = (CheckBoxPreference) findPreference(KEY_SORTASCENDING);
	sortAscendingPreference.setEnabled(enabled);
	if (!enabled) sortAscendingPreference.setChecked(true);
}
 
开发者ID:yongbeam,项目名称:DiaryMemo,代码行数:6,代码来源:Preferences.java


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