@@ -9,23 +9,26 @@ import android.net.Uri
99import android.os.Build
1010import androidx.core.app.NotificationCompat
1111import androidx.core.content.ContextCompat
12- import com.mirrorflysdk.flycommons.LogMessage
13- import com.mirrorflysdk.flycall.call.utils.CallConstants
14- import com.mirrorflysdk.flycall.webrtc.api.CallLogManager
15- import com.mirrorflysdk.flycommons.PendingIntentHelper
12+ import com.contusfly.BuildConfig
1613import com.contusfly.R
1714import com.contusfly.TAG
1815import com.contusfly.activities.DashboardActivity
1916import com.contusfly.call.groupcall.utils.CallUtils
17+ import com.contusfly.constants.MobileApplication
2018import com.contusfly.emptyString
2119import com.contusfly.getDisplayName
2220import com.contusfly.notification.NotificationBuilder
2321import com.contusfly.utils.Constants
2422import com.contusfly.utils.NotifyRefererUtils
2523import com.contusfly.utils.ProfileDetailsUtils
2624import com.contusfly.utils.SharedPreferenceManager
25+ import com.mirrorflysdk.api.ChatManager
2726import com.mirrorflysdk.api.FlyMessenger
27+ import com.mirrorflysdk.flycall.call.utils.CallConstants
2828import com.mirrorflysdk.flycall.webrtc.CallType
29+ import com.mirrorflysdk.flycall.webrtc.api.CallLogManager
30+ import com.mirrorflysdk.flycommons.LogMessage
31+ import com.mirrorflysdk.flycommons.PendingIntentHelper
2932import java.security.SecureRandom
3033
3134object MissedCallNotificationUtils {
@@ -48,7 +51,7 @@ object MissedCallNotificationUtils {
4851 val bound = 1000
4952 val channelId = randomNumberGenerator.nextInt(bound).toString()
5053 val notificationManager = context
51- .getSystemService(Context .NOTIFICATION_SERVICE ) as NotificationManager
54+ .getSystemService(Context .NOTIFICATION_SERVICE ) as NotificationManager
5255
5356 unReadCallCount + = 1
5457 unReadCallCount = if (NotificationBuilder .chatNotifications.size == 0 ) getTotalUnReadCount() else unReadCallCount
@@ -149,7 +152,58 @@ object MissedCallNotificationUtils {
149152 unReadCallCount = 0
150153 }
151154
152- fun clearMissedCallNotificationDetails (){
155+ fun createMissCallNotification ( isOneToOneCall : Boolean , userJid : String , groupId : String? , callType : String ,
156+ userList : ArrayList <String >){
157+ try {
158+ LogMessage .d(TAG , " onMissedCall" )
159+ missedCallNotificationCount + = 1
160+ addMissedCallNotificationUsers(isOneToOneCall, userJid, groupId,callType)
161+ val notificationContent = getMissedCallNotificationContent(isOneToOneCall, userJid, groupId, callType, userList)
162+ if (missedCallNotificationCount > 1 ) {
163+ createNotification(
164+ MobileApplication .getContext(),
165+ " $missedCallNotificationCount $missedCallNotificationCallType " , // Title Missed call Notification
166+ missedCallNotificationUserNames // Message Content Missed call from whom
167+ )
168+ } else {
169+ createNotification(
170+ MobileApplication .getContext(),
171+ notificationContent.first, // Title Missed call Notification
172+ notificationContent.second // Message Content Missed call from whom
173+ )
174+ }
175+ } catch (e: Exception ){
176+ LogMessage .e(TAG ,e.toString())
177+ }
178+ }
179+
180+ private fun getMissedCallNotificationContent (isOneToOneCall : Boolean , userJid : String , groupId : String? , callType : String ,
181+ userList : ArrayList <String >): Pair <String , String > {
182+ var messageContent : String
183+ val missedCallMessage = StringBuilder ()
184+ missedCallMessage.append(ChatManager .applicationContext.resources.getString(R .string.you_missed_call))
185+ if (isOneToOneCall && groupId.isNullOrEmpty()) {
186+ if (callType == CallType .AUDIO_CALL ) {
187+ missedCallMessage.append(" an " )
188+ } else {
189+ missedCallMessage.append(" a " )
190+ }
191+ missedCallMessage.append(callType).append(" call" )
192+ messageContent = ProfileDetailsUtils .getProfileDetails(userJid)?.getDisplayName()!!
193+ } else {
194+ missedCallMessage.append(" a group " ).append(callType).append(" call" )
195+ messageContent = if (! groupId.isNullOrBlank()) {
196+ ProfileDetailsUtils .getProfileDetails(groupId)?.getDisplayName()!!
197+ } else {
198+ CallUtils .getCallUsersName(userList).toString()
199+ }
200+ }
201+ if (BuildConfig .HIPAA_COMPLIANCE_ENABLED )
202+ messageContent = ChatManager .applicationContext.resources.getString(R .string.new_missed_call)
203+ return Pair (missedCallMessage.toString(), messageContent)
204+ }
205+
206+ fun clearMissedCallNotificationDetails () {
153207 missedCallNotificationCount = 0
154208 missedCallNotificationUserJidList.clear()
155209 missedCallNotificationUserNames = emptyString()
@@ -158,7 +212,6 @@ object MissedCallNotificationUtils {
158212 }
159213
160214 fun addMissedCallNotificationUsers (isOneToOneCall : Boolean , userJid : String , groupId : String? , callType : String ) {
161- missedCallNotificationCount + = 1
162215 if (! missedCallTypeList.contains(callType))
163216 missedCallTypeList.add(callType)
164217 if (isOneToOneCall) {
0 commit comments