mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
hangup call notification after 1 minute
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
3bc4c0c983
commit
ec40ca9b66
@ -64,6 +64,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FROM_NOTIFICATION_START_CA
|
|||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences
|
import com.nextcloud.talk.utils.preferences.AppPreferences
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
||||||
|
import io.reactivex.Observable
|
||||||
import io.reactivex.Observer
|
import io.reactivex.Observer
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
@ -78,6 +79,7 @@ import java.net.CookieManager
|
|||||||
import java.security.InvalidKeyException
|
import java.security.InvalidKeyException
|
||||||
import java.security.NoSuchAlgorithmException
|
import java.security.NoSuchAlgorithmException
|
||||||
import java.security.PrivateKey
|
import java.security.PrivateKey
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
import javax.crypto.NoSuchPaddingException
|
import javax.crypto.NoSuchPaddingException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -308,7 +310,7 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
val ncApi = retrofit!!.newBuilder()
|
val ncApi = retrofit!!.newBuilder()
|
||||||
.client(okHttpClient!!.newBuilder().cookieJar(JavaNetCookieJar(CookieManager())).build()).build()
|
.client(okHttpClient!!.newBuilder().cookieJar(JavaNetCookieJar(CookieManager())).build()).build()
|
||||||
.create(NcApi::class.java)
|
.create(NcApi::class.java)
|
||||||
var hasParticipantsInCall = false
|
var hasParticipantsInCall = true
|
||||||
var inCallOnDifferentDevice = false
|
var inCallOnDifferentDevice = false
|
||||||
|
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(
|
val apiVersion = ApiUtils.getConversationApiVersion(
|
||||||
@ -324,8 +326,10 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
decryptedPushMessage.id
|
decryptedPushMessage.id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.takeWhile {
|
.repeatWhen { completed ->
|
||||||
isServiceInForeground
|
completed.zipWith(Observable.range(1, 12), { _, i -> i })
|
||||||
|
.flatMap { Observable.timer(5, TimeUnit.SECONDS) }
|
||||||
|
.takeWhile { isServiceInForeground && hasParticipantsInCall && !inCallOnDifferentDevice }
|
||||||
}
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(object : Observer<ParticipantsOverall> {
|
.subscribe(object : Observer<ParticipantsOverall> {
|
||||||
@ -343,23 +347,17 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasParticipantsInCall || inCallOnDifferentDevice) {
|
if (!hasParticipantsInCall || inCallOnDifferentDevice) {
|
||||||
Log.d(TAG, "no participants in call OR inCallOnDifferentDevice")
|
Log.d(TAG, "no participants in call OR inCallOnDifferentDevice")
|
||||||
stopForeground(true)
|
stopForeground(true)
|
||||||
handler.removeCallbacksAndMessages(null)
|
handler.removeCallbacksAndMessages(null)
|
||||||
} else if (isServiceInForeground) {
|
|
||||||
handler.postDelayed(
|
|
||||||
{
|
|
||||||
checkIfCallIsActive(signatureVerification, decryptedPushMessage)
|
|
||||||
},
|
|
||||||
5000
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {}
|
override fun onError(e: Throwable) {}
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
|
stopForeground(true)
|
||||||
|
handler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user