@@ -36,6 +36,8 @@ import com.wire.android.notification.broadcastreceivers.StopAudioMessageReceiver
36
36
import com.wire.android.ui.WireActivity
37
37
import com.wire.android.ui.calling.CallActivity.Companion.EXTRA_CONVERSATION_ID
38
38
import com.wire.android.ui.calling.CallActivity.Companion.EXTRA_SCREEN_TYPE
39
+ import com.wire.android.ui.calling.CallActivity.Companion.EXTRA_SHOULD_ANSWER_CALL
40
+ import com.wire.android.ui.calling.CallActivity.Companion.EXTRA_USER_ID
39
41
import com.wire.android.ui.calling.StartingCallActivity
40
42
import com.wire.android.ui.calling.StartingCallScreenType
41
43
import com.wire.android.ui.calling.getIncomingCallIntent
@@ -80,10 +82,6 @@ fun otherUserProfilePendingIntent(context: Context, destinationUserId: String, u
80
82
)
81
83
}
82
84
83
- // TODO
84
- fun callMessagePendingIntent (context : Context , conversationId : String , userId : String? ): PendingIntent =
85
- messagePendingIntent(context, conversationId, userId)
86
-
87
85
fun summaryMessagePendingIntent (context : Context ): PendingIntent = openAppPendingIntent(context)
88
86
89
87
fun replyMessagePendingIntent (context : Context , conversationId : String , userId : String? ): PendingIntent = PendingIntent .getBroadcast(
@@ -93,9 +91,13 @@ fun replyMessagePendingIntent(context: Context, conversationId: String, userId:
93
91
PendingIntent .FLAG_MUTABLE
94
92
)
95
93
96
- fun openOngoingCallPendingIntent (context : Context , conversationId : String ): PendingIntent {
97
- val intent = openOngoingCallIntent(context, conversationId)
98
-
94
+ fun openOngoingCallPendingIntent (
95
+ context : Context ,
96
+ conversationId : String ,
97
+ userId : String ,
98
+ shouldAnswerCall : Boolean = false
99
+ ): PendingIntent {
100
+ val intent = ongoingCallIntent(context, conversationId, userId, shouldAnswerCall)
99
101
return PendingIntent .getActivity(
100
102
context.applicationContext,
101
103
OPEN_ONGOING_CALL_REQUEST_CODE ,
@@ -140,21 +142,15 @@ fun answerCallPendingIntent(context: Context, conversationId: String, userId: St
140
142
} != null
141
143
val shouldAnswerCallFromNotificationButton = ! isAlreadyHavingACall &&
142
144
(ContextCompat .checkSelfPermission(context, Manifest .permission.RECORD_AUDIO ) == PackageManager .PERMISSION_GRANTED )
143
- if (shouldAnswerCallFromNotificationButton) {
144
- val intent = IncomingCallActionReceiver .newIntent (
145
+ return if (shouldAnswerCallFromNotificationButton) {
146
+ openOngoingCallPendingIntent (
145
147
context = context,
146
148
conversationId = conversationId,
147
149
userId = userId,
148
- action = IncomingCallActionReceiver .ACTION_ANSWER_CALL
149
- )
150
- return PendingIntent .getBroadcast(
151
- context.applicationContext,
152
- getRequestCode(ANSWER_CALL_REQUEST_CODE , userId, conversationId),
153
- intent,
154
- PendingIntent .FLAG_IMMUTABLE
150
+ shouldAnswerCall = true
155
151
)
156
152
} else {
157
- return fullScreenIncomingCallPendingIntent(context, conversationId, userId)
153
+ fullScreenIncomingCallPendingIntent(context, conversationId, userId)
158
154
}
159
155
}
160
156
@@ -186,10 +182,16 @@ private fun openOutgoingCallIntent(context: Context, conversationId: String) =
186
182
putExtra(EXTRA_SCREEN_TYPE , StartingCallScreenType .Outgoing .name)
187
183
}
188
184
189
- private fun openOngoingCallIntent (context : Context , conversationId : String ) =
190
- Intent (context.applicationContext, OngoingCallActivity ::class .java).apply {
191
- putExtra(EXTRA_CONVERSATION_ID , conversationId)
192
- }
185
+ private fun ongoingCallIntent (
186
+ context : Context ,
187
+ conversationId : String ,
188
+ userId : String ,
189
+ shouldAnswerCall : Boolean
190
+ ) = Intent (context.applicationContext, OngoingCallActivity ::class .java).apply {
191
+ putExtra(EXTRA_CONVERSATION_ID , conversationId)
192
+ putExtra(EXTRA_USER_ID , userId)
193
+ putExtra(EXTRA_SHOULD_ANSWER_CALL , shouldAnswerCall)
194
+ }
193
195
194
196
private fun openMigrationLoginIntent (context : Context , userHandle : String ) =
195
197
Intent (context.applicationContext, WireActivity ::class .java).apply {
@@ -246,7 +248,6 @@ fun stopAudioPendingIntent(context: Context): PendingIntent {
246
248
247
249
private const val MESSAGE_NOTIFICATIONS_SUMMARY_REQUEST_CODE = 0
248
250
private const val DECLINE_CALL_REQUEST_CODE = " decline_call_"
249
- private const val ANSWER_CALL_REQUEST_CODE = " answer_call_"
250
251
private const val FULL_SCREEN_REQUEST_CODE = " incoming_call_"
251
252
private const val OPEN_ONGOING_CALL_REQUEST_CODE = 4
252
253
private const val OPEN_MIGRATION_LOGIN_REQUEST_CODE = 5
0 commit comments