本文整理汇总了Java中android.preference.RingtonePreference类的典型用法代码示例。如果您正苦于以下问题:Java RingtonePreference类的具体用法?Java RingtonePreference怎么用?Java RingtonePreference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RingtonePreference类属于android.preference包,在下文中一共展示了RingtonePreference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.preference.RingtonePreference; //导入依赖的package包/类
@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));
}
示例2: onPreferenceChange
import android.preference.RingtonePreference; //导入依赖的package包/类
@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;
}
示例3: 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);
}
示例4: onCreate
import android.preference.RingtonePreference; //导入依赖的package包/类
@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));
}
示例5: onCreate
import android.preference.RingtonePreference; //导入依赖的package包/类
@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));
}
示例6: onCreate
import android.preference.RingtonePreference; //导入依赖的package包/类
@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));
}
示例7: 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);
}
}
示例8: getRequestCodeViaReflection
import android.preference.RingtonePreference; //导入依赖的package包/类
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;
}
}
示例9: initializeForPrayerTime
import android.preference.RingtonePreference; //导入依赖的package包/类
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));
}
示例10: onCreate
import android.preference.RingtonePreference; //导入依赖的package包/类
@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();
}
示例11: onPreferenceChange
import android.preference.RingtonePreference; //导入依赖的package包/类
@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;
}
示例12: assertThatScreenMatchesExpected
import android.preference.RingtonePreference; //导入依赖的package包/类
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);
}
示例13: onPreferenceChange
import android.preference.RingtonePreference; //导入依赖的package包/类
@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;
}
示例14: onPreferenceChange
import android.preference.RingtonePreference; //导入依赖的package包/类
@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;
}
示例15: onPreferenceChange
import android.preference.RingtonePreference; //导入依赖的package包/类
@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;
}