Skip to content

Commit 2fd7514

Browse files
new SDK version updated to 7.13.22
1 parent 3ea45d0 commit 2fd7514

File tree

159 files changed

+3676
-2389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+3676
-2389
lines changed

app/src/main/java/com/contusfly/AppExtensions.kt

Lines changed: 95 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ import androidx.annotation.StringRes
2828
import androidx.appcompat.app.AppCompatActivity
2929
import androidx.appcompat.widget.AppCompatImageView
3030
import androidx.core.content.ContextCompat
31+
import com.contusfly.activities.DashboardActivity
3132
import com.mirrorflysdk.flycommons.*
3233
import com.mirrorflysdk.flycall.webrtc.api.CallManager
3334
import com.contusfly.chat.AndroidUtils
3435
import com.contusfly.models.Chat
36+
import com.contusfly.notification.AppNotificationManager
37+
import com.contusfly.notification.NotificationBuilder
3538
import com.contusfly.utils.*
3639
import com.contusfly.utils.Constants
3740
import com.contusfly.utils.SharedPreferenceManager.getCurrentUserJid
@@ -46,6 +49,7 @@ import com.mirrorflysdk.api.contacts.ProfileDetails
4649
import com.mirrorflysdk.api.models.ChatMessage
4750
import com.mirrorflysdk.api.models.RecentChat
4851
import com.mirrorflysdk.api.models.ReplyParentChatMessage
52+
import com.mirrorflysdk.flycommons.LogMessage
4953
import com.mirrorflysdk.utils.Utils
5054
import com.mirrorflysdk.views.CustomToast
5155
import java.io.IOException
@@ -258,19 +262,24 @@ val Any.TAG: String
258262

259263
fun AppCompatImageView.loadUserProfileImage(context: Context, recentChat: RecentChat) {
260264
val drawable: Drawable?
265+
261266
var imageUrl = if (!recentChat.profileThumbImage.isNullOrEmpty()) {
262267
recentChat.profileThumbImage
263268
} else recentChat.profileImage ?: Constants.EMPTY_STRING
264-
if (recentChat.isBlockedMe || recentChat.isAdminBlocked) {
265-
imageUrl = Constants.EMPTY_STRING
266-
drawable = CustomDrawable(context).getDefaultDrawable(recentChat)
267-
} else if (recentChat.isDeletedContact()) {
268-
imageUrl = recentChat.profileImage ?: Constants.EMPTY_STRING
269-
drawable = CustomDrawable(context).getDefaultDrawable(recentChat)
270-
} else if (TextUtils.isEmpty(imageUrl) || this.drawable == null)
271-
drawable = CustomDrawable(context).getDefaultDrawable(recentChat)
272-
else
273-
drawable = CustomDrawable(context).getDefaultDrawable(recentChat)
269+
270+
drawable = when {
271+
recentChat.isBlockedMe || recentChat.isAdminBlocked -> {
272+
imageUrl = Constants.EMPTY_STRING
273+
CustomDrawable(context).getDefaultDrawable(recentChat)
274+
}
275+
recentChat.isDeletedContact() -> {
276+
imageUrl = recentChat.profileImage ?: Constants.EMPTY_STRING
277+
CustomDrawable(context).getDefaultDrawable(recentChat)
278+
}
279+
TextUtils.isEmpty(imageUrl) || this.drawable == null -> CustomDrawable(context).getDefaultDrawable(recentChat)
280+
else -> CustomDrawable(context).getDefaultDrawable(recentChat)
281+
}
282+
274283
if (imageUrl.startsWith(Constants.STORAGE))
275284
MediaUtils.loadImageWithGlide(context, imageUrl, this, drawable)
276285
else
@@ -279,19 +288,24 @@ fun AppCompatImageView.loadUserProfileImage(context: Context, recentChat: Recent
279288

280289
fun ImageView.loadUserProfileImage(context: Context, userProfileDetails: ProfileDetails) {
281290
val drawable: Drawable?
282-
var imageUrl = if (!userProfileDetails.thumbImage.isNullOrEmpty()) {
291+
292+
var imageUrl = if (!userProfileDetails.thumbImage.isNullOrEmpty() && !userProfileDetails.image.isNullOrEmpty()) {
283293
userProfileDetails.thumbImage
284294
} else userProfileDetails.image ?: Constants.EMPTY_STRING
285-
if (userProfileDetails.isBlockedMe || userProfileDetails.isAdminBlocked) {
286-
imageUrl = Constants.EMPTY_STRING
287-
drawable = CustomDrawable(context).getDefaultDrawable(userProfileDetails)
288-
} else if (userProfileDetails.isDeletedContact()) {
289-
imageUrl = userProfileDetails.image ?: Constants.EMPTY_STRING
290-
drawable = CustomDrawable(context).getDefaultDrawable(userProfileDetails)
291-
} else if (TextUtils.isEmpty(imageUrl) || this.drawable == null)
292-
drawable = CustomDrawable(context).getDefaultDrawable(userProfileDetails)
293-
else
294-
drawable = CustomDrawable(context).getDefaultDrawable(userProfileDetails)
295+
296+
drawable = when {
297+
userProfileDetails.isBlockedMe || userProfileDetails.isAdminBlocked -> {
298+
imageUrl = Constants.EMPTY_STRING
299+
CustomDrawable(context).getDefaultDrawable(userProfileDetails)
300+
}
301+
userProfileDetails.isDeletedContact() -> {
302+
imageUrl = userProfileDetails.image ?: Constants.EMPTY_STRING
303+
CustomDrawable(context).getDefaultDrawable(userProfileDetails)
304+
}
305+
TextUtils.isEmpty(imageUrl) || this.drawable == null -> CustomDrawable(context).getDefaultDrawable(userProfileDetails)
306+
else -> CustomDrawable(context).getDefaultDrawable(userProfileDetails)
307+
}
308+
295309
if (imageUrl.startsWith(Constants.STORAGE))
296310
MediaUtils.loadImageWithGlide(context, imageUrl, this, drawable)
297311
else
@@ -300,17 +314,23 @@ fun ImageView.loadUserProfileImage(context: Context, userProfileDetails: Profile
300314

301315
fun ImageView.loadUserInfoProfileImage(context: Context, profileDetails: ProfileDetails) {
302316
val drawable: Drawable?
303-
var imageUrl = profileDetails.image ?: Constants.EMPTY_STRING
304-
if (profileDetails.isBlockedMe || profileDetails.isAdminBlocked) {
305-
imageUrl = Constants.EMPTY_STRING
306-
drawable = CustomDrawable(context).getDefaultDrawable(profileDetails)
307-
} else if (profileDetails.isDeletedContact()) {
308-
imageUrl = profileDetails.image ?: Constants.EMPTY_STRING
309-
drawable = CustomDrawable(context).getDefaultDrawable(profileDetails)
310-
} else if (TextUtils.isEmpty(imageUrl) || this.drawable == null)
311-
drawable = CustomDrawable(context).getDefaultDrawable(profileDetails)
312-
else
313-
drawable = CustomDrawable(context).getDefaultDrawable(profileDetails)
317+
var imageUrl = if (!profileDetails.thumbImage.isNullOrEmpty() && !profileDetails.image.isNullOrEmpty()) {
318+
profileDetails.thumbImage
319+
} else profileDetails.image ?: Constants.EMPTY_STRING
320+
321+
drawable = when {
322+
profileDetails.isBlockedMe || profileDetails.isAdminBlocked -> {
323+
imageUrl = Constants.EMPTY_STRING
324+
CustomDrawable(context).getDefaultDrawable(profileDetails)
325+
}
326+
profileDetails.isDeletedContact() -> {
327+
imageUrl = profileDetails.image ?: Constants.EMPTY_STRING
328+
CustomDrawable(context).getDefaultDrawable(profileDetails)
329+
}
330+
TextUtils.isEmpty(imageUrl) || this.drawable == null -> CustomDrawable(context).getDefaultDrawable(profileDetails)
331+
else -> CustomDrawable(context).getDefaultDrawable(profileDetails)
332+
}
333+
314334
if (imageUrl.startsWith(Constants.STORAGE))
315335
MediaUtils.loadImageWithGlide(context, imageUrl, this, drawable)
316336
else {
@@ -529,18 +549,26 @@ fun Chat.getUsername(): String {
529549
return profileDetails?.getDisplayName() ?: toUser
530550
}
531551

532-
fun ProfileDetails.getDisplayName() : String {
533-
return if (BuildConfig.CONTACT_SYNC_ENABLED) {
534-
when {
535-
jid.equals(getCurrentUserJid()) -> Constants.YOU
536-
isUnknownContact() || nickName.isNullOrBlank() -> Utils.getFormattedPhoneNumber(ChatUtils.getUserFromJid(jid))
537-
else -> nickName
552+
fun ProfileDetails.getDisplayName(): String {
553+
try {
554+
return if (BuildConfig.CONTACT_SYNC_ENABLED) {
555+
when {
556+
jid.equals(getCurrentUserJid()) -> Constants.YOU
557+
isUnknownContact() || nickName.isNullOrBlank() -> Utils.getFormattedPhoneNumber(
558+
ChatUtils.getUserFromJid(jid)
559+
)
560+
561+
else -> nickName
562+
}
563+
} else {
564+
if ((name ?: jid).isNotBlank())
565+
name ?: ChatUtils.getUserFromJid(jid)
566+
else
567+
ChatUtils.getUserFromJid(jid)
538568
}
539-
} else {
540-
if ((name ?: jid).isNotBlank())
541-
name ?: ChatUtils.getUserFromJid(jid)
542-
else
543-
ChatUtils.getUserFromJid(jid)
569+
} catch (e: Exception) {
570+
com.contusfly.utils.LogMessage.e(TAG, "Exception in getdisplay name: $e")
571+
return ""
544572
}
545573
}
546574

@@ -758,7 +786,7 @@ fun HashMap<String, Any>.getParams(key: String? = null): Any {
758786

759787
}
760788

761-
fun HashMap<String, Any>.getHttpStatusCode(): Int = if (this.containsKey(FlyConstants.HTTP_STATUS_CODE)) this[FlyConstants.HTTP_STATUS_CODE]!! as Int else 500
789+
fun HashMap<String, Any>.getHttpStatusCode(): Int = if (this.containsKey(FlyConstants.HTTP_STATUS_CODE)) (this[FlyConstants.HTTP_STATUS_CODE]!! as? Int)!! else 500
762790

763791

764792
fun <T> returnEmptyListIfNull(nullableList: List<T>?): List<T> {
@@ -846,4 +874,27 @@ fun View.visibilityChanged(action: (View) -> Unit) {
846874
action(this)
847875
}
848876
}
877+
}
878+
879+
fun checkEqualString(first:String, second:String) : Boolean {
880+
return first.lowercase() == second.lowercase()
881+
}
882+
883+
fun startDashboardActivity(context: Context) {
884+
val dashboardIntent = Intent(context, DashboardActivity::class.java)
885+
dashboardIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
886+
context.startActivity(dashboardIntent)
887+
}
888+
889+
890+
fun clearDeletedGroupChatNotification(groupJid: String, context: Context?){
891+
try {
892+
if (AppNotificationManager.checkGroupHasNotification(groupJid, context!!)) {
893+
val jidList = ArrayList<String>()
894+
jidList.add(groupJid)
895+
NotificationBuilder.clearNotificationTray(jidList, context)
896+
}
897+
} catch (e: Exception) {
898+
LogMessage.e("clearDeletedGroupChatNotification", "Exception in clearDeletedGroupChatNotification: $e")
899+
}
849900
}

app/src/main/java/com/contusfly/EmailContactSyncService.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import android.os.RemoteException
1313
import androidx.core.app.NotificationCompat
1414
import androidx.lifecycle.*
1515
import androidx.localbroadcastmanager.content.LocalBroadcastManager
16-
import com.contusfly.interfaces.ProcessContusContactCallback
1716
import com.contusfly.models.ContusContactSyncTime
1817
import com.contusfly.network.NetworkConnection
1918
import com.contusfly.network.RetrofitClientNetwork
@@ -225,16 +224,14 @@ class EmailContactSyncService : LifecycleService(), LifecycleObserver, Coroutine
225224
when (response.status) {
226225
200 -> {
227226
LogMessage.d(TAG, "#contact #NewContacts getMailContacts success ${response.message}")
228-
ContusContactUtils.processContusContactResponse(response.data, object :
229-
ProcessContusContactCallback {
230-
override fun onProcessContusContactCompleted() {
231-
LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(Intent(Constants.EMAIL_CONTACT_SYNC_COMPLETE))
232-
isEmailContactSyncFailed = false
233-
isEmailSyncInProgress.set(false)
234-
mNotificationManager.cancel(NOTIFICATION_ID)
235-
stopEmailContactService()
236-
}
237-
})
227+
ContusContactUtils.processContusContactResponse(response.data) {
228+
LocalBroadcastManager.getInstance(applicationContext)
229+
.sendBroadcast(Intent(Constants.EMAIL_CONTACT_SYNC_COMPLETE))
230+
isEmailContactSyncFailed = false
231+
isEmailSyncInProgress.set(false)
232+
mNotificationManager.cancel(NOTIFICATION_ID)
233+
stopEmailContactService()
234+
}
238235
}
239236
204 -> {
240237
LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(Intent(Constants.EMAIL_CONTACT_SYNC_COMPLETE))

app/src/main/java/com/contusfly/MyFirebaseMessagingService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ class MyFirebaseMessagingService : FirebaseMessagingService() {
3737
try {
3838
val messageDataString = notificationData["message"]
3939
if (messageDataString != null) {
40-
notificationData = Gson().fromJson<Map<String, String>>(messageDataString, object : TypeToken<Map<String, Any>>() {}.type)
40+
notificationData = Gson().fromJson(messageDataString, object : TypeToken<Map<String, Any>>() {}.type)
4141
if(notificationData.containsKey("android")) {
42-
val dataMap = notificationData["data"] as? Map<String, String>
43-
dataMap?.let { data ->
42+
val getData = notificationData["data"]
43+
val dataMap: Map<String, String> = Gson().fromJson(getData, object : TypeToken<Map<String, String>>() {}.type)?: emptyMap()
44+
dataMap.let { data ->
4445
notificationData = data
4546
}
4647
}

0 commit comments

Comments
 (0)