Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class CallNotificationActivity : CallBaseActivity() {
userBeingCalled = userManager.getUserWithId(internalUserId).blockingGet()

setupCallTypeDescription()
setupCallAnswerButtons()
binding!!.conversationNameTextView.text = displayName
setupAvatar(isOneToOneCall, conversationName)
initClickListeners()
Expand Down Expand Up @@ -110,7 +111,7 @@ class CallNotificationActivity : CallBaseActivity() {
}
}

private fun setupCallTypeDescription() {
private fun hasCallFlagsCapability(): Boolean {
val apiVersion = ApiUtils.getConversationApiVersion(
userBeingCalled!!,
intArrayOf(
Expand All @@ -120,23 +121,25 @@ class CallNotificationActivity : CallBaseActivity() {
)
)

if (apiVersion >= ApiUtils.API_V3) {
val hasCallFlags = hasSpreedFeatureCapability(
userBeingCalled?.capabilities?.spreedCapability!!,
return apiVersion >= ApiUtils.API_V3 &&
hasSpreedFeatureCapability(
userBeingCalled?.capabilities?.spreedCapability,
SpreedFeatures.CONVERSATION_CALL_FLAGS
)
if (hasCallFlags) {
if (isInCallWithVideo(callFlag)) {
binding!!.incomingCallVoiceOrVideoTextView.text = String.format(
resources.getString(R.string.nc_call_video),
resources.getString(R.string.nc_app_product_name)
)
} else {
binding!!.incomingCallVoiceOrVideoTextView.text = String.format(
resources.getString(R.string.nc_call_voice),
resources.getString(R.string.nc_app_product_name)
)
}
}

private fun setupCallTypeDescription() {
if (hasCallFlagsCapability()) {
if (isInCallWithVideo(callFlag)) {
binding!!.incomingCallVoiceOrVideoTextView.text = String.format(
resources.getString(R.string.nc_call_video),
resources.getString(R.string.nc_app_product_name)
)
} else {
binding!!.incomingCallVoiceOrVideoTextView.text = String.format(
resources.getString(R.string.nc_call_voice),
resources.getString(R.string.nc_app_product_name)
)
}
} else {
val callDescriptionWithoutTypeInfo = String.format(
Expand All @@ -147,6 +150,16 @@ class CallNotificationActivity : CallBaseActivity() {
}
}

private fun setupCallAnswerButtons() {
if (hasCallFlagsCapability()) {
if (isInCallWithVideo(callFlag)) {
binding!!.callAnswerVoiceOnlyView.visibility = View.GONE
} else {
binding!!.callAnswerCameraView.visibility = View.GONE
}
}
}

private fun setupNotificationCanceledRoutine() {
val notificationHandler = Handler(Looper.getMainLooper())
notificationHandler.post(object : Runnable {
Expand Down
24 changes: 7 additions & 17 deletions app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,16 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
PendingIntent.FLAG_UPDATE_CURRENT
}

val answerVoiceBundle = Bundle(bundle).apply { putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true) }
val answerVoicePendingIntent = PendingIntent.getActivity(
applicationContext,
requestCode + ANSWER_VOICE_REQUEST_OFFSET,
Intent(applicationContext, CallActivity::class.java).apply {
putExtras(answerVoiceBundle)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
},
pendingIntentFlags
)
val isVideoCall = (conversation.callFlag and Participant.InCallFlags.WITH_VIDEO) > 0

val answerVideoBundle = Bundle(bundle).apply { putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false) }
val answerVideoPendingIntent = PendingIntent.getActivity(
val answerBundle = Bundle(bundle).apply { putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, !isVideoCall) }
val answerPendingIntentOffset =
if (isVideoCall) ANSWER_VIDEO_REQUEST_OFFSET else ANSWER_VOICE_REQUEST_OFFSET
val primaryAnswerIntent = PendingIntent.getActivity(
applicationContext,
requestCode + ANSWER_VIDEO_REQUEST_OFFSET,
requestCode + answerPendingIntentOffset,
Intent(applicationContext, CallActivity::class.java).apply {
putExtras(answerVideoBundle)
putExtras(answerBundle)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
},
pendingIntentFlags
Expand Down Expand Up @@ -363,9 +356,6 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
}
val callerPerson = callerPersonBuilder.build()

val isVideoCall = (conversation.callFlag and Participant.InCallFlags.WITH_VIDEO) > 0
val primaryAnswerIntent = if (isVideoCall) answerVideoPendingIntent else answerVoicePendingIntent

val notification =
NotificationCompat.Builder(applicationContext, notificationChannelId)
.setPriority(NotificationCompat.PRIORITY_HIGH)
Expand Down
Loading