Skip to content

Commit 1d80a88

Browse files
#CONTUIMSER-40959 Release version updated to V7.13.13
1 parent b5751f0 commit 1d80a88

28 files changed

+782
-261
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ dependencies {
199199
implementation project(':sdk:googletranslation')
200200
implementation project(path: ':call')
201201

202-
implementation 'com.mirrorfly.sdk:mirrorflysdk:7.13.11'
202+
implementation 'com.mirrorfly.sdk:mirrorflysdk:7.13.13'
203203

204204
//Socket - versions.gradle
205205
implementation 'com.github.nkzawa:socket.io-client:0.6.0'

app/src/main/java/com/contusfly/activities/ArchivedChatsActivity.kt

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,19 @@ class ArchivedChatsActivity : BaseActivity(), ActionMode.Callback,
238238
viewModel.groupUserRemovedLiveData.observe(this, { onGroupUpdated() })
239239

240240
viewModel.groupAdminChangedLiveData.observe(this, { onGroupUpdated() })
241+
242+
viewModel.updateChatMute.observe( this, { pair ->
243+
try {
244+
mAdapter.notifyItemChanged(pair.first)
245+
} catch(e: Exception) {
246+
com.mirrorflysdk.flycommons.LogMessage.e(TAG,"#mute #chat adapter update exception $e")
247+
}
248+
})
249+
viewModel.updateSelectedChat.observe(this) {
250+
251+
recentClick(viewModel.selectedChats, false)
252+
253+
}
241254
}
242255

243256
private fun setAndFetchData() {
@@ -413,8 +426,10 @@ class ArchivedChatsActivity : BaseActivity(), ActionMode.Callback,
413426
private fun menuValidationForMuteUnMuteIcon(recentList: List<RecentChat>) {
414427
val checkListForMuteUnMuteIcon = ArrayList<Boolean>()
415428
for (i in recentList.indices)
416-
if (!recentList[i].isBroadCast)
429+
if (!recentList[i].isBroadCast) {
417430
checkListForMuteUnMuteIcon.add(recentList[i].isMuted)
431+
}
432+
418433
if (FlyCore.isArchivedSettingsEnabled()) {
419434
actionModeMenu.findItem(R.id.action_mute).isVisible = false
420435
actionModeMenu.findItem(R.id.action_unmute).isVisible = false
@@ -764,7 +779,7 @@ class ArchivedChatsActivity : BaseActivity(), ActionMode.Callback,
764779
getArchiveChatFor(message.getChatUserJid(), RecentChatEvent.MESSAGE_RECEIVED)
765780
} else {
766781
viewModel.getArchivedChats()
767-
unSelectCountForRestoredChat(message)
782+
unSelectCountForRestoredChat(message.senderUserJid)
768783
}
769784
}
770785

@@ -837,11 +852,12 @@ class ArchivedChatsActivity : BaseActivity(), ActionMode.Callback,
837852
override fun onLeftFromGroup(groupJid: String, leftUserJid: String) {
838853
super.onLeftFromGroup(groupJid, leftUserJid)
839854
onGroupUpdated()
855+
unSelectCountForRestoredChat(groupJid)
840856
}
841857

842-
private fun unSelectCountForRestoredChat(message: ChatMessage) {
858+
private fun unSelectCountForRestoredChat(jid: String) {
843859
if (viewModel.selectedChats.size > 0) {
844-
val index = viewModel.selectedChats?.indexOfFirst { it.jid == message.senderUserJid }
860+
val index = viewModel.selectedChats?.indexOfFirst { it.jid == jid }
845861
if (index.isValidIndex()) {
846862
viewModel.selectedChats?.removeAt(index)
847863
recentClick(viewModel.selectedChats, true)
@@ -879,4 +895,13 @@ class ArchivedChatsActivity : BaseActivity(), ActionMode.Callback,
879895
LogMessage.e(TAG,e.toString())
880896
}
881897
}
898+
899+
override fun onMuteStatusUpdated(isSuccess: Boolean,message: String,jidList: List<String>) {
900+
super.onMuteStatusUpdated(isSuccess,message,jidList)
901+
LogMessage.d("DashboardActivity", "#mute #recentChat update")
902+
viewModel.archiveANDPrivateChatmuteChatStatusUpdate(jidList)
903+
if(viewModel.selectedChats.size > 0) {
904+
viewModel.muteChatStatusUpdateSelectedPrivateAndArchiveChat(jidList)
905+
}
906+
}
882907
}

app/src/main/java/com/contusfly/activities/BaseActivity.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.contusfly.constants.MobileApplication
3333
import com.contusfly.notification.AppNotificationManager
3434
import com.contusfly.showToast
3535
import com.contusfly.utils.*
36+
import com.contusfly.utils.Utils.getUserMuteNotificationStatus
3637
import com.mirrorflysdk.AppUtils
3738
import com.mirrorflysdk.activities.FlyBaseActivity
3839
import com.mirrorflysdk.api.AvailableFeaturesCallback
@@ -530,5 +531,15 @@ open class BaseActivity : FlyBaseActivity() {
530531
startActivity(intent)
531532
}
532533

534+
override fun updateMuteSettings(isSuccess: Boolean,message: String,isMute: Boolean) {
535+
super.updateMuteSettings(isSuccess,message,isMute)
536+
getUserMuteNotificationStatus()
537+
}
538+
539+
override fun onMuteStatusUpdated(isSuccess: Boolean,message: String,jidList: List<String>) {
540+
super.onMuteStatusUpdated(isSuccess,message,jidList)
541+
LogMessage.d(TAG, "#mute #recentChat update")
542+
}
543+
533544

534545
}

app/src/main/java/com/contusfly/activities/DashboardActivity.kt

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class DashboardActivity : DashboardParent(), View.OnClickListener, ActionMode.Ca
7474
LogMessage.d("DashboardActivity", "#dashboard onCreate")
7575
dashboardBinding = ActivityDashboardBinding.inflate(layoutInflater)
7676
setContentView(dashboardBinding.root)
77+
Utils.getUserMuteNotificationStatus()
7778
handler = Handler(Looper.getMainLooper())
7879
setSupportActionBar(dashboardBinding.toolbar)
7980
supportActionBar?.title = Constants.EMPTY_STRING
@@ -142,7 +143,7 @@ class DashboardActivity : DashboardParent(), View.OnClickListener, ActionMode.Ca
142143
* @param message Instance of the Message
143144
*/
144145
override fun onGroupNotificationMessage(message: ChatMessage) {
145-
if((message.messageTextContent.contains("removed you") || message.messageTextContent.contains("added you")) &&
146+
if((message.messageTextContent.contains("removed you") || message.messageTextContent.contains("added you") || message.messageTextContent.contains("You left")) &&
146147
viewModel.selectedRecentChats.isNotEmpty())
147148
recentClick(viewModel.selectedRecentChats, false)
148149
viewModel.getRecentChatOfUser(message.chatUserJid, RecentChatEvent.GROUP_EVENT)
@@ -515,14 +516,18 @@ class DashboardActivity : DashboardParent(), View.OnClickListener, ActionMode.Ca
515516
actionModeMenu.findItem(R.id.action_un_pin).isVisible = recentList[0].isChatPinned
516517
actionModeMenu.findItem(R.id.action_pin).isVisible = !recentList[0].isChatPinned
517518

518-
if (ChatType.TYPE_BROADCAST_CHAT != recentList[0].getChatType()) {
519+
if (recentList[0].isGroup && !GroupManager.isMemberOfGroup(
520+
recentList[0].jid,
521+
SharedPreferenceManager.getCurrentUserJid()
522+
)
523+
) {
524+
hideMenuActionsVisibility()
525+
} else if (ChatType.TYPE_BROADCAST_CHAT != recentList[0].getChatType()) {
519526
actionModeMenu.findItem(R.id.action_unmute).isVisible = recentList[0].isMuted
520527
actionModeMenu.findItem(R.id.action_mute).isVisible = !recentList[0].isMuted
521528
actionModeMenu.findItem(R.id.action_add_chat_shortcuts).isVisible = true
522529
} else {
523-
actionModeMenu.findItem(R.id.action_unmute).isVisible = false
524-
actionModeMenu.findItem(R.id.action_mute).isVisible = false
525-
actionModeMenu.findItem(R.id.action_add_chat_shortcuts).isVisible = false
530+
hideMenuActionsVisibility()
526531
}
527532

528533
actionModeMenu.findItem(R.id.action_mark_as_read).isVisible = recentList[0].isConversationUnRead
@@ -532,6 +537,12 @@ class DashboardActivity : DashboardParent(), View.OnClickListener, ActionMode.Ca
532537

533538
}
534539

540+
private fun hideMenuActionsVisibility(){
541+
actionModeMenu.findItem(R.id.action_unmute).isVisible = false
542+
actionModeMenu.findItem(R.id.action_mute).isVisible = false
543+
actionModeMenu.findItem(R.id.action_add_chat_shortcuts).isVisible = false
544+
}
545+
535546

536547
private fun menuValidationForPinIcon(recentList: List<RecentChat>) {
537548
val checkListForPinIcon = ArrayList<Boolean>()
@@ -576,29 +587,44 @@ class DashboardActivity : DashboardParent(), View.OnClickListener, ActionMode.Ca
576587

577588
private fun menuValidationForMuteUnMuteIcon(recentList: List<RecentChat>) {
578589
val checkListForMuteUnMuteIcon = ArrayList<Boolean>()
590+
val leftgroupList = ArrayList<String>()
579591

580-
for (i in recentList.indices)
592+
for (i in recentList.indices){
581593
if (!recentList[i].isBroadCast)
582594
checkListForMuteUnMuteIcon.add(recentList[i].isMuted)
583595

596+
if(recentList[i].isGroup && !GroupManager.isMemberOfGroup(recentList[i].jid,SharedPreferenceManager.getCurrentUserJid())){
597+
leftgroupList.add(recentList[i].jid)
598+
}
599+
}
600+
584601
when {
585-
checkListForMuteUnMuteIcon.contains(true) -> {
586-
actionModeMenu.findItem(R.id.action_mute).isVisible = false
587-
actionModeMenu.findItem(R.id.action_unmute).isVisible = true
602+
603+
leftgroupList.size > 0 -> {
604+
hideMuteUnMuteIconVisibility()
588605
}
589606

590607
checkListForMuteUnMuteIcon.contains(false) -> {
591608
actionModeMenu.findItem(R.id.action_mute).isVisible = true
592609
actionModeMenu.findItem(R.id.action_unmute).isVisible = false
593610
}
594611

595-
else -> {
612+
checkListForMuteUnMuteIcon.contains(true) -> {
596613
actionModeMenu.findItem(R.id.action_mute).isVisible = false
597-
actionModeMenu.findItem(R.id.action_unmute).isVisible = false
614+
actionModeMenu.findItem(R.id.action_unmute).isVisible = true
615+
}
616+
617+
else -> {
618+
hideMuteUnMuteIconVisibility()
598619
}
599620
}
600621
}
601622

623+
private fun hideMuteUnMuteIconVisibility(){
624+
actionModeMenu.findItem(R.id.action_mute).isVisible = false
625+
actionModeMenu.findItem(R.id.action_unmute).isVisible = false
626+
}
627+
602628
/**
603629
* When a new message is received the recent chat has to be updated and set a view to show the latest message...
604630
*
@@ -662,6 +688,11 @@ class DashboardActivity : DashboardParent(), View.OnClickListener, ActionMode.Ca
662688

663689
}
664690

691+
viewModel.updateSelectedChat.observe(this) {
692+
recentClick(viewModel.selectedRecentChats, false)
693+
}
694+
695+
665696
}
666697

667698
private fun launchArchiveChat() {
@@ -867,6 +898,15 @@ class DashboardActivity : DashboardParent(), View.OnClickListener, ActionMode.Ca
867898
callLogviewModel.uploadUnSyncedCallLogs()
868899
}
869900

901+
override fun onMuteStatusUpdated(isSuccess: Boolean,message: String,jidList: List<String>) {
902+
super.onMuteStatusUpdated(isSuccess,message,jidList)
903+
LogMessage.d("DashboardActivity", "#mute #recentChat update")
904+
viewModel.muteChatStatusUpdate(jidList)
905+
if(viewModel.selectedRecentChats.size > 0) {
906+
viewModel.muteChatStatusUpdateSelectedRecentChat(jidList)
907+
}
908+
}
909+
870910
fun getCurrentVisibleFragment(): Fragment? {
871911
return mAdapter.fragmentsArray[currentFragmentPosition]
872912
}

app/src/main/java/com/contusfly/activities/GroupInfoActivity.kt

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import android.content.pm.PackageManager
88
import android.net.Uri
99
import android.os.Build
1010
import android.os.Bundle
11+
import android.os.Handler
12+
import android.os.Looper
1113
import android.view.Menu
1214
import android.view.MenuItem
1315
import android.view.View
16+
import android.widget.CompoundButton
1417
import androidx.activity.result.ActivityResultLauncher
1518
import androidx.activity.result.contract.ActivityResultContracts
1619
import androidx.appcompat.app.AppCompatActivity
@@ -65,6 +68,7 @@ import java.io.File
6568
import java.io.FileOutputStream
6669
import java.io.IOException
6770
import kotlin.collections.ArrayList
71+
import com.contusfly.utils.Constants.Companion.MUTE_STATUS
6872

6973
class GroupInfoActivity : BaseActivity(),CommonAlertDialog.CommonDialogClosedListener ,DialogInterface.OnClickListener{
7074

@@ -268,9 +272,7 @@ class GroupInfoActivity : BaseActivity(),CommonAlertDialog.CommonDialogClosedLis
268272

269273
private fun initListeners() {
270274
mDialog!!.setOnDialogCloseListener(this)
271-
binding.muteSwitch.setOnCheckedChangeListener { _, isChecked ->
272-
FlyCore.updateChatMuteStatus(groupProfileDetails.jid, isChecked)
273-
}
275+
binding.muteSwitch.setOnCheckedChangeListener(listener)
274276
binding.addParticipant.setOnClickListener {
275277
if (!BuildConfig.CONTACT_SYNC_ENABLED || MediaPermissions.isPermissionAllowed(this, Manifest.permission.READ_CONTACTS)) {
276278
onAddParticipantsClick()
@@ -397,6 +399,8 @@ class GroupInfoActivity : BaseActivity(),CommonAlertDialog.CommonDialogClosedLis
397399
binding.leaveGroup.visibility=View.VISIBLE
398400
binding.leaveGroup.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_leave_group, 0, 0, 0)
399401
binding.leaveGroup.text = getString(R.string.label_leave_group)
402+
binding.muteSwitch.isEnabled = true
403+
binding.muteSwitch.alpha = 1F
400404
}
401405
ChatType.TYPE_GROUP_CHAT == groupProfileDetails.getChatType() -> {
402406
if(!ChatManager.getAvailableFeatures().isDeleteChatEnabled){
@@ -406,6 +410,8 @@ class GroupInfoActivity : BaseActivity(),CommonAlertDialog.CommonDialogClosedLis
406410
binding.leaveGroup.visibility=View.VISIBLE
407411
binding.leaveGroup.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_delete_group, 0, 0, 0)
408412
binding.leaveGroup.text = getString(R.string.label_delete_group)
413+
binding.muteSwitch.isEnabled = false
414+
binding.muteSwitch.alpha = 0.5F
409415
}
410416
else -> {
411417
binding.leaveGroup.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_delete_group, 0, 0, 0)
@@ -884,12 +890,34 @@ class GroupInfoActivity : BaseActivity(),CommonAlertDialog.CommonDialogClosedLis
884890
}
885891
}
886892

887-
private fun setMuteNotificationStatus(isMute: Boolean) {
893+
private fun setMuteNotificationStatus(isMute: Boolean,isReceivedFromServer: Boolean = false) {
894+
com.contusfly.utils.LogMessage.d(MUTE_STATUS,"setMuteNotificationStatus called isReceivedFromServer: $isReceivedFromServer")
888895
if (!FlyCore.isUserUnArchived(groupProfileDetails.jid)) {
889896
binding.muteSwitch.isEnabled = false
890897
binding.muteSwitch.alpha = 0.5F
891898
}
899+
if(isReceivedFromServer) binding.muteSwitch.setOnCheckedChangeListener(null)
892900
binding.muteSwitch.isChecked = isMute
901+
Handler(Looper.getMainLooper()).postDelayed(Runnable {
902+
binding.muteSwitch.setOnCheckedChangeListener(listener)
903+
},500)
904+
}
905+
906+
val listener = object: CompoundButton.OnCheckedChangeListener {
907+
override fun onCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) {
908+
com.contusfly.utils.LogMessage.d(MUTE_STATUS,"onCheckedChanged received isChecked: $isChecked")
909+
var userJidList = mutableListOf<String>()
910+
userJidList.add(groupProfileDetails.jid)
911+
updateMuteStatus(userJidList,isChecked)
912+
}
913+
}
914+
915+
private fun updateMuteStatus(jidList: MutableList<String>, muteStatus: Boolean) {
916+
try {
917+
ChatManager.updateChatMuteStatus(jidList, muteStatus)
918+
} catch(e: Exception) {
919+
LogMessage.e(TAG,"#updateMuteStatus exception $e")
920+
}
893921
}
894922

895923
private fun setUserData() {
@@ -901,9 +929,11 @@ class GroupInfoActivity : BaseActivity(),CommonAlertDialog.CommonDialogClosedLis
901929
binding.subTitle.text = "0 members"
902930
}
903931
setMuteNotificationStatus(groupProfileDetails.isMuted)
904-
if (!isGroupMember) binding.muteSwitch.isEnabled = false
932+
muteButtonEnabeDisable()
905933
}
906934

935+
936+
907937
/**
908938
* Callback for delete group button click
909939
*/
@@ -1570,6 +1600,54 @@ class GroupInfoActivity : BaseActivity(),CommonAlertDialog.CommonDialogClosedLis
15701600
}
15711601
}
15721602

1603+
override fun onMuteStatusUpdated(isSuccess: Boolean,message: String,jidList: List<String>) {
1604+
super.onMuteStatusUpdated(isSuccess,message,jidList)
1605+
com.contusfly.utils.LogMessage.d("DashboardActivity", "#mute #recentChat update")
1606+
muteChatStatusUpdate(jidList)
1607+
}
1608+
1609+
private fun muteChatStatusUpdate(jidList: List<String>) {
1610+
try {
1611+
for(jid in jidList) {
1612+
if(groupProfileDetails.jid == jid) {
1613+
var profile = ProfileDetailsUtils.getProfileDetails(jid)!!
1614+
if(profile != null) {
1615+
groupProfileDetails = profile
1616+
com.contusfly.utils.LogMessage.d(MUTE_STATUS,"muteChatStatusUpdate--> isProfileMuteStatus: ${groupProfileDetails.isMuted} switchButtonStatus: ${binding.muteSwitch.isChecked}")
1617+
if(groupProfileDetails.isMuted != binding.muteSwitch.isChecked)
1618+
setMuteNotificationStatus(groupProfileDetails.isMuted,true)
1619+
}
1620+
break
1621+
}
1622+
}
1623+
1624+
} catch(e: Exception) {
1625+
com.contusfly.utils.LogMessage.e(TAG,"#mute #update exception $e")
1626+
}
1627+
}
1628+
1629+
override fun updateArchiveUnArchiveChats(toUser: String?, archiveStatus: Boolean) {
1630+
muteButtonEnabeDisable()
1631+
}
1632+
1633+
override fun updateArchivedSettings(archivedSettingsStatus: Boolean) {
1634+
super.updateArchivedSettings(archivedSettingsStatus)
1635+
muteButtonEnabeDisable()
1636+
}
1637+
1638+
private fun muteButtonEnabeDisable() {
1639+
try {
1640+
if (!FlyCore.isUserUnArchived(groupProfileDetails.jid) || !isGroupMember ) {
1641+
binding.muteSwitch.isEnabled = false
1642+
binding.muteSwitch.alpha = 0.5F
1643+
} else {
1644+
binding.muteSwitch.isEnabled = true
1645+
binding.muteSwitch.alpha = 1F
1646+
}
1647+
} catch(e: Exception){
1648+
com.contusfly.utils.LogMessage.e(TAG,"updateArchiveUnArchiveChats exception $e")
1649+
}
1650+
}
15731651

15741652
override fun onStart() {
15751653
super.onStart()

0 commit comments

Comments
 (0)