android.preference.PreferenceScreen#setSummary ( )源码实例Demo

下面列出了android.preference.PreferenceScreen#setSummary ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: NewsPushMonitor   文件: SettingsFragment.java
private void addMonitorApp(String pkg) {
    if (TextUtils.isEmpty(pkg)) {
        return;
    }

    PreferenceManager manager = getPreferenceManager();
    try {
        PreferenceScreen screen = (PreferenceScreen) RefUtil.callDeclaredMethod(manager,
                "inflateFromResource",
                new Class[]{Context.class, int.class, PreferenceScreen.class},
                getActivity(), R.xml.prefs_monitor_apps, null);
        screen.setKey(pkg);
        screen.setTitle(pkg);
        screen.setSummary(getMonitorAppSummary(pkg, null));

        PreferenceGroup appConfigPref = (PreferenceGroup) screen.findPreference("monitor_app_config_pref");
        appConfigPref.setTitle(pkg);

        Preference titleViewIdPref = appConfigPref.findPreference("title_view_id_pref");
        titleViewIdPref.setKey(GlobalConfig.getSharedPrefKeyForTitleId(pkg));
        titleViewIdPref.getExtras().putString(KEY_PREF_EXTRA, pkg);
        titleViewIdPref.setOnPreferenceChangeListener(mOnPreferenceChangeListener);

        Preference contentViewIdPref = appConfigPref.findPreference("content_view_id_pref");
        contentViewIdPref.setKey(GlobalConfig.getSharedPrefKeyForContentId(pkg));
        contentViewIdPref.getExtras().putString(KEY_PREF_EXTRA, pkg);
        contentViewIdPref.setOnPreferenceChangeListener(mOnPreferenceChangeListener);

        PreferenceCategory container = (PreferenceCategory)
                getPreferenceManager().findPreference("monitor_apps_pref");
        container.addPreference(screen);
    } catch (Exception e) {
        LogWriter.e(TAG, "Add monitor ppp to preference error!", e);
    }
}
 
源代码2 项目: delion   文件: SavePasswordsPreferences.java
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved =
                mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved =
                mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
源代码4 项目: talkback   文件: SwitchAccessPreferenceActivity.java
private void adjustAutoscanPrefs() {
  PreferenceScreen autoScanScreen =
      (PreferenceScreen) findPreference(R.string.pref_category_auto_scan_key);
  PreferenceCategory movementAndSelectionCategory = getMovementAndSelectionCategory();
  Preference autoScanKeyPreference =
      movementAndSelectionCategory.findPreference(
          getString(R.string.pref_key_mapped_to_auto_scan_key));
  Preference reverseAutoScanKeyPreference =
      movementAndSelectionCategory.findPreference(
          getString(R.string.pref_key_mapped_to_reverse_auto_scan_key));

  boolean isAutoScanEnabled = SwitchAccessPreferenceUtils.isAutoScanEnabled(getActivity());
  if (isAutoScanEnabled) {
    autoScanScreen.setSummary(R.string.preference_on);
    autoScanKeyPreference.setTitle(R.string.title_pref_category_auto_scan);
    reverseAutoScanKeyPreference.setTitle(R.string.action_name_reverse_auto_scan);

    if (FeatureFlags.groupSelectionWithAutoScan()) {
      return;
    }

    if (SwitchAccessPreferenceUtils.isGroupSelectionEnabled(getActivity())) {
      /* If somehow both autoscan and group selection are enabled, turn off group selection. */
      SwitchAccessPreferenceUtils.setScanningMethod(
          getActivity(), R.string.row_col_scanning_key);
    }
  } else {
    autoScanScreen.setSummary(R.string.preference_off);
    autoScanKeyPreference.setTitle(R.string.title_pref_auto_scan_disabled);
    reverseAutoScanKeyPreference.setTitle(R.string.title_pref_reverse_auto_scan_disabled);
    if (SwitchAccessPreferenceUtils.isGroupSelectionEnabled(getActivity())
        && !FeatureFlags.groupSelectionWithAutoScan()) {
      findPreference(R.string.pref_category_auto_scan_key).setEnabled(false);
    }
  }
  ((BaseAdapter) autoScanScreen.getRootAdapter()).notifyDataSetChanged();
  ScanningMethodPreference scanMethodsPref = getScanningMethodPreference();
  scanMethodsPref.enableScanningMethod(R.string.group_selection_key, !isAutoScanEnabled);
}
 
源代码5 项目: talkback   文件: SwitchAccessPreferenceActivity.java
private void adjustPointScanPrefs() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
    // Remove point scan screen
    PreferenceCategory customizeScanningCategory =
        (PreferenceCategory) findPreference(R.string.pref_category_customize_scanning_key);
    customizeScanningCategory.removePreference(
        findPreference(R.string.pref_category_point_scan_key));
  } else {
    SwitchPreference pointScanPreference =
        (SwitchPreference) findPreference(R.string.pref_key_point_scan_enabled);
    String enableAnimationsMessage =
        ((VERSION.SDK_INT >= VERSION_CODES.O) && !ValueAnimator.areAnimatorsEnabled())
            ? getString(R.string.point_scan_enable_animations_message)
            : "";
    String pointScanPreferenceSummary =
        getString(R.string.summary_pref_point_scan, enableAnimationsMessage);
    pointScanPreference.setSummary(pointScanPreferenceSummary);
    pointScanPreference.setEnabled(
        (VERSION.SDK_INT < VERSION_CODES.O) || ValueAnimator.areAnimatorsEnabled());

    // Make sure the subtitle reflects Point scan state
    PreferenceScreen pointScanScreen =
        (PreferenceScreen) findPreference(R.string.pref_category_point_scan_key);
    if (SwitchAccessPreferenceUtils.isPointScanEnabled(getActivity())) {
      pointScanScreen.setSummary(R.string.preference_on);
    } else {
      pointScanScreen.setSummary(R.string.preference_off);
    }
    ((BaseAdapter) pointScanScreen.getRootAdapter()).notifyDataSetChanged();
  }
}
 
源代码6 项目: talkback   文件: SwitchAccessPreferenceActivity.java
private void adjustSpokenFeedbackPrefs() {
  PreferenceScreen spokenFeedbackScreen =
      (PreferenceScreen)
          findPreference(R.string.pref_key_category_switch_access_speech_sound_vibration);
  if (SwitchAccessPreferenceUtils.isSpokenFeedbackEnabled(getActivity())) {
    spokenFeedbackScreen.setSummary(R.string.preference_on);
  } else {
    spokenFeedbackScreen.setSummary(R.string.preference_off);
  }
  ((BaseAdapter) spokenFeedbackScreen.getRootAdapter()).notifyDataSetChanged();
}
 
源代码7 项目: 365browser   文件: SavePasswordsPreferences.java
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    resetList(PREF_CATEGORY_SAVED_PASSWORDS_NO_TEXT);

    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved =
                mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
源代码8 项目: wear-notify-for-reddit   文件: SettingsActivity.java
protected void updatePrefsSummary(Preference pref) {
    if (pref == null) {
        return;
    }

    if (pref instanceof ListPreference) {
        ListPreference lst = (ListPreference) pref;
        String currentValue = lst.getValue();

        int index = lst.findIndexOfValue(currentValue);
        CharSequence[] entries = lst.getEntries();
        if (index >= 0 && index < entries.length) {
            pref.setSummary(entries[index]);
        }
    } else if (pref instanceof PreferenceScreen) {
        PreferenceScreen screen = (PreferenceScreen) pref;

        if (screen.getKey().equals(getString(R.string.prefs_key_account_info))) {
            if (mTokenStorage.isLoggedIn()) {
                screen.setSummary(getString(R.string.logged_in));
            } else {
                screen.setSummary(R.string.tap_to_sign_in);
            }
        }
    } else if (pref instanceof DragReorderActionsPreference) {
        pref.setSummary(pref.getSummary());
    }
}