@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
masterSecret = getArguments().getParcelable("master_secret");
addPreferencesFromResource(R.xml.preferences_notifications);
this.findPreference(TextSecurePreferences.LED_COLOR_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(TextSecurePreferences.LED_BLINK_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(TextSecurePreferences.RINGTONE_PREF)
.setOnPreferenceChangeListener(new RingtoneSummaryListener());
this.findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF)
.setOnPreferenceChangeListener(new NotificationPrivacyListener());
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF));
initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF));
}
java类android.preference.RingtonePreference的实例源码
NotificationsPreferenceFragment.java 文件源码
项目:PeSanKita-android
阅读 23
收藏 0
点赞 0
评论 0
PreferencesUtil.java 文件源码
项目:text_converter
阅读 33
收藏 0
点赞 0
评论 0
@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) {
} else if (preference instanceof EditTextPreference) {
EditTextPreference editTextPreference = (EditTextPreference) preference;
editTextPreference.setSummary(editTextPreference.getText());
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
PreferencesUtil.java 文件源码
项目:javaide
阅读 26
收藏 0
点赞 0
评论 0
@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) {
} else if (preference instanceof EditTextPreference) {
EditTextPreference editTextPreference = (EditTextPreference) preference;
editTextPreference.setSummary(editTextPreference.getText());
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
SettingsFragment.java 文件源码
项目:CouponsTracker
阅读 33
收藏 0
点赞 0
评论 0
@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);
}
NotificationsPreferenceFragment.java 文件源码
项目:TextSecure
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
addPreferencesFromResource(R.xml.preferences_notifications);
this.findPreference(TextSecurePreferences.LED_COLOR_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(TextSecurePreferences.LED_BLINK_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(TextSecurePreferences.RINGTONE_PREF)
.setOnPreferenceChangeListener(new RingtoneSummaryListener());
this.findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF));
}
NotificationsPreferenceFragment.java 文件源码
项目:TextSecureSMP
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
addPreferencesFromResource(R.xml.preferences_notifications);
this.findPreference(TextSecurePreferences.LED_COLOR_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(TextSecurePreferences.LED_BLINK_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(TextSecurePreferences.RINGTONE_PREF)
.setOnPreferenceChangeListener(new RingtoneSummaryListener());
this.findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF));
}
NotificationsPreferenceFragment.java 文件源码
项目:Silence
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
masterSecret = getArguments().getParcelable("master_secret");
addPreferencesFromResource(R.xml.preferences_notifications);
this.findPreference(SilencePreferences.LED_COLOR_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(SilencePreferences.LED_BLINK_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(SilencePreferences.RINGTONE_PREF)
.setOnPreferenceChangeListener(new RingtoneSummaryListener());
this.findPreference(SilencePreferences.REPEAT_ALERTS_PREF)
.setOnPreferenceChangeListener(new ListSummaryListener());
this.findPreference(SilencePreferences.NOTIFICATION_PRIVACY_PREF)
.setOnPreferenceChangeListener(new NotificationPrivacyListener());
initializeListSummary((ListPreference) findPreference(SilencePreferences.LED_COLOR_PREF));
initializeListSummary((ListPreference) findPreference(SilencePreferences.LED_BLINK_PREF));
initializeListSummary((ListPreference) findPreference(SilencePreferences.REPEAT_ALERTS_PREF));
initializeListSummary((ListPreference) findPreference(SilencePreferences.NOTIFICATION_PRIVACY_PREF));
initializeRingtoneSummary((RingtonePreference) findPreference(SilencePreferences.RINGTONE_PREF));
}
SettingsFragment.java 文件源码
项目:yelo-android
阅读 28
收藏 0
点赞 0
评论 0
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
mChatRingtoneKey = getString(R.string.pref_chat_ringtone);
mChatRingtonePreference = (RingtonePreference) findPreference(mChatRingtoneKey);
// mLocationCityChangePreference = (ListPreference) findPreference(getActivity().getResources().getString(R.string.pref_location_settings));
//mLocationCityChangePreference.setEntries();
mChatRingtonePreference.setOnPreferenceChangeListener(this);
//mLocationCityChangePreference.setOnPreferenceChangeListener(this);
updateRingtonePreferenceSummary(mChatRingtonePreference, SharedPreferenceHelper
.getString(R.string.pref_chat_ringtone));
//updateLocationPreference(mLocationCityChangePreference,SharedPreferenceHelper.getString(R.string.pref_location_settings));
mOtherRingtoneKey = getString(R.string.pref_other_ringtone);
mOtherRingtonePreference = (RingtonePreference) findPreference(mOtherRingtoneKey);
mOtherRingtonePreference.setOnPreferenceChangeListener(this);
updateRingtonePreferenceSummary(mOtherRingtonePreference, SharedPreferenceHelper
.getString(R.string.pref_other_ringtone));
}
SettingsFragment.java 文件源码
项目:yelo-android
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
RingtoneSelectionPreference.java 文件源码
项目:redalert-android
阅读 20
收藏 0
点赞 0
评论 0
private int getRequestCodeViaReflection() {
try {
// Get request code field by reflection
Field field = android.preference.RingtonePreference.class.getDeclaredField("mRequestCode");
// Make it accessible
field.setAccessible(true);
// Return it
return (Integer) field.get(this);
}
catch (Exception exc) {
// Log it
Log.e(Logging.TAG, "Request code reflection failed", exc);
// Return error
return REQUEST_CODE_FAILED;
}
}
ReminderPreferencesFragment.java 文件源码
项目:Muezzin
阅读 16
收藏 0
点赞 0
评论 0
private void initializeForPrayerTime(final PrayerTimeType prayerTimeType) {
String soundKey = Pref.Reminders.SOUND_BASE + prayerTimeType.name;
RingtonePreference sound = (RingtonePreference) findPreference(soundKey);
sound.setOnPreferenceChangeListener((preference, newValue) -> {
updateSoundSummary(preference, (String) newValue);
return true;
});
String currentSound = Pref.Reminders.sound(getActivity(), prayerTimeType);
updateSoundSummary(sound, currentSound);
String timeToRemindKey = Pref.Reminders.TIME_TO_REMIND_BASE + prayerTimeType.name;
ListPreference timeToRemind = (ListPreference) findPreference(timeToRemindKey);
timeToRemind.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary(getString(R.string.preferences_reminders_timeToRemindSummary, Integer.parseInt((String) newValue)));
return true;
});
int currentTimeToRemind = Pref.Reminders.timeToRemind(getActivity(), prayerTimeType);
timeToRemind.setSummary(getString(R.string.preferences_reminders_timeToRemindSummary, currentTimeToRemind));
}
SettingsActivity.java 文件源码
项目:GallyShuttle
阅读 26
收藏 0
点赞 0
评论 0
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivityComponent().inject(this);
addPreferencesFromResource(R.xml.preferences);
reminderListPreference = (ListPreference) findPreference(getString(R.string.pref_key_alarm_reminder));
bindOnPreferenceChange(reminderListPreference);
alarmRingtonePreference = (RingtonePreference) findPreference(getString(R.string.pref_key_alarm_ringtone));
bindOnPreferenceChange(alarmRingtonePreference);
notificationRingtonePreference = (RingtonePreference) findPreference(getString(R.string.pref_key_notification_ringtone));
bindOnPreferenceChange(notificationRingtonePreference);
setCachePreference();
setSharePreference();
}
BasePreferenceFragment.java 文件源码
项目:GallyShuttle
阅读 27
收藏 0
点赞 0
评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString();
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(value);
preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
} else if (preference instanceof RingtonePreference) {
if (TextUtils.isEmpty(value)) {
preference.setSummary(R.string.pref_summary_silent);
} else {
Ringtone ringtone = RingtoneManager.getRingtone(preference.getContext(), Uri.parse(value));
if (ringtone != null) {
preference.setSummary(ringtone.getTitle(preference.getContext()));
} else {
preference.setSummary(null);
}
}
} else {
preference.setSummary(value);
}
return true;
}
PreferenceLoaderTest.java 文件源码
项目:FullRobolectricTestSample
阅读 17
收藏 0
点赞 0
评论 0
protected void assertThatScreenMatchesExpected(PreferenceScreen screen) {
assertThat(screen.getPreferenceCount()).isEqualTo(8);
assertThat(screen.getPreference(0)).isInstanceOf(PreferenceCategory.class);
assertThat(((PreferenceCategory) screen.getPreference(0)).getPreference(0)).isInstanceOf(Preference.class);
PreferenceScreen innerScreen = (PreferenceScreen) screen.getPreference(1);
assertThat(innerScreen).isInstanceOf(PreferenceScreen.class);
assertThat(innerScreen.getKey()).isEqualTo("screen");
assertThat(innerScreen.getTitle().toString()).isEqualTo("Screen Test");
assertThat(innerScreen.getSummary()).isEqualTo("Screen summary");
assertThat(innerScreen.getPreference(0)).isInstanceOf(Preference.class);
assertThat(screen.getPreference(2)).isInstanceOf(CheckBoxPreference.class);
assertThat(screen.getPreference(3)).isInstanceOf(EditTextPreference.class);
assertThat(screen.getPreference(4)).isInstanceOf(ListPreference.class);
assertThat(screen.getPreference(5)).isInstanceOf(Preference.class);
assertThat(screen.getPreference(6)).isInstanceOf(RingtonePreference.class);
assertThat(screen.getPreference(7)).isInstanceOf(Preference.class);
}
SettingsActivity.java 文件源码
项目:ChattyOwl
阅读 25
收藏 0
点赞 0
评论 0
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
} else if (preference instanceof RingtonePreference) {
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
TS_Settings.java 文件源码
项目:BAGO_TS
阅读 19
收藏 0
点赞 0
评论 0
@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(R.string.pref_ringtone_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;
}
SettingsActivity.java 文件源码
项目:SampleAppArch
阅读 25
收藏 0
点赞 0
评论 0
@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;
}
NotificationsPreferenceFragment.java 文件源码
项目:PeSanKita-android
阅读 19
收藏 0
点赞 0
评论 0
private void initializeRingtoneSummary(RingtonePreference pref) {
RingtoneSummaryListener listener =
(RingtoneSummaryListener) pref.getOnPreferenceChangeListener();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
listener.onPreferenceChange(pref, sharedPreferences.getString(pref.getKey(), ""));
}
NotificationsPreferenceFragment.java 文件源码
项目:Cable-Android
阅读 19
收藏 0
点赞 0
评论 0
private void initializeRingtoneSummary(RingtonePreference pref) {
RingtoneSummaryListener listener =
(RingtoneSummaryListener) pref.getOnPreferenceChangeListener();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
listener.onPreferenceChange(pref, sharedPreferences.getString(pref.getKey(), ""));
}
SettingsActivity.java 文件源码
项目:droidfan
阅读 24
收藏 0
点赞 0
评论 0
@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);
PushService.cancelPushService(AppContext.getContext());
PushService.setServiceAlarm(AppContext.getContext());
} else if (preference instanceof RingtonePreference) {
if (TextUtils.isEmpty(stringValue)) {
preference.setSummary(R.string.pref_ringtone_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;
}
SettingsActivity.java 文件源码
项目:Android-Audio-Recorder
阅读 25
收藏 0
点赞 0
评论 0
@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.
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;
}
Preferences.java 文件源码
项目:xDrip
阅读 37
收藏 0
点赞 0
评论 0
@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) {
// 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;
}
Preferences.java 文件源码
项目:xDrip-plus
阅读 21
收藏 0
点赞 0
评论 0
@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) {
// 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;
}
RingtonePreferenceSubject.java 文件源码
项目:truth-android
阅读 19
收藏 0
点赞 0
评论 0
public static SubjectFactory<RingtonePreferenceSubject, RingtonePreference> type() {
return new SubjectFactory<RingtonePreferenceSubject, RingtonePreference>() {
@Override
public RingtonePreferenceSubject getSubject(FailureStrategy fs, RingtonePreference that) {
return new RingtonePreferenceSubject(fs, that);
}
};
}
NotificationsPreferenceFragment.java 文件源码
项目:TextSecure
阅读 25
收藏 0
点赞 0
评论 0
private void initializeRingtoneSummary(RingtonePreference pref) {
RingtoneSummaryListener listener =
(RingtoneSummaryListener) pref.getOnPreferenceChangeListener();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
listener.onPreferenceChange(pref, sharedPreferences.getString(pref.getKey(), ""));
}
SettingsFragment.java 文件源码
项目:ClockPlus
阅读 26
收藏 0
点赞 0
评论 0
private void setSummary(SharedPreferences prefs, String key) {
Preference pref = findPreference(key);
// Setting a ListPreference's summary value to "%s" in XML automatically updates the
// preference's summary to display the selected value.
if (pref instanceof RingtonePreference) {
Uri ringtoneUri = Uri.parse(prefs.getString(key, ""));
Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), ringtoneUri);
pref.setSummary(ringtone.getTitle(getActivity()));
}
}
SettingsActivity.java 文件源码
项目:iWorkout
阅读 22
收藏 0
点赞 0
评论 0
@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(R.string.pref_ringtone_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;
}
Preferences.java 文件源码
项目:xDrip-Experimental
阅读 26
收藏 0
点赞 0
评论 0
@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) {
// 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;
}
SettingsFragment.java 文件源码
项目:RBTV-Sendeplan
阅读 30
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
SettingsActivity.java 文件源码
项目:NightWatch
阅读 29
收藏 0
点赞 0
评论 0
@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;
}