Search in sources :

Example 16 with RingtoneManager

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();
        }
    }
}
Also used : RingtoneManager(android.media.RingtoneManager) Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 17 with RingtoneManager

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();
        }
    }
}
Also used : RingtoneManager(android.media.RingtoneManager) Cursor(android.database.Cursor)

Example 18 with RingtoneManager

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();
        }
    }
}
Also used : RingtoneManager(android.media.RingtoneManager) Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 19 with RingtoneManager

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 "";
}
Also used : RingtoneManager(android.media.RingtoneManager) Cursor(android.database.Cursor)

Example 20 with RingtoneManager

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;
}
Also used : NotificationSoundModel(com.fastaccess.data.dao.NotificationSoundModel) RingtoneManager(android.media.RingtoneManager) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Uri(android.net.Uri)

Aggregations

RingtoneManager (android.media.RingtoneManager)20 Cursor (android.database.Cursor)16 Uri (android.net.Uri)8 ArrayList (java.util.ArrayList)5 View (android.view.View)4 Handler (android.os.Handler)3 SuppressLint (android.annotation.SuppressLint)2 Activity (android.app.Activity)2 Ringtone (android.media.Ringtone)2 Nullable (android.support.annotation.Nullable)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 SoundsAdapter (james.alarmio.adapters.SoundsAdapter)2 SoundData (james.alarmio.data.SoundData)2 IOException (java.io.IOException)2 AlertDialog (org.holoeverywhere.app.AlertDialog)2 Builder (org.holoeverywhere.app.AlertDialog.Builder)2 Intent (android.content.Intent)1