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


Java TwoStatePreference.setOnPreferenceChangeListener方法代码示例

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


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

示例1: initVibrateWhenRinging

import android.preference.TwoStatePreference; //导入方法依赖的package包/类
private void initVibrateWhenRinging(PreferenceCategory root) {
    mVibrateWhenRinging = (TwoStatePreference) root.findPreference(KEY_VIBRATE_WHEN_RINGING);
    if (mVibrateWhenRinging == null) {
        Log.i(TAG, "Preference not found: " + KEY_VIBRATE_WHEN_RINGING);
        return;
    }
    if (!mVoiceCapable || !Utils.isUserOwner()) {
        root.removePreference(mVibrateWhenRinging);
        mVibrateWhenRinging = null;
        return;
    }
    mVibrateWhenRinging.setPersistent(false);
    updateVibrateWhenRinging();
    mVibrateWhenRinging.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final boolean val = (Boolean) newValue;
            return Settings.System.putInt(getContentResolver(),
                    Settings.System.VIBRATE_WHEN_RINGING,
                    val ? 1 : 0);
        }
    });
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:24,代码来源:SoundSettings.java

示例2: checkTouchExplorationSupportInner

import android.preference.TwoStatePreference; //导入方法依赖的package包/类
/**
 * Touch exploration preference management code
 *
 * @param category The touch exploration category.
 */
private void checkTouchExplorationSupportInner(PreferenceGroup category) {
    final TwoStatePreference prefTouchExploration =
            (TwoStatePreference) findPreferenceByResId(
                    R.string.pref_explore_by_touch_reflect_key);
    if (prefTouchExploration == null) {
        return;
    }

    // Remove single-tap preference if it's not supported on this device.
    final TwoStatePreference prefSingleTap = (TwoStatePreference) findPreferenceByResId(
            R.string.pref_single_tap_key);
    if ((prefSingleTap != null)
            && (Build.VERSION.SDK_INT <
            ProcessorFocusAndSingleTap.MIN_API_LEVEL_SINGLE_TAP)) {
        category.removePreference(prefSingleTap);
    }

    // Ensure that changes to the reflected preference's checked state never
    // trigger content observers.
    prefTouchExploration.setPersistent(false);

    // Synchronize the reflected state.
    updateTouchExplorationState();

    // Set up listeners that will keep the state synchronized.
    prefTouchExploration.setOnPreferenceChangeListener(mTouchExplorationChangeListener);

    // Hook in the external PreferenceActivity for gesture management
    final Preference shortcutsScreen = findPreferenceByResId(
            R.string.pref_category_manage_gestures_key);

    Activity activity = getActivity();
    if (activity != null) {
        final Intent shortcutsIntent = new Intent(
                activity, TalkBackShortcutPreferencesActivity.class);
        shortcutsScreen.setIntent(shortcutsIntent);
    }
}
 
开发者ID:google,项目名称:talkback,代码行数:44,代码来源:TalkBackPreferencesActivity.java

示例3: updateInfoPref

import android.preference.TwoStatePreference; //导入方法依赖的package包/类
private void updateInfoPref(PreferenceCategory category, int index, int helpId, boolean isOn) {
  TwoStatePreference pref = (TwoStatePreference) category.getPreference(index);
  pref.setChecked(isOn);
  pref.setOnPreferenceChangeListener(this);
  pref.setIntent(getHelpIntent(helpId));
}
 
开发者ID:sunnygoyal,项目名称:PowerToggles,代码行数:7,代码来源:InfoFrag.java

示例4: onCreate

import android.preference.TwoStatePreference; //导入方法依赖的package包/类
/**
 * Loads the preferences from the XML preference definition and defines an
 * onPreferenceChangeListener
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Activity activity = getActivity();
    if (activity == null) {
        return;
    }

    // Set preferences to use device-protected storage.
    if (BuildCompat.isAtLeastN()) {
        getPreferenceManager().setStorageDeviceProtected();
    }

    mPrefs = SharedPreferencesUtils.getSharedPreferences(activity);
    addPreferencesFromResource(R.xml.preferences);

    final TwoStatePreference prefTreeDebug = (TwoStatePreference) findPreferenceByResId(
            R.string.pref_tree_debug_reflect_key);
    prefTreeDebug.setOnPreferenceChangeListener(mTreeDebugChangeListener);

    fixListSummaries(getPreferenceScreen());

    assignTtsSettingsIntent();
    assignTutorialIntent();
    assignLabelManagerIntent();
    assignKeyboardShortcutIntent();
    assignDumpA11yEventIntent();

    checkTelevision();
    checkTouchExplorationSupport();
    checkWebScriptsSupport();
    checkTelephonySupport();
    checkVibrationSupport();
    checkProximitySupport();
    checkAccelerometerSupport();
    checkInstalledBacks();
    showTalkBackVersion();
    updateTalkBackShortcutStatus();

    // We should never try to open the play store in WebActivity.
    assignPlayStoreIntentToPreference(R.string.pref_play_store_key,
            "https://play.google.com/store/apps/details" +
                    "?id=com.google.android.marvin.talkback");

    assignWebIntentToPreference(R.string.pref_policy_key,
            "http://www.google.com/policies/privacy/");
    assignWebIntentToPreference(R.string.pref_show_tos_key,
            "http://www.google.com/mobile/toscountry");

    assignFeedbackIntentToPreference(R.string.pref_help_and_feedback_key);

    if (TalkBackService.isInArc()) {
        hidePreferencesForArc();
    }
}
 
开发者ID:google,项目名称:talkback,代码行数:61,代码来源:TalkBackPreferencesActivity.java

示例5: updateDimingPreferenceStatus

import android.preference.TwoStatePreference; //导入方法依赖的package包/类
private void updateDimingPreferenceStatus() {
    final TwoStatePreference dimPreference = (TwoStatePreference) findPreferenceByResId(
            R.string.pref_dim_when_talkback_enabled_key);
    final TwoStatePreference dimShortcutPreference =
            (TwoStatePreference) findPreferenceByResId(
                    R.string.pref_dim_volume_three_clicks_key);
    if (dimPreference == null || dimShortcutPreference == null) {
        return;
    }
    final TalkBackService talkBack = TalkBackService.getInstance();
    if (!DimScreenControllerApp.IS_SUPPORTED_PLATFORM) {
        final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
                R.string.pref_category_miscellaneous_key);
        if (category == null) {
            return;
        }
        category.removePreference(dimPreference);
        category.removePreference(dimShortcutPreference);
        return;
    }

    // Make sure that we have the latest value of the dim preference before continuing.
    boolean dimEnabled = SharedPreferencesUtils.getBooleanPref(mPrefs, getResources(),
            R.string.pref_dim_when_talkback_enabled_key,
            R.bool.pref_dim_when_talkback_enabled_default);
    dimPreference.setChecked(dimEnabled);

    dimPreference.setEnabled(
            TalkBackService.isServiceActive() || dimPreference.isChecked());
    dimPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (newValue == null || !(newValue instanceof Boolean)) {
                return true;
            }

            boolean dimPreferenceOn = (Boolean) newValue;

            if (dimPreferenceOn) {
                if (talkBack != null) {
                    // A TalkBack instance should be available if you can check the box,
                    // but let's err on the side of safety here.
                    talkBack.getDimScreenController().showDimScreenDialog();
                }
                return false; // The DimScreenController will take care of any pref changes.
            } else {
                if (talkBack != null) {
                    // We allow turning off screen dimming when TalkBack is off, so we
                    // definitely do need to check if a TalkBack instance is available.
                    talkBack.getDimScreenController().disableDimming();
                }
                if (!TalkBackService.isServiceActive()) {
                    dimPreference.setEnabled(false);
                }
                return true; // Let the preferences system turn the preference off.
            }
        }
    });
}
 
开发者ID:google,项目名称:talkback,代码行数:60,代码来源:TalkBackPreferencesActivity.java


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