diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2021-02-19 17:30:55 +0300 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2021-02-19 17:31:01 +0300 |
commit | 53da64b7e2af6349c0796acefae0cbcaf7371e53 (patch) | |
tree | 5449423701a4ef4b82982ef754907ffc848482fb | |
parent | ebb38d7d753a57eaf7a68844739bffee47c8649c (diff) |
do not attempt to play 'none' ringtone
trying to play 'none' ringtone resulted in the default ring tone being played
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/NotificationService.java | 21 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 2 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 755895961..c7384b5fb 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -34,6 +34,8 @@ import androidx.core.app.RemoteInput; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.IconCompat; +import com.google.common.base.Strings; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -397,20 +399,25 @@ public class NotificationService { public void startRinging(final AbstractJingleConnection.Id id, final Set<Media> media) { showIncomingCallNotification(id, media); + this.vibrationFuture = SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate( + new VibrationRunnable(), + 0, + 3, + TimeUnit.SECONDS + ); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mXmppConnectionService); final Resources resources = mXmppConnectionService.getResources(); - final Uri uri = Uri.parse(preferences.getString("call_ringtone", resources.getString(R.string.incoming_call_ringtone))); + final String ringtonePreference = preferences.getString("call_ringtone", resources.getString(R.string.incoming_call_ringtone)); + if (Strings.isNullOrEmpty(ringtonePreference)) { + Log.d(Config.LOGTAG,"ringtone has been set to none"); + return; + } + final Uri uri = Uri.parse(ringtonePreference); this.currentlyPlayingRingtone = RingtoneManager.getRingtone(mXmppConnectionService, uri); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { this.currentlyPlayingRingtone.setLooping(true); } this.currentlyPlayingRingtone.play(); - this.vibrationFuture = SCHEDULED_EXECUTOR_SERVICE.scheduleAtFixedRate( - new VibrationRunnable(), - 0, - 3, - TimeUnit.SECONDS - ); } private void showIncomingCallNotification(final AbstractJingleConnection.Id id, final Set<Media> media) { diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 05c6237e4..d1d803688 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -122,7 +122,7 @@ <string name="pref_ringtone">Ringtone</string> <string name="pref_notification_sound">Notification sound</string> <string name="pref_notification_sound_summary">Notification sound for new messages</string> - <string name="pref_call_ringtone_summary">Ringtone for incoming call</string> + <string name="pref_call_ringtone_summary">Ringtone for incoming calls</string> <string name="pref_notification_grace_period">Grace Period</string> <string name="pref_notification_grace_period_summary">The length of time notifications are silenced after detecting activity on one of your other devices.</string> <string name="pref_advanced_options">Advanced</string> |