use of android.media.RingtoneManager in project android_packages_apps_OmniClock by omnirom.
the class AlarmRingtoneDialog method cacheAlarmTones.
private void cacheAlarmTones() {
mAlarms = new ArrayList<Uri>();
Cursor alarmsCursor = null;
try {
RingtoneManager ringtoneMgr = new RingtoneManager(getActivity().getApplicationContext());
ringtoneMgr.setType(RingtoneManager.TYPE_ALARM);
alarmsCursor = ringtoneMgr.getCursor();
int alarmsCount = alarmsCursor.getCount();
if (alarmsCount == 0 && !alarmsCursor.moveToFirst()) {
return;
}
while (!alarmsCursor.isAfterLast() && alarmsCursor.moveToNext()) {
int currentPosition = alarmsCursor.getPosition();
mAlarms.add(ringtoneMgr.getRingtoneUri(currentPosition));
}
} finally {
if (alarmsCursor != null) {
alarmsCursor.close();
}
}
}
use of android.media.RingtoneManager in project android_packages_apps_OmniClock by omnirom.
the class BrowseActivity method cacheRingtones.
private void cacheRingtones() {
mRingtones = new ArrayList<QueryItem>();
Cursor alarmsCursor = null;
try {
RingtoneManager ringtoneMgr = new RingtoneManager(this.getApplicationContext());
ringtoneMgr.setType(RingtoneManager.TYPE_RINGTONE);
alarmsCursor = ringtoneMgr.getCursor();
int alarmsCount = alarmsCursor.getCount();
if (alarmsCount == 0 && !alarmsCursor.moveToFirst()) {
return;
}
while (!alarmsCursor.isAfterLast() && alarmsCursor.moveToNext()) {
QueryItem queryItem = new QueryItem();
queryItem.mName = alarmsCursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
queryItem.mUri = getUriFromCursor(alarmsCursor).toString();
queryItem.mIconId = R.drawable.ic_bell;
mRingtones.add(queryItem);
}
} finally {
if (alarmsCursor != null) {
alarmsCursor.close();
}
}
}
use of android.media.RingtoneManager in project android_packages_apps_OmniClock by omnirom.
the class AlarmClockFragment method cacheRingtones.
private void cacheRingtones() {
mRingtones = new ArrayList<Uri>();
Cursor alarmsCursor = null;
try {
RingtoneManager ringtoneMgr = new RingtoneManager(getActivity().getApplicationContext());
ringtoneMgr.setType(RingtoneManager.TYPE_RINGTONE);
alarmsCursor = ringtoneMgr.getCursor();
int alarmsCount = alarmsCursor.getCount();
if (alarmsCount == 0 && !alarmsCursor.moveToFirst()) {
return;
}
while (!alarmsCursor.isAfterLast() && alarmsCursor.moveToNext()) {
int currentPosition = alarmsCursor.getPosition();
mRingtones.add(ringtoneMgr.getRingtoneUri(currentPosition));
}
} finally {
if (alarmsCursor != null) {
alarmsCursor.close();
}
}
}
use of android.media.RingtoneManager in project PhoneProfiles by henrichg.
the class TonesHandler method getToneName.
static String getToneName(Context context, int type, String _uri) {
RingtoneManager manager = new RingtoneManager(context);
manager.setType(type);
Cursor cursor = manager.getCursor();
while (cursor.moveToNext()) {
String id = cursor.getString(RingtoneManager.ID_COLUMN_INDEX);
String uri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX);
String title = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
String uriId = uri + "/" + id;
if (uriId.equals(_uri))
return title;
}
return "";
}
use of android.media.RingtoneManager in project FastHub by k0shk0sh.
the class FileHelper method getNotificationSounds.
public static ArrayList<NotificationSoundModel> getNotificationSounds(Context context, @Nullable String defaultValue) {
ArrayList<NotificationSoundModel> notificationSounds = new ArrayList<>();
RingtoneManager ringtoneManager = new RingtoneManager(context);
ringtoneManager.setType(RingtoneManager.TYPE_NOTIFICATION);
try (Cursor ringsCursor = ringtoneManager.getCursor()) {
while (ringsCursor.moveToNext()) {
String title = ringsCursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
Uri uri = Uri.parse(ringsCursor.getString(RingtoneManager.URI_COLUMN_INDEX) + "/" + ringsCursor.getString(RingtoneManager.ID_COLUMN_INDEX));
boolean selected = defaultValue != null && (uri.toString().contains(defaultValue) || title.equalsIgnoreCase(defaultValue) || defaultValue.contains(title));
Logger.e(defaultValue, title, uri, selected);
notificationSounds.add(new NotificationSoundModel(title, uri, selected));
}
}
return notificationSounds;
}
Aggregations