Search in sources :

Example 36 with Ringtone

use of android.media.Ringtone in project Memento-Calendar by alexstyl.

the class DailyReminderFragment method updateRingtoneSummaryFor.

private void updateRingtoneSummaryFor(Uri ringtoneUri) {
    String name = null;
    if (ringtoneUri.toString().length() > 0) {
        Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), ringtoneUri);
        if (ringtone != null) {
            name = ringtone.getTitle(getActivity());
        }
    } else {
        name = getString(R.string.no_sound);
    }
    ringtonePreference.setSummary(name);
}
Also used : Ringtone(android.media.Ringtone)

Example 37 with Ringtone

use of android.media.Ringtone in project android_packages_apps_OmniClock by omnirom.

the class SettingsActivity method setTimerAlarmSummary.

private void setTimerAlarmSummary() {
    Uri defaultAlarmNoise = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String soundValue = prefs.getString(KEY_TIMER_ALARM, null);
    Uri soundUri = null;
    if (!mCustomTimerAlarm.isChecked()) {
        soundUri = TextUtils.isEmpty(soundValue) ? defaultAlarmNoise : Uri.parse(soundValue);
    } else {
        // we can have the None alarm tone which is empty
        soundUri = TextUtils.isEmpty(soundValue) ? null : Uri.parse(soundValue);
    }
    final Ringtone tone = soundUri != null ? RingtoneManager.getRingtone(this, soundUri) : null;
    mHandler.post(new Runnable() {

        @Override
        public void run() {
            mTimerAlarmPref.setSummary(tone != null ? tone.getTitle(SettingsActivity.this) : getResources().getString(R.string.ringtone_disabled));
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) Ringtone(android.media.Ringtone) Uri(android.net.Uri)

Example 38 with Ringtone

use of android.media.Ringtone in project xabber-android by redsolution.

the class CustomNotifSettingsFragment method getSoundTitle.

@RequiresApi(api = Build.VERSION_CODES.O)
private String getSoundTitle(NotificationChannel channel) {
    if (channel == null)
        return null;
    Uri uri = channel.getSound();
    Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
    if (ringtone != null)
        return ringtone.getTitle(getActivity());
    else
        return "Unknown ringtone";
}
Also used : Ringtone(android.media.Ringtone) Uri(android.net.Uri) RequiresApi(androidx.annotation.RequiresApi)

Example 39 with Ringtone

use of android.media.Ringtone in project coursera-android by aporter.

the class AudioVideoRingtoneManagerActivity method playRingtone.

// Shut off current Ringtone and play new one
private void playRingtone(int newRingtoneType) {
    Ringtone newRingtone = RingtoneManager.getRingtone(getApplicationContext(), RingtoneManager.getDefaultUri(newRingtoneType));
    if (null != mCurrentRingtone && mCurrentRingtone.isPlaying())
        mCurrentRingtone.stop();
    mCurrentRingtone = newRingtone;
    if (null != newRingtone) {
        mCurrentRingtone.play();
        postStopRingtoneMessage();
    }
}
Also used : Ringtone(android.media.Ringtone)

Example 40 with Ringtone

use of android.media.Ringtone in project weiciyuan by qii.

the class NotificationFragment method buildSummary.

private void buildSummary() {
    if (SettingUtility.getEnableFetchMSG()) {
        String value = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString(SettingActivity.FREQUENCY, "1");
        frequency.setSummary(getActivity().getResources().getStringArray(R.array.frequency)[Integer.valueOf(value) - 1]);
    } else {
        frequency.setSummary(getString(R.string.stopped));
    }
    if (uri != null) {
        Ringtone r = RingtoneManager.getRingtone(getActivity(), uri);
        ringtone.setSummary(r.getTitle(getActivity()));
    } else {
        ringtone.setSummary(getString(R.string.silent));
    }
}
Also used : Ringtone(android.media.Ringtone)

Aggregations

Ringtone (android.media.Ringtone)49 Uri (android.net.Uri)33 ContentResolver (android.content.ContentResolver)8 Intent (android.content.Intent)6 AudioManager (android.media.AudioManager)4 SuppressLint (android.annotation.SuppressLint)2 Context (android.content.Context)2 Cursor (android.database.Cursor)2 SQLiteException (android.database.sqlite.SQLiteException)2 RingtoneManager (android.media.RingtoneManager)2 RingtonePreference (android.preference.RingtonePreference)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 ArrayList (java.util.ArrayList)2 CallNotificationBuilder (org.thoughtcrime.securesms.webrtc.CallNotificationBuilder)2 SharedPreferences (android.content.SharedPreferences)1 Handler (android.os.Handler)1 Vibrator (android.os.Vibrator)1 Preference (android.support.v7.preference.Preference)1