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

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

源代码1 项目: pushfish-android   文件: SettingsActivity.java
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
源代码3 项目: AndroidChromium   文件: AutofillPreferences.java
private void rebuildProfileList() {
    // Add an edit preference for each current Chrome profile.
    PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES);
    profileCategory.removeAll();
    for (AutofillProfile profile : PersonalDataManager.getInstance().getProfilesForSettings()) {
        // Add an item on the current page...
        Preference pref = new Preference(getActivity());
        pref.setTitle(profile.getFullName());
        pref.setSummary(profile.getLabel());

        if (profile.getIsLocal()) {
            pref.setFragment(AutofillProfileEditor.class.getName());
        } else {
            pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
            pref.setFragment(AutofillServerProfilePreferences.class.getName());
        }

        Bundle args = pref.getExtras();
        args.putString(AUTOFILL_GUID, profile.getGUID());
        profileCategory.addPreference(pref);
    }
}
 
源代码4 项目: remotekeyboard   文件: SettingsActivity.java
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
		String key) {
	Preference preference = findPreference(key);
	if (preference instanceof ListPreference) {
		preference.setSummary(((ListPreference) preference).getEntry());
	}
	SharedPreferences sharedPref = PreferenceManager
			.getDefaultSharedPreferences(this);
	if (sharedPref.getString(TelnetEditorShell.PREF_PASSWORD, "").equals("")) {
		findPreference(TelnetEditorShell.PREF_PASSWORD).setSummary(
				R.string.msg_password_not_set);
	}
	else {
		findPreference(TelnetEditorShell.PREF_PASSWORD).setSummary(
				R.string.msg_password_set);
	}
	
	try {
		RemoteKeyboardService.self.updateFullscreenMode();
	}
	catch (Exception e) {}

}
 
static void updateKeyboardThemeSummary(final Preference pref) {
    final Context context = pref.getContext();
    final Resources res = context.getResources();
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeNames.length; index++) {
        if (keyboardTheme.mThemeId == keyboardThemeIds[index]) {
            pref.setSummary(keyboardThemeNames[index]);
            return;
        }
    }
}
 
源代码6 项目: wshell   文件: SettingsActivity.java
private void setSummary(Preference pref, boolean init) {
	if (pref instanceof EditTextPreference) {
		EditTextPreference editPref = (EditTextPreference) pref;
		pref.setSummary(editPref.getText());
	}

	if (pref instanceof ListPreference) {
		ListPreference listPref = (ListPreference) pref;
		pref.setSummary(listPref.getEntry());
	}
}
 
源代码7 项目: mOrgAnd   文件: SettingsActivity.java
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    preference.setSummary(value.toString());

    PreferenceUtils.set("git_local_path", "");
    preference.getPreferenceManager().findPreference("git_local_path").setSummary("");

    return true;
}
 
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
	if (isNewAccount) {
		builder.setUserId(newValue.toString());
	} else {
		mPrefs.setAccountUserId(n, newValue.toString());
	}
	preference.setSummary(newValue.toString());
	return true;
}
 
源代码9 项目: MHViewer   文件: AboutFragment.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.about_settings);

    Preference author = findPreference(KEY_AUTHOR);
    // Preference donate = findPreference(KEY_DONATE);
    // Preference checkForUpdate = findPreference(KEY_CHECK_FOR_UPDATES);

    author.setSummary(getString(R.string.settings_about_author_summary).replace('$', '@'));

    author.setOnPreferenceClickListener(this);
    // donate.setOnPreferenceClickListener(this);
    // checkForUpdate.setOnPreferenceClickListener(this);
}
 
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
	if (isNewAccount) {
		builder.setDisplayName(newValue.toString());
	} else {
		mPrefs.setAccountDisplayName(n, newValue.toString());
	}
	preference.setSummary(newValue.toString());
	return true;
}
 
源代码11 项目: NightWatch   文件: SettingsActivity.java
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else if (preference instanceof RingtonePreference) {
        if (TextUtils.isEmpty(stringValue)) {
            preference.setSummary("Silent");
        } else {
            Ringtone ringtone = RingtoneManager.getRingtone(
                    preference.getContext(), Uri.parse(stringValue));

            if (ringtone == null) {
                preference.setSummary(null);
            } else {
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
            }
        }
    } else {
        preference.setSummary(stringValue);
    }
    return true;
}
 
private void refreshPaymentAppsPref() {
    Preference pref = findPreference(PREF_ANDROID_PAYMENT_APPS);
    if (pref != null) {
        if (AndroidPaymentAppFactory.hasAndroidPaymentApps()) {
            pref.setSummary(null);
            pref.setEnabled(true);
        } else {
            pref.setSummary(getActivity().getString(R.string.payment_no_apps_summary));
            pref.setEnabled(false);
        }
    }
}
 
源代码13 项目: Dashchan   文件: BasePreferenceFragment.java
public Preference makeButton(PreferenceGroup parent, CharSequence title, CharSequence summary,
		boolean information) {
	Preference preference = information ? new Preference(getActivity(), null,
			android.R.attr.preferenceInformationStyle) : new Preference(getActivity());
	preference.setTitle(title);
	preference.setSummary(summary);
	addPreference(parent, preference);
	return preference;
}
 
源代码14 项目: journaldev   文件: SettingsActivity.java
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else if (preference instanceof RingtonePreference) {
        // For ringtone preferences, look up the correct display value
        // using RingtoneManager.
        if (TextUtils.isEmpty(stringValue)) {
            // Empty values correspond to 'silent' (no ringtone).
            preference.setSummary(R.string.pref_ringtone_silent);

        } else {
            Ringtone ringtone = RingtoneManager.getRingtone(
                    preference.getContext(), Uri.parse(stringValue));

            if (ringtone == null) {
                // Clear the summary if there was a lookup error.
                preference.setSummary(null);
            } else {
                // Set the summary to reflect the new ringtone display
                // name.
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
            }
        }

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
源代码15 项目: AndroidChromium   文件: PrivacyPreferences.java
/**
 * Updates the summaries for several preferences.
 */
public void updateSummaries() {
    PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();

    PrivacyPreferencesManager privacyPrefManager = PrivacyPreferencesManager.getInstance();

    CharSequence textOn = getActivity().getResources().getText(R.string.text_on);
    CharSequence textOff = getActivity().getResources().getText(R.string.text_off);

    CheckBoxPreference navigationErrorPref = (CheckBoxPreference) findPreference(
            PREF_NAVIGATION_ERROR);
    if (navigationErrorPref != null) {
        navigationErrorPref.setChecked(
                prefServiceBridge.isResolveNavigationErrorEnabled());
    }

    CheckBoxPreference searchSuggestionsPref = (CheckBoxPreference) findPreference(
            PREF_SEARCH_SUGGESTIONS);
    if (searchSuggestionsPref != null) {
        searchSuggestionsPref.setChecked(prefServiceBridge.isSearchSuggestEnabled());
    }

    String extended_reporting_pref = prefServiceBridge.isSafeBrowsingScoutReportingActive()
            ? PREF_SAFE_BROWSING_SCOUT_REPORTING : PREF_SAFE_BROWSING_EXTENDED_REPORTING;
    CheckBoxPreference extendedReportingPref =
            (CheckBoxPreference) findPreference(extended_reporting_pref);
    if (extendedReportingPref != null) {
        extendedReportingPref.setChecked(
                prefServiceBridge.isSafeBrowsingExtendedReportingEnabled());
    }

    CheckBoxPreference safeBrowsingPref =
            (CheckBoxPreference) findPreference(PREF_SAFE_BROWSING);
    if (safeBrowsingPref != null) {
        safeBrowsingPref.setChecked(prefServiceBridge.isSafeBrowsingEnabled());
    }

    Preference doNotTrackPref = findPreference(PREF_DO_NOT_TRACK);
    if (doNotTrackPref != null) {
        doNotTrackPref.setSummary(prefServiceBridge.isDoNotTrackEnabled() ? textOn : textOff);
    }

    Preference contextualPref = findPreference(PREF_CONTEXTUAL_SEARCH);
    if (contextualPref != null) {
        boolean isContextualSearchEnabled = !prefServiceBridge.isContextualSearchDisabled();
        contextualPref.setSummary(isContextualSearchEnabled ? textOn : textOff);
    }

    Preference physicalWebPref = findPreference(PREF_PHYSICAL_WEB);
    if (physicalWebPref != null) {
        physicalWebPref.setSummary(privacyPrefManager.isPhysicalWebEnabled()
                ? textOn : textOff);
    }

    Preference usageAndCrashPref = findPreference(PREF_USAGE_AND_CRASH_REPORTING);
    if (usageAndCrashPref != null) {
        usageAndCrashPref.setSummary(
                privacyPrefManager.isUsageAndCrashReportingPermittedByUser() ? textOn
                                                                             : textOff);
    }
}
 
源代码16 项目: SkyTube   文件: AboutPreferenceFragment.java
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	addPreferencesFromResource(R.xml.preference_about);

	// set the app's version number
	Preference versionPref = findPreference(getString(R.string.pref_key_version));
	versionPref.setSummary(getAppVersion());

	// check for updates option
	Preference updatesPref = findPreference(getString(R.string.pref_key_updates));
	if (BuildConfig.FLAVOR.equalsIgnoreCase("oss")) {
		// remove the updates option if the user is running the OSS flavor...
		getPreferenceScreen().removePreference(updatesPref);
	} else {
		updatesPref.setOnPreferenceClickListener(preference -> {
			new UpdatesCheckerTask(getActivity(), true).executeInParallel();
			return true;
		});
	}

	// if the user clicks on the website link, then open it using an external browser
	Preference websitePref = findPreference(getString(R.string.pref_key_website));
	websitePref.setSummary(BuildConfig.SKYTUBE_WEBSITE);
	websitePref.setOnPreferenceClickListener(preference -> {
		// view the app's website in a web browser
		Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(BuildConfig.SKYTUBE_WEBSITE));
		startActivity(browserIntent);
		return true;
	});

	// credits
	Preference creditsPref = findPreference(getString(R.string.pref_key_credits));
	creditsPref.setOnPreferenceClickListener(preference -> {
		displayCredits();
		return true;
	});

	// if the user clicks on the license, then open the display the actual license
	Preference licensePref = findPreference(getString(R.string.pref_key_license));
	licensePref.setOnPreferenceClickListener(preference -> {
		displayAppLicense();
		return true;
	});
}
 
源代码17 项目: MicroReader   文件: SettingsFragment.java
private void showCacheSize(Preference preference) {
    preference.setSummary(getActivity().getString(R.string.cache_size) + CacheUtil.getCacheSize(getActivity().getCacheDir()));
}
 
源代码18 项目: JayPS-AndroidApp   文件: SettingsActivity.java
private void setLoginMmtSummary() {
    String login = _sharedPreferences.getString("LIVE_TRACKING_MMT_LOGIN", "");
    Preference loginPref = findPreference("LIVE_TRACKING_MMT_LOGIN");
    loginPref.setSummary(login);
}
 
源代码19 项目: SuntimesWidget   文件: SuntimesSettingsActivity.java
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    Intent calendarIntent = new Intent();
    calendarIntent.setComponent(new ComponentName(calendarPackage, calendarActivity));
    calendarIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    PackageManager packageManager = getActivity().getPackageManager();
    if (calendarIntent.resolveActivity(packageManager) != null)
    {
        try {
            startActivity(calendarIntent);
            getActivity().finish();
            getActivity().overridePendingTransition(R.anim.transition_next_in, R.anim.transition_next_out);
            return;

        } catch (Exception e) {
            Log.e("CalendarPrefs", "Unable to launch SuntimesCalendarActivity! " + e);
        }
    }

    AppSettings.initLocale(getActivity());
    addPreferencesFromResource(R.xml.preference_calendar);
    Preference calendarReadme = findPreference("appwidget_0_calendars_readme");
    if (calendarReadme != null)
    {
        calendarReadme.setSummary(SuntimesUtils.fromHtml(getString(R.string.help_calendar)));
        calendarReadme.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
        {
            @Override
            public boolean onPreferenceClick(Preference preference)
            {
                Activity activity = getActivity();
                if (activity != null) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(AboutDialog.ADDONS_URL));
                    if (intent.resolveActivity(activity.getPackageManager()) != null) {
                        activity.startActivity(intent);
                        activity.overridePendingTransition(R.anim.transition_next_in, R.anim.transition_next_out);
                    }
                }
                return false;
            }
        });
    }
    Log.i(LOG_TAG, "CalendarPrefsFragment: Arguments: " + getArguments());
}
 
源代码20 项目: AndroidChromium   文件: MainPreferences.java
private void setOnOffSummary(Preference pref, boolean isOn) {
    pref.setSummary(getResources().getString(isOn ? R.string.text_on : R.string.text_off));
}