mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 14:24:05 +01:00
Merge pull request #1634 from nextcloud/feature/noid/timeoutCallNotification
timeout call notification after 1 minute
This commit is contained in:
commit
706573212f
@ -63,7 +63,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys
|
|||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FROM_NOTIFICATION_START_CALL
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FROM_NOTIFICATION_START_CALL
|
||||||
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 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 +78,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 +309,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 +325,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> {
|
||||||
@ -337,29 +340,24 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
|||||||
hasParticipantsInCall = participantList.isNotEmpty()
|
hasParticipantsInCall = participantList.isNotEmpty()
|
||||||
if (hasParticipantsInCall) {
|
if (hasParticipantsInCall) {
|
||||||
for (participant in participantList) {
|
for (participant in participantList) {
|
||||||
if (participant.userId == signatureVerification.userEntity.userId) {
|
if (participant.actorId == signatureVerification.userEntity.userId &&
|
||||||
|
participant.actorType == Participant.ActorType.USERS) {
|
||||||
inCallOnDifferentDevice = true
|
inCallOnDifferentDevice = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ import org.parceler.Parcels;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import autodagger.AutoInjector;
|
import autodagger.AutoInjector;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
@ -217,7 +219,9 @@ public class CallNotificationActivity extends CallBaseActivity {
|
|||||||
ncApi.getPeersForCall(credentials, ApiUtils.getUrlForCall(apiVersion, userBeingCalled.getBaseUrl(),
|
ncApi.getPeersForCall(credentials, ApiUtils.getUrlForCall(apiVersion, userBeingCalled.getBaseUrl(),
|
||||||
currentConversation.getToken()))
|
currentConversation.getToken()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.takeWhile(observable -> !leavingScreen)
|
.repeatWhen(completed -> completed.zipWith(Observable.range(1, 12), (n, i) -> i)
|
||||||
|
.flatMap(retryCount -> Observable.timer(5, TimeUnit.SECONDS))
|
||||||
|
.takeWhile(observable -> !leavingScreen))
|
||||||
.subscribe(new Observer<ParticipantsOverall>() {
|
.subscribe(new Observer<ParticipantsOverall>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(Disposable d) {
|
||||||
@ -253,9 +257,7 @@ public class CallNotificationActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
if (!leavingScreen) {
|
runOnUiThread(() -> hangup());
|
||||||
handler.postDelayed(() -> checkIfAnyParticipantsRemainInRoom(), 5000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ class ChatController(args: Bundle) :
|
|||||||
this.sharedText = args.getString(BundleKeys.KEY_SHARED_TEXT, "")
|
this.sharedText = args.getString(BundleKeys.KEY_SHARED_TEXT, "")
|
||||||
|
|
||||||
Log.d(TAG, " roomToken = $roomToken")
|
Log.d(TAG, " roomToken = $roomToken")
|
||||||
if (roomToken.isNullOrEmpty()){
|
if (roomToken.isNullOrEmpty()) {
|
||||||
Log.d(TAG, " roomToken was null or empty!")
|
Log.d(TAG, " roomToken was null or empty!")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +322,10 @@ class ChatController(args: Bundle) :
|
|||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onNext(roomOverall: RoomOverall) {
|
override fun onNext(roomOverall: RoomOverall) {
|
||||||
currentConversation = roomOverall.ocs.data
|
currentConversation = roomOverall.ocs.data
|
||||||
Log.d(TAG, "getRoomInfo. token: " + currentConversation?.getToken() + " sessionId: " + currentConversation?.sessionId)
|
Log.d(
|
||||||
|
TAG, "getRoomInfo. token: " + currentConversation?.getToken() +
|
||||||
|
" sessionId: " + currentConversation?.sessionId
|
||||||
|
)
|
||||||
loadAvatarForStatusBar()
|
loadAvatarForStatusBar()
|
||||||
|
|
||||||
setTitle()
|
setTitle()
|
||||||
@ -1627,9 +1630,10 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
private fun joinRoomWithPassword() {
|
private fun joinRoomWithPassword() {
|
||||||
|
|
||||||
if (currentConversation == null
|
if (currentConversation == null ||
|
||||||
|| TextUtils.isEmpty(currentConversation?.sessionId)
|
TextUtils.isEmpty(currentConversation?.sessionId) ||
|
||||||
|| currentConversation?.sessionId == "0") {
|
currentConversation?.sessionId == "0"
|
||||||
|
) {
|
||||||
var apiVersion = 1
|
var apiVersion = 1
|
||||||
// FIXME Fix API checking with guests?
|
// FIXME Fix API checking with guests?
|
||||||
if (conversationUser != null) {
|
if (conversationUser != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user