本文整理汇总了Java中android.preference.RingtonePreference.setSummary方法的典型用法代码示例。如果您正苦于以下问题:Java RingtonePreference.setSummary方法的具体用法?Java RingtonePreference.setSummary怎么用?Java RingtonePreference.setSummary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.RingtonePreference
的用法示例。
在下文中一共展示了RingtonePreference.setSummary方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.preference.RingtonePreference; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
DebugLog.logMethod();
EventBus.getDefault().register(this);
buildGoogleApiClient();
findPreference(KEY_EXPORT_TO_DRIVE).setOnPreferenceClickListener(this);
findPreference(KEY_IMPORT_FROM_DRIVE).setOnPreferenceClickListener(this);
timePreference = findPreference(KEY_NOTIFICATION_TIME);
timePreference.setSummary(getNotificationTimeSummary());
timePreference.setOnPreferenceClickListener(this);
ringtonePreference = (RingtonePreference) findPreference(KEY_NOTIFICATION_RINGTONE);
ringtonePreference.setSummary(getRingtoneTitle());
getPreferenceManager().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
showProgressDialog();
return super.onCreateView(inflater, container, savedInstanceState);
}
示例2: updateRingtonePreferenceSummary
import android.preference.RingtonePreference; //导入方法依赖的package包/类
/**
* Sets the summary of the Ringtone Preference to the human readable name of the selected
* ringtone
*
* @param ringtonePreference The preference to update
* @param selectedRingtoneUriString The String version of the selected ringtone Uri
*/
private void updateRingtonePreferenceSummary(final RingtonePreference ringtonePreference, final String selectedRingtoneUriString) {
if (!TextUtils.isEmpty(selectedRingtoneUriString)) {
final Ringtone selectedRingtone = RingtoneManager
.getRingtone(getActivity(), Uri.parse(selectedRingtoneUriString));
if (selectedRingtone == null) {
ringtonePreference.setSummary(null);
} else {
ringtonePreference.setSummary(selectedRingtone.getTitle(getActivity()));
}
} else {
ringtonePreference.setSummary(null);
}
}
示例3: updatePreferenceSummary
import android.preference.RingtonePreference; //导入方法依赖的package包/类
/**
* Updates the summary of the preference with the currently corresponding data.
* @param preference The Preference to be updated
*/
private void updatePreferenceSummary(SharedPreferences sharedPreferences,
Preference preference) {
if (preference == null) return;
if (preference.getKey().equals(getString(R.string.pref_reminder_offset_key))) {
// Reminder offset preference
NumberPickerPreference offsetPreference = (NumberPickerPreference) preference;
offsetPreference.setSummary(String.format(
getString(R.string.pref_reminder_offset_summary),
offsetPreference.getEntry()));
return;
}
if (preference.getKey().equals(getString(R.string.pref_refresh_time_key))) {
// Refresh timer preference
ListPreference timerPreference = (ListPreference) preference;
timerPreference.setSummary(String.format(getString(R.string.pref_refresh_time_summary),
timerPreference.getEntry()));
return;
}
if (preference.getKey().equals(getString(R.string.pref_notification_ringtone_key))) {
// Refresh ringtone name
RingtonePreference ringtonePreference = (RingtonePreference) preference;
String ringtoneString = sharedPreferences.getString(preference.getKey(),
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString());
String name;
if (ringtoneString.equals("")) {
// No ringtone
name = getString(R.string.pref_notification_ringtone_none);
} else {
Uri ringtoneUri = Uri.parse(ringtoneString);
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
name = ringtone == null ? "" : ringtone.getTitle(context);
}
ringtonePreference.setSummary(String.format(
getString(R.string.pref_notification_ringtone_summary), name));
}
}
示例4: setSummaries
import android.preference.RingtonePreference; //导入方法依赖的package包/类
private void setSummaries(Recipients recipients) {
CheckBoxPreference mutePreference = (CheckBoxPreference) this.findPreference(PREFERENCE_MUTED);
RingtonePreference ringtonePreference = (RingtonePreference) this.findPreference(PREFERENCE_TONE);
ListPreference vibratePreference = (ListPreference) this.findPreference(PREFERENCE_VIBRATE);
Preference blockPreference = this.findPreference(PREFERENCE_BLOCK);
mutePreference.setChecked(recipients.isMuted());
if (recipients.getRingtone() != null) {
Ringtone tone = RingtoneManager.getRingtone(getActivity(), recipients.getRingtone());
if (tone != null) {
ringtonePreference.setSummary(tone.getTitle(getActivity()));
}
} else {
ringtonePreference.setSummary(R.string.preferences__default);
}
if (recipients.getVibrate() == VibrateState.DEFAULT) {
vibratePreference.setSummary(R.string.preferences__default);
vibratePreference.setValueIndex(0);
} else if (recipients.getVibrate() == VibrateState.ENABLED) {
vibratePreference.setSummary(R.string.RecipientPreferenceActivity_enabled);
vibratePreference.setValueIndex(1);
} else {
vibratePreference.setSummary(R.string.RecipientPreferenceActivity_disabled);
vibratePreference.setValueIndex(2);
}
if (!recipients.isSingleRecipient() || recipients.isGroupRecipient()) {
blockPreference.setEnabled(false);
} else {
blockPreference.setEnabled(true);
if (recipients.isBlocked()) blockPreference.setTitle(R.string.RecipientPreferenceActivity_unblock);
else blockPreference.setTitle(R.string.RecipientPreferenceActivity_block);
}
}
示例5: onSharedPreferenceChanged
import android.preference.RingtonePreference; //导入方法依赖的package包/类
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
//Update a preference's summary as soon as a user changes it
Preference pref = findPreference(key);
if(key.equals(getString(R.string.prefs_notification_sound_key))){
Uri ringtoneUri = Uri.parse(sharedPreferences.getString(key, ""));
Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), ringtoneUri);
String name = ringtone.getTitle(getActivity());
RingtonePreference ringtonePref = (RingtonePreference) findPreference(key);
ringtonePref.setSummary(name);
}else if(key.equals(getString(R.string.prefs_notification_resend_toggle_key))){
}else if(key.equals(getString(R.string.prefs_notification_resend_delay_key))){
}else if(key.equals(getString(R.string.prefs_display_name_key))){
String newName = ((EditTextPreference) pref).getText().trim();
if(newName.equals("")){//override
((EditTextPreference) pref).setText(defaultFName);
Toast.makeText(getActivity(), R.string.str_blank_name_msg, Toast.LENGTH_SHORT).show();
}
else {
defaultFName = newName;
pref.setSummary(newName);
ParseUser u = ParseUser.getCurrentUser();
u.put("friendlyName", newName);
u.saveInBackground();
}
}else if(key.equals(getString(R.string.prefs_clear_pings_key))){
//will not run
}
}
示例6: updateRingtoneSummary
import android.preference.RingtonePreference; //导入方法依赖的package包/类
private void updateRingtoneSummary(RingtonePreference pref, String newValue)
{
String ringtoneName = "None";
Uri uri = Uri.parse(newValue);
if (uri.getScheme().equals("file"))
{
ringtoneName = uri.getLastPathSegment();
}
else if (uri.getScheme().equals("content"))
{
try
{
String[] projection = { MediaStore.Audio.Media.TITLE };
Cursor c = mActivity.getContentResolver().query(uri, projection, null, null, null);
if (c != null && c.getCount() > 0)
{
int columnIndex = c.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE);
c.moveToFirst();
ringtoneName = c.getString(columnIndex);
}
}
catch (SQLiteException ex)
{
Ringtone ringtone = RingtoneManager.getRingtone(mActivity, Uri.parse(newValue));
if (ringtone != null)
ringtoneName = ringtone.getTitle(mActivity);
}
}
pref.setSummary(ringtoneName);
}
示例7: setSummary
import android.preference.RingtonePreference; //导入方法依赖的package包/类
/**
* Set the summaries of the given preference
*/
private static void setSummary(Context context, Preference pref) {
// react on type or key
if (pref instanceof EditTextPreference) {
EditTextPreference editPref = (EditTextPreference) pref;
String prefText = editPref.getText();
int editInputType = editPref.getEditText().getInputType();
if (prefText != null && prefText.length() > 0) {
if ((editInputType & InputType.TYPE_NUMBER_VARIATION_PASSWORD) > 0) {
pref.setSummary("********");
} else {
pref.setSummary(prefText);
}
}
} else if (pref instanceof ListPreference) {
ListPreference listPref = (ListPreference) pref;
pref.setSummary(listPref.getEntry());
} else if (pref instanceof RingtonePreference) {
RingtonePreference ringPref = (RingtonePreference) pref;
String ringtoneString = ringPref.getPreferenceManager().getSharedPreferences().getString(ringPref.getKey(), null);
if (!TextUtils.isEmpty(ringtoneString)) {
Uri ringtoneUri = Uri.parse(ringtoneString);
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
String name = ringtone.getTitle(context);
ringPref.setSummary(name);
}
}
}
示例8: setupPreferences
import android.preference.RingtonePreference; //导入方法依赖的package包/类
private void setupPreferences() {
final Vibrator v = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
if (!v.hasVibrator()) {
getPreferenceScreen().removePreference(findPreference(Const.PrefsNames.HAS_VIBRATION));
}
mHasNotifications = findPreference(Const.PrefsNames.HAS_NOTIFICATIONS);
mHasVibration = findPreference(Const.PrefsNames.HAS_VIBRATION);
mRingtone = (RingtonePreference) findPreference(Const.PrefsNames.RINGTONE);
mScreenLockStatus = findPreference(Const.PrefsNames.SCREEN_LOCK_STATUS);
mPowerConnectionStatus = findPreference(Const.PrefsNames.POWER_CONNECTION_STATUS);
mPowerConnectionType = findPreference(Const.PrefsNames.POWER_CONNECTION_TYPE);
mDelayToLock = findPreference(Const.PrefsNames.DELAY_TO_LOCK);
mDeviceAdmin = (CheckBoxPreference) findPreference(Const.PrefsNames.IS_ADMIN);
// Synchronize pref value, done before settings the ChangeListener
mDeviceAdmin.setChecked(ComponentHelper.isDeviceAdmin(getActivity()));
/**
* Update summaries
*/
mRingtone.setSummary(getRingtoneSummary());
mScreenLockStatus.setSummary(getLockStatusSummary());
mPowerConnectionStatus.setSummary(getConnectionStatusSummary());
mPowerConnectionType.setSummary(getConnectionTypeSummary());
mDelayToLock.setSummary(getLockDelaySummary());
findPreference(Const.PrefsNames.CACHE_AGE).setSummary(getCacheAgeSummary());
}
示例9: onCreate
import android.preference.RingtonePreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
// Set the summary of the Name preference to the user's friendly name.
SharedPreferences sp = getPreferenceScreen().getSharedPreferences();
String fname = ParseUser.getCurrentUser().get("friendlyName").toString();
String dispNameKey = getString(R.string.prefs_display_name_key);
EditTextPreference editTextPref = (EditTextPreference) findPreference(dispNameKey);
editTextPref.setSummary(fname);
try{
// Set the summary of the Notification Sound preference to the tone's friendly name.
String notKey = getString(R.string.prefs_notification_sound_key);
String uriPath = sp.getString(notKey, "");
String name;
if(uriPath.length()==0) {
Uri defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(getActivity().getApplicationContext(), RingtoneManager.TYPE_NOTIFICATION);
Ringtone defaultRingtone = RingtoneManager.getRingtone(getActivity(), defaultRingtoneUri);
name = defaultRingtone.getTitle(getActivity());
if (name.trim().equals("")) name = "Blank Name";
}
else{
Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), Uri.parse(uriPath));
name = ringtone.getTitle(getActivity());
}
RingtonePreference ringtonePref = (RingtonePreference)
findPreference(notKey);
ringtonePref.setSummary(name);
}
catch(Exception e){
Toast.makeText(getActivity(), getString(R.string.prefs_ringtone_failed), Toast.LENGTH_SHORT).show();
}
}