mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-19 10:45:13 +01:00
parent
4f87607aa7
commit
a79a8733a6
@ -59,6 +59,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.controllers.base.BaseController
|
||||
import com.nextcloud.talk.events.ConfigurationChangeEvent
|
||||
import com.nextcloud.talk.models.RingtoneSettings
|
||||
import com.nextcloud.talk.models.database.ArbitraryStorageEntity
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
import com.nextcloud.talk.models.json.conversations.RoomsOverall
|
||||
@ -67,6 +68,7 @@ import com.nextcloud.talk.models.json.participants.ParticipantsOverall
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DoNotDisturbUtils
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import com.nextcloud.talk.utils.database.arbitrarystorage.ArbitraryStorageUtils
|
||||
import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder
|
||||
import com.uber.autodispose.AutoDispose
|
||||
import io.reactivex.Observer
|
||||
@ -89,6 +91,10 @@ class CallNotificationController(private val originalBundle: Bundle) : BaseContr
|
||||
@Inject
|
||||
internal var ncApi: NcApi? = null
|
||||
|
||||
@JvmField
|
||||
@Inject
|
||||
internal var arbitraryStorageUtils: ArbitraryStorageUtils? = null
|
||||
|
||||
@JvmField
|
||||
@BindView(R.id.conversationNameTextView)
|
||||
var conversationNameTextView: TextView? = null
|
||||
@ -289,7 +295,18 @@ class CallNotificationController(private val originalBundle: Bundle) : BaseContr
|
||||
runAllThings()
|
||||
}
|
||||
|
||||
if (DoNotDisturbUtils.shouldPlaySound()) {
|
||||
var importantConversation = false
|
||||
val arbitraryStorageEntity: ArbitraryStorageEntity? = arbitraryStorageUtils!!.getStorageSetting(
|
||||
userBeingCalled!!.id,
|
||||
"important_conversation",
|
||||
currentConversation!!.token
|
||||
)
|
||||
|
||||
if (arbitraryStorageEntity != null) {
|
||||
importantConversation = arbitraryStorageEntity.value!!.toBoolean()
|
||||
}
|
||||
|
||||
if (DoNotDisturbUtils.shouldPlaySound(importantConversation)) {
|
||||
val callRingtonePreferenceString = appPreferences.callRingtoneUri
|
||||
var ringtoneUri: Uri?
|
||||
|
||||
|
@ -563,7 +563,7 @@ class NotificationWorker(
|
||||
} else {
|
||||
try {
|
||||
val ringtoneSettings: RingtoneSettings =
|
||||
LoganSquare.parse<RingtoneSettings>(
|
||||
LoganSquare.parse(
|
||||
ringtonePreferencesString, RingtoneSettings::class.java
|
||||
)
|
||||
ringtoneSettings.ringtoneUri
|
||||
@ -574,8 +574,9 @@ class NotificationWorker(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (soundUri != null && !ApplicationWideCurrentRoomHolder.getInstance().isInCall &&
|
||||
(shouldPlaySound() || importantConversation)
|
||||
(shouldPlaySound(importantConversation))
|
||||
) {
|
||||
val audioAttributesBuilder: AudioAttributes.Builder =
|
||||
AudioAttributes.Builder()
|
||||
@ -602,10 +603,7 @@ class NotificationWorker(
|
||||
Log.e(TAG, "Failed to set data source")
|
||||
}
|
||||
}
|
||||
if (shouldVibrate(
|
||||
appPreferences!!.shouldVibrateSetting
|
||||
)
|
||||
|| importantConversation
|
||||
if (shouldVibrate(appPreferences!!.shouldVibrateSetting)
|
||||
) {
|
||||
val vibrator =
|
||||
context!!.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
||||
|
@ -62,7 +62,7 @@ object DoNotDisturbUtils {
|
||||
return false
|
||||
}
|
||||
|
||||
fun shouldPlaySound(): Boolean {
|
||||
fun shouldPlaySound(importantConversation: Boolean): Boolean {
|
||||
val context = NextcloudTalkApplication.sharedApplication?.applicationContext
|
||||
|
||||
val notificationManager =
|
||||
@ -82,6 +82,14 @@ object DoNotDisturbUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldPlaySound && importantConversation) {
|
||||
shouldPlaySound = true
|
||||
}
|
||||
|
||||
if (audioManager.mode == AudioManager.MODE_IN_CALL) {
|
||||
shouldPlaySound = false
|
||||
}
|
||||
|
||||
return shouldPlaySound
|
||||
}
|
||||
|
||||
@ -92,6 +100,12 @@ object DoNotDisturbUtils {
|
||||
}
|
||||
|
||||
fun shouldVibrate(vibrate: Boolean): Boolean {
|
||||
val context = NextcloudTalkApplication.sharedApplication?.applicationContext
|
||||
val audioManager = context?.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
|
||||
if (audioManager.mode == AudioManager.MODE_IN_CALL) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (hasVibrator()) {
|
||||
val context = NextcloudTalkApplication.sharedApplication?.applicationContext
|
||||
|
Loading…
Reference in New Issue
Block a user