Skip to content

Commit

Permalink
Rename notification methods and params (breaking changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
liviu-timar committed Jan 24, 2025
1 parent badeb7c commit 5dfcdbc
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions stream-video-android-core/api/stream-video-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -4428,14 +4428,14 @@ public class io/getstream/video/android/core/notifications/DefaultNotificationHa
public fun isInForeground ()Z
public fun maybeCreateChannel (Ljava/lang/String;Landroid/content/Context;Lkotlin/jvm/functions/Function1;)V
public static synthetic fun maybeCreateChannel$default (Lio/getstream/video/android/core/notifications/DefaultNotificationHandler;Ljava/lang/String;Landroid/content/Context;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
public fun onIncomingCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public fun onLiveCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public fun onMissedCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public fun onNotification (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public fun onPermissionDenied ()V
public fun onPermissionGranted ()V
public fun onPermissionRationale ()V
public fun onPermissionRequested ()V
public fun onRingingCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public fun showLiveCallNotification (Landroid/app/PendingIntent;Ljava/lang/String;I)V
public fun showMissedCallNotification (Landroid/app/PendingIntent;Ljava/lang/String;I)V
public fun showNotificationCallNotification (Landroid/app/PendingIntent;Ljava/lang/String;I)V
Expand Down Expand Up @@ -4507,10 +4507,10 @@ public abstract interface class io/getstream/video/android/core/notifications/No
public abstract fun getRingingCallNotification (Lio/getstream/video/android/core/RingingState;Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;Z)Landroid/app/Notification;
public static synthetic fun getRingingCallNotification$default (Lio/getstream/video/android/core/notifications/NotificationHandler;Lio/getstream/video/android/core/RingingState;Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;ZILjava/lang/Object;)Landroid/app/Notification;
public abstract fun getSettingUpCallNotification ()Landroid/app/Notification;
public abstract fun onIncomingCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public abstract fun onLiveCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public abstract fun onMissedCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public abstract fun onNotification (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
public abstract fun onRingingCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)V
}

public final class io/getstream/video/android/core/notifications/NotificationHandler$Companion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ public open class DefaultNotificationHandler(
}
}

override fun onRingingCall(callId: StreamCallId, callDisplayName: String) {
override fun onIncomingCall(callId: StreamCallId, callerName: String) {
logger.d { "[onRingingCall] #ringing; callId: ${callId.id}" }

TelecomCompat.registerCall(
application,
callId = callId,
callDisplayName = callDisplayName,
callInfo = callerName,
isIncomingCall = true,
)
}

override fun onMissedCall(callId: StreamCallId, callDisplayName: String) {
override fun onMissedCall(callId: StreamCallId, callerName: String) {
logger.d { "[onMissedCall] #ringing; callId: ${callId.id}" }
val notificationId = callId.hashCode()
val intent = intentResolver.searchMissedCallPendingIntent(callId, notificationId)
Expand All @@ -112,15 +112,15 @@ public open class DefaultNotificationHandler(
}
showMissedCallNotification(
intent,
callDisplayName,
callerName,
notificationId,
)
}

override fun getRingingCallNotification(
ringingState: RingingState,
callId: StreamCallId,
callDisplayName: String?,
callInfo: String?,
shouldHaveContentIntent: Boolean,
): Notification? {
return if (ringingState is RingingState.Incoming) {
Expand All @@ -133,7 +133,7 @@ public open class DefaultNotificationHandler(
fullScreenPendingIntent,
acceptCallPendingIntent,
rejectCallPendingIntent,
callDisplayName,
callInfo,
shouldHaveContentIntent,
)
} else {
Expand All @@ -147,7 +147,7 @@ public open class DefaultNotificationHandler(
if (outgoingCallPendingIntent != null && endCallPendingIntent != null) {
getOngoingCallNotification(
callId,
callDisplayName,
callInfo,
isOutgoingCall = true,
)
} else {
Expand Down Expand Up @@ -196,7 +196,7 @@ public open class DefaultNotificationHandler(
fullScreenPendingIntent: PendingIntent,
acceptCallPendingIntent: PendingIntent,
rejectCallPendingIntent: PendingIntent,
callerName: String?,
callInfo: String?,
shouldHaveContentIntent: Boolean,
): Notification {
// if the app is in foreground then don't interrupt the user with a high priority
Expand All @@ -216,7 +216,7 @@ public open class DefaultNotificationHandler(

return getNotification {
priority = NotificationCompat.PRIORITY_HIGH
setContentTitle(callerName)
setContentTitle(callInfo)
setContentText(
application.getString(R.string.stream_video_incoming_call_notification_description),
)
Expand All @@ -236,7 +236,7 @@ public open class DefaultNotificationHandler(
setContentIntent(emptyIntent)
setAutoCancel(false)
}
addCallActions(acceptCallPendingIntent, rejectCallPendingIntent, callerName)
addCallActions(acceptCallPendingIntent, rejectCallPendingIntent, callInfo)
}
}

Expand Down Expand Up @@ -271,33 +271,33 @@ public open class DefaultNotificationHandler(
)
}

override fun onNotification(callId: StreamCallId, callDisplayName: String) {
override fun onNotification(callId: StreamCallId, callCreatorName: String) {
val notificationId = callId.hashCode()
intentResolver.searchNotificationCallPendingIntent(callId, notificationId)
?.let { notificationPendingIntent ->
showNotificationCallNotification(
notificationPendingIntent,
callDisplayName,
callCreatorName,
notificationId,
)
} ?: logger.e { "Couldn't find any activity for $ACTION_NOTIFICATION" }
}

override fun onLiveCall(callId: StreamCallId, callDisplayName: String) {
override fun onLiveCall(callId: StreamCallId, callCreatorName: String) {
val notificationId = callId.hashCode()
intentResolver.searchLiveCallPendingIntent(callId, notificationId)
?.let { liveCallPendingIntent ->
showLiveCallNotification(
liveCallPendingIntent,
callDisplayName,
callCreatorName,
notificationId,
)
} ?: logger.e { "Couldn't find any activity for $ACTION_LIVE_CALL" }
}

override fun getOngoingCallNotification(
callId: StreamCallId,
callDisplayName: String?,
callInfo: String?,
isOutgoingCall: Boolean,
remoteParticipantCount: Int,
): Notification? {
Expand Down Expand Up @@ -359,7 +359,7 @@ public open class DefaultNotificationHandler(
.setOngoing(true)
.addHangUpAction(
hangUpIntent,
callDisplayName ?: application.getString(
callInfo ?: application.getString(
R.string.stream_video_ongoing_call_notification_title,
),
remoteParticipantCount,
Expand Down Expand Up @@ -422,7 +422,7 @@ public open class DefaultNotificationHandler(

getOngoingCallNotification(
callId = StreamCallId.fromCallCid(call.cid),
callDisplayName = callDisplayName,
callInfo = callDisplayName,
isOutgoingCall = true,
remoteParticipantCount = remoteMembersCount,
)?.let {
Expand Down Expand Up @@ -453,7 +453,7 @@ public open class DefaultNotificationHandler(
// Use latest call display name in notification
getOngoingCallNotification(
callId = StreamCallId.fromCallCid(call.cid),
callDisplayName = callDisplayName,
callInfo = callDisplayName,
remoteParticipantCount = remoteParticipants.size,
)?.let {
onUpdate(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,44 @@ public interface NotificationHandler : NotificationPermissionHandler {
/**
* Configures incoming call push notification behavior.
* @param callId An instance of [StreamCallId] representing the call identifier.
* @param callDisplayName The name of the caller.
* @param callerName The name of the caller.
*/
fun onRingingCall(callId: StreamCallId, callDisplayName: String)
fun onIncomingCall(callId: StreamCallId, callerName: String)

/**
* Configures missed call push notification behavior.
* @param callId An instance of [StreamCallId] representing the call identifier.
* @param callDisplayName The name of the caller.
* @param callerName The name of the caller.
*/
fun onMissedCall(callId: StreamCallId, callDisplayName: String)
fun onMissedCall(callId: StreamCallId, callerName: String)

/**
* Configures live started push notification behavior.
* @param callId An instance of [StreamCallId] representing the call identifier.
* @param callDisplayName The name of the call creator.
* @param callCreatorName The name of the call creator.
*/
fun onLiveCall(callId: StreamCallId, callDisplayName: String)
fun onLiveCall(callId: StreamCallId, callCreatorName: String)

/**
* Configures generic push notification behavior.
* @param callId An instance of [StreamCallId] representing the call identifier.
* @param callDisplayName The name of the call creator.
* @param callCreatorName The name of the call creator.
*/
fun onNotification(callId: StreamCallId, callDisplayName: String)
fun onNotification(callId: StreamCallId, callCreatorName: String)

/**
* Customizes the [Notification] to be displayed for incoming and outgoing ringing calls.
* @param ringingState The state of the ringing call, see [RingingState.Incoming] and [RingingState.Outgoing].
* @param callId An instance of [StreamCallId] representing the call identifier.
* @param callDisplayName Call information that can be displayed as the primary content of the notification.
* @param callInfo Call information that can be displayed as the primary content of the notification.
* @param shouldHaveContentIntent If the notification should have a content intent set. Used when the notification is clicked.
*
* @return A nullable [Notification].
*/
fun getRingingCallNotification(
ringingState: RingingState,
callId: StreamCallId,
callDisplayName: String? = null,
callInfo: String? = null,
shouldHaveContentIntent: Boolean = true,
): Notification?

Expand All @@ -75,7 +75,7 @@ public interface NotificationHandler : NotificationPermissionHandler {
* @param fullScreenPendingIntent A high-priority intent that launches an activity in full-screen mode, bypassing the lock screen.
* @param acceptCallPendingIntent The intent triggered when accepting the call from the notification.
* @param rejectCallPendingIntent The intent triggered when rejecting the call from the notification.
* @param callerName Call information that can be displayed as the primary content of the notification.
* @param callInfo Call information that can be displayed as the primary content of the notification.
* @param shouldHaveContentIntent If the notification should have a content intent set. Used when the notification is clicked.
*
* @return A nullable [Notification].
Expand All @@ -84,22 +84,22 @@ public interface NotificationHandler : NotificationPermissionHandler {
fullScreenPendingIntent: PendingIntent,
acceptCallPendingIntent: PendingIntent,
rejectCallPendingIntent: PendingIntent,
callerName: String?,
callInfo: String?,
shouldHaveContentIntent: Boolean,
): Notification?

/**
* Customizes the [Notification] to be displayed for ongoing calls. Outgoing calls are also considered ongoing, see the [isOutgoingCall] parameter.
* @param callId An instance of [StreamCallId] representing the call identifier.
* @param callDisplayName Call information that can be displayed as the primary content of the notification.
* @param callInfo Call information that can be displayed as the primary content of the notification.
* @param isOutgoingCall True if the call is outgoing.
* @param remoteParticipantCount Number of remote participant. Can be used to further customize the notification.
*
* @return A nullable [Notification].
*/
fun getOngoingCallNotification(
callId: StreamCallId,
callDisplayName: String? = null,
callInfo: String? = null,
isOutgoingCall: Boolean = false,
remoteParticipantCount: Int = 0,
): Notification?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@ import io.getstream.video.android.model.User
import kotlinx.coroutines.CoroutineScope

internal object NoOpNotificationHandler : NotificationHandler {
override fun onRingingCall(callId: StreamCallId, callDisplayName: String) { /* NoOp */ }
override fun onMissedCall(callId: StreamCallId, callDisplayName: String) { /* NoOp */ }
override fun onNotification(callId: StreamCallId, callDisplayName: String) { /* NoOp */ }
override fun onLiveCall(callId: StreamCallId, callDisplayName: String) { /* NoOp */ }
override fun onIncomingCall(callId: StreamCallId, callerName: String) { /* NoOp */ }
override fun onMissedCall(callId: StreamCallId, callerName: String) { /* NoOp */ }
override fun onNotification(callId: StreamCallId, callCreatorName: String) { /* NoOp */ }
override fun onLiveCall(callId: StreamCallId, callCreatorName: String) { /* NoOp */ }

override fun getIncomingCallNotification(
fullScreenPendingIntent: PendingIntent,
acceptCallPendingIntent: PendingIntent,
rejectCallPendingIntent: PendingIntent,
callerName: String?,
callInfo: String?,
shouldHaveContentIntent: Boolean,
): Notification? = null

override fun getOngoingCallNotification(
callId: StreamCallId,
callDisplayName: String?,
callInfo: String?,
isOutgoingCall: Boolean,
remoteParticipantCount: Int,
): Notification? = null
override fun getRingingCallNotification(
ringingState: RingingState,
callId: StreamCallId,
callDisplayName: String?,
callInfo: String?,
shouldHaveContentIntent: Boolean,
): Notification? = null
override fun getSettingUpCallNotification(): Notification? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class VideoPushDelegate(

private suspend fun handleRingType(callId: StreamCallId, payload: Map<String, Any?>) {
val callDisplayName = (payload[KEY_CREATED_BY_DISPLAY_NAME] as String).ifEmpty { DEFAULT_CALL_TEXT }
getStreamVideo("ring-type-notification")?.onRingingCall(callId, callDisplayName)
getStreamVideo("ring-type-notification")?.onIncomingCall(callId, callDisplayName)
}

private suspend fun handleMissedType(callId: StreamCallId, payload: Map<String, Any?>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ internal open class CallService : Service() {
TRIGGER_ONGOING_CALL -> Pair(
first = streamVideo.getOngoingCallNotification(
callId = intentCallId,
callDisplayName = intentCallDisplayName,
callInfo = intentCallDisplayName,
),
second = intentCallId.hashCode(),
)
Expand All @@ -289,7 +289,7 @@ internal open class CallService : Service() {
first = streamVideo.getRingingCallNotification(
ringingState = RingingState.Incoming(),
callId = intentCallId,
callDisplayName = intentCallDisplayName,
callInfo = intentCallDisplayName,
shouldHaveContentIntent = streamVideo.state.activeCall.value == null,
),
second = INCOMING_CALL_NOTIFICATION_ID,
Expand All @@ -299,7 +299,7 @@ internal open class CallService : Service() {
first = streamVideo.getRingingCallNotification(
ringingState = RingingState.Outgoing(),
callId = intentCallId,
callDisplayName = getString(
callInfo = getString(
R.string.stream_video_outgoing_call_notification_title,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ internal class TelecomHandler private constructor(
streamVideo.getRingingCallNotification(
ringingState = RingingState.Incoming(),
callId = StreamCallId.fromCallCid(telecomCall.streamCall.cid),
callDisplayName = telecomCall.attributes.displayName.toString(),
callInfo = telecomCall.attributes.displayName.toString(),
shouldHaveContentIntent = streamVideo.state.activeCall.value == null,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal object TelecomCompat {
context: Context,
call: StreamCall? = null,
callId: StreamCallId? = null,
callDisplayName: String = "Unknown",
callInfo: String = "Unknown",
isIncomingCall: Boolean = false,
) {
withCall(call, callId) { streamCall, callConfig ->
Expand All @@ -55,13 +55,13 @@ internal object TelecomCompat {
CallService.showIncomingCall(
context.applicationContext,
StreamCallId.fromCallCid(streamCall.cid),
callDisplayName,
callInfo,
callServiceConfiguration = callConfig,
notification = callId?.let {
getRingingCallNotification(
RingingState.Incoming(),
callId,
callDisplayName,
callInfo,
shouldHaveContentIntent = true,
)
},
Expand Down
Loading

0 comments on commit 5dfcdbc

Please sign in to comment.