From ca683c2f9304bfc76e597c49ae1a70f60836baaf Mon Sep 17 00:00:00 2001 From: Amose Vasanth S Date: Wed, 16 Aug 2023 12:07:24 +0530 Subject: [PATCH] v5.11.1 release --- .../AuthenticationPINViewController.swift | 64 +- .../FingerPrintPINViewController.swift | 4 +- .../ChangeAppLockViewController.swift | 8 +- .../AppLockPasswordViewController.swift | 12 +- .../SharKitVerifyOtpViewModel.swift | 2 +- .../ShareKitBaseViewController.swift | 5 +- MirrorflyShareKit/ShareKitExtension.swift | 9 +- MirrorflyShareKit/ShareKitUtility.swift | 2 +- MirrorflyShareKit/ShareKitViewModel.swift | 4 +- .../Models/ShareKitContactViewModel.swift | 5 +- .../ShareKitParticipantCell.swift | 4 +- .../SharekitShareToViewController.swift | 14 +- MirrorflyShareKit/ShareViewController.swift | 16 +- MirrorflyUIkit.xcodeproj/project.pbxproj | 101 +- .../xcshareddata/xcschemes/UiKitQ19.xcscheme | 78 ++ .../UiKitQaNotification19Extention.xcscheme | 101 ++ .../privateChat.imageset/Contents.json | 22 + .../privateChat.imageset/Group 34903@2x.png | Bin 0 -> 4110 bytes .../privateChat.imageset/Group 34903@3x.png | Bin 0 -> 7680 bytes .../privateChat_enable.imageset/Contents.json | 22 + .../privateChat_enable.imageset/talk@2x.png | Bin 0 -> 1256 bytes .../privateChat_enable.imageset/talk@3x.png | Bin 0 -> 1873 bytes .../private_down.imageset/Contents.json | 22 + .../private_down.imageset/Group 34899.png | Bin 0 -> 407 bytes .../private_down.imageset/Group 34899@2x.png | Bin 0 -> 717 bytes MirrorflyUIkit/BaseViewController.swift | 15 +- .../Calls/CallLogViewController.swift | 29 +- MirrorflyUIkit/Calls/CallViewController.swift | 114 +- .../Calls/GroupCallViewController.swift | 6 +- .../Calls/JoinCallViaLinkViewController.swift | 41 +- MirrorflyUIkit/Calls/RootViewController.swift | 14 +- .../Chat/ChatViewParentController.swift | 155 ++- .../ReceiverDocumentsTableViewCell.swift | 10 +- .../SenderDocumentsTableViewCell.swift | 7 +- .../Chat/Image Cells/ReceiverImageCell.swift | 2 +- .../ChatViewParentMessageCell.swift | 6 +- .../video/ChatViewVideoIncomingCell.swift | 6 +- .../video/ChatViewVideoOutgoingCell.swift | 2 +- MirrorflyUIkit/Common/AppUtils.swift | 47 +- MirrorflyUIkit/Common/ChatUtils.swift | 8 +- MirrorflyUIkit/Common/Color.swift | 1 + .../Common/Extensions/ViewExtension.swift | 21 + MirrorflyUIkit/Common/Identifiers.swift | 2 + MirrorflyUIkit/Common/StringConstants.swift | 3 + .../Audio/TableCells/AudioReceiver.swift | 2 +- .../Audio/TableCells/AudioSender.swift | 2 +- .../AuthenticationPINViewController.swift | 117 ++- .../FingerPrintPINViewController.swift | 23 +- .../ChangeAppLockViewController.swift | 10 +- .../AutodownloadSelectionViewController.swift | 68 +- .../ChatBackup/BackupViewController.swift | 8 +- .../ChatBackup/RestoreViewController.swift | 2 +- .../ChatSettingsViewController.swift | 46 +- .../SelectedUserCollectionCell.swift | 2 +- .../UserListCell/UserListCell.swift | 2 +- MirrorflyUIkit/Controllers/ContactCell.swift | 2 +- .../Controllers/ContactSyncController.swift | 10 +- .../Controllers/ContactViewController.swift | 74 +- .../Controllers/ContactViewModel.swift | 2 +- MirrorflyUIkit/Controllers/DMAReasonVC.swift | 7 +- .../Controllers/Delegates/AppDelegate.swift | 138 ++- .../Controllers/Delegates/SceneDelegate.swift | 53 +- .../DeleteMyAccount/DMAReasonVC.swift | 1 - .../DeleteMyAccount/DeleteMyAccountVC.swift | 6 +- .../Controllers/DeleteMyAccountVC.swift | 6 +- .../ForwardViewController.swift | 24 +- .../Image/ImageEditController.swift | 12 +- .../LanguageSelectionViewController.swift | 6 +- .../Controllers/MainTabBarController.swift | 124 ++- .../Controllers/OTPViewController.swift | 1 - .../AppLockPasswordViewController.swift | 33 +- .../Profile/ImageViewerViewController.swift | 2 +- .../Profile/View/ProfileViewController.swift | 85 +- .../Profile/ViewModel/ProfileViewModel.swift | 6 +- .../RecentChat/RecentChatViewController.swift | 663 ++++++++++-- .../AppLock/AppLockViewController.swift | 36 +- .../BlockedContactsViewController.swift | 13 +- .../NotificationAlertViewController.swift | 50 +- .../NotificationTonesListViewController.swift | 6 +- .../NotificationsViewController.swift | 2 +- .../Settings/SettingsViewController.swift | 4 +- .../UserProfileViewController.swift | 31 +- .../Controllers/VerifyOTPViewController.swift | 12 +- .../Controllers/VerifyOTPViewModel.swift | 12 +- .../GroupInfoOptionsViewController.swift | 2 +- .../Controller/GroupInfoViewController.swift | 111 +- .../Views/GroupMembersTableViewCell.swift | 27 +- MirrorflyUIkit/Mirrorfly.entitlements | 12 + .../Storyboards/Base.lproj/Main.storyboard | 8 +- .../MentionTextview/MentionTextView.swift | 2 +- .../Utilities/UserDefaults/UserDefaults.swift | 4 +- .../ContactInfoViewController.swift | 94 +- ...eChatAuthenticationPINViewController.swift | 982 ++++++++++++++++++ ...ateChatAuthenticationPINViewController.xib | 373 +++++++ ...vateChatFingerPrintPINViewController.swift | 185 ++++ ...rivateChatFingerPrintPINViewController.xib | 94 ++ .../privateChat/LockScreenController.swift | 29 + .../privateChat/LockScreenController.xib | 49 + .../privateChat/PrivateChatCell.swift | 25 + .../privateChat/PrivateChatCell.xib | 89 ++ .../PrivateChatScreen/Animation.json | 1 + .../PrivateChatEnableController.swift | 220 ++++ .../PrivateChatEnableController.xib | 338 ++++++ .../PrivateChatPopupViewController.swift | 84 ++ .../PrivateChatPopupViewController.xib | 182 ++++ .../GroupCreationPreviewController.swift | 5 +- .../participantCell/ParticipantCell.swift | 4 +- .../iCloudManager/iCloudmanager.swift | 20 +- MirrorflyUIkit/qrCode/QRCodeScanner.swift | 2 +- .../NotificationService.swift | 102 +- Podfile | 10 +- 111 files changed, 4896 insertions(+), 845 deletions(-) create mode 100644 MirrorflyUIkit.xcodeproj/xcshareddata/xcschemes/UiKitQ19.xcscheme create mode 100644 MirrorflyUIkit.xcodeproj/xcshareddata/xcschemes/UiKitQaNotification19Extention.xcscheme create mode 100644 MirrorflyUIkit/Assets.xcassets/privateChat.imageset/Contents.json create mode 100644 MirrorflyUIkit/Assets.xcassets/privateChat.imageset/Group 34903@2x.png create mode 100644 MirrorflyUIkit/Assets.xcassets/privateChat.imageset/Group 34903@3x.png create mode 100644 MirrorflyUIkit/Assets.xcassets/privateChat_enable.imageset/Contents.json create mode 100644 MirrorflyUIkit/Assets.xcassets/privateChat_enable.imageset/talk@2x.png create mode 100644 MirrorflyUIkit/Assets.xcassets/privateChat_enable.imageset/talk@3x.png create mode 100644 MirrorflyUIkit/Assets.xcassets/private_down.imageset/Contents.json create mode 100644 MirrorflyUIkit/Assets.xcassets/private_down.imageset/Group 34899.png create mode 100644 MirrorflyUIkit/Assets.xcassets/private_down.imageset/Group 34899@2x.png create mode 100755 MirrorflyUIkit/Mirrorfly.entitlements create mode 100644 MirrorflyUIkit/contactInfo/privateChat/Authentication/PrivateChatAuthenticationPINViewController.swift create mode 100644 MirrorflyUIkit/contactInfo/privateChat/Authentication/PrivateChatAuthenticationPINViewController.xib create mode 100644 MirrorflyUIkit/contactInfo/privateChat/Authentication/PrivateChatFingerPrintPINViewController.swift create mode 100644 MirrorflyUIkit/contactInfo/privateChat/Authentication/PrivateChatFingerPrintPINViewController.xib create mode 100644 MirrorflyUIkit/contactInfo/privateChat/LockScreenController.swift create mode 100644 MirrorflyUIkit/contactInfo/privateChat/LockScreenController.xib create mode 100644 MirrorflyUIkit/contactInfo/privateChat/PrivateChatCell.swift create mode 100644 MirrorflyUIkit/contactInfo/privateChat/PrivateChatCell.xib create mode 100644 MirrorflyUIkit/contactInfo/privateChat/PrivateChatScreen/Animation.json create mode 100644 MirrorflyUIkit/contactInfo/privateChat/PrivateChatScreen/PrivateChatEnableController.swift create mode 100644 MirrorflyUIkit/contactInfo/privateChat/PrivateChatScreen/PrivateChatEnableController.xib create mode 100644 MirrorflyUIkit/contactInfo/privateChat/privateChatAlert/PrivateChatPopupViewController.swift create mode 100644 MirrorflyUIkit/contactInfo/privateChat/privateChatAlert/PrivateChatPopupViewController.xib diff --git a/MirrorflyShareKit/Authentication PIN/AuthenticationPINViewController.swift b/MirrorflyShareKit/Authentication PIN/AuthenticationPINViewController.swift index 2474748..06f4c79 100644 --- a/MirrorflyShareKit/Authentication PIN/AuthenticationPINViewController.swift +++ b/MirrorflyShareKit/Authentication PIN/AuthenticationPINViewController.swift @@ -155,7 +155,7 @@ class AuthenticationPINViewController: ShareKitBaseViewController, UITextFieldDe } func showChangePinAlert() { - FlyDefaults.pinChangeAlertShownDate = Date().xmppDateString + CommonDefaults.pinChangeAlertShownDate = Date().xmppDateString let values : [String] = ["Change PIN", "OK"] var actions = [(String, UIAlertAction.Style)]() @@ -163,7 +163,7 @@ class AuthenticationPINViewController: ShareKitBaseViewController, UITextFieldDe actions.append((title, UIAlertAction.Style.default)) } - ShareKitActionSheet.shared.showActionSeet(view: self, title : "", message: "Your PIN will be expired in \(31 - daysBetween(start: FlyDefaults.appLockPasswordDate, end: Date())) day(s)", showCancel: false, actions: actions, style: .alert, sheetCallBack: { [weak self] didCancelTap, tappedTitle in + ShareKitActionSheet.shared.showActionSeet(view: self, title : "", message: "Your PIN will be expired in \(31 - daysBetween(start: CommonDefaults.appLockPasswordDate, end: Date())) day(s)", showCancel: false, actions: actions, style: .alert, sheetCallBack: { [weak self] didCancelTap, tappedTitle in if !didCancelTap { switch tappedTitle { case "Change PIN": @@ -246,7 +246,7 @@ class AuthenticationPINViewController: ShareKitBaseViewController, UITextFieldDe txtSixth.delegate = self verifyOTPViewModel = ShareVerifyOTPViewModel() otpViewModel = ShareOTPViewModel() - phoneNumber = FlyDefaults.myMobileNumber + phoneNumber = ContactManager.getMyProfile().mobileNumber self.collectionview.register(UINib(nibName:Identifiers.authenticationPINCollectionViewCell, bundle: .main), forCellWithReuseIdentifier:Identifiers.authenticationPINCollectionViewCell) @@ -439,69 +439,69 @@ class AuthenticationPINViewController: ShareKitBaseViewController, UITextFieldDe //PIN VALIDATION func validateAppPIN() { - if FlyDefaults.passwordAuthenticationAttemps > 4 { + if CommonDefaults.passwordAuthenticationAttemps > 4 { showfailedAttempsActionAlert() } - if pinInput == FlyDefaults.appLockPassword { + if pinInput == CommonDefaults.appLockPassword { if isResetByFailedAttempts { // if FlyDefaults.showAppLock { // self.navigationController?.popToRootViewController(animated: false) // } else { // self.navigationController?.popViewController(animated: true) // } - FlyDefaults.showAppLock = false - FlyDefaults.faceOrFingerAuthenticationFails = false + CommonDefaults.showAppLock = false + CommonDefaults.faceOrFingerAuthenticationFails = false } else if isDisablePin { - FlyDefaults.appLockenable = false - FlyDefaults.appFingerprintenable = false - if FlyDefaults.showAppLock { + CommonDefaults.appLockenable = false + CommonDefaults.appFingerprintenable = false + if CommonDefaults.showAppLock { self.navigationController?.popToRootViewController(animated: false) } else { self.navigationController?.popViewController(animated: true) } - FlyDefaults.showAppLock = false - FlyDefaults.faceOrFingerAuthenticationFails = false + CommonDefaults.showAppLock = false + CommonDefaults.faceOrFingerAuthenticationFails = false } else { if login == true { - FlyDefaults.appLockenable = true + CommonDefaults.appLockenable = true } else if logout == true{ - FlyDefaults.appLockenable = false + CommonDefaults.appLockenable = false requestLogout() } - else if FlyDefaults.appLockenable == true { + else if CommonDefaults.appLockenable == true { if disableBothPIN == true { - FlyDefaults.appLockenable = false - FlyDefaults.appFingerprintenable = false + CommonDefaults.appLockenable = false + CommonDefaults.appFingerprintenable = false } else if fingerPrintEnable == true{ - FlyDefaults.appFingerprintenable = true - FlyDefaults.appLockenable = true + CommonDefaults.appFingerprintenable = true + CommonDefaults.appLockenable = true } } - if FlyDefaults.appFingerprintenable == true && FlyDefaults.appLockenable == true { + if CommonDefaults.appFingerprintenable == true && CommonDefaults.appLockenable == true { if fingerPrintLogin == true { - FlyDefaults.appFingerprintenable = true - FlyDefaults.appLockenable = true + CommonDefaults.appFingerprintenable = true + CommonDefaults.appLockenable = true } else if fingerPrintLogout == true { - FlyDefaults.appFingerprintenable = false + CommonDefaults.appFingerprintenable = false } } if fingerPrintLogin || noFingerprintAdded{ if noFingerprintAdded == true{ - FlyDefaults.appFingerprintenable = false + CommonDefaults.appFingerprintenable = false } - FlyDefaults.showAppLock = false - FlyDefaults.faceOrFingerAuthenticationFails = false + CommonDefaults.showAppLock = false + CommonDefaults.faceOrFingerAuthenticationFails = false let initialViewController = SharekitShareToViewController(nibName: "SharekitShareToViewController", bundle: nil) self.navigationController?.setNavigationBarHidden(true, animated: true) self.navigationController?.pushViewController(initialViewController, animated: false) } else { - FlyDefaults.showAppLock = false - FlyDefaults.faceOrFingerAuthenticationFails = false + CommonDefaults.showAppLock = false + CommonDefaults.faceOrFingerAuthenticationFails = false let initialViewController = SharekitShareToViewController(nibName: "SharekitShareToViewController", bundle: nil) self.navigationController?.setNavigationBarHidden(true, animated: true) self.navigationController?.pushViewController(initialViewController, animated: false) @@ -523,7 +523,7 @@ class AuthenticationPINViewController: ShareKitBaseViewController, UITextFieldDe } func forgotPassword() { - phoneNumber = "+"+FlyDefaults.myMobileNumber + phoneNumber = "+" + ContactManager.getMyProfile().mobileNumber if NetworkReachability.shared.isConnected { startLoading(view: self, withText: pleaseWait) //Request SMS @@ -601,7 +601,9 @@ extension AuthenticationPINViewController: UICollectionViewDelegate,UICollection cell.passwordImage.image = UIImage(named: ImageConstant.otpPin) } if (pinInput.count == 4 && indexPath.item == 3){ - validateAppPIN() + DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { [weak self] in + self?.validateAppPIN() + } } return cell @@ -623,7 +625,7 @@ extension AuthenticationPINViewController: UICollectionViewDelegate,UICollection print(array[indexPath.row]) if indexPath.row != 11 && indexPath.row != 9{ let text = array[indexPath.row] - if (pinInput.count <= 4) { + if (pinInput.count < 4) { pinInput.append(text) } print("pinInput",pinInput) diff --git a/MirrorflyShareKit/Authentication PIN/FingerPrint PIN/FingerPrintPINViewController.swift b/MirrorflyShareKit/Authentication PIN/FingerPrint PIN/FingerPrintPINViewController.swift index 3fd3367..a967b41 100644 --- a/MirrorflyShareKit/Authentication PIN/FingerPrint PIN/FingerPrintPINViewController.swift +++ b/MirrorflyShareKit/Authentication PIN/FingerPrint PIN/FingerPrintPINViewController.swift @@ -39,7 +39,7 @@ class FingerPrintPINViewController: ShareKitBaseViewController { print("\(TAG) #### evaluatePolicy \(success) \(authenticationError.debugDescription)") DispatchQueue.main.async { if success { - FlyDefaults.showAppLock = false + CommonDefaults.showAppLock = false let initialViewController = SharekitShareToViewController(nibName: "SharekitShareToViewController", bundle: nil) self?.navigationController?.setNavigationBarHidden(true, animated: true) self?.navigationController?.pushViewController(initialViewController, animated: false) @@ -63,7 +63,7 @@ class FingerPrintPINViewController: ShareKitBaseViewController { switch errorCode { case LAError.authenticationFailed.rawValue: navigateToAuthentication() - FlyDefaults.faceOrFingerAuthenticationFails = true + CommonDefaults.faceOrFingerAuthenticationFails = true case LAError.userCancel.rawValue: navigateToAuthentication() case LAError.userFallback.rawValue: diff --git a/MirrorflyShareKit/Change Password View Controller/ChangeAppLockViewController.swift b/MirrorflyShareKit/Change Password View Controller/ChangeAppLockViewController.swift index ddf3d7f..863949d 100644 --- a/MirrorflyShareKit/Change Password View Controller/ChangeAppLockViewController.swift +++ b/MirrorflyShareKit/Change Password View Controller/ChangeAppLockViewController.swift @@ -80,9 +80,9 @@ class ChangeAppLockViewController: UIViewController, UITextFieldDelegate { if changePassword() == false { return } - if enterOldPassword.text == FlyDefaults.appLockPassword && enterNewPassword.text == confirmNewPassword.text{ - FlyDefaults.appLockPassword = confirmNewPassword.text ?? "" - FlyDefaults.appLockPasswordDate = Date() + if enterOldPassword.text == CommonDefaults.appLockPassword && enterNewPassword.text == confirmNewPassword.text{ + CommonDefaults.appLockPassword = confirmNewPassword.text ?? "" + CommonDefaults.appLockPasswordDate = Date() print(confirmNewPassword.text ?? "") ShareKitAlert.shared.showToast(controller: self, message: SuccessMessage.PINsetsuccessfully) } @@ -139,7 +139,7 @@ class ChangeAppLockViewController: UIViewController, UITextFieldDelegate { ShareKitAlert.shared.showToast(controller: self, message: ErrorMessage.enterValidPIN) return false } - if enterOldPassword.text != FlyDefaults.appLockPassword{ + if enterOldPassword.text != CommonDefaults.appLockPassword{ ShareKitAlert.shared.showToast(controller: self, message: ErrorMessage.invalidOLDPIN) return false } diff --git a/MirrorflyShareKit/Password View Controller/AppLockPasswordViewController.swift b/MirrorflyShareKit/Password View Controller/AppLockPasswordViewController.swift index 3cb6c8d..b520af9 100644 --- a/MirrorflyShareKit/Password View Controller/AppLockPasswordViewController.swift +++ b/MirrorflyShareKit/Password View Controller/AppLockPasswordViewController.swift @@ -66,12 +66,12 @@ class AppLockPasswordViewController: UIViewController, UITextFieldDelegate { else if enterNewPassword.text ?? "" == confirmNewPassword.text ?? "" { print("saved") if fingerPINisOn == true{ - FlyDefaults.appFingerprintenable = true + CommonDefaults.appFingerprintenable = true } - FlyDefaults.appLockenable = true - FlyDefaults.appLockPassword = confirmNewPassword.text ?? "" - FlyDefaults.appLockPasswordDate = Date() - FlyDefaults.passwordAuthenticationAttemps = 0 + CommonDefaults.appLockenable = true + CommonDefaults.appLockPassword = confirmNewPassword.text ?? "" + CommonDefaults.appLockPasswordDate = Date() + CommonDefaults.passwordAuthenticationAttemps = 0 ShareKitAlert.shared.showToast(controller: self, message: SuccessMessage.PINsetsuccessfully) self.navigationController?.popViewController(animated: true) } @@ -93,7 +93,7 @@ class AppLockPasswordViewController: UIViewController, UITextFieldDelegate { ShareKitAlert.shared.showToast(controller: self, message: ErrorMessage.passwordShouldbeSame) return false } - else if enterNewPassword.text == FlyDefaults.appLockPassword { + else if enterNewPassword.text == CommonDefaults.appLockPassword { ShareKitAlert.shared.showToast(controller: self, message: ErrorMessage.oldPINnewPINsholdnotSame) return false } diff --git a/MirrorflyShareKit/SharKitVerifyOtpViewModel.swift b/MirrorflyShareKit/SharKitVerifyOtpViewModel.swift index 1dd1994..e7e2b35 100644 --- a/MirrorflyShareKit/SharKitVerifyOtpViewModel.swift +++ b/MirrorflyShareKit/SharKitVerifyOtpViewModel.swift @@ -23,7 +23,7 @@ class ShareVerifyOTPViewModel : NSObject } func validateUser(params: NSDictionary, completionHandler: @escaping (VerifyToken?, Error?)-> Void) { - let Baseurl = FlyDefaults.baseURL + let Baseurl = ChatManager.getAppConfigDetails().baseURL let url = Baseurl + verifyUser print("verifyOTPViewModel.validateUser \(url)") apiService.post(withEndPoint: url, params: params as? Parameters, headers: nil).responseJSON { (response) in diff --git a/MirrorflyShareKit/ShareKitBaseViewController.swift b/MirrorflyShareKit/ShareKitBaseViewController.swift index d6c0b96..7163199 100644 --- a/MirrorflyShareKit/ShareKitBaseViewController.swift +++ b/MirrorflyShareKit/ShareKitBaseViewController.swift @@ -72,9 +72,8 @@ class ShareKitBaseViewController: UIViewController { ChatManager.logoutApi { [weak self] isSuccess, flyError, flyData in guard let self else { return } if isSuccess { - FlyDefaults.appLockPassword = "" - FlyDefaults.appLockenable = false - FlyDefaults.hideLastSeen = false + CommonDefaults.appLockPassword = "" + CommonDefaults.appLockenable = false self.stopLoading() Utility.saveInPreference(key: isProfileSaved, value: false) Utility.saveInPreference(key: isLoggedIn, value: false) diff --git a/MirrorflyShareKit/ShareKitExtension.swift b/MirrorflyShareKit/ShareKitExtension.swift index afb9d8a..c4c8ef3 100644 --- a/MirrorflyShareKit/ShareKitExtension.swift +++ b/MirrorflyShareKit/ShareKitExtension.swift @@ -233,15 +233,18 @@ extension UIImageView { } func loadFlyImage(imageURL: String, name: String, chatType: ChatType = .singleChat, uniqueId: String = "", contactType : ContactType = .unknown,jid: String, isBlockedByAdmin: Bool = false, validateBlock: Bool = true){ - let urlString = FlyDefaults.baseURL + "media/" + imageURL + "?mf=" + FlyDefaults.authtoken + let urlString = ChatManager.getImageUrl(imageName: imageURL) var url = URL(string: urlString) var placeholder : UIImage? + guard let myJid = try? FlyUtils.getMyJid() else { + return + } if validateBlock { switch chatType { case .groupChat: placeholder = UIImage(named: "smallGroupPlaceHolder") default: - if uniqueId == FlyDefaults.myJid || contactType == .unknown || getIsBlockedByMe(jid: jid) || isBlockedByAdmin { + if uniqueId == myJid || contactType == .unknown || getIsBlockedByMe(jid: jid) || isBlockedByAdmin { placeholder = UIImage(named: "ic_profile_placeholder") } else { let trimmedName = name.trimmingCharacters(in: .whitespacesAndNewlines) @@ -256,7 +259,7 @@ extension UIImageView { case .groupChat: placeholder = UIImage(named: "smallGroupPlaceHolder") default: - if uniqueId == FlyDefaults.myJid || getIsBlockedByMe(jid: jid) || isBlockedByAdmin { + if uniqueId == myJid || getIsBlockedByMe(jid: jid) || isBlockedByAdmin { placeholder = UIImage(named: "ic_profile_placeholder") } else { let trimmedName = name.trimmingCharacters(in: .whitespacesAndNewlines) diff --git a/MirrorflyShareKit/ShareKitUtility.swift b/MirrorflyShareKit/ShareKitUtility.swift index 5ac9f9a..d25d079 100644 --- a/MirrorflyShareKit/ShareKitUtility.swift +++ b/MirrorflyShareKit/ShareKitUtility.swift @@ -64,7 +64,7 @@ class ShareKitUtility { public func getMentionTextContent(message: String, uiLabel: UILabel? = nil, isMessageSentByMe: Bool, mentionedUsers: [String], searchedText: String? = "") -> NSMutableAttributedString { let attributedString = NSMutableAttributedString(string: message) for user in mentionedUsers { - let JID = user + "@" + FlyDefaults.xmppDomain + let JID = user + "@" + ChatManager.getXMPPDetails().XMPPDomain let myJID = try? FlyUtils.getMyJid() if let profileDetail = ContactManager.shared.getUserProfileDetails(for: JID) { let userName = "@\(FlyUtils.getGroupUserName(profile: profileDetail))" diff --git a/MirrorflyShareKit/ShareKitViewModel.swift b/MirrorflyShareKit/ShareKitViewModel.swift index bc0bb99..1dc590c 100644 --- a/MirrorflyShareKit/ShareKitViewModel.swift +++ b/MirrorflyShareKit/ShareKitViewModel.swift @@ -15,7 +15,7 @@ import Contacts let BASE_URL = "https://api-preprod-sandbox.mirrorfly.com/api/v1/" let CONTAINER_ID = "group.com.mirrorfly.qa" -let LICENSE_KEY = "XXXXXXXXXXXXXXX" +let LICENSE_KEY = "xxxxxxxxxxxxxxxxxx" let IS_LIVE = false let APP_NAME = "UiKit" let ENABLE_CONTACT_SYNC = false @@ -56,7 +56,7 @@ class ShareKitViewModel { } func isLoggedIn() -> Bool { - return FlyDefaults.isLoggedIn + return ChatManager.getAppLoggedIn() } func clearModel() { diff --git a/MirrorflyShareKit/ShareScreen/Models/ShareKitContactViewModel.swift b/MirrorflyShareKit/ShareScreen/Models/ShareKitContactViewModel.swift index 744022a..94051ec 100644 --- a/MirrorflyShareKit/ShareScreen/Models/ShareKitContactViewModel.swift +++ b/MirrorflyShareKit/ShareScreen/Models/ShareKitContactViewModel.swift @@ -19,11 +19,14 @@ class ContactViewModel : NSObject if fromServer{ syncContacts() } + guard let myJid = try? FlyUtils.getMyJid() else { + return + } ContactManager.shared.getRegisteredUsers(fromServer: fromServer) { isSuccess, flyError, flyData in var data = flyData if isSuccess { if let contactsList = data.getData() as? [ProfileDetails] { - var filteredContact = contactsList.filter( {$0.profileChatType != .groupChat && $0.jid != FlyDefaults.myJid && $0.isBlockedByAdmin == false}) + var filteredContact = contactsList.filter( {$0.profileChatType != .groupChat && $0.jid != myJid && $0.isBlockedByAdmin == false}) filteredContact.removeAll { pd in removeContacts.contains(pd.jid) } diff --git a/MirrorflyShareKit/ShareScreen/ShareScreenTableCell/ShareKitParticipantCell.swift b/MirrorflyShareKit/ShareScreen/ShareScreenTableCell/ShareKitParticipantCell.swift index 64f32e6..7a92b08 100755 --- a/MirrorflyShareKit/ShareScreen/ShareScreenTableCell/ShareKitParticipantCell.swift +++ b/MirrorflyShareKit/ShareScreen/ShareScreenTableCell/ShareKitParticipantCell.swift @@ -90,7 +90,7 @@ class ShareKitParticipantCell: UITableViewCell { } func setImage(imageURL: String?, name: String, color: UIColor , recentChat : RecentChat) { - let urlString = "\(FlyDefaults.baseURL)\(media)/\(imageURL ?? "")?mf=\(FlyDefaults.authtoken)" + let urlString = ChatManager.getImageUrl(imageName: imageURL ?? emptyString()) var url = URL(string: urlString) var placeHolder = UIImage() if recentChat.profileType == .groupChat { @@ -129,7 +129,7 @@ class ShareKitParticipantCell: UITableViewCell { } func setImage(imageURL: String, name: String, color: UIColor , profile : ProfileDetails) { - let urlString = "\(FlyDefaults.baseURL + "" + media + "/" + imageURL + "?mf=" + "" + FlyDefaults.authtoken)" + let urlString = ChatManager.getImageUrl(imageName: imageURL) var url = URL(string: urlString) var placeHolder = UIImage() if profile.profileChatType == .groupChat { diff --git a/MirrorflyShareKit/ShareScreen/SharekitShareToViewController.swift b/MirrorflyShareKit/ShareScreen/SharekitShareToViewController.swift index 97148b4..0390df0 100755 --- a/MirrorflyShareKit/ShareScreen/SharekitShareToViewController.swift +++ b/MirrorflyShareKit/ShareScreen/SharekitShareToViewController.swift @@ -221,7 +221,11 @@ class SharekitShareToViewController: ShareKitBaseViewController { } func isParticipantExist(jid: String) -> (doesExist : Bool, message : String) { - return GroupManager.shared.isParticiapntExistingIn(groupJid: jid, participantJid: FlyDefaults.myJid) + guard let myJid = try? FlyUtils.getMyJid() else { + ShareKitUtility.shared.exitApp() + return (false,emptyString()) + } + return GroupManager.shared.isParticiapntExistingIn(groupJid: jid, participantJid: myJid) } func getLastMesssage() -> [ChatMessage]? { @@ -708,6 +712,9 @@ extension SharekitShareToViewController : UITableViewDelegate, UITableViewDataSo cell.statusUILabel?.text = recentChatDetails.lastMessageContent + (recentChatDetails.lastMessageType?.rawValue ?? "") } } + if ChatManager.isPrivateChat(jid: recentChatDetails.jid) { + cell.statusUILabel?.text = "" + } showHideEmptyMessage(totalCount: isSearchEnabled == true ? getRecentChat.filter({$0.profileType == .groupChat}).count : getAllRecentChat.filter({$0.profileType == .groupChat}).count) case 3: showHideEmptyMessage(totalCount: 0) @@ -743,6 +750,9 @@ extension SharekitShareToViewController : UITableViewDelegate, UITableViewDataSo cell.statusUILabel?.isHidden = false cell.removeButton?.isHidden = true cell.removeIcon?.isHidden = true + if ChatManager.isPrivateChat(jid: recentChatDetails.jid) { + cell.statusUILabel?.text = "" + } showHideEmptyMessage(totalCount: isSearchEnabled == true ? getRecentChat.count : getAllRecentChat.count) default: break @@ -1803,7 +1813,7 @@ extension SharekitShareToViewController { if ChatManager.shared.isBusyStatusEnabled() && ContactManager.shared.getUserProfileDetails(for: jid)?.profileChatType == .singleChat { let alertController = UIAlertController.init(title: "Disable busy Status. Do you want to continue?" , message: "", preferredStyle: .alert) let shareAction = UIAlertAction(title: "Yes", style: .default) {_ in - ChatManager.shared.enableDisableBusyStatus(!FlyDefaults.isUserBusyStatusEnabled) + ChatManager.shared.enableDisableBusyStatus(!ChatManager.shared.isBusyStatusEnabled()) completion(true) } let cancelAction = UIAlertAction(title: "No", style: .cancel) { [weak controller] (action) in diff --git a/MirrorflyShareKit/ShareViewController.swift b/MirrorflyShareKit/ShareViewController.swift index da90105..3042cc5 100644 --- a/MirrorflyShareKit/ShareViewController.swift +++ b/MirrorflyShareKit/ShareViewController.swift @@ -35,15 +35,15 @@ class ShareViewController: ShareKitBaseViewController { extension ShareViewController { func handleDisplayStatus() { - if (FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable) { - FlyDefaults.showAppLock = true + if (CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable) { + CommonDefaults.showAppLock = true } exit(0) } @objc func handleBackgroundStatus() { - if (FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable) { - FlyDefaults.showAppLock = true + if (CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable) { + CommonDefaults.showAppLock = true } exit(0) } @@ -64,9 +64,9 @@ extension ShareViewController { extension ShareViewController { private func checkForAppLock() { - if FlyDefaults.showAppLock { - if FlyDefaults.appFingerprintenable && FlyDefaults.appLockenable { - if !FlyDefaults.faceOrFingerAuthenticationFails { + if CommonDefaults.showAppLock { + if CommonDefaults.appFingerprintenable && CommonDefaults.appLockenable { + if !CommonDefaults.faceOrFingerAuthenticationFails { let initialViewController = FingerPrintPINViewController(nibName: "FingerPrintPINViewController", bundle: nil) self.navigationController?.setNavigationBarHidden(true, animated: true) self.navigationController?.pushViewController(initialViewController, animated: false) @@ -77,7 +77,7 @@ extension ShareViewController { self.navigationController?.setNavigationBarHidden(true, animated: true) self.navigationController?.pushViewController(initialViewController, animated: false) } - } else if FlyDefaults.appLockenable && FlyDefaults.appFingerprintenable == false { + } else if CommonDefaults.appLockenable && CommonDefaults.appFingerprintenable == false { let initialViewController = AuthenticationPINViewController(nibName: "AuthenticationPINViewController", bundle: nil) initialViewController.login = true initialViewController.modalPresentationStyle = .fullScreen diff --git a/MirrorflyUIkit.xcodeproj/project.pbxproj b/MirrorflyUIkit.xcodeproj/project.pbxproj index d8e37d0..6ff8c61 100644 --- a/MirrorflyUIkit.xcodeproj/project.pbxproj +++ b/MirrorflyUIkit.xcodeproj/project.pbxproj @@ -152,6 +152,11 @@ CE5BB0A02900281B00D16A49 /* NotificationTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE5BB09E2900281B00D16A49 /* NotificationTableViewCell.xib */; }; CE5BB0A229002FAF00D16A49 /* NotificationAlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5BB0A129002FAF00D16A49 /* NotificationAlertViewController.swift */; }; CE5E31C52959CE4F00D1C802 /* LinkCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE5E31C42959CE4F00D1C802 /* LinkCell.xib */; }; + CE5FD3422A6976E60047D654 /* PrivateChatEnableController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5FD3402A6976E60047D654 /* PrivateChatEnableController.swift */; }; + CE5FD3442A6976E60047D654 /* PrivateChatEnableController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE5FD3412A6976E60047D654 /* PrivateChatEnableController.xib */; }; + CE5FD34C2A6E98540047D654 /* PrivateChatPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5FD34A2A6E98540047D654 /* PrivateChatPopupViewController.swift */; }; + CE5FD34E2A6E98540047D654 /* PrivateChatPopupViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE5FD34B2A6E98540047D654 /* PrivateChatPopupViewController.xib */; }; + CE5FD3512A6FDEF70047D654 /* Animation.json in Resources */ = {isa = PBXBuildFile; fileRef = CE5FD3502A6FDEF60047D654 /* Animation.json */; }; CE60641727E1A716003AE9F0 /* MirrorflyUIkit-info.plist in Resources */ = {isa = PBXBuildFile; fileRef = CEA2F93626569C5C0013F5E8 /* MirrorflyUIkit-info.plist */; }; CE613AEF293A18F900995C9B /* ClearAllChatTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE613AED293A18F900995C9B /* ClearAllChatTableViewCell.swift */; }; CE613AF1293A18F900995C9B /* ClearAllChatTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE613AEE293A18F900995C9B /* ClearAllChatTableViewCell.xib */; }; @@ -165,6 +170,8 @@ CE6C986328045C4D009D508E /* LanguageSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6C986228045C4D009D508E /* LanguageSelectionViewController.swift */; }; CE6C9868280477E9009D508E /* LanguageSelectionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6C9867280477E9009D508E /* LanguageSelectionTableViewCell.swift */; }; CE6C986A28047807009D508E /* LanguageSelectionTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE6C986928047807009D508E /* LanguageSelectionTableViewCell.xib */; }; + CE6E5F112A696F5600CB2257 /* PrivateChatCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE6E5F0F2A696F5600CB2257 /* PrivateChatCell.swift */; }; + CE6E5F122A696F5600CB2257 /* PrivateChatCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE6E5F102A696F5600CB2257 /* PrivateChatCell.xib */; }; CE72209827D07BFF001F64FF /* GroupInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE72209727D07BFF001F64FF /* GroupInfoViewController.swift */; }; CE728406292F54C70023FDB4 /* BlockedContactsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE728405292F54C70023FDB4 /* BlockedContactsViewController.swift */; }; CE79DEA828FD2A150008B3D7 /* MessageInfoDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE79DEA628FD2A150008B3D7 /* MessageInfoDivider.swift */; }; @@ -210,6 +217,8 @@ CE91211A279549AE00B007E0 /* QRScannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE912119279549AE00B007E0 /* QRScannerView.swift */; }; CE91211E279563FF00B007E0 /* QRCodeScannerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE91211D279563FF00B007E0 /* QRCodeScannerViewModel.swift */; }; CE94E80426D9FA9800F2E3A7 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = CE94E80326D9FA9800F2E3A7 /* GoogleService-Info.plist */; }; + CE9536192A8393A500E510CA /* LockScreenController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE9536172A8393A500E510CA /* LockScreenController.swift */; }; + CE95361B2A8393A500E510CA /* LockScreenController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE9536182A8393A500E510CA /* LockScreenController.xib */; }; CE955ACA295EFD75006525EA /* popcorn.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = CE955ABE295EFD73006525EA /* popcorn.mp3 */; }; CE955ACC295EFD75006525EA /* bell.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = CE955ABF295EFD73006525EA /* bell.mp3 */; }; CE955ACE295EFD75006525EA /* twitters.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = CE955AC0295EFD73006525EA /* twitters.mp3 */; }; @@ -362,6 +371,10 @@ CED5EE0827990D850071A109 /* WebSettingsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CED5EE0627990D850071A109 /* WebSettingsCell.swift */; }; CED5EE0927990D850071A109 /* WebSettingsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CED5EE0727990D850071A109 /* WebSettingsCell.xib */; }; CED70D44274B6069005895ED /* CustomPhotoAlbum.swift in Sources */ = {isa = PBXBuildFile; fileRef = CED70D43274B6069005895ED /* CustomPhotoAlbum.swift */; }; + CED7F7FA2A76311D00DA50D8 /* PrivateChatFingerPrintPINViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CED7F7F62A76311C00DA50D8 /* PrivateChatFingerPrintPINViewController.swift */; }; + CED7F7FC2A76311D00DA50D8 /* PrivateChatAuthenticationPINViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CED7F7F72A76311C00DA50D8 /* PrivateChatAuthenticationPINViewController.xib */; }; + CED7F7FE2A76311D00DA50D8 /* PrivateChatFingerPrintPINViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CED7F7F82A76311D00DA50D8 /* PrivateChatFingerPrintPINViewController.xib */; }; + CED7F8002A76311D00DA50D8 /* PrivateChatAuthenticationPINViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CED7F7F92A76311D00DA50D8 /* PrivateChatAuthenticationPINViewController.swift */; }; CED877AE2911F327004E425E /* ConversionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CED877AD2911F327004E425E /* ConversionViewModel.swift */; }; CEE70878276893D90072A50F /* ForwardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE70876276893D90072A50F /* ForwardViewController.swift */; }; CEE70879276893D90072A50F /* ForwardViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CEE70877276893D90072A50F /* ForwardViewController.xib */; }; @@ -613,6 +626,11 @@ CE5BB09E2900281B00D16A49 /* NotificationTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NotificationTableViewCell.xib; sourceTree = ""; }; CE5BB0A129002FAF00D16A49 /* NotificationAlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationAlertViewController.swift; sourceTree = ""; }; CE5E31C42959CE4F00D1C802 /* LinkCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LinkCell.xib; sourceTree = ""; }; + CE5FD3402A6976E60047D654 /* PrivateChatEnableController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateChatEnableController.swift; sourceTree = ""; }; + CE5FD3412A6976E60047D654 /* PrivateChatEnableController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PrivateChatEnableController.xib; sourceTree = ""; }; + CE5FD34A2A6E98540047D654 /* PrivateChatPopupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivateChatPopupViewController.swift; sourceTree = ""; }; + CE5FD34B2A6E98540047D654 /* PrivateChatPopupViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PrivateChatPopupViewController.xib; sourceTree = ""; }; + CE5FD3502A6FDEF60047D654 /* Animation.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Animation.json; sourceTree = ""; }; CE613AED293A18F900995C9B /* ClearAllChatTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClearAllChatTableViewCell.swift; sourceTree = ""; }; CE613AEE293A18F900995C9B /* ClearAllChatTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ClearAllChatTableViewCell.xib; sourceTree = ""; }; CE62CD9B275E85E100E77310 /* BaseTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTableViewCell.swift; sourceTree = ""; }; @@ -625,6 +643,8 @@ CE6C986228045C4D009D508E /* LanguageSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageSelectionViewController.swift; sourceTree = ""; }; CE6C9867280477E9009D508E /* LanguageSelectionTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageSelectionTableViewCell.swift; sourceTree = ""; }; CE6C986928047807009D508E /* LanguageSelectionTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LanguageSelectionTableViewCell.xib; sourceTree = ""; }; + CE6E5F0F2A696F5600CB2257 /* PrivateChatCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateChatCell.swift; sourceTree = ""; }; + CE6E5F102A696F5600CB2257 /* PrivateChatCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PrivateChatCell.xib; sourceTree = ""; }; CE72209727D07BFF001F64FF /* GroupInfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupInfoViewController.swift; sourceTree = ""; }; CE728405292F54C70023FDB4 /* BlockedContactsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockedContactsViewController.swift; sourceTree = ""; }; CE79DEA628FD2A150008B3D7 /* MessageInfoDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageInfoDivider.swift; sourceTree = ""; }; @@ -686,6 +706,8 @@ CE912119279549AE00B007E0 /* QRScannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRScannerView.swift; sourceTree = ""; }; CE91211D279563FF00B007E0 /* QRCodeScannerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeScannerViewModel.swift; sourceTree = ""; }; CE94E80326D9FA9800F2E3A7 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + CE9536172A8393A500E510CA /* LockScreenController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenController.swift; sourceTree = ""; }; + CE9536182A8393A500E510CA /* LockScreenController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LockScreenController.xib; sourceTree = ""; }; CE955ABE295EFD73006525EA /* popcorn.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = popcorn.mp3; sourceTree = ""; }; CE955ABF295EFD73006525EA /* bell.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = bell.mp3; sourceTree = ""; }; CE955AC0295EFD73006525EA /* twitters.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = twitters.mp3; sourceTree = ""; }; @@ -826,12 +848,12 @@ CEB66AC429ADDE630084559C /* ShareKitParticipantCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShareKitParticipantCell.xib; sourceTree = ""; }; CEB66AC929AE2DC90084559C /* ShareKitShareViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareKitShareViewModel.swift; sourceTree = ""; }; CEBE3BD82959CF1F004E7C49 /* FooterSectionCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FooterSectionCell.xib; sourceTree = ""; }; - CEC08B7227E23B9F005E48C5 /* MirrorflyNotificationExtention-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "MirrorflyNotificationExtention-Info.plist"; path = "/Users/user/Desktop/UiKit/MirrorflyNotificationExtention-Info.plist"; sourceTree = ""; }; CEC08B7427E243D9005E48C5 /* MirrorflyNotificationextention.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = MirrorflyNotificationextention.entitlements; sourceTree = ""; }; CEC08B7E27E24F41005E48C5 /* GoogleService-Qa-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Qa-Info.plist"; sourceTree = ""; }; CEC2D48827A5AAA700AB107A /* ContactInfoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactInfoViewModel.swift; sourceTree = ""; }; CEC3E76F29E6C6850073705C /* ChatTags.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = ChatTags.storyboard; sourceTree = ""; }; CECB62482933B0400041D2B1 /* NavigationControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationControllerExtension.swift; sourceTree = ""; }; + CECB98F426CE658D00B24448 /* Mirrorfly.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Mirrorfly.entitlements; sourceTree = ""; }; CECB98F526CE65EE00B24448 /* MirrorflyUIkitQa.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MirrorflyUIkitQa.entitlements; sourceTree = ""; }; CECB992426CE71BF00B24448 /* SF-UI-Display-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-UI-Display-Bold.otf"; sourceTree = ""; }; CECB992626CE71CB00B24448 /* SF-UI-Display-Heavy.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SF-UI-Display-Heavy.otf"; sourceTree = ""; }; @@ -847,6 +869,10 @@ CED5EE0627990D850071A109 /* WebSettingsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebSettingsCell.swift; sourceTree = ""; }; CED5EE0727990D850071A109 /* WebSettingsCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = WebSettingsCell.xib; sourceTree = ""; }; CED70D43274B6069005895ED /* CustomPhotoAlbum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPhotoAlbum.swift; sourceTree = ""; }; + CED7F7F62A76311C00DA50D8 /* PrivateChatFingerPrintPINViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivateChatFingerPrintPINViewController.swift; sourceTree = ""; }; + CED7F7F72A76311C00DA50D8 /* PrivateChatAuthenticationPINViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PrivateChatAuthenticationPINViewController.xib; sourceTree = ""; }; + CED7F7F82A76311D00DA50D8 /* PrivateChatFingerPrintPINViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PrivateChatFingerPrintPINViewController.xib; sourceTree = ""; }; + CED7F7F92A76311D00DA50D8 /* PrivateChatAuthenticationPINViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivateChatAuthenticationPINViewController.swift; sourceTree = ""; }; CED877AD2911F327004E425E /* ConversionViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversionViewModel.swift; sourceTree = ""; }; CEE08DD529A738000057D295 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CEE70876276893D90072A50F /* ForwardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForwardViewController.swift; sourceTree = ""; }; @@ -1047,6 +1073,7 @@ CE0B4FAA27A3E35C005349EB /* contactInfo */ = { isa = PBXGroup; children = ( + CE6E5F0E2A696F2C00CB2257 /* privateChat */, CE0B4FB427A3E487005349EB /* contactData */, CE0B4FB327A3E47B005349EB /* viewAllMedia */, CE0B4FB227A3E463005349EB /* muteNotification */, @@ -1521,6 +1548,25 @@ path = footersection; sourceTree = ""; }; + CE5FD33F2A69766E0047D654 /* PrivateChatScreen */ = { + isa = PBXGroup; + children = ( + CE5FD3502A6FDEF60047D654 /* Animation.json */, + CE5FD3402A6976E60047D654 /* PrivateChatEnableController.swift */, + CE5FD3412A6976E60047D654 /* PrivateChatEnableController.xib */, + ); + path = PrivateChatScreen; + sourceTree = ""; + }; + CE5FD3492A6E98280047D654 /* privateChatAlert */ = { + isa = PBXGroup; + children = ( + CE5FD34A2A6E98540047D654 /* PrivateChatPopupViewController.swift */, + CE5FD34B2A6E98540047D654 /* PrivateChatPopupViewController.xib */, + ); + path = privateChatAlert; + sourceTree = ""; + }; CE6C985728040039009D508E /* Chat Settings */ = { isa = PBXGroup; children = ( @@ -1562,6 +1608,20 @@ path = View; sourceTree = ""; }; + CE6E5F0E2A696F2C00CB2257 /* privateChat */ = { + isa = PBXGroup; + children = ( + CED7F7F52A76310800DA50D8 /* Authentication */, + CE5FD3492A6E98280047D654 /* privateChatAlert */, + CE5FD33F2A69766E0047D654 /* PrivateChatScreen */, + CE6E5F0F2A696F5600CB2257 /* PrivateChatCell.swift */, + CE6E5F102A696F5600CB2257 /* PrivateChatCell.xib */, + CE9536172A8393A500E510CA /* LockScreenController.swift */, + CE9536182A8393A500E510CA /* LockScreenController.xib */, + ); + path = privateChat; + sourceTree = ""; + }; CE72209527D07BCB001F64FF /* Group Info */ = { isa = PBXGroup; children = ( @@ -1968,6 +2028,7 @@ CE9121122795453100B007E0 /* qrCode */, CE968372274B94E600701ADF /* group */, CECB98F526CE65EE00B24448 /* MirrorflyUIkitQa.entitlements */, + CECB98F426CE658D00B24448 /* Mirrorfly.entitlements */, CE31D80A274365760052FFFF /* ViewModels */, CEF4371827390BDA008D0F39 /* Calls */, CEA2F9C62657D0210013F5E8 /* Strings */, @@ -2420,6 +2481,17 @@ name = WebSetting; sourceTree = ""; }; + CED7F7F52A76310800DA50D8 /* Authentication */ = { + isa = PBXGroup; + children = ( + CED7F7F92A76311D00DA50D8 /* PrivateChatAuthenticationPINViewController.swift */, + CED7F7F72A76311C00DA50D8 /* PrivateChatAuthenticationPINViewController.xib */, + CED7F7F62A76311C00DA50D8 /* PrivateChatFingerPrintPINViewController.swift */, + CED7F7F82A76311D00DA50D8 /* PrivateChatFingerPrintPINViewController.xib */, + ); + path = Authentication; + sourceTree = ""; + }; CEE70875276893AE0072A50F /* ForwardMessages */ = { isa = PBXGroup; children = ( @@ -2578,7 +2650,6 @@ CEC08B7427E243D9005E48C5 /* MirrorflyNotificationextention.entitlements */, CEF43750273BCAB2008D0F39 /* NotificationExtentionQa.entitlements */, CEF43746273BCA77008D0F39 /* NotificationService.swift */, - CEC08B7227E23B9F005E48C5 /* MirrorflyNotificationExtention-Info.plist */, CEF43748273BCA77008D0F39 /* Info.plist */, ); path = NotificationExtention; @@ -2749,6 +2820,7 @@ CE46745829BAF39900169A96 /* ChatTagsFooterCell.xib in Resources */, CE955AD8295EFD75006525EA /* coin_drop.mp3 in Resources */, CE46746229BAF39900169A96 /* UserListCell.xib in Resources */, + CE5FD3512A6FDEF70047D654 /* Animation.json in Resources */, CE56254426E14E200020BDD3 /* ChatViewLocationIncomingCell.xib in Resources */, CE613AF1293A18F900995C9B /* ClearAllChatTableViewCell.xib in Resources */, CE1391FB29C86BC400F31957 /* ProgressBar.xib in Resources */, @@ -2760,6 +2832,7 @@ CE79DEC928FD7DFA0008B3D7 /* GroupDividerCell.xib in Resources */, CE8C1AB226E6225C00433470 /* test-image.jpg in Resources */, CE9CD31B2951DB2200EFE68A /* AutoBackupPopupViewController.xib in Resources */, + CE5FD34E2A6E98540047D654 /* PrivateChatPopupViewController.xib in Resources */, CEA3D8C827F4283200C9BE92 /* PrivacyHelpTableViewCell.xib in Resources */, CE79DEAA28FD2A150008B3D7 /* MessageInfoDivider.xib in Resources */, CE4AF3AA26F23AA3001EBB3B /* AudioSender.xib in Resources */, @@ -2790,10 +2863,12 @@ CEE71270291B7DE200C16387 /* AuthenticationPINViewController.xib in Resources */, 3DF9C9A928E6E6A300154BBE /* DeleteMessageForEveryOneAlertController.xib in Resources */, CE501496294A1D9300B61CE3 /* FingerPrintPINViewController.xib in Resources */, + CED7F7FE2A76311D00DA50D8 /* PrivateChatFingerPrintPINViewController.xib in Resources */, CE9705D9294C6DA6007246A8 /* RestoreInstructionsTableViewCell.xib in Resources */, 3D3C47DD28E5315D001F2520 /* DeleteForEveryOneViewCell.xib in Resources */, CE9B7FD02A00D47D000349B2 /* MentionTableViewCell.xib in Resources */, CE9A65562754A997007DB23C /* NoResultFoundCell.xib in Resources */, + CE95361B2A8393A500E510CA /* LockScreenController.xib in Resources */, CEFA0EC7292F56EF003CBE9C /* BlockedContactTableViewCell.xib in Resources */, CE4549FD2907C2350041212C /* NotDeliveredCell.xib in Resources */, CE2A390C29227862005F7AF0 /* AppLockTableViewCell.xib in Resources */, @@ -2815,6 +2890,7 @@ CECD351E29E3E44500A728F8 /* GoogleService-Prod-Info.plist in Resources */, CEA2F93526569C5C0013F5E8 /* LaunchScreen.storyboard in Resources */, CECB992726CE71CB00B24448 /* SF-UI-Display-Heavy.otf in Resources */, + CE5FD3442A6976E60047D654 /* PrivateChatEnableController.xib in Resources */, CE56257026E2B49D0020BDD3 /* ChatViewContactIncomingCell.xib in Resources */, CE955AE9295EFDE3006525EA /* NotificationTonesListViewController.xib in Resources */, CEFD043026CD25B90017287F /* countries.json in Resources */, @@ -2825,6 +2901,7 @@ CE955AD6295EFD75006525EA /* ding.mp3 in Resources */, CE8F53D32743AD7C00B201F4 /* ChatViewVideoOutgoingCell.xib in Resources */, CE5B64B527FADBFE003F9038 /* ChatViewTextOutgoingCell.xib in Resources */, + CE6E5F122A696F5600CB2257 /* PrivateChatCell.xib in Resources */, CEC3E77029E6C6850073705C /* ChatTags.storyboard in Resources */, CE46745229BAF39900169A96 /* CustomChatTagsCell.xib in Resources */, CE9705BD294C5E7B007246A8 /* BackupRestore.storyboard in Resources */, @@ -2836,6 +2913,7 @@ CE955AE0295EFD75006525EA /* spell.mp3 in Resources */, CE955AD2295EFD75006525EA /* tri_tone.mp3 in Resources */, CEA2F93026569C590013F5E8 /* Main.storyboard in Resources */, + CED7F7FC2A76311D00DA50D8 /* PrivateChatAuthenticationPINViewController.xib in Resources */, CE56256E26E2B4850020BDD3 /* ChatViewContactOutgoingCell.xib in Resources */, CE955AED295EFDE3006525EA /* NotificationToneListCell.xib in Resources */, CE0B4FC027A414E3005349EB /* ContactInfoCell.xib in Resources */, @@ -3138,10 +3216,12 @@ CE2FA0542812B38E004C0A85 /* ContactUsController.swift in Sources */, CE56250A26E0ED550020BDD3 /* LocationViewController.swift in Sources */, CEF8A4C92959CD5100D669B6 /* SectionHeaderView.swift in Sources */, + CE5FD34C2A6E98540047D654 /* PrivateChatPopupViewController.swift in Sources */, CE0B4FAC27A3E3E9005349EB /* ContactInfoViewController.swift in Sources */, CEF4372727391D78008D0F39 /* GroupCallViewController.swift in Sources */, CEA22E0C26F4B54C002034C0 /* AppUtils.swift in Sources */, CEA22F2426F62901002034C0 /* TableviewExtension.swift in Sources */, + CE5FD3422A6976E60047D654 /* PrivateChatEnableController.swift in Sources */, CEA4FFB926DFBB42004A1268 /* ProfileModel.swift in Sources */, CE9705C7294C6D9C007246A8 /* BackupPopupViewController.swift in Sources */, CE8FAC6B27269AA000C92634 /* AudioView.swift in Sources */, @@ -3160,6 +3240,7 @@ CEE70878276893D90072A50F /* ForwardViewController.swift in Sources */, CEA22DBD26F4A5F4002034C0 /* MenuItemWithIndexPath.swift in Sources */, CE9EC7F126CA71FD0089D9EB /* UserDefaultsExtension.swift in Sources */, + CE9536192A8393A500E510CA /* LockScreenController.swift in Sources */, CE084E462747687F005D304E /* DateFormatterUtility.swift in Sources */, CE9F7F0C26F2BB1B002BF24A /* IPImage.swift in Sources */, CE9705CD294C6D9C007246A8 /* RestoreInstructionViewController.swift in Sources */, @@ -3191,6 +3272,7 @@ CE91211E279563FF00B007E0 /* QRCodeScannerViewModel.swift in Sources */, CE85EDF6274CDAED002A6D50 /* AddParticipantsViewController.swift in Sources */, CE46745429BAF39900169A96 /* ChatTagsCell.swift in Sources */, + CED7F7FA2A76311D00DA50D8 /* PrivateChatFingerPrintPINViewController.swift in Sources */, CEF8A4D22959CD5100D669B6 /* LinkCell.swift in Sources */, CE4AF3A826F23AA3001EBB3B /* AudioReceiver.swift in Sources */, CE56257226E2B7400020BDD3 /* ChatContactViewController.swift in Sources */, @@ -3271,10 +3353,12 @@ CE40C5CA26DDC0B5001F829F /* OTPViewController.swift in Sources */, CE005CA729C9D431009BE471 /* AuthenticationExtenison.swift in Sources */, CEF2D9C628F3F7470059693B /* MessageInfoViewController.swift in Sources */, + CED7F8002A76311D00DA50D8 /* PrivateChatAuthenticationPINViewController.swift in Sources */, CE9B7FC52A00D46B000349B2 /* MentionTextView.swift in Sources */, 3D12788F27A7AC6D00A34436 /* UserProfileViewController.swift in Sources */, CE9FA02826F06BC70082EFA5 /* SearchRecentChatTableViewCell.swift in Sources */, CEA2F94626569F2F0013F5E8 /* ApiEndPoints.swift in Sources */, + CE6E5F112A696F5600CB2257 /* PrivateChatCell.swift in Sources */, CE79DEC728FD7DFA0008B3D7 /* GroupDividerCell.swift in Sources */, CE501490294A1D3B00B61CE3 /* ContextMenu.swift in Sources */, CED0F3DB26CBB35E002E376A /* NetworkReachability.swift in Sources */, @@ -3527,7 +3611,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 379; + CURRENT_PROJECT_VERSION = 380; DEVELOPMENT_TEAM = G44VFA67ZG; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = G44VFA67ZG; ENABLE_BITCODE = NO; @@ -3580,7 +3664,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 379; + CURRENT_PROJECT_VERSION = 380; DEVELOPMENT_TEAM = G44VFA67ZG; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = G44VFA67ZG; ENABLE_BITCODE = NO; @@ -3628,7 +3712,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 379; + CURRENT_PROJECT_VERSION = 380; DEVELOPMENT_TEAM = G44VFA67ZG; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = G44VFA67ZG; "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; @@ -3637,6 +3721,7 @@ INFOPLIST_KEY_CFBundleDisplayName = MirrorFlyQa; INFOPLIST_KEY_NSFaceIDUsageDescription = "Identify Yourself!"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_UIUserInterfaceStyle = Light; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -3665,7 +3750,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 379; + CURRENT_PROJECT_VERSION = 380; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = G44VFA67ZG; "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; @@ -3702,7 +3787,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 379; + CURRENT_PROJECT_VERSION = 380; DEVELOPMENT_TEAM = G44VFA67ZG; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = G44VFA67ZG; ENABLE_BITCODE = NO; @@ -3749,7 +3834,7 @@ CODE_SIGN_ENTITLEMENTS = notificationextention/NotificationExtentionQa.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution: CONTUS SUPPORT INTERACTIVE PRIVATE LIMITED"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 379; + CURRENT_PROJECT_VERSION = 380; DEVELOPMENT_TEAM = G44VFA67ZG; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = G44VFA67ZG; ENABLE_BITCODE = NO; diff --git a/MirrorflyUIkit.xcodeproj/xcshareddata/xcschemes/UiKitQ19.xcscheme b/MirrorflyUIkit.xcodeproj/xcshareddata/xcschemes/UiKitQ19.xcscheme new file mode 100644 index 0000000..79d824d --- /dev/null +++ b/MirrorflyUIkit.xcodeproj/xcshareddata/xcschemes/UiKitQ19.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MirrorflyUIkit.xcodeproj/xcshareddata/xcschemes/UiKitQaNotification19Extention.xcscheme b/MirrorflyUIkit.xcodeproj/xcshareddata/xcschemes/UiKitQaNotification19Extention.xcscheme new file mode 100644 index 0000000..66f4384 --- /dev/null +++ b/MirrorflyUIkit.xcodeproj/xcshareddata/xcschemes/UiKitQaNotification19Extention.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MirrorflyUIkit/Assets.xcassets/privateChat.imageset/Contents.json b/MirrorflyUIkit/Assets.xcassets/privateChat.imageset/Contents.json new file mode 100644 index 0000000..1e79e5f --- /dev/null +++ b/MirrorflyUIkit/Assets.xcassets/privateChat.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Group 34903@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Group 34903@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/MirrorflyUIkit/Assets.xcassets/privateChat.imageset/Group 34903@2x.png b/MirrorflyUIkit/Assets.xcassets/privateChat.imageset/Group 34903@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ab4ebb70ed3b5069c26cae9d0d36a1fc49ea28c5 GIT binary patch literal 4110 zcmeHKX*iqP+78tkdQ?zNwZ;@}DQRhIsyRW5noDa)TSJgGilAmXY#~(5RMEyfRB9fB z{naekL8&3^YD3htNlFdjyzSoSI_LVX@0_3K*Z2Ne&w8%4o@c$!d*Ao_tQdX@VHBI zJ5t}JIyzKgqY$&uL~dazp^H$yE(_zvx`Nt~01dzS;mkqx{#t@jWlBZZe0lBAe(N_) z

r&r*`aMi|rnm9k%K0!Vlwd)opiwk%$Lh#6Rb{1=eL<=rc8jcSl{|kqSQHCMQGu ztb2kBtVK{37NYt{9p%L5AToJl7-}yLbHIm)l&5fT+^Jn zjGC@~FLAO%tjXn=DQkS5CTpVN9)anc?(%hg!Iv-DY(IbBaUsVGTN@bWk*D=CykqP6 zMKD#MWo2_)<@?%T-9V3&zRLU^o^nhRJw|Xh6BF>Us5D29PHe-ChJ|6Nd+*+7^_60r z26fbSKF}BVKsfcw(>hV2@R;4!Hnixr8c+bcH(U>xOEv(hAP@9GY%h?<%MY` z`~8iweu1{Xo-Equk~172Rm^&}S#+8z2(k<6XS&kv)n)G#+6tZ-9 zp?OC)q@^-BET@@I#U0zQDztlVIRyz{cp0>;Odmm&VwRBbh<$!la*J0T-C8243u-Yv z7cwFeAb&H07EUBMJ6c`SLLaNXALCSdZAT#u)=awWqFL?~m#Nmo*th;I+8p+h)bUCt zjE=a&Ji=5w@Lb$-DSWQ9Lx`SMIodxzpOKtTYT?OmD3ovlPWx5N(XrBwZhLCDOXl6( zkK~<7T6~$yrl=EZ0k!tZ89UYc=lZzIv}Lo9Q(5(<>?wipN8=;?nX<*g8EV~8Nq1zgPLHpENhQCLy`q^Zr>rh^q+*8$Y2x@InJmbNtA zzc%J-82xsA*FCGU*!&pu#c@tAI7%BsSsy$265hsneArvE-rY4jMd;GdNiG|FxYw_l z)U3fo3W#37Af9ImWM_&U%^594xO< zs4z}=&wqt&a5$WIJ|do%L;wTJbudh3&~fkU1l6LoaI(*E=7*OiGudnJ(!;iH?%Oqe zG;gw}3giaNQ?9>C{uta={n;(+ORV-BV)hvWlB!qEAem_jFI6tiRZb`r?W0)t7Jd6* zPHC9%o9IQWRo7@n&d4)3EIJ`C|3|W~1%wn%bBdMj z{H^DJO?VV~$EKo3%*{1Ixla*v&M_^Lp%N@um0PQ!>Yw@nzV9=KK$R^UE1_nbg^Iys z9?BC4IYq0@37tQKUFD zk|C{MQwAuhe4jBM%mEh=Bsv|Anj{R80xUmGv>S|uCtJcL8_vkfS%gq0Ty37A4+&WA z791rCObdz#>*7S*WZ-xZF`9>3@it_ES+jlESR0uL~MRjY9K-+(Q|MCBery( zi*b*rTvA=UyDIGufl_-Q*H-piRTkFXmuiweN=$#>ZE3}W*UBq$ zZZbYE#k^poTh1t%jZ6E}5A3ER&L4Koq4VHH$oOt^pc! zm|{|(2}NshyGQ9ZPNJaS2>4d9KT5f)7@<82yU7}za(b6lQ6b4$N!+Tws?+v#xv(K&10DX#!AI;7^28f|dF!BQI7GA(w%I#t6%6iYRK-gNkv=$a7R81io{t%+K0R zsK{%g1YnZ9X43d@w`;PMbg*7DH!Mk=NOS@4SoSNnNxmgcLO+{9<)yyiaxJnleXZ$7^}O2Kqpfzcs*eTuQ#*epuw5SzNY`+F^E`p?u@iP(3HXP0U}&rCxj@k z;Qy@@9B?~JL;a^fD~AWK$n!`w#VQLy;UKEPQx7|!Q?pG;1WR+`C7|%;e{+z(q~rfn z{x1psZx%LchoC*B{-8YbZ-?KAbFP`RXHJy#b`@qky-yj8Z7p2T;NH_2?^;dYuY&$j zrIUw(sQB*YKJAypN)?YfOJ>w}n~I}Y6PqqwlSAD=pX6rP-pIC29?<;RCB@v_ zm0no3bGeb!x&giOHssONBW6@aNghF)<{NlwAzb`N98nI;+RIb*37w|mPORiXGu&~&NS_~GES*08EdSiqzVahKjt z4&UA|UhW-69pNfxC!y-DoznC?MTJZk6s|n~-Yd7LbCqkSjGsew@?HA#_=$+l97|=v zBJ`BNPJi5NjMm*9Yt#0|wVnQ0fkNX9Q`VfBXEWV-{g7kQy*XA1A(H96vfMxp?wh)H#4$!TgWNn9Lbt95oPT8na^+pb>ml)RoQU&0t{d?T#5Wu&t`Wp(&9YMX0sV$Xb^ zpHcL-wyb1WMueP!E29?<;->xfA1togNHgp%a-fgJ+lP#FJk?56M)*<*y^^Shs*`oQ z)d#*#eHU4Zgh-uaSmrP6(alS{Tcau@ILmLzzv69CMM1-UcH6f1ZUfs)M3`jCI_L>c zIFMRAyN|&N6cd}iiMw=)hRkmA?lMaY?MoPl;$*+ov^t-*twY{#yQ-M1ZhR2gayU5ht*b9d`L}l7?^m{uhMTnxk$MwswKAjd&QDqC64B;0 zlyo*^mi0g06&h-vZH?PAMGwwz3)IDDMYCl)Qu&Pb*DMYRlQo}=3_j4F`WiYld%{l# zv!!?L1(xDxXB!vd@u+1z&unZk|MdB3W;>r!K;==kYiqbd6jPT%+On{7wc3bJW3dsXi2lEc;YBdgP2%NwWLf+iN}vx{rC zt(4gX?W+&HOxsCn11+RZLD;vuXqw;>B`e}ozR5L+qh?t_UDpkdO+;zWqec!tGkMECr@49Qw$Rtw$p``j2E!My zV<1o!xGh?x`qOzBia_fB4Fw5B!6b>Oo6a0i#9J(l5kbHppy@h@av5d@V7bWv$DrU0 zWFffOnQ#b9lIte~hC+lvsBAE?SXBr#oh29oMZi@dc&3M`zY9PZ$l=O|ZUqP=*t_db zfnTaBKXCpKJp7?;u^}7-!55tTAD>339eLsV`Xs*%=Z?P>F{}OKyMS9;6~k+}!;MeM zEe1Ws7ahOhX(t%&yx$tNCpoSzyvfWc9iGo#x#e_2cX~`TepkE8RwWq!Y_o)9zlL|0|k##>vYU9+@Ky}f3aa1C}fG!%*R zzi+Vrxy~=E@2+s+2-aHO=~_d>-Gd6ZojIc!(&OiR#1mJ^3q`eR*Mf|vEiDtHD7J|wVYqXW4S(phY$uSE>wP50GrIkz zUrRJC{Hk9(e^y=vWe)vgZ%fgSudGF`eCAecczh)qqNG8S&vlEO(1?YO+w22^W>sli4B zMi1tDvO908ZsuyHLdiUJcDr$JOWWcekHdCJgh~*66B>%VY(d)n{j^?-oF@+NzvI4J zk2jw;4^%O6Az;w34@Vbb{CH*fwKMc__#JxI)@EBxvxpGPPAz{Fe(YptmfxEW-s=|T zMtFJGwXaqp^K9!Ui&vrV=^D`emZy1FX7#RL|Do-IuF9$9Klt*{e%H)N^%neiXdF|s zYe~@j2oIS{(c^B`@pG4n>$#N&i*3<6FWsrVqo54w!dK6vEI!!GCy8(t6;U_Vl6|A_ z5k}hj6l;;seJVIt>!ZfQ8Dy;WHBbKZjN}J;rdPZK44|P(cQ!tY2lfnJaM5){OSC#1 z*m-D&2x<(x55ru587U{}Iil&S1tp8b`F$hxXL|4=)aR{<;16rHyO`*)E^>Gmg#*X_ zN(Opi+h5xWeKA+8BG1?p3cbKJC?pMHHX?zpIKAbe-Twt{aUwJ&u=yOgsyAf5;xlL- zM>b&&{Q;cB0VjR@e(P!-PP*!F4vn|mV(W^t)yau0CObfCbT`HdnkJ{E$bwx%h_+|Z{8O3zC`>S91TGZKAR;kd5@8x+D6Sng8=cSZvrc7jI*K{4%xdk(16Y!;W056R{pGjEAS(e`a^AvH1l{^nuOQ-i2 zrDB!DG!O6Vl3enQMc_o?K_oGcXxkpPu>wBHx zLaj;7==Soaywb7nLsM;L`-QJx1oL9~B=W2+-f~23cc5E0xuU1Nsw4v!|8}oXiDwHf zZr1857MJ%cm-n(cm+;1b8U*iLn0mmPmleA!Htj}VSk(|?=?+jZeSE{e@zg_?G1*H* z;UG0-0T-b~NBy|Cym(jd+f9@$OF54roPF}Z)RyIfl>k_>E-lwfFuc7}FuZ^vk+CT& ze)kgbLz89JltRR>#Qv=<(CBp=avE(NeB1*u^}FH+HFNKjdV0bq&$4>N)J?wn6nqlz z+@?IN^@TP~rOt|Y@A3A}*49@I`VeIjGx~M^Xc>H-9s|WMnb^NM8Oi}X&1N* zzbi~2-8GA+2qatrn(B_1)^TVi6NeMp7;kD`ayKm%4CDe1XENST&iNTbDq8opH#iCw za4e^k4LWdW*@vv>ZRTysVy#w(w)c>1(L%m>7d;gSURxz69dRD$Eh9o_3j8n#M2?{- zrcfvd?vckgq7YiZXo=7`)3*>k+2`P2{L*VEX>zpv!Oe^G14zu!d!gh6;y?^bn9;|SBpR_lt5 z@70D966v1Rxi)vh-C)u0a=?JO=*$J)sYwdJ|v*G9q&WCxZh zHD!4_exlR^?_!f!l8Hg)@kTMsEF0Vn(Ai`a1oNGwT`4@L+XN*3L_%NH1Nm$9d&uQ0 z92LjMuw}U*X3xT6=dcxuy|rG--l_U?SIoUSNHwf}oYvSu9stk@?@hrB4L`(Qp(0^= zWX2!SQW|xPq+}U!2PryG&PP&1-2oB(Fq?1& zCIh_7ywId0I@2N4q?cEUjxzMXqNRzYq_P*rGTqnd2rYeE+{GS-=C0m__t;N<3R34E z0k%Z+nlOdZ4lNhsCZl7vp1P`F;F}zwvsA1kF?YF@Bl+*BYKzVs7W9ML1NU7wd5srC|T>IK$P4lO*D=uAYE3?-gdGK?!2HnlKu@~7Td1KP6TtEqUU1|+D<)t`a zIzz8{$({p_qBe!Bl*b$kuqQ%KfK|FfHW#^d`^@E1V|8Cedhk?}Oq4*j6^2bw_GaR3 zg*Ca`Ow{`vt^-rfusKR0b3y|Q$^*h`8kfqm2 zjK=evKJ7N`)ocB_rn|#y?6^^{LaF zxZG%LD9{q(vI=6sn7Rq_=9;-`2)<5EOEG5ZKw)$9ITajuVhh6etJ#LK#8 z|LQs2Tgvi6GK5+aP8Z1IeHpKlajns)>;qQxe9zITze=U3F9@bB_e+zoUWc;7tms@E zZOzV`+&|&N8$EK=4Q;A_SgPATcvX%d7bmXpH-0Sf%6`!>haG?1#4J&{bQ}Qmo5IgT za-rhmkO3sdb7lSN^e5qUZV^qUK6PGw;j??aJ_?{II|*d3@vpl-Su~C-km#9hJ!z!T2 z=9dp^kVzHbR6`D}%+qgtEUFhAssBt8=XZN$fR4mOg6POXe&U}zTYQoA@x!xmwfg@k zQ$~hu9`yZnP03`zW4A>M7o`rBD07>ahv5+|EHv~uI1_JFm(#q+qqf7&Ak6*l>(f<3 zpgn}!aAw}|TLB-V!8V9<==e2G1*Mj~uF10H9qnl~_G~AURIbsbLs{7WAF?oP{{HBd z>?k&naGxG-N0okkn)bavWD_@dPCtIuH@GkyARr^KYCfHt72CAd{eABD-;b(w>+T{R zYXT2#3iIrRW}i0Z&s&#>81Wu*pw|iA_$?36wwll3E@u8Mom&6{7?dU7dV}9eA zCd%d@?O$IBQKkoV2QX`H%O3n$^id?wL)4BpQ}9N>;<>IgAVAW)({j#5vfM9Bd&Io9 zKme_6$U0uz`*OWT)LTEqDZHUn!3uw@g!N=f8DooSNGj8<)EXu*1vx&Al~uBR4%cDT z;JaAZ{USLjRu8O(W$NaB)ho4RALT_hQ_e}b;SD;RCGA5Ri-Mwz#UfzmxH^k$ z%*T?aNm0s&0x&cD-v!{$5J`J%4yfy)oIKv0tpD z$g?@Xg?Q{L4tbro{9AR^W#Z`|S^8zW&IQp#^8l%4bPXQ)B zOG08E{U-%ziyla1M?f7wm;TtFAu50XOJzgKGYI^>O#GJ-sFnZ1>0c21pU#5weOSj8 zuJ+FRr#Fm*U~H__Qi}4{lR0M_wONNcvNK<_QuiB#OoL`s^AXUhro`?Fu*2nyp1F5q zCadtSooYS`I^#{n*+d5nW^}JkB-@dHGv?5}0q0PAJ0YPTw;g<5qos@N5D>D4AIa4G z_n{Qkx7@osQ3G!}jE1s$vDDQ$v(*x#!<)d!V}Cn4a*%>X%Y~kW(Hzn*hv-7^_GkpZ zg5Rl@CQ1}Pmn$YwmdOjl92)HG&|<_rDlSW!>%d<2r$`3r$8~>RKuEgBD} z4`It|_XhF4(W4NfE`3U_kgY?n_^$rX09_+INnyRst}%CQh9fNj)7Fk(F)fiJ`tJ(7 z+*)V*h`9^jtCkOsMp^(~BX zcv67tdzz2~Kgu_r^`5I0pO>rEzJQN~MS4u+y^zZNDs)Dk-tn*>;5FlItmS_2`pvZx z+;agQyw_9WE``!PiYKU^Kp5z}P0#bHSD)z=IB+8`EYlq7_Mc=0?qE*Xb}~RG;5Wtk z=*X(6Je_HajBawXQk~=4g9T{hRaAZyrYHT*Xly1C-z6`GcP6)#2T$l~?dhQjos7^k z@FMHwnJ0$6)LA~=tR??lQ{rl$Ga{8&AR&{`ip=DdKG~qz=bd9u+_fh%APj& z4l?cUdDGnRM2XH%*sF~7)$~)_o3ta-iqRB7cu6E7@IhxZ zDR8}E$2v~i$rWwBXydr{$fIb{Gtou9O;7}W?wmo@Fqv^QHvNHi`XA26 zewXLoKG!8tqew~4i6}%>Uk)9eq9&dsiKuzH1v~!~8%mGSysYTDeKBUQhUZ=LH6;Zp z0>%VtgVzt|>;1FTK#aMJ+|Ko-{%(5iiwEy=Mt)=&77KC1l31(rGPo<0=p!%7g>-K7 zgbrtP2gK4fIs$VB8it!U-nb9-n4=Pu80yc`{hiLoH|?Z)I_9}0!-g}v1H|dhpCm@w zL)tiTH=aV~kA)s+zWo?etNhJtJALPLkM~ek_W?!pR+5eH_KgR${asBN7FD_i`;Xi} zw#{Akrui;P+J>iQYOW;lz^WloVu@H@aqaBLRhn?fw%c#aGoct6sF@?>#_ZsSp?&4Z zskufAzrKua1ztJ+LAlEk*PM&?6CMOD?jQ6_!8EN9Gy)+o#jVvvcdfLGbw|#fz1DPv zZh;?%e{QZ7#973REaS#nGy=wkmg)NVG2Kk0?|Kp+75S{}R>Vr(Ia`O3Gx7@|*b>T$ zSczK;bw9=UduDdhEnHC5C1Rc1)8EkNKVSneV%G@-QLsrRO42$74FGy3;PqK!`17*_ s((|Mkdx8AJ?F3CRsqp_lM!)2sqiMR_TdY3dUtEZ`hMsz*s_nyn13nary8r+H literal 0 HcmV?d00001 diff --git a/MirrorflyUIkit/Assets.xcassets/privateChat_enable.imageset/Contents.json b/MirrorflyUIkit/Assets.xcassets/privateChat_enable.imageset/Contents.json new file mode 100644 index 0000000..489e1ff --- /dev/null +++ b/MirrorflyUIkit/Assets.xcassets/privateChat_enable.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "talk@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "talk@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/MirrorflyUIkit/Assets.xcassets/privateChat_enable.imageset/talk@2x.png b/MirrorflyUIkit/Assets.xcassets/privateChat_enable.imageset/talk@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..e52c96e073459275f38cfc54169512b18c618dcc GIT binary patch literal 1256 zcmVP)1^@s6JKvMJ00001b5ch_0Itp) z=>Px#1am@3R0s$N2z&@+hyVZtl1W5CRCr$Pn^98RFc3hsrsR(nK08wqI6)mQ0Gyz3 z0>TLzW|~a@O8+`ZXPTaXaDt{MAY6dBCm;!(>1PA)XoR~PaY|FNi;za(+II_HY z+Fh-7WgxE0toDw8kum_7?)zE!%^0&7kcL$&oU4`@c!y^B_d2ZJU1SxI7m5w+;rYJR z*chk+W`inLdYwgqW4CNY}NBk6*7TWn;0XPY-P1% zeR|nd@q&5vVZQ&h1%Dr!0AzO-S_M1RK64L-8mrq`gXGB1VHxz{+C84DTHbaqX)hlr zRUM}lEa~&!iB~lq4N7uGG$;*fL_nKffF@`kC21lWlm;b9K(bk;G-?sE5K6;?Mb1Jf z1+~ao2xXuaJqw`>)S_o0l!03GEX2$}soFY7Mg_{7c_%(opm@HC(BZB@j4e)v651t3 z?s69Sv&@1*!FjqG)7HYPff{_GQmrxxN+#@3T};RvsGZ79g8+Lgr7aA;Uez~)v`(rE zr%|RriE`kmIXx^OH2HwA5K_W2Tft30Rn9+Cpu9mWhlGVq(< zbKr(TnNhUruPpzJPM_Rc8c^c$Q?LoBEM+G#qa@FSxf3bV8yy@S@*~v~lOyCura*`MGN;lg@5300 zfA7@uQx0A90+pb6|HW#*354N$;YB>dW4DYz3*CfoWscKNq>plU=1slEnSnH`UYr5V zs%;i1Q9UVWRe!?HJJE+HsK9OMt>qfUWF_qVFgHy;>F3 z{(t`;_FbP0s1qy+HIfX%-W%rb+inv~($8F<32-q!P{m5W?R>f=8wx}XgqtDuS)??ReyAVeEJ4+|!`OB*b}n_UNBAD3==fV?Q*(m0Xd>ej1bu)aY2z5R;IT{iJgs zO@s0{CUKzb&!8yzF!`xC>7;UCh}6Px=1ti18WhqQ6?gBtVJRIAYOF?4WjPJXWp81H zUJc6Qn1VL;8kBDp6h`etgAy!tqMD`#6%Z3lg$$UA(V#+tCw`y}kNK_htja%uNbhF9 S8kS)I0000Px#1am@3R0s$N2z&@+hyVZv`$=5aJiB#Y#boZ*k4HyZ;M zf8M;0Sl}#7)g#s-5*CGWc~_o3hwS5^t6W|1X_n`aji(#;% zEZI6A{rhGKJo9bKI6ocR%BwQAWt zzB&;B$VUz|1;%rBSkC57ix z2$wJDs%%-K_o+98XGs^~St>4uYzQv~3YIb;JWIvJkPYF*K*3T5glDO^7_uR}7${iE zfbc987eh9L7Xt-L84#YO;$p~#@M54~DFea-#i6s4y!DhhI|WAKE_u!?S@j*h#+tM*>ErG zKg+UYz<*DYtPOt-A(ZQTQF@=f58(lU-Oh(ILfMOD80=HVHrn@x!YS-KfGGgT=$nh~ zV}R@aL3p5J7%~T77W^!LCk-T(uPu_lAqJiIPUjE8%i)QmfK@}FY=Yx63KrqE!(j!o2pk)vwTUcN~w!^;oY4sl{tY|$KDuM1Hw}`q}t)} zNdVovd0)r31mSsx2d&{xsPbtYgHH%}{A^50*rkd5jL@d&Y|@n)Hes8DZ&JQCd2v_s+>t+ad=rqOE>m4SJ@B+Zw?Tp_NN)AL- zn@p2qf(PS#k5Fo4DnKxJQ=|tI9oXQr?s@6)_-R52x9J2A440GbrtYF_RPb!HD9IBg zyfU*OBjnlWv~jMh2ZX1qsl{|wJx}QxZn2V%@I1kT$^VgT6$SRNu3!%<)g3NpB8Pyd zGH>iuDg1mmz5T_w=c!)I)=xhKyy;B&{{gH?{!|~VZzXa2mQ5bCO&hX_EH%Pozrh_t zCnlAL?0K`gr*>){JW|`kgHn9l+Eoj@s2Ty`$D)FW8z^&mD-1l}C zGwW@xR?*jV(fhV1juEd?^6KR+J6TBzPqgJzR#=_t$~}jQ(hNk<-_O3 zR!cV1mcrx06bGo~$5Jp#dM4XEE?y>7nS3-LpFcNU)z2HL>`r>s0R>8Uu7t&Mmo*?? zsK~pHaNQW;MbeVWCTk+|0pUdgkBg!5IA`F3&nDZg`7I`d7ZE%zigK|6oTDzfjps9w z5ng2Q_$G0(b#o~_m~PHL2;oHrFQ4TrJoDzw2ZR?Py!`toJ&Ew!ok0jMQg}s>>S%eD zYbLPV5e#fbd_rqLeTb`EI)oRRTv5M`iz32{1YW86AdnN`MFh`uuM^=#1TQxq3@+AeMtFc?6`70r6@^M#fF(+8B`qfCd-? z`Mp4FkIe!kv4cQ%G0?!XFfq76P*41m+@eV1x1%M)boByLxfQ#~@pxo1nJTE# z4y6f74U`Hf#VpJ#eBML3f^rJwz%YzkFSjsMF9t{guI+)+qFRStcMPAa09#k7=L!Ny zCj^>=Ql}D7a!nfJ0Bl)QX6Cze$22{UOOj{5@%Ai70qkB~C*o`rOJ&F}_ zKn%0zLl?Q>unWT?$_{k&hb8A!y;CwJWDI@)Ef zNi9P;fiy7KWHhOjhP@NY4y1`e5FPf)4@Nswdo-3c+wX6hbP!lMqtH!!GSLSkZflgM z4iSaxA3TQ#{~Z(9BL+i+v?f;(C5{(O%=hGq!E}}%PAE+bGJcmI4COl7#Fh|Id0?^^ zXbglKLeEQB3xzQ>a>n|Pxl34v(%KmEN$vCqmYmPpI0kzg#99e=t-;wSa;RWzrTM 0 { memberCell?.contactNamelabel.attributedText = getAttributedUserName(name: callLog.displayName, searchText: (callLogSearchBar.text ?? "").trim()) @@ -557,7 +554,7 @@ extension CallLogViewController : UITableViewDataSource, UITableViewDelegate { if callLog.callMode == .ONE_TO_ONE { var jidString = String() - if callLog.fromUserId == FlyDefaults.myJid { + if callLog.fromUserId == AppUtils.getMyJid() { jidString = callLog.toUserId } else { jidString = callLog.fromUserId @@ -609,7 +606,7 @@ extension CallLogViewController : UITableViewDataSource, UITableViewDelegate { } if callLog.callMode == .ONE_TO_ONE { var jidString = String() - if callLog.fromUserId == FlyDefaults.myJid { + if callLog.fromUserId == AppUtils.getMyJid() { jidString = callLog.toUserId }else{ jidString = callLog.fromUserId @@ -762,10 +759,10 @@ extension CallLogViewController : UITableViewDataSource, UITableViewDelegate { return } if getSelectedLogs().isEmpty { - if seletedCallLog.callMode == .ONE_TO_ONE && (seletedCallLog.groupId?.isEmpty ?? true) && ContactManager.shared.getUserProfileDetails(for: (seletedCallLog.fromUserId == FlyDefaults.myJid) ? seletedCallLog.toUserId : seletedCallLog.fromUserId) != nil{ + if seletedCallLog.callMode == .ONE_TO_ONE && (seletedCallLog.groupId?.isEmpty ?? true) && ContactManager.shared.getUserProfileDetails(for: (seletedCallLog.fromUserId == AppUtils.getMyJid()) ? seletedCallLog.toUserId : seletedCallLog.fromUserId) != nil{ let vc = UIStoryboard.init(name: Storyboards.chat, bundle: Bundle.main).instantiateViewController(withIdentifier: Identifiers.chatViewParentController) as? ChatViewParentController var jidString = String() - if seletedCallLog.fromUserId == FlyDefaults.myJid { + if seletedCallLog.fromUserId == AppUtils.getMyJid() { jidString = seletedCallLog.toUserId } else { jidString = seletedCallLog.fromUserId @@ -774,7 +771,7 @@ extension CallLogViewController : UITableViewDataSource, UITableViewDelegate { vc?.getProfileDetails = profileDetails let color = getColor(userName: ChatManager.getRechtChat(jid: jidString)?.profileName ?? "") vc?.contactColor = color - + vc?.isFromContactScreen = true vc?.isStarredMessagePage = false navigationController?.modalPresentationStyle = .overFullScreen navigationController?.pushViewController(vc!, animated: true) @@ -906,7 +903,7 @@ extension CallLogViewController { VOIPManager.sharedInstance.refreshToken { isSuccess in if isSuccess{ - FlyCallUtils.sharedInstance.setConfigUserDefaults(FlyDefaults.authtoken, withKey: "token") + FlyCallUtils.sharedInstance.setConfigUserDefaults(ChatManager.getAppConfigDetails().baseURL, withKey: "token") onCompletion(true) }else{ onCompletion(false) diff --git a/MirrorflyUIkit/Calls/CallViewController.swift b/MirrorflyUIkit/Calls/CallViewController.swift index c664e1c..85628d2 100755 --- a/MirrorflyUIkit/Calls/CallViewController.swift +++ b/MirrorflyUIkit/Calls/CallViewController.swift @@ -147,7 +147,7 @@ class CallViewController: UIViewController ,AVPictureInPictureControllerDelegate var jidToCheck = "" if CallManager.isOneToOneCall() { - let filteredJid = members.filter({$0.jid != FlyDefaults.myJid}) + let filteredJid = members.filter({$0.jid != AppUtils.getMyJid()}) if filteredJid.count > 0 { jidToCheck = filteredJid[0].jid } @@ -344,8 +344,8 @@ class CallViewController: UIViewController ,AVPictureInPictureControllerDelegate print(members) var membersJid = members.compactMap { $0.jid } - if membersJid.contains(FlyDefaults.myJid){ - membersJid.removeAll(where: { $0 == FlyDefaults.myJid}) + if membersJid.contains(AppUtils.getMyJid()){ + membersJid.removeAll(where: { $0 == AppUtils.getMyJid()}) } if membersJid.count == 1{ returnToCall.image = UIImage(named: "Default Avatar_ic") @@ -698,7 +698,7 @@ class CallViewController: UIViewController ,AVPictureInPictureControllerDelegate self?.oneToOneVideoViewTransforms() }) }else{ - if let myCell = collectionView?.cellForItem(at: IndexPath(item: findIndexOfUser(jid: FlyDefaults.myJid) ?? members.count - 1, section: 0)) as? GroupCallCell{ + if let myCell = collectionView?.cellForItem(at: IndexPath(item: findIndexOfUser(jid: AppUtils.getMyJid()) ?? members.count - 1, section: 0)) as? GroupCallCell{ DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(600)) { myCell.videoBaseView.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) } @@ -710,7 +710,7 @@ class CallViewController: UIViewController ,AVPictureInPictureControllerDelegate self?.oneToOneVideoViewTransforms() }) }else{ - if let myCell = collectionView?.cellForItem(at: IndexPath(item: findIndexOfUser(jid: FlyDefaults.myJid) ?? members.count - 1, section: 0)) as? GroupCallCell{ + if let myCell = collectionView?.cellForItem(at: IndexPath(item: findIndexOfUser(jid: AppUtils.getMyJid()) ?? members.count - 1, section: 0)) as? GroupCallCell{ DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(600)) { myCell.videoBaseView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0) } @@ -861,7 +861,7 @@ class CallViewController: UIViewController ,AVPictureInPictureControllerDelegate func getContactNames(){ var unknowGroupMembers = [String]() - let membersJid = members.compactMap { $0.jid }.filter {$0 != FlyDefaults.myJid} + let membersJid = members.compactMap { $0.jid }.filter {$0 != AppUtils.getMyJid()} if membersJid.count == 1 { if let contact = ChatManager.getContact(jid: membersJid[0].lowercased()){ outgoingCallView?.OutGoingPersonLabel.text = getNameStringWithGroupName(userNames: getUserName(jid: contact.jid, name: contact.name, nickName: contact.nickName, contactType: contact.contactType)) @@ -1149,7 +1149,7 @@ extension CallViewController : UICollectionViewDelegate , UICollectionViewDataSo let member = members[indexPath.row] let isLastRow = (indexPath.row == members.count - 1) let callStatus = isLastRow ? (CallManager.getCallStatus(userId: member.jid) == .ON_HOLD ? .onHold : .connected) : convertCallStatus(status: CallManager.getCallStatus(userId: member.jid)) - if member.jid == FlyDefaults.myJid && CallManager.getCallStatus(userId: member.jid) == .ON_HOLD{ + if member.jid == AppUtils.getMyJid() && CallManager.getCallStatus(userId: member.jid) == .ON_HOLD{ _ = updateCallStatus(jid: member.jid, status: .onHold) } groupCell.contentView.backgroundColor = UIColor(hexString: member.color) @@ -1237,7 +1237,7 @@ extension CallViewController : UICollectionViewDelegate , UICollectionViewDataSo if let baseView = groupCell.videoBaseView { member.videoTrackView = localRen member.videoTrackView.frame = CGRect(x: 0, y: 0, width: baseView.bounds.width, height: baseView.bounds.height) - if member.jid == FlyDefaults.myJid { + if member.jid == AppUtils.getMyJid() { let track = CallManager.getRemoteVideoTrack(jid: member.jid) print("#remoteTrack 1243 \(member.jid), \(track)") member.videoTrack = track @@ -1336,10 +1336,10 @@ extension CallViewController : CallViewControllerDelegate { setVideoBtnIcon() outgoingCallView?.cameraButton.isHidden = isVideoMuted if !isVideoMuted { - addGroupTracks(jid: FlyDefaults.myJid) + addGroupTracks(jid: AppUtils.getMyJid()) } else { - if let index = findIndexOfUser(jid: FlyDefaults.myJid) { - updateVideoMuteStatus(index: index, userid: FlyDefaults.myJid, isMute: status) + if let index = findIndexOfUser(jid: AppUtils.getMyJid()) { + updateVideoMuteStatus(index: index, userid: AppUtils.getMyJid(), isMute: status) } } AudioManager.shared().autoReRoute() @@ -1348,7 +1348,7 @@ extension CallViewController : CallViewControllerDelegate { func onAudioMute(status:Bool) { outgoingCallView?.audioButton.setImage(UIImage(named: isAudioMuted ? "IconAudioOn" : "IconAudioOff" ), for: .normal) - updateSpeakingUI(userId: FlyDefaults.myJid, isSpeaking: false) + updateSpeakingUI(userId: AppUtils.getMyJid(), isSpeaking: false) CallManager.muteAudio(status) } @@ -1369,7 +1369,7 @@ extension CallViewController : CallViewControllerDelegate { extension CallViewController { func makeCall(usersList : [String], callType: CallType, groupId : String = "", onCompletion: @escaping (_ isSuccess: Bool, _ message: String) -> Void) { - CallManager.setMyInfo(name: FlyDefaults.myName, imageUrl: FlyDefaults.myImageUrl) + CallManager.setMyInfo(name: ContactManager.getMyProfile().name, imageUrl: ContactManager.getMyProfile().image) self.groupId = groupId AudioManager.shared().audioManagerDelegate = self print("#lifecycle makeCall") @@ -1379,7 +1379,7 @@ extension CallViewController { } self.callType = callType addMyInfoToMembersArray() - for userJid in usersList where userJid != FlyDefaults.myJid { + for userJid in usersList where userJid != AppUtils.getMyJid() { let _ = addRemoteMembers(for: ChatManager.getContact(jid: userJid.lowercased())!) } var membersJid = members.compactMap { $0.jid } @@ -1466,7 +1466,7 @@ extension CallViewController : CallManagerDelegate { if let contact = ContactManager.shared.getUserProfileDetails(for: self.members.first?.jid ?? "") { if !contact.image.isEmpty { - if let contact = ChatManager.profileDetaisFor(jid: FlyDefaults.myJid), !contact.image.isEmpty{ + if let contact = ChatManager.profileDetaisFor(jid: AppUtils.getMyJid()), !contact.image.isEmpty{ //localProfileImageView.contentMode = .scaleAspectFill self.outgoingCallView?.remoteImageView.loadFlyImage(imageURL: contact.image, name: getUserName(jid: contact.jid, name: contact.name, nickName: contact.nickName, contactType: contact.contactType), jid: contact.jid) } @@ -1573,15 +1573,15 @@ extension CallViewController : CallManagerDelegate { func addMyInfoToMembersArray(videoTrack: RTCVideoTrack) { let callMember = CallMember() - callMember.name = FlyDefaults.myName - callMember.image = FlyDefaults.myImageUrl + callMember.name = ContactManager.getMyProfile().name + callMember.image = ContactManager.getMyProfile().image callMember.isCaller = CallManager.getCallDirection() == .Incoming ? false : true - callMember.jid = FlyDefaults.myJid + callMember.jid = AppUtils.getMyJid() callMember.isVideoMuted = CallManager.getCallType() == .Audio callMember.callStatus = CallManager.getCallDirection() == .Incoming ? (CallManager.isCallConnected() ? .connected : .connecting) : (CallManager.isCallConnected() ? .connected : .calling) callMember.videoTrack = videoTrack - if let index = findIndexOfUser(jid: FlyDefaults.myJid) { + if let index = findIndexOfUser(jid: AppUtils.getMyJid()) { members[index].videoTrack = videoTrack } else { isVideoMuted = callMember.isVideoMuted @@ -1592,14 +1592,14 @@ extension CallViewController : CallManagerDelegate { func addMyInfoToMembersArray() { let callMember = CallMember() - callMember.name = FlyDefaults.myName - callMember.image = FlyDefaults.myImageUrl + callMember.name = ContactManager.getMyProfile().name + callMember.image = ContactManager.getMyProfile().image callMember.isCaller = CallManager.getCallDirection() == .Incoming ? false : true - callMember.jid = FlyDefaults.myJid - callMember.isVideoMuted = CallManager.getMuteStatus(jid: FlyDefaults.myJid, isAudioStatus: false) //CallManager.getCallType() == .Audio + callMember.jid = AppUtils.getMyJid() + callMember.isVideoMuted = CallManager.getMuteStatus(jid: AppUtils.getMyJid(), isAudioStatus: false) //CallManager.getCallType() == .Audio callMember.callStatus = CallManager.getCallDirection() == .Incoming ? (CallManager.isCallConnected() ? .connected : .connecting) : (CallManager.isCallConnected() ? .connected : .calling) - if let index = findIndexOfUser(jid: FlyDefaults.myJid) { + if let index = findIndexOfUser(jid: AppUtils.getMyJid()) { } else { isVideoMuted = callMember.isVideoMuted @@ -1622,7 +1622,7 @@ extension CallViewController : CallManagerDelegate { callMember.name = getUserName(jid: remoteUserProfile?.jid ?? "",name: remoteUserProfile?.name ?? userId, nickName: remoteUserProfile?.nickName ?? userId,contactType: remoteUserProfile?.contactType ?? .unknown) callMember.image = remoteUserProfile?.image ?? user.image callMember.color = remoteUserProfile?.colorCode ?? "#00008B" - callMember.isVideoMuted = CallManager.getMuteStatus(jid: FlyDefaults.myJid, isAudioStatus: false) //CallManager.getCallType() == .Audio + callMember.isVideoMuted = CallManager.getMuteStatus(jid: AppUtils.getMyJid(), isAudioStatus: false) //CallManager.getCallType() == .Audio callMember.isVideoTrackAdded = false remoteImage = remoteUserProfile?.image ?? user.image if let index = findIndexOfUser(jid: user.jid){ @@ -1639,10 +1639,10 @@ extension CallViewController : CallManagerDelegate { func getDisplayName(IncomingUser :[String]) { var userString = [String]() - if FlyDefaults.hideNotificationContent{ - userString.append(FlyDefaults.appName) + if isHideNotificationContent { + userString.append(APP_NAME) }else{ - for JID in IncomingUser where JID != FlyDefaults.myJid { + for JID in IncomingUser where JID != AppUtils.getMyJid() { print("#jid \(JID)") if let contact = ChatManager.getContact(jid: JID.lowercased()){ if ENABLE_CONTACT_SYNC{ @@ -1666,8 +1666,8 @@ extension CallViewController : CallManagerDelegate { func getGroupName(_ groupId : String) { self.groupId = groupId - if FlyDefaults.hideNotificationContent{ - CallManager.getContactNames(IncomingUserName: [FlyDefaults.appName]) + if isHideNotificationContent { + CallManager.getContactNames(IncomingUserName: [APP_NAME]) }else{ if let groupContact = ChatManager.getContact(jid: groupId.lowercased()){ CallManager.getContactNames(IncomingUserName: [groupContact.name]) @@ -1698,7 +1698,7 @@ extension CallViewController : CallManagerDelegate { DispatchQueue.main.async { [weak self] in - if userId == FlyDefaults.myJid && (callStatus != .RECONNECTING && callStatus != .RECONNECTED) { + if userId == AppUtils.getMyJid() && (callStatus != .RECONNECTING && callStatus != .RECONNECTED) { return } @@ -1777,7 +1777,7 @@ extension CallViewController : CallManagerDelegate { } print("#call CONNECTED : \(userId)") self?.myCallStatus = .connected - _ = self?.updateCallStatus(jid: userId.isEmpty ? FlyDefaults.myJid : userId, status: .connected) + _ = self?.updateCallStatus(jid: userId.isEmpty ? AppUtils.getMyJid() : userId, status: .connected) self?.showHideCallAgainView(show: false, status: "Connected") self?.enableButtons(buttons:self?.outgoingCallView?.videoButton, isEnable: true) @@ -1803,9 +1803,9 @@ extension CallViewController : CallManagerDelegate { self?.collectionView.reloadData() if self?.checkIfGroupCallUiIsVisible() ?? false { self?.showGroupCallUI() } //_ = self?.requestForVideoTrack(jid: userId) - self?.addGroupTracks(jid: FlyDefaults.myJid) + self?.addGroupTracks(jid: AppUtils.getMyJid()) _ = self?.updateMuteStatus(jid: userId, isMute: false, isAudio: CallManager.getCallType() == .Audio) - if CallManager.getCallStatus(userId: userId.isEmpty ? FlyDefaults.myJid : userId ) == .ON_HOLD{ + if CallManager.getCallStatus(userId: userId.isEmpty ? AppUtils.getMyJid() : userId ) == .ON_HOLD{ self?.addUpdateCallUsersWithStatus(userJid: userId, status: .onHold, reload: true) }else{ self?.addUpdateCallUsersWithStatus(userJid: userId, status: .connected, reload: true) @@ -1854,7 +1854,7 @@ extension CallViewController : CallManagerDelegate { FlyLogWriter.sharedInstance.writeText("#call UI .DISCONNECTED => \(userId) \(self?.members.count)") case .ON_HOLD: self?.isOnCall = true - let userId = userId.isEmpty ? FlyDefaults.myJid : userId + let userId = userId.isEmpty ? AppUtils.getMyJid() : userId if let index = self?.findIndexOfUser(jid: userId) { print("#callStatus onCallStatus ==== .ON_HOLD for \(userId) at \(index) \(CallManager.isOneToOneCall()) \(String(describing: self?.members.count ?? 0))") self?.members[index].callStatus = .onHold @@ -1869,9 +1869,9 @@ extension CallViewController : CallManagerDelegate { FlyLogWriter.sharedInstance.writeText("#call UI .ON_HOLD => \(userId) \(self?.members.count)") case .ON_RESUME: self?.isOnCall = true - let userId = userId.isEmpty ? FlyDefaults.myJid : userId + let userId = userId.isEmpty ? AppUtils.getMyJid() : userId var indexValue : Int? = nil - if userId == FlyDefaults.myJid { + if userId == AppUtils.getMyJid() { self?.myCallStatus = .connected } if let index = self?.findIndexOfUser(jid: userId) { @@ -1883,7 +1883,7 @@ extension CallViewController : CallManagerDelegate { self?.outgoingCallView?.OutgoingRingingStatusLabel.text = CallStatus.connected.rawValue self?.myCallStatus = .connected }else{ - if !CallManager.getMuteStatus(jid: userId, isAudioStatus: false) && userId != FlyDefaults.myJid { + if !CallManager.getMuteStatus(jid: userId, isAudioStatus: false) && userId != AppUtils.getMyJid() { print("#callStatusRE ON_RESUME If") self?.onCallAction(callAction: .ACTION_REMOTE_VIDEO_ADDED, userId: userId) }else{ @@ -1996,7 +1996,7 @@ extension CallViewController : CallManagerDelegate { } func onCallAction(callAction: CallAction, userId: String) { - if userId == FlyDefaults.myJid { + if userId == AppUtils.getMyJid() { return } @@ -2150,12 +2150,12 @@ extension CallViewController { func validateAndAddMember(jid: String? = nil, with status: CallStatus = .calling) -> Bool { - if members.isEmpty || !members.contains(where: {$0.jid == FlyDefaults.myJid}) { + if members.isEmpty || !members.contains(where: {$0.jid == AppUtils.getMyJid()}) { //addMyInfoToMembersArray(requestTrack: CallManager.getCallType() == .Video) addMyInfoToMembersArray() } - if let jid = jid, jid != FlyDefaults.myJid { + if let jid = jid, jid != AppUtils.getMyJid() { if !(members.contains{$0.jid == jid} ) { let profileDetails = ProfileDetails(jid: jid) _ = addRemoteMembers(for: profileDetails, with: status) @@ -2243,12 +2243,12 @@ extension CallViewController { if isMute { member.videoTrackView.removeFromSuperview() groupCell.videoBaseView.willRemoveSubview(member.videoTrackView) - if userid == FlyDefaults.myJid { + if userid == AppUtils.getMyJid() { groupCell.videoBaseView.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) } } else { addGroupTracks(jid: userid) - if userid == FlyDefaults.myJid { + if userid == AppUtils.getMyJid() { groupCell.videoBaseView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0) } } @@ -2258,12 +2258,12 @@ extension CallViewController { member.videoTrackView.removeFromSuperview() groupCell.videoBaseView.willRemoveSubview(member.videoTrackView) groupCell.videoMuteImage.isHidden = !isMute - if userid == FlyDefaults.myJid { + if userid == AppUtils.getMyJid() { groupCell.videoBaseView.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) } } else { addGroupTracks(jid: userid) - if userid == FlyDefaults.myJid { + if userid == AppUtils.getMyJid() { groupCell.videoBaseView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0) } groupCell.videoMuteImage.isHidden = !isMute @@ -2597,7 +2597,7 @@ extension CallViewController { } func isCallOnHoldForOneToCall() -> Bool { - if let firstUserJid = members.first?.jid , let firstStatus = CallManager.getCallStatus(userId: firstUserJid), let myStatus = CallManager.getCallStatus(userId: FlyDefaults.myJid) { + if let firstUserJid = members.first?.jid , let firstStatus = CallManager.getCallStatus(userId: firstUserJid), let myStatus = CallManager.getCallStatus(userId: AppUtils.getMyJid()) { if firstStatus == .ON_HOLD || myStatus == .ON_HOLD{ return true } @@ -2612,13 +2612,15 @@ extension CallViewController : ConnectionEventDelegate{ if error.description.contains(FlyConstants.ErrorMessage.authorization_error) { CallManager.disconnectCall() dismiss() - FlyDefaults.myMobileNumber = "" - FlyDefaults.myXmppUsername = "" - FlyDefaults.myXmppPassword = "" - FlyDefaults.myXmppResource = "" - FlyDefaults.xmppDomain = "" - FlyDefaults.xmppPort = 0 - FlyDefaults.isLoggedIn = false + ChatManager.shared.resetFlyDefaults() + //Commented private flydefaults +// FlyDefaults.myMobileNumber = "" +// FlyDefaults.myXmppUsername = "" +// FlyDefaults.myXmppPassword = "" +// FlyDefaults.myXmppResource = "" +// FlyDefaults.xmppDomain = "" +// FlyDefaults.xmppPort = 0 + ChatManager.updateAppLoggedIn(isLoggedin: false) let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first let controller : OTPViewController if #available(iOS 13.0, *) { @@ -2708,7 +2710,7 @@ extension CallViewController { func updateSpeakingUI(userId : String, isSpeaking : Bool, audioLevel : Int = 0 ){ if !CallManager.isOneToOneCall() { - if userId == FlyDefaults.myJid && isAudioMuted == true && isSpeaking == true { + if userId == AppUtils.getMyJid() && isAudioMuted == true && isSpeaking == true { updateSpeakingUI(userId: userId, isSpeaking: false) } if getCallStatusOf(userId: userId) != .connected{ @@ -2783,7 +2785,7 @@ extension CallViewController { if let baseView = groupCell.videoBaseView { member.videoTrackView = localRen member.videoTrackView.frame = CGRect(x: 0, y: 0, width: baseView.bounds.width, height: baseView.bounds.height) - if jid == FlyDefaults.myJid { + if jid == AppUtils.getMyJid() { if !member.isVideoMuted { let track = CallManager.getRemoteVideoTrack(jid: jid) track?.add(member.videoTrackView) @@ -2864,7 +2866,7 @@ extension CallViewController { if let contact = ContactManager.shared.getUserProfileDetails(for: members.last?.jid ?? "") { if !contact.image.isEmpty { - if let contact = ChatManager.profileDetaisFor(jid: FlyDefaults.myJid), !contact.image.isEmpty{ + if let contact = ChatManager.profileDetaisFor(jid: AppUtils.getMyJid()), !contact.image.isEmpty{ localProfileImageView.contentMode = .scaleAspectFill localProfileImageView.loadFlyImage(imageURL: contact.image, name: getUserName(jid: contact.jid, name: contact.name, nickName: contact.nickName, contactType: contact.contactType), jid: contact.jid) } diff --git a/MirrorflyUIkit/Calls/GroupCallViewController.swift b/MirrorflyUIkit/Calls/GroupCallViewController.swift index 2c32047..2fe53fe 100755 --- a/MirrorflyUIkit/Calls/GroupCallViewController.swift +++ b/MirrorflyUIkit/Calls/GroupCallViewController.swift @@ -41,7 +41,7 @@ class GroupCallViewController: UIViewController { setUpStatusBar() var userList = callLog.userList userList.removeAll { jid in - jid == FlyDefaults.myJid + jid == AppUtils.getMyJid() } let fullNameArr = userList if isGroup{ @@ -158,7 +158,7 @@ class GroupCallViewController: UIViewController { func loadImagesForMutiUserCall(){ var userList = callLog.userList userList.removeAll { jid in - jid == FlyDefaults.myJid + jid == AppUtils.getMyJid() } if callLog.userProfileList.count == 2 { @@ -273,7 +273,7 @@ extension GroupCallViewController : ProfileEventsDelegate { func usersProfilesFetched() { var userList = callLog.userList userList.removeAll { jid in - jid == FlyDefaults.myJid + jid == AppUtils.getMyJid() } callUserProfiles.removeAll() let contactArr = NSMutableArray() diff --git a/MirrorflyUIkit/Calls/JoinCallViaLinkViewController.swift b/MirrorflyUIkit/Calls/JoinCallViaLinkViewController.swift index 34a3438..e8ced0e 100644 --- a/MirrorflyUIkit/Calls/JoinCallViaLinkViewController.swift +++ b/MirrorflyUIkit/Calls/JoinCallViaLinkViewController.swift @@ -48,7 +48,7 @@ class JoinCallViaLinkViewController: UIViewController { CallManager.startVideoCapture() localRenderer.frame = CGRect(x: 0, y: 0, width: videoView.bounds.width, height: videoView.bounds.height) - CallManager.subscribeToCallEvents(link: self.callLink, name: FlyDefaults.myName) { isSuccess, flyError in + CallManager.subscribeToCallEvents(link: self.callLink, name: ContactManager.getMyProfile().name) { isSuccess, flyError in if !isSuccess { let error = flyError?.description ?? "" self.handleErrorResponse(errorMessage: error) @@ -83,9 +83,14 @@ class JoinCallViaLinkViewController: UIViewController { func setupUI() { + NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground), name: UIApplication.willEnterForegroundNotification + , object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(didEnterBackground), name: UIApplication.didEnterBackgroundNotification + , object: nil) + self.networkMonitor() - if let profileDetail = ContactManager.shared.getUserProfileDetails(for: FlyDefaults.myJid) { + if let profileDetail = ContactManager.shared.getUserProfileDetails(for: AppUtils.getMyJid()) { let profileImageStr = profileDetail.thumbImage.isEmpty ? profileDetail.image : profileDetail.thumbImage @@ -111,6 +116,30 @@ class JoinCallViaLinkViewController: UIViewController { videoView.addSubview(self.localRenderer) } + @objc func willEnterForeground() { + initJoinLink() + } + + func initJoinLink() { + CallManager.setJoinCallDelegate(delegate: self) + CallManager.setupJoinCallViaLink() + CallManager.subscribeToCallEvents(link: self.callLink, name: ContactManager.getMyProfile().name) { isSuccess, flyError in + if !isSuccess { + let error = flyError?.description ?? "" + self.handleErrorResponse(errorMessage: error) + }else{ + self.joinButton.isEnabled = true + self.joinButton.alpha = 1 + self.checkMicPermission() + self.checkCameraPermission(sourceType: .camera) + } + } + } + + @objc func didEnterBackground() { + CallManager.cleanUpJoinCallViaLink() + } + @IBAction func backButtonAction(_ sender: UIButton) { CallManager.cleanUpJoinCallViaLink() @@ -144,8 +173,10 @@ class JoinCallViaLinkViewController: UIViewController { userProfileImage.isHidden = true videoButton.isSelected = false - localRenderer.isHidden = false CallManager.muteVideo(false) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + self.localRenderer.isHidden = false + } }else { @@ -242,6 +273,7 @@ class JoinCallViaLinkViewController: UIViewController { let userName = CallManager.getUserName(userId: jid) unknowGroupMembers.append(userName) profileImage[index].image = UIImage(named: "ic_profile_placeholder") + profileImage[index].isHidden = false countLabel.isHidden = true } @@ -289,6 +321,7 @@ class JoinCallViaLinkViewController: UIViewController { NetworkReachability.shared.netStatusChangeHandler = { if !NetworkReachability.shared.isConnected { executeOnMainThread { + self.initJoinLink() self.alertLabel.isHidden = false self.alertLabel.text = "Please check you’re internet connection" } @@ -351,7 +384,7 @@ extension JoinCallViaLinkViewController: JoinCallDelegate { func onUsersUpdated(usersList: [String]) { - if usersList.count == 8 && usersList.contains(FlyDefaults.myJid){ + if usersList.count == 8 && usersList.contains(AppUtils.getMyJid()){ return } self.updateUsersDetails(usersList: usersList) diff --git a/MirrorflyUIkit/Calls/RootViewController.swift b/MirrorflyUIkit/Calls/RootViewController.swift index 878694d..25a249f 100755 --- a/MirrorflyUIkit/Calls/RootViewController.swift +++ b/MirrorflyUIkit/Calls/RootViewController.swift @@ -70,17 +70,19 @@ extension RootViewController : CallManagerDelegate { DispatchQueue.main.async { [weak self] in - if userId == FlyDefaults.myJid && (callStatus != .RECONNECTING && callStatus != .RECONNECTED) { + if userId == AppUtils.getMyJid() && (callStatus != .RECONNECTING && callStatus != .RECONNECTED) { return } switch callStatus { case .ATTENDED: - if (FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable) { - let secondsDifference = Calendar.current.dateComponents([.minute, .second], from: FlyDefaults.appBackgroundTime, to: Date()) + if (CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable) { + let secondsDifference = Calendar.current.dateComponents([.minute, .second], from: CommonDefaults.appBackgroundTime, to: Date()) if secondsDifference.second ?? 0 > 32 || secondsDifference.minute ?? 0 > 0 { - FlyDefaults.showAppLock = true + CommonDefaults.showAppLock = true + CommonDefaults.appLockOnPrivateChat = false + CommonDefaults.privateChatOnChatScreen = false } } @@ -172,7 +174,7 @@ extension RootViewController { iceServerList.append(iceServer) let iceServer1 = RTCIceServer.init(urlStrings: ["stun:stun.l.google.com:19302"], username: "", credential: "") iceServerList.append(iceServer1) - try? CallSDK.Builder.setUserId(id: FlyDefaults.myJid) + try? CallSDK.Builder.setUserId(id: AppUtils.getMyJid()) .setDomainBaseUrl(baseUrl: "https://api-beta.mirrorfly.com/api/v1/") .setSignalSeverUrl(url: "https://signal-beta.mirrorfly.com/") .setJanusSeverUrl(url: "wss://janus.mirrorfly.com") @@ -182,7 +184,7 @@ extension RootViewController { .setCallViewController(viewController: callViewController!) .buildAndInitialize() } - CallManager.setMyInfo(name: FlyDefaults.myName, imageUrl: FlyDefaults.myImageUrl) + CallManager.setMyInfo(name: ContactManager.getMyProfile().name, imageUrl: ContactManager.getMyProfile().image) if let callViewController = callViewController { CallManager.setCallViewController(callViewController) } diff --git a/MirrorflyUIkit/Chat/ChatViewParentController.swift b/MirrorflyUIkit/Chat/ChatViewParentController.swift index fa56a1a..87adbe4 100755 --- a/MirrorflyUIkit/Chat/ChatViewParentController.swift +++ b/MirrorflyUIkit/Chat/ChatViewParentController.swift @@ -304,6 +304,14 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, var mentionUsersList: [String] = [] var mentionRanges: [(String, NSRange)] = [] var searchGroupMembers = [GroupParticipantDetail]() + + var groupIdForPrivateChat: String? + var isFromSearchSelect: Bool = false + var isFromNotificationSelect: Bool = false + var lockScreenShown = false + var isFromContactScreen = false + var isFromForward = false + var isFromPrivateChat = false @IBOutlet weak var mentionBaseView: UIView! @IBOutlet weak var mentionBottom: NSLayoutConstraint! @@ -313,6 +321,23 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, override func viewDidLoad() { super.viewDidLoad() checkifStarredMessages() + if isFromContactScreen || isFromForward || isFromGroupInfo { + if ChatManager.isPrivateChat(jid: getProfileDetails.jid) { + //if recent.isPrivateChat { + if let group = groupIdForPrivateChat { + if ChatManager.isPrivateChat(jid: group) { + + } else { + showLockScreen() + } + } else if isFromForward && isFromPrivateChat { + + } else { + showLockScreen() + } + //} + } + } } @objc internal override func keyboardWillShow(notification: NSNotification) { @@ -353,7 +378,7 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, func checkifStarredMessages() { if !isStarredMessagePage { - searchGroupMembers = groupMembers.sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }).filter({$0.memberJid != FlyDefaults.myJid}) + searchGroupMembers = groupMembers.sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }).filter({$0.memberJid != AppUtils.getMyJid()}) mentionBaseView.isHidden = true mentionBaseView.addBorder(toSide: .Top, withColor: .lightGray.withAlphaComponent(0.8), andThickness: 0.5) mentionTableView.register(UINib(nibName: "MentionTableViewCell", @@ -367,8 +392,8 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, handleSendButton() audioButton.imageEdgeInsets = UIEdgeInsets(top: 6, left: 8, bottom: 6, right: 8) videoButton.imageEdgeInsets = UIEdgeInsets(top: 6, left: 6, bottom: 6, right: 6) - print("MYJId \(FlyDefaults.myJid)") - print("username : \(FlyDefaults.myXmppUsername)") + print("MYJId \(AppUtils.getMyJid())") + print("username : \(ChatManager.getXMPPDetails().XMPPUsername)") checkGalleryPermission() chatTextViewXib?.cannotSendMessageView?.isHidden = true UNUserNotificationCenter.current().getDeliveredNotifications { notifications in @@ -465,12 +490,19 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, } else { print("Keyboard is not presented") } - + if ChatManager.isPrivateChat(jid: getProfileDetails.jid ?? "") { + // if recent.isPrivateChat { + CommonDefaults.appLockOnPrivateChat = false + CommonDefaults.privateChatOnChatScreen = true + self.view.addLaunchSubview() + //} + } removeUnreadMessageLabelFromChat() } @objc override func willCometoForeground() { print("ChatViewParentController ABC appComestoForeground") + self.view.removeLaunchSubview() self.viewDidLayoutSubviews() self.mentionBaseView.isHidden = !isMention DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in @@ -499,6 +531,12 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, self?.getInitialMessages() self?.checkUserBlocked() } + if CommonDefaults.privateChatOnChatScreen && !CommonDefaults.showAppLock { + if lockScreenShown == false { + showLockScreen() + lockScreenShown = true + } + } } private func groupPreviousMessages(messages: [ChatMessage]){ @@ -599,6 +637,15 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, } override func viewDidLayoutSubviews() { + +// if let pushId = pushChatId { +// if let recent = ChatManager.getRechtChat(jid: pushId) { +// if recent.isPrivateChat { +// showLockScreen() +// } +// } +// } + pushChatId = nil if !isStarredMessagePage { self.chatTableView.backgroundView = UIImageView(image: UIImage(named: "chat_background")) @@ -716,6 +763,8 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, view.backgroundColor = .white NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground), + name: NSNotification.Name(didBecomeActive), object: nil) if !isStarredMessagePage { let unsentMessage = FlyMessenger.getUnsentMessageOf(id: getProfileDetails.jid) if !unsentMessage.mentionSearch.isEmpty { @@ -732,6 +781,27 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, mentionBaseView.isHidden = false } } + if isFromSearchSelect || isFromNotificationSelect { + if let recent = ChatManager.getRechtChat(jid: getProfileDetails.jid) { + if recent.isPrivateChat && !CommonDefaults.isInPrivateChat { + showLockScreen() + isFromNotificationSelect = false + } + } + isFromSearchSelect = false + } else if (pushNotificationSelected && CommonDefaults.showAppLock == false) { +// if CommonDefaults.isInPrivateChat == true { +// showLockScreen() +// } else { +// +// } + showLockScreen() + } + lockScreenShown = false + } + + @objc func willEnterForeground() { + self.view.removeLaunchSubview() } private func presentPreviewScreen() { @@ -838,7 +908,26 @@ class ChatViewParentController: BaseViewController, UITextViewDelegate, chatTableView.reloadData() } - + + func showLockScreen() { + if CommonDefaults.appFingerprintenable { + let vc = PrivateChatFingerPrintPINViewController(nibName: "PrivateChatFingerPrintPINViewController", bundle: nil) + vc.isFromSearchSelect = isFromSearchSelect + vc.isFromNotificationSelect = isFromNotificationSelect + vc.isFromContactScreen = isFromContactScreen + vc.isFromForward = isFromForward + vc.isFromGroupInfo = isFromGroupInfo + self.navigationController?.pushViewController(vc, animated: false) + } else { + let vc = PrivateChatAuthenticationPINViewController(nibName:"PrivateChatAuthenticationPINViewController", bundle: nil) + vc.isFromSearchSelect = isFromSearchSelect + vc.isFromNotificationSelect = isFromNotificationSelect + vc.isFromContactScreen = isFromContactScreen + vc.isFromForward = isFromForward + vc.isFromGroupInfo = isFromGroupInfo + self.navigationController?.pushViewController(vc, animated: false) + } + } func showDeletePicker() { executeOnMainThread { [weak self] in @@ -1621,7 +1710,7 @@ extension ChatViewParentController { if getProfileDetails != nil { userNameLabel.text = getUserName(jid : getProfileDetails.jid ,name: getProfileDetails.name, nickName: getProfileDetails.nickName, contactType: getProfileDetails.contactType) let imageUrl = (getProfileDetails?.thumbImage.isEmpty ?? true) ? getProfileDetails?.image : getProfileDetails.thumbImage - let urlString = FlyDefaults.baseURL + "media/" + (imageUrl ?? emptyString()) + "?mf=" + FlyDefaults.authtoken + let urlString = ChatManager.getImageUrl(imageName: imageUrl ?? emptyString()) print("setProfile \(urlString)") var url = URL(string: urlString) var placeholder = UIImage() @@ -1719,6 +1808,12 @@ extension ChatViewParentController { if !isStarredMessagePage { destination.fromJid = getProfileDetails.jid } + if ChatManager.isPrivateChat(jid: getProfileDetails.jid) { + destination.hidePrivateChatUsers = false + } else { + destination.hidePrivateChatUsers = true + } + destination.isFromPrivateChat = isFromPrivateChat presentViewController(source: self, destination: destination) } @@ -2347,7 +2442,7 @@ extension ChatViewParentController : QLPreviewControllerDataSource { if getProfileDetails.profileChatType == .groupChat { self.mentionshouldChangeTextIn(textView, shouldChangeTextIn: range, replacementText: text) } - return true + //return true } if getProfileDetails.profileChatType == .groupChat { self.mentionshouldChangeTextIn(textView, shouldChangeTextIn: range, replacementText: text) @@ -3296,7 +3391,7 @@ extension ChatViewParentController { controller.textMentioned = messageTextView.mentionedUsers controller.selectedAssets = self.selectedAssets controller.profileName = getProfileDetails.name - controller.groupMembers = groupMembers.filter({$0.memberJid != FlyDefaults.myJid}) + controller.groupMembers = groupMembers.filter({$0.memberJid != AppUtils.getMyJid()}) controller.getProfileDetails = getProfileDetails navigationController?.navigationBar.isHidden = true navigationController?.pushViewController(controller, animated: false) @@ -3652,7 +3747,7 @@ extension ChatViewParentController { guard let queryString = queryString else {return} //MARK: - GoogleApi call for the translation - FlyTranslationManager.shared.languageTransalation(jid: getProfileDetails.jid, messageId: message.messageId, QueryString: queryString, targetLanguageCode: FlyDefaults.targetLanguageCode, GooogleAPIKey: googleApiKey_Translation){ (translatedText,isSuccess,errorMessage) in + FlyTranslationManager.shared.languageTransalation(jid: getProfileDetails.jid, messageId: message.messageId, QueryString: queryString, targetLanguageCode: CommonDefaults.targetLanguageCode, GooogleAPIKey: googleApiKey_Translation){ (translatedText,isSuccess,errorMessage) in if isSuccess{ print("translatedText-->", translatedText) } else @@ -3866,7 +3961,7 @@ extension ChatViewParentController : UITableViewDataSource ,UITableViewDelegate, //MARK: - Adding Double Tap Gesture for the Incoming Messages - if FlyDefaults.isTranlationEnabled { + if CommonDefaults.isTranlationEnabled { let tap = UITapGestureRecognizer(target: self, action: #selector(self.translationLanguage(_:))) tap.numberOfTapsRequired = 2 cell.addGestureRecognizer(tap) @@ -4247,7 +4342,7 @@ extension ChatViewParentController : UITableViewDataSource ,UITableViewDelegate, cell = cell.getCellFor(message, at: indexPath, isShowForwardView: isShowForwardView, isDeleteMessageSelected: isStarredMessageSelected ? true : isDeleteSelected, fromChat: true, isMessageSearch: isStarredMessagePage == true && isStarredSearchEnabled == true ? true : messageSearchEnabled, searchText: isStarredSearchEnabled == true ? searchBar?.text ?? "" : messageSearchBar?.text ?? "", profileDetails: getProfileDetails)! //MARK: - Double tap gesture for VideoIncomingCel - if FlyDefaults.isTranlationEnabled { + if CommonDefaults.isTranlationEnabled { let tapVideoCaption = UITapGestureRecognizer(target: self, action: #selector(self.translationLanguage(_:))) tapVideoCaption.numberOfTapsRequired = 2 cell.captionView.isUserInteractionEnabled = true @@ -4745,9 +4840,9 @@ extension ChatViewParentController : MessageEventsDelegate { if (self?.getProfileDetails.jid == message.chatUserJid){ self?.selectedIndexs.removeAll() self?.removeUnreadMessageLabelFromChat() - if FlyDefaults.myJid != chatJid { + if AppUtils.getMyJid() != chatJid { self?.appendNewMessage(message: message) - } else if FlyDefaults.myJid == chatJid && message.chatUserJid == self?.getProfileDetails.jid { + } else if AppUtils.getMyJid() == chatJid && message.chatUserJid == self?.getProfileDetails.jid { if self?.getProfileDetails.profileChatType == .singleChat { self?.appendNewMessage(message: message) } else if self?.getProfileDetails.profileChatType == .groupChat { @@ -5996,7 +6091,7 @@ extension ChatViewParentController { FlyMessenger.downloadMedia(messageId: chatMessage?.messageId ?? "") { [weak self] isSuccess, error, message in print("videoDownload \(success) \(error)") if message?.messageType == .image { if let cell = self?.chatTableView.cellForRow(at: indexPath) as? ChatViewVideoIncomingCell { - cell.getCellFor(message, at: indexPath, isShowForwardView: self?.isShowForwardView, isDeleteMessageSelected: self?.isDeleteSelected, profileDetails: self?.getProfileDetails ?? ProfileDetails(jid: FlyDefaults.myJid)) + cell.getCellFor(message, at: indexPath, isShowForwardView: self?.isShowForwardView, isDeleteMessageSelected: self?.isDeleteSelected, profileDetails: self?.getProfileDetails ?? ProfileDetails(jid: AppUtils.getMyJid())) } } } @@ -6611,7 +6706,7 @@ extension ChatViewParentController { extension ChatViewParentController { @objc func makeCall(_ sender : UIButton){ - print("#callopt \(FlyUtils.printTime()) makeCall from \(FlyDefaults.myJid)") + print("#callopt \(FlyUtils.printTime()) makeCall from \(AppUtils.getMyJid())") if CallManager.isAlreadyOnAnotherCall(){ AppAlert.shared.showToast(message: "You’re already on call, can't make new MirrorFly call") return @@ -6663,7 +6758,7 @@ extension ChatViewParentController : TypingStatusDelegate { func onGroupTypingStatus(groupJid: String, groupUserJid: String, status: TypingStatus) { executeOnMainThread { [weak self] in - if groupJid == self?.getProfileDetails.jid && groupUserJid != FlyDefaults.myJid { + if groupJid == self?.getProfileDetails.jid && groupUserJid != AppUtils.getMyJid() { if status == TypingStatus.composing { let user = self?.groupMembers.filter({$0.memberJid == groupUserJid}).first let name = getUserName(jid: user?.profileDetail?.jid ?? "", name: user?.profileDetail?.name ?? "", nickName: user?.profileDetail?.nickName ?? "", contactType: user?.profileDetail?.contactType ?? .unknown) @@ -6770,13 +6865,13 @@ extension ChatViewParentController { } func isParticipantExist() -> (doesExist : Bool, message : String) { - return GroupManager.shared.isParticiapntExistingIn(groupJid: getProfileDetails.jid, participantJid: FlyDefaults.myJid) + return GroupManager.shared.isParticiapntExistingIn(groupJid: getProfileDetails.jid, participantJid: AppUtils.getMyJid()) } func getGroupMember() { print("getGrouMember") groupMembers = [GroupParticipantDetail]() - groupMembers = GroupManager.shared.getGroupMemebersFromLocal(groupJid: getProfileDetails.jid).participantDetailArray.filter({$0.memberJid != FlyDefaults.myJid}) + groupMembers = GroupManager.shared.getGroupMemebersFromLocal(groupJid: getProfileDetails.jid).participantDetailArray.filter({$0.memberJid != AppUtils.getMyJid()}) print("getGrouMember \(groupMembers.count)") if mentionSearch.isEmpty { searchGroupMembers = mentionArrayFilter().sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }) @@ -6797,7 +6892,7 @@ extension ChatViewParentController { let members = self?.groupMembers ?? [GroupParticipantDetail]() for (index, member) in members.enumerated() { let profileDetail = member.profileDetail - let myProfile = self?.contactManager.getUserProfileDetails(for: FlyDefaults.myJid) + let myProfile = self?.contactManager.getUserProfileDetails(for: AppUtils.getMyJid()) if myProfile?.jid != profileDetail?.jid { let participantName = getUserName(jid : profileDetail?.jid ?? "" ,name: profileDetail?.name ?? "", nickName: profileDetail?.nickName ?? "", contactType: profileDetail?.contactType ?? .live) memberList.append(participantName) @@ -6805,15 +6900,15 @@ extension ChatViewParentController { } members.forEach { member in - if FlyDefaults.myJid == member.profileDetail?.jid { - memberList.append("You") + if AppUtils.getMyJid() == member.profileDetail?.jid { + memberList.append("You ") } } self?.groupMemberLable.type = .continuous self?.groupMemberLable.animationCurve = .linear self?.groupMemberLable.speed = .duration(45) - self?.groupMemberLable.text = memberList.joined(separator: ",") + self?.groupMemberLable.text = memberList.joined(separator: ", ") print("setGroupMemberInHeader \(memberList)") } @@ -8555,7 +8650,7 @@ extension ChatViewParentController : UIScrollViewDelegate { print("#scroll loadPreviousMessages success") if let chatMessages = result.getData() as? [ChatMessage]{ self.groupOldMessages(messages: chatMessages) - if self.availableFeatures.isChatHistoryEnabled && FlyDefaults.chatHistoryEnabled { + if self.availableFeatures.isChatHistoryEnabled && CommonDefaults.chatHistoryEnabled { if chatMessages.isEmpty { self.previousMessagesLoadingDone = true } else { @@ -8777,7 +8872,7 @@ extension ChatViewParentController { if ChatManager.shared.isBusyStatusEnabled() && getProfileDetails.profileChatType == .singleChat { let alertController = UIAlertController.init(title: "Disable busy Status. Do you want to continue?" , message: "", preferredStyle: .alert) let forwardAction = UIAlertAction(title: "Yes", style: .default) {_ in - ChatManager.shared.enableDisableBusyStatus(!FlyDefaults.isUserBusyStatusEnabled) + ChatManager.shared.enableDisableBusyStatus(!ChatManager.shared.isBusyStatusEnabled()) completion(true) } let cancelAction = UIAlertAction(title: "No", style: .cancel) { [weak controller] (action) in @@ -8997,7 +9092,7 @@ extension ChatViewParentController { extension ChatViewParentController { func getStarredMessageList() -> [ChatMessage] { - return isStarredMessagePage ? chatViewModel?.getAllFavouriteList().reversed() ?? [] : [] + return isStarredMessagePage ? chatViewModel?.getAllFavouriteList().filter { !(ChatManager.getRechtChat(jid: $0.chatUserJid)?.isPrivateChat ?? false) }.reversed() ?? [] : [] } func scrollToSelectedMessage() { @@ -9070,8 +9165,10 @@ extension ChatViewParentController: UISearchBarDelegate { let receiverName = getUserName(jid : $0.chatUserJid ,name: ChatManager.profileDetaisFor(jid: $0.chatUserJid )?.name ?? "", nickName: ChatManager.profileDetaisFor(jid: $0.chatUserJid )?.nickName ?? "", contactType: ChatManager.profileDetaisFor(jid: $0.chatUserJid )?.contactType ?? .local) let senderName = getUserName(jid : $0.chatUserJid ,name: ChatManager.profileDetaisFor(jid: $0.senderUserJid)?.name ?? "", nickName: ChatManager.profileDetaisFor(jid: $0.senderUserJid )?.nickName ?? "", contactType: ChatManager.profileDetaisFor(jid: $0.senderUserJid )?.contactType ?? .local) - return ((FlyDefaults.myName == senderName ? "" : senderName.lowercased()).localizedCaseInsensitiveContains(searchText.lowercased()) || - (FlyDefaults.myName == receiverName ? "" : receiverName.lowercased()).localizedCaseInsensitiveContains(searchText.lowercased()) || + let myName = ContactManager.getMyProfile().name + + return ((myName == senderName ? "" : senderName.lowercased()).localizedCaseInsensitiveContains(searchText.lowercased()) || + (myName == receiverName ? "" : receiverName.lowercased()).localizedCaseInsensitiveContains(searchText.lowercased()) || "You".localizedCaseInsensitiveContains(searchText.lowercased()) || $0.mediaChatMessage?.mediaCaptionText.lowercased().localizedCaseInsensitiveContains(searchText.lowercased()) ?? false || $0.messageTextContent.lowercased().localizedCaseInsensitiveContains(searchText.lowercased()) || @@ -9499,11 +9596,11 @@ extension ChatViewParentController { } func mentionArrayFilter() -> [GroupParticipantDetail] { - groupMembers.filter({ $0.memberJid != FlyDefaults.myJid && $0.profileDetail?.isBlockedByAdmin == false && $0.profileDetail?.contactType != .deleted }) + groupMembers.filter({ $0.memberJid != AppUtils.getMyJid() && $0.profileDetail?.isBlockedByAdmin == false && $0.profileDetail?.contactType != .deleted }) } func mentionArraySearchFilter() -> [GroupParticipantDetail] { - groupMembers.filter({ $0.displayName.lowercased().contains(mentionSearch.lowercased()) && $0.memberJid != FlyDefaults.myJid && $0.profileDetail?.isBlockedByAdmin == false && $0.profileDetail?.contactType != .deleted }) + groupMembers.filter({ $0.displayName.lowercased().contains(mentionSearch.lowercased()) && $0.memberJid != AppUtils.getMyJid() && $0.profileDetail?.isBlockedByAdmin == false && $0.profileDetail?.contactType != .deleted }) } } diff --git a/MirrorflyUIkit/Chat/Documents/Receiver Documents/ReceiverDocumentsTableViewCell.swift b/MirrorflyUIkit/Chat/Documents/Receiver Documents/ReceiverDocumentsTableViewCell.swift index c3c9576..8402f30 100644 --- a/MirrorflyUIkit/Chat/Documents/Receiver Documents/ReceiverDocumentsTableViewCell.swift +++ b/MirrorflyUIkit/Chat/Documents/Receiver Documents/ReceiverDocumentsTableViewCell.swift @@ -183,12 +183,12 @@ class ReceiverDocumentsTableViewCell: BaseTableViewCell { if isDeletedOrStarredSelected == false { if message?.mediaChatMessage?.mediaDownloadStatus == .downloaded && !(isShowForwardView ?? false) { - forwardView?.isHidden = false - forwardButton?.isHidden = false - isAllowSwipe = true - } else { forwardView?.isHidden = true forwardButton?.isHidden = true + isAllowSwipe = true + } else { + forwardView?.isHidden = false + forwardButton?.isHidden = false isAllowSwipe = false } } @@ -411,7 +411,7 @@ class ReceiverDocumentsTableViewCell: BaseTableViewCell { } func showHideForwardView(message: ChatMessage?,isShowForwardView: Bool?,isDeletedMessageSelected: Bool?) { - if isDeletedMessageSelected == true || isStarredMessagePage == true { + if isDeletedMessageSelected == true { // Forward view elements and its data forwardView?.isHidden = (isShowForwardView == false || message?.mediaChatMessage?.mediaDownloadStatus == .downloading) ? true : false forwardView?.makeCircleView(borderColor: Color.forwardCircleBorderColor.cgColor, borderWidth: 1.5) diff --git a/MirrorflyUIkit/Chat/Documents/Sender Documents/SenderDocumentsTableViewCell.swift b/MirrorflyUIkit/Chat/Documents/Sender Documents/SenderDocumentsTableViewCell.swift index 17912e1..15545d9 100644 --- a/MirrorflyUIkit/Chat/Documents/Sender Documents/SenderDocumentsTableViewCell.swift +++ b/MirrorflyUIkit/Chat/Documents/Sender Documents/SenderDocumentsTableViewCell.swift @@ -147,7 +147,8 @@ class SenderDocumentsTableViewCell: BaseTableViewCell { forwardButton?.isSelected = !(forwardButton?.isSelected ?? false) forwardView?.makeCircleView(borderColor: Color.forwardCircleBorderColor.cgColor, borderWidth: 1.5) } - isAllowSwipe = (message?.messageStatus == .notAcknowledged || message?.mediaChatMessage?.mediaUploadStatus == .not_uploaded || message?.mediaChatMessage?.mediaUploadStatus == .failed || message?.mediaChatMessage?.mediaUploadStatus == .uploading) ? false : true + isAllowSwipe = ( message?.mediaChatMessage?.mediaUploadStatus == .uploaded || message?.mediaChatMessage?.mediaDownloadStatus == .downloaded ) ? true : false + if message?.isCarbonMessage == true { if isDeletedMessageSelected == false { if (message?.mediaChatMessage?.mediaDownloadStatus == .downloaded && isShowForwardView == true) { @@ -170,7 +171,7 @@ class SenderDocumentsTableViewCell: BaseTableViewCell { } } - if (message?.mediaChatMessage?.mediaUploadStatus == .not_uploaded || message?.mediaChatMessage?.mediaUploadStatus == .failed || message?.mediaChatMessage?.mediaUploadStatus == .uploading || message?.messageStatus == .notAcknowledged || isShowForwardView == true || isStarredMessagePage == true) { + if ((!(message?.isCarbonMessage ?? true) && message?.mediaChatMessage?.mediaUploadStatus != .uploaded) || ( message?.isCarbonMessage ?? false && message?.mediaChatMessage?.mediaDownloadStatus != .downloaded ) || isShowForwardView == true || isStarredMessagePage == true) { fwdButton?.isHidden = true } else { fwdButton?.isHidden = false @@ -479,7 +480,7 @@ class SenderDocumentsTableViewCell: BaseTableViewCell { } func showHideForwardView(message: ChatMessage?, isShowForwardView: Bool?,isDeletedMessageSelected: Bool?) { - if isDeletedMessageSelected == true || isStarredMessagePage == true { + if isDeletedMessageSelected == true { // Forward view elements and its data forwardView?.isHidden = (isShowForwardView == false || message?.mediaChatMessage?.mediaUploadStatus == .uploading) || (message?.isMessageRecalled == true) ? true : false forwardButton?.isHidden = (isShowForwardView == false || message?.mediaChatMessage?.mediaUploadStatus == .uploading) || (message?.isMessageRecalled == true) ? true : false diff --git a/MirrorflyUIkit/Chat/Image Cells/ReceiverImageCell.swift b/MirrorflyUIkit/Chat/Image Cells/ReceiverImageCell.swift index 6cba3d0..0615b5c 100755 --- a/MirrorflyUIkit/Chat/Image Cells/ReceiverImageCell.swift +++ b/MirrorflyUIkit/Chat/Image Cells/ReceiverImageCell.swift @@ -344,7 +344,7 @@ class ReceiverImageCell: BaseTableViewCell { //MARK: - Populating the Incoming Cell with the translated message - if (message!.isMessageTranslated && FlyDefaults.isTranlationEnabled) { + if (message!.isMessageTranslated && CommonDefaults.isTranlationEnabled) { translatedTextLabel?.isHidden = false guard let chatMessage = message else {return self } print(chatMessage.mediaChatMessage?.mediaCaptionText) diff --git a/MirrorflyUIkit/Chat/ParentCell/ChatViewParentMessageCell.swift b/MirrorflyUIkit/Chat/ParentCell/ChatViewParentMessageCell.swift index aa9b3c2..da031dd 100755 --- a/MirrorflyUIkit/Chat/ParentCell/ChatViewParentMessageCell.swift +++ b/MirrorflyUIkit/Chat/ParentCell/ChatViewParentMessageCell.swift @@ -178,9 +178,9 @@ class ChatViewParentMessageCell: BaseTableViewCell { // Forward view elements and its data bubbleImageLeadingCons?.constant = (isShowForwardView == true) ? 10 : 0 - stackViewTimeStampTopCons?.constant = FlyDefaults.isTranlationEnabled && message?.isMessageTranslated ?? false ? 5 : -2 + stackViewTimeStampTopCons?.constant = CommonDefaults.isTranlationEnabled && message?.isMessageTranslated ?? false ? 5 : -2 // stackViewTimeStampTopCons?.constant = message!.isMessageTranslated ? 5 : 0 - stackViewTranslateTrailingCons?.constant = FlyDefaults.isTranlationEnabled && message!.isMessageTranslated ? 0 : 20 + stackViewTranslateTrailingCons?.constant = CommonDefaults.isTranlationEnabled && message!.isMessageTranslated ? 0 : 20 if selectedForwardMessage?.filter({$0.chatMessage.messageId == message?.messageId}).first?.isSelected == true { forwardImageView?.image = UIImage(named: "forwardSelected") @@ -557,7 +557,7 @@ class ChatViewParentMessageCell: BaseTableViewCell { //MARK: - Populating the Incoming Cell with the translated message - if (message!.isMessageTranslated && FlyDefaults.isTranlationEnabled) { + if (message!.isMessageTranslated && CommonDefaults.isTranlationEnabled) { guard let chatMessage = message,let messageLabeltemp = messageLabel, let translatedTextLabeltemp = translatedTextLabel else {return self } messageLabel?.attributedText = processTextMessage(message: chatMessage.messageTextContent , uiLabel: messageLabeltemp, fromChat: fromChat, isMessageSearch: isMessageSearch, searchText: searchText, isMessageSentByMe: message?.isMessageSentByMe ?? false, mentionedUsers: message?.mentionedUsersIds ?? [], profileDetails: profileDetails) diff --git a/MirrorflyUIkit/Chat/video/ChatViewVideoIncomingCell.swift b/MirrorflyUIkit/Chat/video/ChatViewVideoIncomingCell.swift index 324cb27..63d1a91 100755 --- a/MirrorflyUIkit/Chat/video/ChatViewVideoIncomingCell.swift +++ b/MirrorflyUIkit/Chat/video/ChatViewVideoIncomingCell.swift @@ -163,7 +163,7 @@ class ChatViewVideoIncomingCell: BaseTableViewCell { replyTextLabel?.text = "" replyUserLabel?.text = "" translatedCaptionLabel?.text = "" - captionViewHolder?.spacing = FlyDefaults.isTranlationEnabled && message?.isMessageTranslated ?? false ? 10 : 0 + captionViewHolder?.spacing = CommonDefaults.isTranlationEnabled && message?.isMessageTranslated ?? false ? 10 : 0 // Starred Messages // Starred Messages if let captionTxt = message?.mediaChatMessage?.mediaCaptionText, captionTxt == "" { @@ -427,7 +427,7 @@ class ChatViewVideoIncomingCell: BaseTableViewCell { //MARK: - Populating the Incoming Cell with the translated message - if (message!.isMessageTranslated && FlyDefaults.isTranlationEnabled) { + if (message!.isMessageTranslated && CommonDefaults.isTranlationEnabled) { guard let chatMessage = message else {return self } print(chatMessage.mediaChatMessage?.mediaCaptionText) print(chatMessage.translatedMessageTextContent) @@ -438,7 +438,7 @@ class ChatViewVideoIncomingCell: BaseTableViewCell { } func showHideForwardView(message : ChatMessage?,isDeletedSelected: Bool?,isShowForwardView: Bool?) { - if isDeletedSelected ?? false || isStarredMessagePage == true { + if isDeletedSelected ?? false { // Forward view elements and its data forwardView?.isHidden = (isShowForwardView == false || message?.mediaChatMessage?.mediaDownloadStatus == .downloading) ? true : false forwardView?.makeCircleView(borderColor: Color.forwardCircleBorderColor.cgColor, borderWidth: 1.5) diff --git a/MirrorflyUIkit/Chat/video/ChatViewVideoOutgoingCell.swift b/MirrorflyUIkit/Chat/video/ChatViewVideoOutgoingCell.swift index 705298e..9c003cf 100755 --- a/MirrorflyUIkit/Chat/video/ChatViewVideoOutgoingCell.swift +++ b/MirrorflyUIkit/Chat/video/ChatViewVideoOutgoingCell.swift @@ -422,7 +422,7 @@ class ChatViewVideoOutgoingCell: BaseTableViewCell { } func showHideForwardView(message: ChatMessage?,isShowForwardView: Bool?,isDeleteMessageSelected: Bool?) { - if isDeleteMessageSelected ?? false || isStarredMessagePage == true { + if isDeleteMessageSelected ?? false { // Forward view elements and its data forwardView?.isHidden = (isShowForwardView == false || message?.mediaChatMessage?.mediaUploadStatus == .uploading) || (message?.isMessageRecalled == true) ? true : false forwardView?.makeCircleView(borderColor: Color.forwardCircleBorderColor.cgColor, borderWidth: 1.5) diff --git a/MirrorflyUIkit/Common/AppUtils.swift b/MirrorflyUIkit/Common/AppUtils.swift index 5836961..e8a56c5 100755 --- a/MirrorflyUIkit/Common/AppUtils.swift +++ b/MirrorflyUIkit/Common/AppUtils.swift @@ -156,6 +156,32 @@ class AppUtils: NSObject { let errorMessage = split.isEmpty ? description : split[0] return errorMessage } + + class func getMyJid() -> String { + guard let myJid = try? FlyUtils.getMyJid() else { + AppUtils.shared.forceLogout() + return emptyString() + } + return myJid + } + + func forceLogout() { + ChatManager.logoutApi() {isSuccess,error,data in + + } + var controller : OTPViewController? + if #available(iOS 13.0, *) { + controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "OTPViewController") + } else { + + controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "OTPViewController") as? OTPViewController + } + let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first + if let navigationController = window?.rootViewController as? UINavigationController, let otpViewController = controller { + navigationController.popToRootViewController(animated: false) + navigationController.pushViewController(otpViewController, animated: false) + } + } } public struct Units { @@ -281,7 +307,7 @@ func checkFileType(urlExtension: String, typeImageView: UIImageView!) { func getPhoneNumberToUpdate(phoneNumber : String) -> String { if phoneNumber.isEmpty { - return FlyDefaults.myMobileNumber + return ContactManager.getMyProfile().mobileNumber } var tempMobileNumber = phoneNumber @@ -299,7 +325,7 @@ private func getIsBlockedByMe(jid: String) -> Bool { extension UIImageView { func loadFlyImage(imageURL: String, name: String, chatType: ChatType = .singleChat, uniqueId: String = "", contactType : ContactType = .unknown,jid: String, isBlockedByAdmin: Bool = false, validateBlock: Bool = true){ - let urlString = FlyDefaults.baseURL + "media/" + imageURL + "?mf=" + FlyDefaults.authtoken + let urlString = ChatManager.getImageUrl(imageName: imageURL) var url = URL(string: urlString) var placeholder : UIImage? if validateBlock { @@ -307,15 +333,17 @@ extension UIImageView { case .groupChat: placeholder = UIImage(named: "smallGroupPlaceHolder") default: - if uniqueId == FlyDefaults.myJid || contactType == .deleted || getIsBlockedByMe(jid: jid) || isBlockedByAdmin || (IS_LIVE && ENABLE_CONTACT_SYNC && ContactManager.shared.getUserProfileDetails(for: jid)?.isItSavedContact == false) { + if uniqueId == AppUtils.getMyJid() || contactType == .deleted || getIsBlockedByMe(jid: jid) || isBlockedByAdmin || (IS_LIVE && ENABLE_CONTACT_SYNC && ContactManager.shared.getUserProfileDetails(for: jid)?.isItSavedContact == false) { placeholder = UIImage(named: "ic_profile_placeholder") url = URL(string: "") } else { let trimmedName = name.trimmingCharacters(in: .whitespacesAndNewlines) - let ipimage = IPImage(text: trimmedName, radius: Double(self.frame.size.height), font: UIFont.font32px_appBold(), - textColor: nil, color: getColor(userName: name)) - placeholder = ipimage.generateInitialImage() - self.backgroundColor = ChatUtils.getColorForUser(userName: name) +// executeOnMainThread { + let ipimage = IPImage(text: trimmedName, radius: Double(self.frame.size.height), font: UIFont.font32px_appBold(), + textColor: nil, color: getColor(userName: name)) + placeholder = ipimage.generateInitialImage() + self.backgroundColor = ChatUtils.getColorForUser(userName: name) +// } } } } else { @@ -323,7 +351,7 @@ extension UIImageView { case .groupChat: placeholder = UIImage(named: "smallGroupPlaceHolder") default: - if uniqueId == FlyDefaults.myJid || getIsBlockedByMe(jid: jid) || isBlockedByAdmin || (IS_LIVE && ENABLE_CONTACT_SYNC && ContactManager.shared.getUserProfileDetails(for: jid)?.isItSavedContact == false) { + if uniqueId == AppUtils.getMyJid() || getIsBlockedByMe(jid: jid) || isBlockedByAdmin || (IS_LIVE && ENABLE_CONTACT_SYNC && ContactManager.shared.getUserProfileDetails(for: jid)?.isItSavedContact == false) { placeholder = UIImage(named: "ic_profile_placeholder") url = URL(string: "") } else { @@ -342,8 +370,7 @@ extension UIImageView { if isBlockedByAdmin { url = URL(string: "") } - - self.sd_setImage(with: url, placeholderImage: placeholder, options: [.continueInBackground,.decodeFirstFrameOnly,.highPriority,.scaleDownLargeImages], progress: nil){ (image, responseError, isFromCache, imageUrl) in + self.sd_setImage(with: url, placeholderImage: placeholder, options: [.continueInBackground,.decodeFirstFrameOnly,.lowPriority], progress: nil){ (image, responseError, isFromCache, imageUrl) in if let error = responseError as? NSError{ if let errorCode = error.userInfo[SDWebImageErrorDownloadStatusCodeKey] as? Int { if errorCode == 401{ diff --git a/MirrorflyUIkit/Common/ChatUtils.swift b/MirrorflyUIkit/Common/ChatUtils.swift index 3094ee6..0c7bd14 100755 --- a/MirrorflyUIkit/Common/ChatUtils.swift +++ b/MirrorflyUIkit/Common/ChatUtils.swift @@ -66,7 +66,7 @@ class ChatUtils { var replyMessage = message.trim() for user in mentionedUsersIds { - let JID = user + "@" + FlyDefaults.xmppDomain + guard let JID = try? FlyUtils.getJid(from: user) else { return message } let myJID = try? FlyUtils.getMyJid() if let profileDetail = ContactManager.shared.getUserProfileDetails(for: JID) { let userName = "@`\(FlyUtils.getGroupUserName(profile: profileDetail)) `" @@ -81,7 +81,7 @@ class ChatUtils { var replyMessage = message.trim() for user in mentionedUsersIds { - let JID = user + "@" + FlyDefaults.xmppDomain + guard let JID = try? FlyUtils.getJid(from: user) else { return message } let myJID = try? FlyUtils.getMyJid() if let profileDetail = ContactManager.shared.getUserProfileDetails(for: JID) { let userName = "@\(FlyUtils.getGroupUserName(profile: profileDetail))" @@ -95,7 +95,7 @@ class ChatUtils { static func getMentionTextContent(message: String, uiLabel: UILabel? = nil, isMessageSentByMe: Bool, mentionedUsers: [String], searchedText: String? = "") -> NSMutableAttributedString { var attributedString = NSMutableAttributedString(string: message) for user in mentionedUsers { - let JID = user + "@" + FlyDefaults.xmppDomain + let JID = user + "@" + ChatManager.getXMPPDetails().XMPPDomain let myJID = try? FlyUtils.getMyJid() if let profileDetail = ContactManager.shared.getUserProfileDetails(for: JID) { let userName = "@`\(FlyUtils.getGroupUserName(profile: profileDetail))` " @@ -336,7 +336,7 @@ class ChatUtils { } static func getUserImaeUrl(imageUrl : String) -> URL? { - let urlString = FlyDefaults.baseURL + "media/" + imageUrl + "?mf=" + FlyDefaults.authtoken + let urlString = ChatManager.getImageUrl(imageName: imageUrl) print("ContactInfoViewController setProfile \(urlString)") return URL(string: urlString) } diff --git a/MirrorflyUIkit/Common/Color.swift b/MirrorflyUIkit/Common/Color.swift index 0cf5dc0..44d77e8 100755 --- a/MirrorflyUIkit/Common/Color.swift +++ b/MirrorflyUIkit/Common/Color.swift @@ -88,6 +88,7 @@ enum Color { static let mentionColor = UIColor(named: "Mention_color") static let highlightColor = UIColor.init(hex: "FFF4BC") static let color_AFBDDF = UIColor(named: "color_AFBDDF") + static let color_D0D8EB = UIColor(named: "color_D0D8EB") } extension UIColor { diff --git a/MirrorflyUIkit/Common/Extensions/ViewExtension.swift b/MirrorflyUIkit/Common/Extensions/ViewExtension.swift index 888074d..2791053 100755 --- a/MirrorflyUIkit/Common/Extensions/ViewExtension.swift +++ b/MirrorflyUIkit/Common/Extensions/ViewExtension.swift @@ -140,3 +140,24 @@ extension UIWindow { public func getCGSize(width: Int, height: Int) -> CGSize { return CGSize(width: 15, height: 15) } + +extension UIView { + func addLaunchSubview() { + let view = UIView() + view.accessibilityIdentifier = "addLaunchSubview" + view.frame = self.bounds + if let launch = LockScreenController(nibName: "LockScreenController", bundle: nil).view { + launch.frame = self.bounds + view.addSubview(launch) + } + self.addSubview(view) + } + + func removeLaunchSubview() { + for view in self.subviews { + if view.accessibilityIdentifier == "addLaunchSubview" { + view.removeFromSuperview() + } + } + } +} diff --git a/MirrorflyUIkit/Common/Identifiers.swift b/MirrorflyUIkit/Common/Identifiers.swift index 92474b2..3493a59 100644 --- a/MirrorflyUIkit/Common/Identifiers.swift +++ b/MirrorflyUIkit/Common/Identifiers.swift @@ -31,6 +31,7 @@ enum Identifiers { static let contactCell = "ContactCell" static let contactViewController = "ContactViewController" static let dmaReasonVC = "DMAReasonVC" + static let privateChatPopupViewController = "PrivateChatPopupViewController" //MARK: - Chat static let chatTextView = "ChatTextView" @@ -134,6 +135,7 @@ enum Identifiers { static let messageInfoViewController = "MessageInfoViewController" static let groupInfoOptionsViewController = "GroupInfoOptionsViewController" static let groupInfoOptionsTableViewCell = "GroupInfoOptionsTableViewCell" + static let privateChatCell = "PrivateChatCell" //MARK: ChatSettings static let chatSettingsTableViewCell = "ChatSettingsTableViewCell" diff --git a/MirrorflyUIkit/Common/StringConstants.swift b/MirrorflyUIkit/Common/StringConstants.swift index 25108e7..72bbae4 100755 --- a/MirrorflyUIkit/Common/StringConstants.swift +++ b/MirrorflyUIkit/Common/StringConstants.swift @@ -83,6 +83,7 @@ let thisWillMuteAllNotificationsAlertsForIncomingMessages = "This will mute all //MARK: EmptyTable Handler let noResultFound = "No results found" let noNewMessage = "No new Messages" +let noPrivateMessage = "No Private chats" //MARK: RecentChat HeaderSection Title let chatTitle = "Chats" @@ -147,6 +148,7 @@ let deleteGroupMessage = "Group deleted successfully" //Finger Print Set let biometricAuthentication = "You need to set pin first in order to enable bio metric authentication" +let pinAuthentication = "You need to enable PIN Lock first in order to enable bio metric authentication" /// Contact access permission let contactAccessTitle = "Allow Contact Access" @@ -288,6 +290,7 @@ let youWantToLogout = "Are you sure you want to logout?" let email = "Email" let mobileNumber = "Mobile Number" let status = "Status" +let unarchiveForPrivateLock = "This chat is Archived. To lock this chat Unarchive it." // MARK: notification name let foregroundNotification = "foregroundNotification" diff --git a/MirrorflyUIkit/Controllers/Audio/TableCells/AudioReceiver.swift b/MirrorflyUIkit/Controllers/Audio/TableCells/AudioReceiver.swift index 359c86e..6e5821a 100755 --- a/MirrorflyUIkit/Controllers/Audio/TableCells/AudioReceiver.swift +++ b/MirrorflyUIkit/Controllers/Audio/TableCells/AudioReceiver.swift @@ -387,7 +387,7 @@ class AudioReceiver: BaseTableViewCell, AVAudioPlayerDelegate { } func showHideForwardView(message: ChatMessage?,isShowForwardView: Bool?,isDeletedMessageSelected: Bool?) { - if isDeletedMessageSelected ?? false || isStarredMessagePage == true { + if isDeletedMessageSelected ?? false { // Forward view elements and its data forwardView?.isHidden = (isShowForwardView == false || message?.mediaChatMessage?.mediaDownloadStatus == .downloading) ? true : false forwardView?.makeCircleView(borderColor: Color.forwardCircleBorderColor.cgColor, borderWidth: 1.5) diff --git a/MirrorflyUIkit/Controllers/Audio/TableCells/AudioSender.swift b/MirrorflyUIkit/Controllers/Audio/TableCells/AudioSender.swift index e79182e..8ffef3c 100755 --- a/MirrorflyUIkit/Controllers/Audio/TableCells/AudioSender.swift +++ b/MirrorflyUIkit/Controllers/Audio/TableCells/AudioSender.swift @@ -457,7 +457,7 @@ class AudioSender: BaseTableViewCell, AVAudioPlayerDelegate { } func showHideForwardView(message: ChatMessage?,isShowForwardView: Bool?,isDeleteMessageSelected: Bool?) { - if isDeleteMessageSelected ?? false || isStarredMessagePage == true { + if isDeleteMessageSelected ?? false { // Forward view elements and its data forwardView?.isHidden = (isShowForwardView == false || message?.mediaChatMessage?.mediaUploadStatus == .uploading) || (message?.isMessageRecalled == true) ? true : false forwardView?.makeCircleView(borderColor: Color.forwardCircleBorderColor.cgColor, borderWidth: 1.5) diff --git a/MirrorflyUIkit/Controllers/Authentication PIN/AuthenticationPINViewController.swift b/MirrorflyUIkit/Controllers/Authentication PIN/AuthenticationPINViewController.swift index 4f3ffaa..e99d256 100644 --- a/MirrorflyUIkit/Controllers/Authentication PIN/AuthenticationPINViewController.swift +++ b/MirrorflyUIkit/Controllers/Authentication PIN/AuthenticationPINViewController.swift @@ -81,14 +81,14 @@ class AuthenticationPINViewController: BaseViewController, UITextFieldDelegate { } func showAlerts() { - if FlyDefaults.showAppLock { - if FlyDefaults.passwordAuthenticationAttemps > 5 { + if CommonDefaults.showAppLock { + if CommonDefaults.passwordAuthenticationAttemps > 5 { showfailedAttempsActionAlert() - } else if daysBetween(start: FlyDefaults.appLockPasswordDate, end: Date()) > 31-5 && daysBetween(start: FlyDefaults.appLockPasswordDate, end: Date()) < 31 { - if FlyDefaults.pinChangeAlertShownDate != Date().xmppDateString { + } else if daysBetween(start: CommonDefaults.appLockPasswordDate, end: Date()) > 31-5 && daysBetween(start: CommonDefaults.appLockPasswordDate, end: Date()) < 31 { + if CommonDefaults.pinChangeAlertShownDate != Date().xmppDateString { showChangePinAlert() } - } else if daysBetween(start: FlyDefaults.appLockPasswordDate, end: Date()) >= 31 { + } else if daysBetween(start: CommonDefaults.appLockPasswordDate, end: Date()) >= 31 { showPinActionAlert() } } @@ -153,7 +153,7 @@ class AuthenticationPINViewController: BaseViewController, UITextFieldDelegate { } func showChangePinAlert() { - FlyDefaults.pinChangeAlertShownDate = Date().xmppDateString + CommonDefaults.pinChangeAlertShownDate = Date().xmppDateString let values : [String] = ["Change PIN", "OK"] var actions = [(String, UIAlertAction.Style)]() @@ -161,7 +161,7 @@ class AuthenticationPINViewController: BaseViewController, UITextFieldDelegate { actions.append((title, UIAlertAction.Style.default)) } - AppActionSheet.shared.showActionSeet(title : "", message: "Your PIN will be expired in \(31 - daysBetween(start: FlyDefaults.appLockPasswordDate, end: Date())) day(s)", showCancel: false, actions: actions, style: .alert, sheetCallBack: { [weak self] didCancelTap, tappedTitle in + AppActionSheet.shared.showActionSeet(title : "", message: "Your PIN will be expired in \(31 - daysBetween(start: CommonDefaults.appLockPasswordDate, end: Date())) day(s)", showCancel: false, actions: actions, style: .alert, sheetCallBack: { [weak self] didCancelTap, tappedTitle in if !didCancelTap { switch tappedTitle { case "Change PIN": @@ -253,7 +253,7 @@ class AuthenticationPINViewController: BaseViewController, UITextFieldDelegate { txtSixth.delegate = self verifyOTPViewModel = VerifyOTPViewModel() otpViewModel = OTPViewModel() - phoneNumber = FlyDefaults.myMobileNumber + phoneNumber = ContactManager.getMyProfile().mobileNumber self.collectionview.register(UINib(nibName:Identifiers.authenticationPINCollectionViewCell, bundle: .main), forCellWithReuseIdentifier:Identifiers.authenticationPINCollectionViewCell) @@ -450,84 +450,95 @@ class AuthenticationPINViewController: BaseViewController, UITextFieldDelegate { //PIN VALIDATION func validateAppPIN() { - if pinInput != FlyDefaults.appLockPassword { - if FlyDefaults.passwordAuthenticationAttemps > 4 { + if pinInput != CommonDefaults.appLockPassword { + if CommonDefaults.passwordAuthenticationAttemps > 4 { showfailedAttempsActionAlert() } } - if pinInput == FlyDefaults.appLockPassword { - if isResetByFailedAttempts { - if FlyDefaults.showAppLock { + if pinInput == CommonDefaults.appLockPassword { + if isResetByFailedAttempts && !CommonDefaults.privateChatOnChatScreen { + if CommonDefaults.showAppLock { self.popToRootView() } else { self.popToView() } - FlyDefaults.showAppLock = false - FlyDefaults.faceOrFingerAuthenticationFails = false + CommonDefaults.showAppLock = false + CommonDefaults.faceOrFingerAuthenticationFails = false } else if isDisablePin { - FlyDefaults.appLockenable = false - FlyDefaults.appFingerprintenable = false - if FlyDefaults.showAppLock { + CommonDefaults.appLockenable = false + CommonDefaults.appFingerprintenable = false + if CommonDefaults.showAppLock { self.popToRootView() } else { self.popToView() } - FlyDefaults.showAppLock = false - FlyDefaults.faceOrFingerAuthenticationFails = false + CommonDefaults.showAppLock = false + CommonDefaults.faceOrFingerAuthenticationFails = false } else { if login == true { - FlyDefaults.appLockenable = true + CommonDefaults.appLockenable = true } else if logout == true{ - FlyDefaults.appLockenable = false + CommonDefaults.appLockenable = false requestLogout() } - else if FlyDefaults.appLockenable == true { + else if CommonDefaults.appLockenable == true { if disableBothPIN == true { - FlyDefaults.appLockenable = false - FlyDefaults.appFingerprintenable = false + CommonDefaults.appLockenable = false + CommonDefaults.appFingerprintenable = false } else if fingerPrintEnable == true{ - FlyDefaults.appFingerprintenable = true - FlyDefaults.appLockenable = true + CommonDefaults.appFingerprintenable = true + CommonDefaults.appLockenable = true } } - if FlyDefaults.appFingerprintenable == true && FlyDefaults.appLockenable == true { + if CommonDefaults.appFingerprintenable == true && CommonDefaults.appLockenable == true { if fingerPrintLogin == true { - FlyDefaults.appFingerprintenable = true - FlyDefaults.appLockenable = true + CommonDefaults.appFingerprintenable = true + CommonDefaults.appLockenable = true } else if fingerPrintLogout == true { - FlyDefaults.appFingerprintenable = false + CommonDefaults.appFingerprintenable = false } } - if fingerPrintLogin || noFingerprintAdded{ - if noFingerprintAdded == true{ - FlyDefaults.appFingerprintenable = false - } - if FlyDefaults.showAppLock { - self.popToRootView() + if CommonDefaults.privateChatOnChatScreen { + if CommonDefaults.appFingerprintenable { + if let viewControllers: [UIViewController] = self.navigationController?.viewControllers as? [UIViewController] { + self.navigationController?.popToViewController(viewControllers[viewControllers.count - 3], animated: false) + } } else { - self.popToView() + self.navigationController?.popViewController(animated: false) } - FlyDefaults.showAppLock = false - FlyDefaults.faceOrFingerAuthenticationFails = false + CommonDefaults.privateChatOnChatScreen = false } else { - - if FlyDefaults.showAppLock { - self.popToRootView() + if fingerPrintLogin || noFingerprintAdded{ + if noFingerprintAdded == true{ + CommonDefaults.appFingerprintenable = false + } + if CommonDefaults.showAppLock { + self.popToRootView() + } else { + self.popToView() + } + CommonDefaults.showAppLock = false + CommonDefaults.faceOrFingerAuthenticationFails = false } else { - self.popToView() + + if CommonDefaults.showAppLock { + self.popToRootView() + } else { + self.popToView() + } + CommonDefaults.showAppLock = false + CommonDefaults.faceOrFingerAuthenticationFails = false } - FlyDefaults.showAppLock = false - FlyDefaults.faceOrFingerAuthenticationFails = false } } } else { - FlyDefaults.passwordAuthenticationAttemps+=1 + CommonDefaults.passwordAuthenticationAttemps+=1 AppAlert.shared.showToast(message: ErrorMessage.validateAppLock) } DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in @@ -538,7 +549,7 @@ class AuthenticationPINViewController: BaseViewController, UITextFieldDelegate { func popToRootView() { DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in - FlyDefaults.passwordAuthenticationAttemps = 0 + CommonDefaults.passwordAuthenticationAttemps = 0 self?.navigationController?.popToRootViewController(animated: false) self?.dismiss(animated: false) self?.presentingViewController?.dismiss(animated: false) @@ -547,7 +558,7 @@ class AuthenticationPINViewController: BaseViewController, UITextFieldDelegate { func popToView() { DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in - FlyDefaults.passwordAuthenticationAttemps = 0 + CommonDefaults.passwordAuthenticationAttemps = 0 self?.navigationController?.popViewController(animated: true) self?.dismiss(animated: false) } @@ -558,7 +569,7 @@ class AuthenticationPINViewController: BaseViewController, UITextFieldDelegate { } func forgotPassword() { - phoneNumber = "+"+FlyDefaults.myMobileNumber + phoneNumber = "+" + ContactManager.getMyProfile().mobileNumber if NetworkReachability.shared.isConnected { startLoading(withText: pleaseWait) //Request SMS @@ -636,7 +647,9 @@ extension AuthenticationPINViewController: UICollectionViewDelegate,UICollection cell.passwordImage.image = UIImage(named: ImageConstant.otpPin) } if (pinInput.count == 4 && indexPath.item == 3){ - validateAppPIN() + DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { [weak self] in + self?.validateAppPIN() + } } return cell @@ -658,7 +671,7 @@ extension AuthenticationPINViewController: UICollectionViewDelegate,UICollection print(array[indexPath.row]) if indexPath.row != 11 && indexPath.row != 9{ let text = array[indexPath.row] - if (pinInput.count <= 4) { + if (pinInput.count < 4) { pinInput.append(text) } print("pinInput",pinInput) diff --git a/MirrorflyUIkit/Controllers/Authentication PIN/FingerPrint PIN/FingerPrintPINViewController.swift b/MirrorflyUIkit/Controllers/Authentication PIN/FingerPrint PIN/FingerPrintPINViewController.swift index 5ad3b72..8f47507 100644 --- a/MirrorflyUIkit/Controllers/Authentication PIN/FingerPrint PIN/FingerPrintPINViewController.swift +++ b/MirrorflyUIkit/Controllers/Authentication PIN/FingerPrint PIN/FingerPrintPINViewController.swift @@ -72,15 +72,20 @@ class FingerPrintPINViewController: UIViewController { [weak self] success, authenticationError in DispatchQueue.main.async { if success { - if self?.daysBetween(start: FlyDefaults.appLockPasswordDate, end: Date()) ?? 0 >= 31 { - let initialViewController = AuthenticationPINViewController(nibName: "AuthenticationPINViewController", bundle: nil) - initialViewController.noFingerprintAdded = true - self?.navigationController?.pushViewController(initialViewController, animated: false) + if CommonDefaults.privateChatOnChatScreen { + self?.navigationController?.popViewController(animated: true) + CommonDefaults.privateChatOnChatScreen = false } else { - FlyDefaults.showAppLock = false - FlyDefaults.passwordAuthenticationAttemps = 0 - self?.navigationController?.popToRootViewController(animated: false) - self?.dismiss(animated: false) + if self?.daysBetween(start: CommonDefaults.appLockPasswordDate, end: Date()) ?? 0 >= 31 { + let initialViewController = AuthenticationPINViewController(nibName: "AuthenticationPINViewController", bundle: nil) + initialViewController.noFingerprintAdded = true + self?.navigationController?.pushViewController(initialViewController, animated: false) + } else { + CommonDefaults.showAppLock = false + CommonDefaults.passwordAuthenticationAttemps = 0 + self?.navigationController?.popToRootViewController(animated: false) + self?.dismiss(animated: false) + } } } else { guard let error = authenticationError else { @@ -99,7 +104,7 @@ class FingerPrintPINViewController: UIViewController { switch errorCode { case LAError.authenticationFailed.rawValue: navigateToAuthentication() - FlyDefaults.faceOrFingerAuthenticationFails = true + CommonDefaults.faceOrFingerAuthenticationFails = true case LAError.userCancel.rawValue: navigateToAuthentication() case LAError.userFallback.rawValue: diff --git a/MirrorflyUIkit/Controllers/Change Password View Controller/ChangeAppLockViewController.swift b/MirrorflyUIkit/Controllers/Change Password View Controller/ChangeAppLockViewController.swift index 887d9de..4b20f79 100644 --- a/MirrorflyUIkit/Controllers/Change Password View Controller/ChangeAppLockViewController.swift +++ b/MirrorflyUIkit/Controllers/Change Password View Controller/ChangeAppLockViewController.swift @@ -89,11 +89,11 @@ class ChangeAppLockViewController: UIViewController, UITextFieldDelegate { if changePassword() == false { return } - if enterOldPassword.text == FlyDefaults.appLockPassword && enterNewPassword.text == confirmNewPassword.text{ - FlyDefaults.appLockPassword = confirmNewPassword.text ?? "" - FlyDefaults.appLockPasswordDate = Date() + if enterOldPassword.text == CommonDefaults.appLockPassword && enterNewPassword.text == confirmNewPassword.text{ + CommonDefaults.appLockPassword = confirmNewPassword.text ?? "" + CommonDefaults.appLockPasswordDate = Date() print(confirmNewPassword.text ?? "") - FlyDefaults.appFingerprintenable = false + CommonDefaults.appFingerprintenable = false self.showToastWithMessage(message: SuccessMessage.pinChangedSuccessfully) } self.navigationController?.popViewController(animated: true) @@ -152,7 +152,7 @@ class ChangeAppLockViewController: UIViewController, UITextFieldDelegate { self.showToastWithMessage(message: ErrorMessage.enterValidPIN) return false } - if enterOldPassword.text != FlyDefaults.appLockPassword{ + if enterOldPassword.text != CommonDefaults.appLockPassword{ self.showToastWithMessage(message: ErrorMessage.invalidOLDPIN) return false } diff --git a/MirrorflyUIkit/Controllers/Chat Settings/AutodownloadSelectionViewController.swift b/MirrorflyUIkit/Controllers/Chat Settings/AutodownloadSelectionViewController.swift index 7549c2c..056e7a7 100644 --- a/MirrorflyUIkit/Controllers/Chat Settings/AutodownloadSelectionViewController.swift +++ b/MirrorflyUIkit/Controllers/Chat Settings/AutodownloadSelectionViewController.swift @@ -31,8 +31,6 @@ class AutodownloadSelectionViewController: UIViewController { var sectionlist = NetworkType.allCases var downloadfiles = MessageDownloadType.allCases - var mobiledata = [String : Bool]() - var wifi = [String : Bool]() var sectionName = [DownlaodList]() @IBOutlet weak var autoDownloadTableview: UITableView! @@ -42,8 +40,6 @@ class AutodownloadSelectionViewController: UIViewController { self.autoDownloadTableview.dataSource = self sectionName = [DownlaodList(isopened: false, sectionTitle:sectionlist, sectionValues: downloadfiles),DownlaodList(isopened: false, sectionTitle:sectionlist, sectionValues: downloadfiles)] - mobiledata = FlyDefaults.autoDownloadMobile - wifi = FlyDefaults.autoDownloadWifi autoDownloadTableview.reloadData() } @@ -103,33 +99,35 @@ extension AutodownloadSelectionViewController : UITableViewDelegate,UITableViewD let cell = tableView.dequeueReusableCell(withIdentifier: "AutodownloadsTableViewCell", for: indexPath) as! AutodownloadsTableViewCell if indexPath.section == 0 { + let autoDownloadMobile = ChatManager.autoDownloadMobileConfig() cell.labeltitle.text = sectionName[indexPath.section].sectionValues[indexPath.row].rawValue switch sectionName[0].sectionValues[indexPath.row] { case .Photos: - cell.selectedImageoutlet.image = getSelectedImage(isselected: FlyDefaults.autoDownloadMobile["photo"] ?? false) + cell.selectedImageoutlet.image = getSelectedImage(isselected: autoDownloadMobile[AutoDownloadType.photo.rawValue] ?? false) case .Videos: - cell.selectedImageoutlet.image = getSelectedImage(isselected: FlyDefaults.autoDownloadMobile["videos"] ?? false) + cell.selectedImageoutlet.image = getSelectedImage(isselected: autoDownloadMobile[AutoDownloadType.videos.rawValue] ?? false) case .Audios: - cell.selectedImageoutlet.image = getSelectedImage(isselected: FlyDefaults.autoDownloadMobile["audio"] ?? false) + cell.selectedImageoutlet.image = getSelectedImage(isselected: autoDownloadMobile[AutoDownloadType.audio.rawValue] ?? false) case .Documents: - cell.selectedImageoutlet.image = getSelectedImage(isselected: FlyDefaults.autoDownloadMobile["documents"] ?? false) + cell.selectedImageoutlet.image = getSelectedImage(isselected: autoDownloadMobile[AutoDownloadType.documents.rawValue] ?? false) break } } else{ + let autoDownloadWiFi = ChatManager.autoDownloadWiFiConfig() cell.labeltitle.text = sectionName[indexPath.section].sectionValues[indexPath.row].rawValue switch sectionName[1].sectionValues[indexPath.row] { case .Photos: - cell.selectedImageoutlet.image = getSelectedImage(isselected: FlyDefaults.autoDownloadWifi["photo"] ?? false ) + cell.selectedImageoutlet.image = getSelectedImage(isselected: autoDownloadWiFi[AutoDownloadType.photo.rawValue] ?? false ) case .Videos: - cell.selectedImageoutlet.image = getSelectedImage(isselected: FlyDefaults.autoDownloadWifi["videos"] ?? false) + cell.selectedImageoutlet.image = getSelectedImage(isselected: autoDownloadWiFi[AutoDownloadType.videos.rawValue] ?? false) case .Audios: - cell.selectedImageoutlet.image = getSelectedImage(isselected: FlyDefaults.autoDownloadWifi["audio"] ?? false) + cell.selectedImageoutlet.image = getSelectedImage(isselected: autoDownloadWiFi[AutoDownloadType.audio.rawValue] ?? false) case .Documents: - cell.selectedImageoutlet.image = getSelectedImage(isselected: FlyDefaults.autoDownloadWifi["documents"] ?? false) + cell.selectedImageoutlet.image = getSelectedImage(isselected: autoDownloadWiFi[AutoDownloadType.documents.rawValue] ?? false) break } @@ -146,52 +144,38 @@ extension AutodownloadSelectionViewController : UITableViewDelegate,UITableViewD switch sectionName[0].sectionValues[indexPath.row] { case .Photos: - let isPhotoEnabled = !(mobiledata["photo"] ?? false) - mobiledata["photo"] = isPhotoEnabled - FlyDefaults.autoDownloadTimeMobileDataImage = isPhotoEnabled ? FlyUtils.getTimeInMillis() : 0 + let status = ChatManager.autoDownloadMobileConfig()[AutoDownloadType.photo.rawValue] ?? false + ChatManager.updateAutoDownloadMobile(type: .photo, enable: !status) case .Videos: - let isVideoEnabled = !(mobiledata["videos"] ?? false) - mobiledata["videos"] = isVideoEnabled - FlyDefaults.autoDownloadTimeMobileDataVideo = isVideoEnabled ? FlyUtils.getTimeInMillis() : 0 + let status = ChatManager.autoDownloadMobileConfig()[AutoDownloadType.videos.rawValue] ?? false + ChatManager.updateAutoDownloadMobile(type: .videos, enable: !status) case .Audios: - let isAudioEnabled = !(mobiledata["audio"] ?? false) - mobiledata["audio"] = isAudioEnabled - FlyDefaults.autoDownloadTimeMobileDataAudio = isAudioEnabled ? FlyUtils.getTimeInMillis() : 0 + let status = ChatManager.autoDownloadMobileConfig()[AutoDownloadType.audio.rawValue] ?? false + ChatManager.updateAutoDownloadMobile(type: .audio, enable: !status) case .Documents: - let isDocumentEnalbed = !(mobiledata["documents"] ?? false) - mobiledata["documents"] = isDocumentEnalbed - FlyDefaults.autoDownloadTimeMobileDataDocument = isDocumentEnalbed ? FlyUtils.getTimeInMillis() : 0 + let status = ChatManager.autoDownloadMobileConfig()[AutoDownloadType.documents.rawValue] ?? false + ChatManager.updateAutoDownloadMobile(type: .documents, enable: !status) } case 1: switch sectionName[1].sectionValues[indexPath.row] { case .Photos: - let isPhotoEnabled = !(wifi["photo"] ?? false) - wifi["photo"] = isPhotoEnabled - FlyDefaults.autoDownloadTimeWifiImage = isPhotoEnabled ? FlyUtils.getTimeInMillis() : 0 + let status = ChatManager.autoDownloadWiFiConfig()[AutoDownloadType.photo.rawValue] ?? false + ChatManager.updateAutoDownloadWiFi(type: .photo, enable: !status) case .Videos: - let isVideoEnabled = !(wifi["videos"] ?? false) - wifi["videos"] = isVideoEnabled - FlyDefaults.autoDownloadTimeWifiVideo = isVideoEnabled ? FlyUtils.getTimeInMillis() : 0 + let status = ChatManager.autoDownloadWiFiConfig()[AutoDownloadType.videos.rawValue] ?? false + ChatManager.updateAutoDownloadWiFi(type: .videos, enable: !status) case .Audios: - let isAudioEnabled = !(wifi["audio"] ?? false) - wifi["audio"] = isAudioEnabled - FlyDefaults.autoDownloadTimeWifiAudio = isAudioEnabled ? FlyUtils.getTimeInMillis() : 0 + let status = ChatManager.autoDownloadWiFiConfig()[AutoDownloadType.audio.rawValue] ?? false + ChatManager.updateAutoDownloadWiFi(type: .audio, enable: !status) case .Documents: - let isDocumentDownload = !(wifi["documents"] ?? false) - wifi["documents"] = isDocumentDownload - FlyDefaults.autoDownloadTimeWifiDocument = isDocumentDownload ? FlyUtils.getTimeInMillis() : 0 + let status = ChatManager.autoDownloadWiFiConfig()[AutoDownloadType.documents.rawValue] ?? false + ChatManager.updateAutoDownloadWiFi(type: .documents, enable: !status) } default: break } - FlyDefaults.autoDownloadMobile = mobiledata - FlyDefaults.autoDownloadWifi = wifi - - print("case0",mobiledata) - print("case1",wifi) - self.autoDownloadTableview.reloadData() } diff --git a/MirrorflyUIkit/Controllers/Chat Settings/ChatBackup/BackupViewController.swift b/MirrorflyUIkit/Controllers/Chat Settings/ChatBackup/BackupViewController.swift index 0c6948e..541fc78 100644 --- a/MirrorflyUIkit/Controllers/Chat Settings/ChatBackup/BackupViewController.swift +++ b/MirrorflyUIkit/Controllers/Chat Settings/ChatBackup/BackupViewController.swift @@ -52,9 +52,9 @@ class BackupViewController: UIViewController { self.navigationController?.isNavigationBarHidden = true initialSetup(isAutoBackup: Utility.getAutoBackupIsOn()) setupiCloud() - if FlyDefaults.isBackupInProgress { + if BackupManager.isBackupInProgress() { presentProgressController() - } else if !FlyDefaults.isBackupCompleted { + } else if !CommonDefaults.isBackupCompleted { progressView.isHidden = false cancelButton.isHidden = false uploadProgressLabel.isHidden = false @@ -99,8 +99,8 @@ class BackupViewController: UIViewController { setupSwitchUI(uiSwitch: autoBackupSwitch) // setupSwitchUI(uiSwitch: autoBackupOverSwitch) backupButton.titleLabel?.font = AppFont.Medium.size(14) - backupButton.alpha = FlyDefaults.isBackupInProgress ? 0.5 : 1 - backupButton.isUserInteractionEnabled = FlyDefaults.isBackupInProgress ? false : true + backupButton.alpha = BackupManager.isBackupInProgress() ? 0.5 : 1 + backupButton.isUserInteractionEnabled = BackupManager.isBackupInProgress() ? false : true } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) diff --git a/MirrorflyUIkit/Controllers/Chat Settings/ChatBackup/RestoreViewController.swift b/MirrorflyUIkit/Controllers/Chat Settings/ChatBackup/RestoreViewController.swift index ae69095..842171e 100644 --- a/MirrorflyUIkit/Controllers/Chat Settings/ChatBackup/RestoreViewController.swift +++ b/MirrorflyUIkit/Controllers/Chat Settings/ChatBackup/RestoreViewController.swift @@ -149,7 +149,7 @@ class RestoreViewController: UIViewController { func profileNavigation() { if let profileVc = UIStoryboard.init(name: Storyboards.profile, bundle: Bundle.main).instantiateViewController(withIdentifier: Identifiers.profileViewController) as? ProfileViewController { - profileVc.getMobileNumber = FlyDefaults.myMobileNumber + profileVc.getMobileNumber = ContactManager.getMyProfile().mobileNumber self.navigationController?.pushViewController(profileVc, animated: true) navigationController?.viewControllers.removeAll(where: { viewControllers in !viewControllers.isKind(of: ProfileViewController.self) diff --git a/MirrorflyUIkit/Controllers/Chat Settings/ChatSettingsViewController.swift b/MirrorflyUIkit/Controllers/Chat Settings/ChatSettingsViewController.swift index f74fe26..1e1a1e4 100644 --- a/MirrorflyUIkit/Controllers/Chat Settings/ChatSettingsViewController.swift +++ b/MirrorflyUIkit/Controllers/Chat Settings/ChatSettingsViewController.swift @@ -80,15 +80,15 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource let cell : ChatSettingsTableViewCell = tableView.dequeueReusableCell(withIdentifier: Identifiers.chatSettingsTableViewCell, for: indexPath) as! ChatSettingsTableViewCell cell.lblTitle.text = self.chatSettingsArray[indexPath.row].rawValue cell.defaultLanguageHeight.constant = 14.5 - cell.defaultLanguageLabel.text = FlyDefaults.selectedLanguage + cell.defaultLanguageLabel.text = CommonDefaults.selectedLanguage cell.defaultLanguageLabel.isHidden = false cell.helpTextLabel.text = enableTranslateMessageToChooseTranslationLanguage cell.ChooseLangugaeLabel.text = chooseTranslationLaguage cell.doubleTapLabel.text = doubleTapTheReceivedMessageToTranslate - cell.separaterView.isHidden = FlyDefaults.isTranlationEnabled ? false : true - cell.helpTextView.isHidden = FlyDefaults.isTranlationEnabled ? false : true - cell.formaImageView.isHidden = FlyDefaults.isTranlationEnabled ? false : true - cell.selectedImageView.image = FlyDefaults.isTranlationEnabled ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) + cell.separaterView.isHidden = CommonDefaults.isTranlationEnabled ? false : true + cell.helpTextView.isHidden = CommonDefaults.isTranlationEnabled ? false : true + cell.formaImageView.isHidden = CommonDefaults.isTranlationEnabled ? false : true + cell.selectedImageView.image = CommonDefaults.isTranlationEnabled ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:))) let formaImageViewTap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:))) cell.helpTextView.addGestureRecognizer(tap) @@ -101,7 +101,7 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource let cell : ChatSettingsTableViewCell = tableView.dequeueReusableCell(withIdentifier: Identifiers.chatSettingsTableViewCell, for: indexPath) as! ChatSettingsTableViewCell cell.lblTitle.text = self.chatSettingsArray[indexPath.row].rawValue cell.helpTextLabel.text = hidingLastSeenActivityToOtherusers - cell.selectedImageView.image = FlyDefaults.hideLastSeen ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) + cell.selectedImageView.image = ChatManager.isLastSeenEnabled() ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) cell.separaterView.isHidden = true cell.helpTextView.isHidden = true cell.formaImageView.isHidden = true @@ -112,13 +112,13 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource let cell : ChatSettingsTableViewCell = tableView.dequeueReusableCell(withIdentifier: Identifiers.chatSettingsTableViewCell, for: indexPath) as! ChatSettingsTableViewCell cell.lblTitle.text = self.chatSettingsArray[indexPath.row].rawValue cell.helpTextLabel.text = enableAutodownlaodToTurnAllTypes - cell.selectedImageView.image = FlyDefaults.autoDownloadEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) + cell.selectedImageView.image = ChatManager.isAutoDownloadEnabled() ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) cell.defaultLanguageLabel.isHidden = true cell.ChooseLangugaeLabel.text = dataUsageSettings cell.doubleTapLabel.text = setupYourMobileAndWifiDataUsageBasedOnMediaType - cell.separaterView.isHidden = FlyDefaults.autoDownloadEnable ? false : true - cell.helpTextView.isHidden = FlyDefaults.autoDownloadEnable ? false : true - cell.formaImageView.isHidden = FlyDefaults.autoDownloadEnable ? false : true + cell.separaterView.isHidden = ChatManager.isAutoDownloadEnabled() ? false : true + cell.helpTextView.isHidden = ChatManager.isAutoDownloadEnabled() ? false : true + cell.formaImageView.isHidden = ChatManager.isAutoDownloadEnabled() ? false : true cell.defaultLanguageHeight.constant = 0 cell.doubleTapHeight.constant = 5 let tap = UITapGestureRecognizer(target: self, action: #selector(self.download(_:))) @@ -133,7 +133,7 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource let cell : ChatSettingsTableViewCell = tableView.dequeueReusableCell(withIdentifier: Identifiers.chatSettingsTableViewCell, for: indexPath) as! ChatSettingsTableViewCell cell.lblTitle.text = self.chatSettingsArray[indexPath.row].rawValue cell.helpTextLabel.text = ArchiveSettingsDescription - cell.selectSwitch.isOn = FlyDefaults.isArchivedChatEnabled + cell.selectSwitch.isOn = ChatManager.isArchivedSettingsEnabled() cell.selectSwitch.isUserInteractionEnabled = false cell.helpTextView.isHidden = true cell.separaterView.isHidden = true @@ -189,12 +189,12 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource let cell:ChatSettingsTableViewCell = tableView.cellForRow(at: indexPath) as! ChatSettingsTableViewCell if isInternetConnected { - FlyDefaults.isTranlationEnabled = !FlyDefaults.isTranlationEnabled - cell.defaultLanguageLabel.text = FlyDefaults.selectedLanguage + CommonDefaults.isTranlationEnabled = !CommonDefaults.isTranlationEnabled + cell.defaultLanguageLabel.text = CommonDefaults.selectedLanguage } case .lastseen: if isInternetConnected { - ChatManager.enableDisableHideLastSeen(EnableLastSeen: !FlyDefaults.hideLastSeen) { isSuccess, flyError, flyData in + ChatManager.enableDisableHideLastSeen(EnableLastSeen: !ChatManager.isLastSeenEnabled()) { isSuccess, flyError, flyData in print(flyData) tableView.reloadData() } @@ -218,7 +218,7 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource if isSuccess{ self?.clearBadgeCountDelegate?.clearAllConversations(isCleared: true) self?.stopLoading() - UIApplication.shared.applicationIconBadgeNumber = FlyDefaults.unreadMissedCallCount + UIApplication.shared.applicationIconBadgeNumber = CallLogManager.getUnreadMissedCallCount() NotificationCenter.default.post(name: NSNotification.Name("updateMessageUnreadCount"), object: 0) ChatUtils.clearAllPushNotifications() AppAlert.shared.showToast(message: allYourChatsAreCleared ) @@ -238,11 +238,11 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource } case.autodownload: - ChatManager.shared.enableAutoDownload(isEnable: !FlyDefaults.autoDownloadEnable) + ChatManager.shared.enableAutoDownload(isEnable: !ChatManager.isAutoDownloadEnabled()) case .ArchiveSettings: if isInternetConnected { - ChatManager.enableDisableArchivedSettings(!FlyDefaults.isArchivedChatEnabled) { isSuccess, error, data in + ChatManager.enableDisableArchivedSettings(!ChatManager.isArchivedSettingsEnabled()) { isSuccess, error, data in } } @@ -255,7 +255,7 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource case .UserBusyStatus: - ChatManager.shared.enableDisableBusyStatus(!FlyDefaults.isUserBusyStatusEnabled) + ChatManager.shared.enableDisableBusyStatus(!ChatManager.shared.isBusyStatusEnabled()) } if !isInternetConnected && chatSettingsArray[indexPath.row] != .UserBusyStatus { AppAlert.shared.showToast(message: ErrorMessage.noInternet) @@ -302,10 +302,10 @@ extension ChatSettingsViewController : UITableViewDelegate,UITableViewDataSource @objc func handleSwitch(_ sender: UISwitch) { if NetworkReachability.shared.isConnected { - FlyDefaults.isArchivedChatEnabled = !FlyDefaults.isArchivedChatEnabled - ChatManager.enableDisableArchivedSettings(FlyDefaults.isArchivedChatEnabled) { isSuccess, error, data in +// FlyDefaults.isArchivedChatEnabled = !FlyDefaults.isArchivedChatEnabled + ChatManager.enableDisableArchivedSettings(!ChatManager.isArchivedSettingsEnabled()) { isSuccess, error, data in if !isSuccess { - FlyDefaults.isArchivedChatEnabled = !FlyDefaults.isArchivedChatEnabled +// FlyDefaults.isArchivedChatEnabled = !FlyDefaults.isArchivedChatEnabled } } } @@ -352,10 +352,10 @@ extension ChatSettingsViewController : AvailableFeaturesDelegate { if availableFeatures.isTranslationEnabled && availableFeatures.isClearChatEnabled { chatSettingsArray = ChatSettingList.allCases }else if !availableFeatures.isTranslationEnabled && !availableFeatures.isClearChatEnabled { - FlyDefaults.isTranlationEnabled = false + CommonDefaults.isTranlationEnabled = false chatSettingsArray = [.ArchiveSettings,.lastseen,.UserBusyStatus,.autodownload,.chatBackup] }else if !availableFeatures.isTranslationEnabled && availableFeatures.isClearChatEnabled { - FlyDefaults.isTranlationEnabled = false + CommonDefaults.isTranlationEnabled = false chatSettingsArray = [.ArchiveSettings,.lastseen,.UserBusyStatus,.autodownload,.chatBackup,.clearAllConversation] }else if availableFeatures.isTranslationEnabled && !availableFeatures.isClearChatEnabled { chatSettingsArray = [.ArchiveSettings,.TranslateMessage,.lastseen,.UserBusyStatus,.autodownload,.chatBackup] diff --git a/MirrorflyUIkit/Controllers/ChatTags/AddPeopleOrGroup/SelectedUserCollectionCell.swift b/MirrorflyUIkit/Controllers/ChatTags/AddPeopleOrGroup/SelectedUserCollectionCell.swift index 983b72f..b71715c 100644 --- a/MirrorflyUIkit/Controllers/ChatTags/AddPeopleOrGroup/SelectedUserCollectionCell.swift +++ b/MirrorflyUIkit/Controllers/ChatTags/AddPeopleOrGroup/SelectedUserCollectionCell.swift @@ -17,7 +17,7 @@ class SelectedUserCollectionCell: UICollectionViewCell { } func setImage(imageURL: String, name: String, color: UIColor , recentChat : RecentChat) { - let urlString = "\(FlyDefaults.baseURL + "" + media + "/" + imageURL + "?mf=" + "" + FlyDefaults.authtoken)" + let urlString = ChatManager.getImageUrl(imageName: imageURL) var url = URL(string: urlString) var placeHolder = UIImage() if recentChat.profileType == .groupChat { diff --git a/MirrorflyUIkit/Controllers/ChatTags/AddPeopleOrGroup/UserListCell/UserListCell.swift b/MirrorflyUIkit/Controllers/ChatTags/AddPeopleOrGroup/UserListCell/UserListCell.swift index aa8ff9a..f7d5d91 100644 --- a/MirrorflyUIkit/Controllers/ChatTags/AddPeopleOrGroup/UserListCell/UserListCell.swift +++ b/MirrorflyUIkit/Controllers/ChatTags/AddPeopleOrGroup/UserListCell/UserListCell.swift @@ -43,7 +43,7 @@ class UserListCell: UITableViewCell { } func setImage(imageURL: String, name: String, color: UIColor , recentChat : RecentChat) { - let urlString = "\(FlyDefaults.baseURL + "" + media + "/" + imageURL + "?mf=" + "" + FlyDefaults.authtoken)" + let urlString = ChatManager.getImageUrl(imageName: imageURL) var url = URL(string: urlString) var placeHolder = UIImage() if recentChat.profileType == .groupChat { diff --git a/MirrorflyUIkit/Controllers/ContactCell.swift b/MirrorflyUIkit/Controllers/ContactCell.swift index 7e9db45..74df5b1 100755 --- a/MirrorflyUIkit/Controllers/ContactCell.swift +++ b/MirrorflyUIkit/Controllers/ContactCell.swift @@ -79,7 +79,7 @@ class ContactCell: UITableViewCell { } func setImage(imageURL: String, name: String, color: UIColor) { - let urlString = FlyDefaults.baseURL + "media/" + imageURL + "?mf=" + FlyDefaults.authtoken + let urlString = ChatManager.getImageUrl(imageName: imageURL) let url = URL(string: urlString) profile.sd_setImage(with: url, placeholderImage: getPlaceholder(name: name, color: color)) } diff --git a/MirrorflyUIkit/Controllers/ContactSyncController.swift b/MirrorflyUIkit/Controllers/ContactSyncController.swift index a80e365..5a98be5 100644 --- a/MirrorflyUIkit/Controllers/ContactSyncController.swift +++ b/MirrorflyUIkit/Controllers/ContactSyncController.swift @@ -23,7 +23,7 @@ class ContactSyncController: UIViewController { syncImage.isHidden = true NotificationCenter.default.addObserver(self, selector: #selector(networkChange(_:)), name: Notification.Name(NetStatus.networkNotificationObserver), object: nil) progressInfoLabel.text = "" - userName.text = FlyDefaults.myName + userName.text = ContactManager.getMyProfile().name let authorizationStatus = CNContactStore.authorizationStatus(for: .contacts) if authorizationStatus == .authorized || authorizationStatus == .denied{ @@ -86,11 +86,11 @@ class ContactSyncController: UIViewController { func startSyncingContacts(initialSync : Bool = true) { let authorizationStatus = CNContactStore.authorizationStatus(for: .contacts) if authorizationStatus == .authorized{ - FlyDefaults.isContactPermissionDenied = false - FlyDefaults.isContactSyncNeeded = true + ContactSyncManager.updateContactPermission(isDeined: false) + ContactSyncManager.needContactSync(isSync: true) } else if authorizationStatus == .denied{ - FlyDefaults.isContactPermissionDenied = true - FlyDefaults.isContactSyncNeeded = false + ContactSyncManager.updateContactPermission(isDeined: true) + ContactSyncManager.needContactSync(isSync: false) } if NetworkReachability.shared.isConnected{ executeOnMainThread { diff --git a/MirrorflyUIkit/Controllers/ContactViewController.swift b/MirrorflyUIkit/Controllers/ContactViewController.swift index 2a6157b..dd65dac 100755 --- a/MirrorflyUIkit/Controllers/ContactViewController.swift +++ b/MirrorflyUIkit/Controllers/ContactViewController.swift @@ -163,7 +163,7 @@ class ContactViewController: UIViewController { topBarViewHeight.constant = 98 serachFieldTopMargin.constant = 4 } - + NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedPrivateChatNotification(notification:)), name: Notification.Name("PrivateChatAlertView"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedNotification(notification:)), name: Notification.Name(Identifiers.ncContactRefresh), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(self.contactSyncCompleted(notification:)), name: NSNotification.Name(FlyConstants.contactSyncState), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(networkChange(_:)),name:Notification.Name(NetStatus.networkNotificationObserver),object: nil) @@ -200,6 +200,11 @@ class ContactViewController: UIViewController { ChatManager.shared.adminBlockDelegate = nil ChatManager.shared.availableFeaturesDelegate = nil } + + override func viewDidDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + NotificationCenter.default.removeObserver(self, name: Notification.Name("PrivateChatAlertView"), object: nil) + } func setupUI() { navigationController?.view.backgroundColor = .white @@ -210,6 +215,7 @@ class ContactViewController: UIViewController { searchTxt.placeholder = search contactList.estimatedRowHeight = 60 contactList.tableFooterView = UIView() + contactList.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0.1)) } func configureDefaults() { @@ -244,6 +250,10 @@ class ContactViewController: UIViewController { self?.profilePopupContainer.isHidden = true }) } + + @objc func methodOfReceivedPrivateChatNotification(notification: Notification) { + MainTabBarController.privateChatTabBarDelegate?.moveToRecentInTabBar() + } @objc func methodOfReceivedNotification(notification: Notification) { if (self.view.window != nil) { @@ -299,7 +309,7 @@ class ContactViewController: UIViewController { } } }else{ - var groupMembers = GroupManager.shared.getGroupMemebersFromLocal(groupJid: groupJid).participantDetailArray.filter({$0.memberJid != FlyDefaults.myJid && $0.profileDetail?.isBlockedByAdmin == false}) + var groupMembers = GroupManager.shared.getGroupMemebersFromLocal(groupJid: groupJid).participantDetailArray.filter({$0.memberJid != AppUtils.getMyJid() && $0.profileDetail?.isBlockedByAdmin == false}) if isInvite{ groupMembers.removeAll { member in callUsers.contains(member.memberJid) @@ -335,7 +345,7 @@ class ContactViewController: UIViewController { } func refreshContacts() { - if ENABLE_CONTACT_SYNC && CNContactStore.authorizationStatus(for: CNEntityType.contacts) == .denied && groupJid.isEmpty || FlyDefaults.isContactPermissionSkipped && ENABLE_CONTACT_SYNC{ + if ENABLE_CONTACT_SYNC && CNContactStore.authorizationStatus(for: CNEntityType.contacts) == .denied && groupJid.isEmpty || ContactSyncManager.isPermissionSkipped() && ENABLE_CONTACT_SYNC{ contacts.removeAll() allContacts.removeAll() return @@ -436,14 +446,14 @@ class ContactViewController: UIViewController { if let profile = tappedProfile{ let name = getUserName(jid: profile.jid,name: profile.name, nickName: profile.nickName, contactType: profile.contactType) self.userName.text = name - let urlString = FlyDefaults.baseURL + "media/" + profile.image + "?mf=" + FlyDefaults.authtoken + let urlString = ChatManager.getImageUrl(imageName: profile.image) var url = URL(string: urlString) var placeholder : UIImage? switch profile.profileChatType { case .groupChat: placeholder = UIImage(named: "smallGroupPlaceHolder") default: - if profile.jid == FlyDefaults.myJid || getIsBlockedByMe(jid: profile.jid) || (IS_LIVE && ENABLE_CONTACT_SYNC && profile.isItSavedContact == false) { + if profile.jid == AppUtils.getMyJid() || getIsBlockedByMe(jid: profile.jid) || (IS_LIVE && ENABLE_CONTACT_SYNC && profile.isItSavedContact == false) { url = nil placeholder = UIImage(named: "ic_profile_placeholder") userImage?.backgroundColor = Color.groupIconBackgroundGray @@ -544,6 +554,7 @@ class ContactViewController: UIViewController { if profile.profileChatType == .singleChat{ let vc = UIStoryboard.init(name: Storyboards.chat, bundle: Bundle.main).instantiateViewController(withIdentifier: Identifiers.contactInfoViewController) as? ContactInfoViewController vc?.contactJid = profile.jid + vc?.isFromContactInfo = true vc?.navigationController?.modalPresentationStyle = .overFullScreen self.navigationController?.pushViewController(vc!, animated: true) } @@ -555,7 +566,7 @@ class ContactViewController: UIViewController { let contactPermissionStatus = CNContactStore.authorizationStatus(for: CNEntityType.contacts) - if FlyDefaults.isContactPermissionSkipped && contactPermissionStatus == .authorized{ + if ContactSyncManager.isPermissionSkipped() && contactPermissionStatus == .authorized{ syncSkippedDialog() }else if ENABLE_CONTACT_SYNC { @@ -572,7 +583,7 @@ class ContactViewController: UIViewController { } else if (contactPermissionStatus == .restricted || contactPermissionStatus == .notDetermined){ CNContactStore().requestAccess(for: .contacts){ [weak self] (access, error) in executeOnMainThread { - FlyDefaults.isContactPermissionSkipped = false + ContactSyncManager.updateContactPermission(isSkipped: false) self?.contactViewModel.syncContacts() self?.refreshControl.endRefreshing() } @@ -611,7 +622,7 @@ class ContactViewController: UIViewController { preferredStyle: UIAlertController.Style.alert) alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: { (alert) -> Void in executeOnMainThread { [weak self] in - FlyDefaults.isContactPermissionSkipped = false + ContactSyncManager.updateContactPermission(isSkipped: false) self?.contactViewModel.syncContacts() } })) @@ -646,11 +657,32 @@ extension ContactViewController: CallStatusContactDelegate { callUsers.removeAll { user in user == userId } - resetParams() - allContacts.removeAll() - contacts.removeAll() - contactList.reloadData() - getUsersList(pageNo: 1, pageSize: 20, searchTerm: searchTerm) + if isInvite && !groupJid.isEmpty { + executeOnMainThread { + let profileDetail = self.allContacts.filter { profile in + return profile.jid == userId + } + let contact = self.contacts.filter({$0.jid == userId}) + if (contact.count == 0) { + self.contacts.append(contentsOf: profileDetail) + } + self.contactList.reloadData() + } + }else { + resetParams() + allContacts.removeAll() + contacts.removeAll() + contactList.reloadData() + getUsersList(pageNo: 1, pageSize: 20, searchTerm: searchTerm) + } + case .CONNECTED: + executeOnMainThread { + self.contacts.removeAll { pd in + pd.jid == userId + } + self.contactList.reloadData() + } + default: break } } @@ -749,14 +781,17 @@ extension ContactViewController : UITableViewDelegate, UITableViewDataSource { linkLable.text = callLink headerView.addSubview(linkLable) - let copyButton = UIImageView.init(frame: CGRect(x: headerView.frame.size.width - 40, y: CGRectGetMinY(profileImg.frame) + 10, width: 20, height: 20)) - copyButton.isUserInteractionEnabled = true - copyButton.image = UIImage(named: "copy_link") - copyButton.contentMode = .scaleAspectFit + let copyButton = UIButton() + copyButton.translatesAutoresizingMaskIntoConstraints = false headerView.addSubview(copyButton) + copyButton.rightAnchor.constraint(equalTo: headerView.rightAnchor, constant: -10).isActive = true + copyButton.widthAnchor.constraint(equalToConstant: 40).isActive = true + copyButton.heightAnchor.constraint(equalToConstant: 40).isActive = true + copyButton.centerYAnchor.constraint(equalTo: profileImg.centerYAnchor, constant: 0).isActive = true + copyButton.isUserInteractionEnabled = true + copyButton.setImage(UIImage(named: "copy_link"), for: .normal) - let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTapWithCopy(_:))) - copyButton.addGestureRecognizer(tap) + copyButton.addTarget(self, action: #selector(handleTapWithCopy), for: .touchUpInside) let borderView = UIView.init(frame: CGRect(x: 20, y: CGRectGetMaxY(headerView.frame) - 5, width: headerView.frame.size.width - 20, height: 1)) @@ -913,6 +948,7 @@ extension ContactViewController : UITableViewDelegate, UITableViewDataSource { vc?.replyMessageObj = replyMessageObj vc?.replyMessagesDelegate = self vc?.messageText = messageTxt + vc?.isFromContactScreen = true ContactManager.shared.saveUser(profileDetails: profile, saveAs: .live) navigationController?.modalPresentationStyle = .fullScreen guard let viewController = vc else { return } diff --git a/MirrorflyUIkit/Controllers/ContactViewModel.swift b/MirrorflyUIkit/Controllers/ContactViewModel.swift index cd492ca..8154e07 100755 --- a/MirrorflyUIkit/Controllers/ContactViewModel.swift +++ b/MirrorflyUIkit/Controllers/ContactViewModel.swift @@ -23,7 +23,7 @@ class ContactViewModel : NSObject var data = flyData if isSuccess { if let contactsList = data.getData() as? [ProfileDetails] { - var filteredContact = contactsList.filter( {$0.profileChatType != .groupChat && $0.jid != FlyDefaults.myJid && $0.isBlockedByAdmin == false}) + var filteredContact = contactsList.filter( {$0.profileChatType != .groupChat && $0.jid != AppUtils.getMyJid() && $0.isBlockedByAdmin == false}) filteredContact.removeAll { pd in removeContacts.contains(pd.jid) } diff --git a/MirrorflyUIkit/Controllers/DMAReasonVC.swift b/MirrorflyUIkit/Controllers/DMAReasonVC.swift index 95fad0d..3abe8e9 100644 --- a/MirrorflyUIkit/Controllers/DMAReasonVC.swift +++ b/MirrorflyUIkit/Controllers/DMAReasonVC.swift @@ -57,14 +57,13 @@ class DMAReasonVC: UIViewController { ContactManager.shared.deleteMyAccountRequest(reason: reason, feedback: feedBack) { isSuccess, error, data in let message = data["message"] as? String ?? "" if isSuccess{ - FlyDefaults.appLockPassword = "" - FlyDefaults.appLockenable = false - FlyDefaults.hideLastSeen = false + CommonDefaults.appLockPassword = "" + CommonDefaults.appLockenable = false Utility.saveInPreference(key: firstTimeSandboxContactSyncDone, value: false) CallLogManager().deleteCallLogs() ChatManager.deleteAllRecentChats() //CallLogs Badge Count - FlyDefaults.unreadMissedCallCount = 0 + CallLogManager.resetUnreadMissedCallCount() UIApplication.shared.applicationIconBadgeNumber = 0 AppAlert.shared.showToast(message: "Your Mirrorfly account has been deleted.") }else{ diff --git a/MirrorflyUIkit/Controllers/Delegates/AppDelegate.swift b/MirrorflyUIkit/Controllers/Delegates/AppDelegate.swift index e8c5398..786a897 100755 --- a/MirrorflyUIkit/Controllers/Delegates/AppDelegate.swift +++ b/MirrorflyUIkit/Controllers/Delegates/AppDelegate.swift @@ -21,7 +21,7 @@ import AVFoundation import MirrorFlySDK let BASE_URL = "https://api-preprod-sandbox.mirrorfly.com/api/v1/" -let LICENSE_KEY = "XXXXXXXXXXXXXXX" +let LICENSE_KEY = "xxxxxxxxxxxxxxxxxx" let XMPP_DOMAIN = "xmpp-preprod-sandbox.mirrorfly.com" let XMPP_PORT = 5222 let SOCKETIO_SERVER_HOST = "https://signal-preprod-sandbox.mirrorfly.com" @@ -36,8 +36,8 @@ let APP_NAME = "UiKitQa" let ICLOUD_CONTAINER_ID = "iCloud.com.mirrorfly.qa" - let isMigrationDone = "isMigrationDone" +let isHideNotificationContent = false #if DEBUG @@ -48,6 +48,7 @@ let ISEXPORT = true var pushChatId: String? +var pushNotificationSelected: Bool = false @main class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { @@ -70,10 +71,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { ChatManager.enableChatHistory(isEnable: ENABLE_CHAT_HISTORY) ChatManager.setMaximumPinningForRecentChat(maxPinChat: 4) ChatManager.deleteMediaFromDevice(delete: true) + ChatManager.updateLoginDetails(isMobileNumLogin: IS_MOBILE_NUMBER_LOGIN) + ChatManager.updateWebUrlDetails(webLoginUrl: WEB_LOGIN_URL) - - FlyDefaults.isMobileNumberLogin = IS_MOBILE_NUMBER_LOGIN - FlyDefaults.webLoginUrl = WEB_LOGIN_URL if ENABLE_CONTACT_SYNC{ startObservingContactChanges() } @@ -87,15 +87,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { NetworkReachability.shared.startMonitoring() KeyboardStateListener.shared.start() - if FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable { - FlyDefaults.showAppLock = true + if CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable { + CommonDefaults.showAppLock = true } + CommonDefaults.isInPrivateChat = false + CommonDefaults.showPrivateLockRecent = false // Clear Push clearPushNotifications() registerForPushNotifications() - if FlyDefaults.isBlockedByAdmin { + if ContactManager.isBlockedByAdmin() { navigateToBlockedScreen() } else { navigateTo() @@ -127,16 +129,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { application.registerForRemoteNotifications() if Utility.getBoolFromPreference(key: isLoggedIn) { - FlyDefaults.isNewLoggedIn = false +// FlyDefaults.isNewLoggedIn = false VOIPManager.sharedInstance.updateDeviceToken() RootViewController.sharedInstance.initCallSDK() }else { - FlyDefaults.isNewLoggedIn = true +// FlyDefaults.isNewLoggedIn = true } // Added this line so that we can start receing contact updates let contactPermissionStatus = CNContactStore.authorizationStatus(for: CNEntityType.contacts) if contactPermissionStatus == .authorized || contactPermissionStatus == .denied{ - FlyDefaults.isContactPermissionSkipped = false + ContactSyncManager.updateContactPermission(isSkipped: false) } NotificationCenter.default.removeObserver(self, name: NSNotification.Name.CNContactStoreDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(contactsDidChange), name: NSNotification.Name.CNContactStoreDidChange, object: nil) @@ -147,7 +149,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { // Fallback on earlier versions } ChatManager.setMediaEncryption(isEnable: false) - ChatManager.hideNotificationContent(hide: false) + ChatManager.hideNotificationContent(hide: isHideNotificationContent) FlyUtils.setAppName(appName: APP_NAME) VOIPManager.sharedInstance.updateDeviceToken() networkMonitor() @@ -177,14 +179,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { func applicationDidBecomeActive(_ application: UIApplication) { print("#appDelegate applicationDidBecomeActive") - if FlyDefaults.isBlockedByAdmin { + if ContactManager.isBlockedByAdmin() { navigateToBlockedScreen() return } - if Utility.getBoolFromPreference(key: isLoggedIn) && (FlyDefaults.isLoggedIn) { + //if Utility.getBoolFromPreference(key: isLoggedIn) && (FlyDefaults.isLoggedIn) { // ChatManager.connect() - } + // } let current = UIApplication.shared.keyWindow?.getTopViewController() if (current is AuthenticationPINViewController || current is FingerPrintPINViewController) { if let vc = current as? FingerPrintPINViewController { @@ -199,7 +201,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { func applicationDidEnterBackground(_ application: UIApplication) { print("#appDelegate applicationDidEnterBackground") - FlyDefaults.appBackgroundTime = Date() + CommonDefaults.appBackgroundTime = Date() postNotificationdidEnterBackground = NotificationCenter.default postNotificationdidEnterBackground?.post(name: Notification.Name(didEnterBackground), object: nil) } @@ -208,8 +210,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { contactSyncSubscription?.dispose() NetStatus.shared.stopMonitoring() - if FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable { - FlyDefaults.showAppLock = true + if CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable { + CommonDefaults.showAppLock = true } NotificationCenter.default.removeObserver(self, name: NSNotification.Name.CNContactStoreDidChange, object: nil) @@ -217,12 +219,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { func applicationProtectedDataDidBecomeAvailable(_ application: UIApplication) { print("applicationProtectedDataDidBecomeAvailable") - if (FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable) { - FlyDefaults.showAppLock = true + if CommonDefaults.showAppLock == true { showApplockScreen() } } + func applicationProtectedDataWillBecomeUnavailable(_ application: UIApplication) { + if (CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable) { + CommonDefaults.showAppLock = true + } + } + func showApplockScreen() { let current = UIApplication.shared.keyWindow?.getTopViewController() @@ -232,8 +239,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first let navigationController = window?.rootViewController as? UINavigationController - if FlyDefaults.appFingerprintenable && FlyDefaults.appLockenable && FlyDefaults.showAppLock { - if !FlyDefaults.faceOrFingerAuthenticationFails { + if CommonDefaults.appFingerprintenable && CommonDefaults.appLockenable && CommonDefaults.showAppLock && !CommonDefaults.appLockOnPrivateChat { + if !CommonDefaults.faceOrFingerAuthenticationFails { let initialViewController = FingerPrintPINViewController(nibName: "FingerPrintPINViewController", bundle: nil) initialViewController.modalPresentationStyle = .overFullScreen navigationController?.present(initialViewController, animated: false) @@ -244,7 +251,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate { navigationController?.pushViewController(initialViewController, animated: false) } } - else if FlyDefaults.appLockenable && FlyDefaults.appFingerprintenable == false && FlyDefaults.showAppLock { + else if CommonDefaults.appLockenable && CommonDefaults.appFingerprintenable == false && CommonDefaults.showAppLock { let initialViewController = AuthenticationPINViewController(nibName: "AuthenticationPINViewController", bundle: nil) initialViewController.modalPresentationStyle = .overFullScreen //navigationController?.present(initialViewController, animated: false) @@ -298,17 +305,35 @@ extension AppDelegate : UNUserNotificationCenterDelegate { completionHandler(.noData) } func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { - if response.notification.request.content.threadIdentifier.contains(FlyDefaults.xmppDomain){ - if FlyDefaults.isBlockedByAdmin { + if response.notification.request.content.threadIdentifier.contains(ChatManager.getXMPPDetails().XMPPDomain){ + if ContactManager.isBlockedByAdmin() { navigateToBlockedScreen() } else { let messageId = response.notification.request.content.userInfo["message_id"] as? String ?? "" let message = FlyMessenger.getMessageOfId(messageId: messageId) if response.notification.request.trigger is UNPushNotificationTrigger { + + let current = UIApplication.shared.keyWindow?.getTopViewController() + if (current is PrivateChatFingerPrintPINViewController) { + if let vc = current as? PrivateChatFingerPrintPINViewController { + return + } + } + pushChatId = message?.chatUserJid ?? "" + if let recent = ChatManager.getRechtChat(jid: pushChatId ?? "") { + if recent.isPrivateChat && !CommonDefaults.privateChatOnChatScreen && !CommonDefaults.appLockOnPrivateChat { + pushNotificationSelected = true + pushChatId = nil + navigateToChatScreen(chatId: message?.chatUserJid ?? "", completionHandler: completionHandler) + } else { + pushChatId = nil + navigateToChatScreen(chatId: message?.chatUserJid ?? "", completionHandler: completionHandler) + } + } } else { pushChatId = message?.chatUserJid ?? "" - if !FlyDefaults.showAppLock { + if !CommonDefaults.showAppLock { pushChatId = nil navigateToChatScreen(chatId: message?.chatUserJid ?? "", completionHandler: completionHandler) } @@ -316,7 +341,7 @@ extension AppDelegate : UNUserNotificationCenterDelegate { } }else if response.notification.request.content.threadIdentifier == "media-call" { pushChatId = "media-call" - if FlyDefaults.isBlockedByAdmin { + if ContactManager.isBlockedByAdmin() { navigateToBlockedScreen() } else { @@ -366,7 +391,7 @@ extension AppDelegate { func startObservingContactChanges(){ contactSyncSubscription = contactSyncSubject.throttle(.seconds(3), latest: false ,scheduler: MainScheduler.instance).subscribe(onNext: { bool in if bool{ - if !FlyDefaults.isContactPermissionSkipped{ + if !ContactSyncManager.isPermissionSkipped() { ContactSyncManager.shared.syncContacts(){ isSuccess,_,_ in print("#contact Sync status => \(isSuccess)") } @@ -379,7 +404,7 @@ extension AppDelegate { @objc func contactsDidChange(notification: NSNotification){ print("#contact #appdelegate @contactsDidChange") if Utility.getBoolFromPreference(key: isLoggedIn) && ENABLE_CONTACT_SYNC { - FlyDefaults.isContactSyncNeeded = true + ContactSyncManager.needContactSync(isSync: true) contactSyncSubject.onNext(true) } } @@ -387,7 +412,7 @@ extension AppDelegate { func navigateToChatScreen(chatId : String,completionHandler: @escaping () -> Void){ var dismisLastViewController = false - if let profileDetails = ContactManager.shared.getUserProfileDetails(for: chatId) , chatId != FlyDefaults.myJid{ + if let profileDetails = ContactManager.shared.getUserProfileDetails(for: chatId) , chatId != AppUtils.getMyJid() { if #available(iOS 13, *) { guard let rootViewController = (UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.window?.rootViewController else { completionHandler() @@ -402,6 +427,11 @@ extension AppDelegate { if let chatViewController = UIStoryboard.init(name: Storyboards.chat, bundle: Bundle.main).instantiateViewController(withIdentifier: Identifiers.chatViewParentController) as? ChatViewParentController, let navigationController = rootViewController as? UINavigationController{ chatViewController.getProfileDetails = profileDetails + if let recent = ChatManager.getRechtChat(jid: profileDetails.jid) { + if recent.isPrivateChat && pushNotificationSelected == false { + chatViewController.isFromNotificationSelect = true + } + } let color = getColor(userName: getUserName(jid: profileDetails.jid,name: profileDetails.name, nickName: profileDetails.nickName, contactType: profileDetails.contactType)) chatViewController.contactColor = color if dismisLastViewController{ @@ -421,6 +451,11 @@ extension AppDelegate { chatViewController.getProfileDetails = profileDetails let color = getColor(userName: getUserName(jid: profileDetails.jid,name: profileDetails.name, nickName: profileDetails.nickName, contactType: profileDetails.contactType)) chatViewController.contactColor = color + if let recent = ChatManager.getRechtChat(jid: profileDetails.jid) { + if recent.isPrivateChat && pushNotificationSelected == false { + chatViewController.isFromNotificationSelect = true + } + } if dismisLastViewController{ navigationController.popViewController(animated: false) } @@ -510,7 +545,6 @@ extension AppDelegate { Utility.saveInPreference(key: isLoggedIn, value: false) ChatManager.disconnect() ChatManager.shared.resetFlyDefaults() - FlyDefaults.isBlockedByAdmin = false } func navigateToBlockedScreen() { @@ -544,7 +578,7 @@ extension AppDelegate { } UIApplication.shared.keyWindow?.rootViewController = navigationController UIApplication.shared.keyWindow?.makeKeyAndVisible() - }else if Utility.getBoolFromPreference(key: isLoggedIn) && FlyDefaults.myMobileNumber != "" { + }else if Utility.getBoolFromPreference(key: isLoggedIn) && ContactManager.getMyProfile().mobileNumber != "" { let storyboard = UIStoryboard(name: "Profile", bundle: nil) let initialViewController = storyboard.instantiateViewController(withIdentifier: "ProfileViewController") as! ProfileViewController UIApplication.shared.keyWindow?.rootViewController = UINavigationController(rootViewController: initialViewController) @@ -572,7 +606,7 @@ extension AppDelegate : LocalNotificationDelegate { if (current is RestoreViewController || current is BackupProgressViewController) { return } - if ChatManager.onGoingChatUserJid == chatMessage.senderUserJid || (ChatManager.onGoingChatUserJid == groupId && groupId != "") { + if (ChatManager.onGoingChatUserJid == chatMessage.senderUserJid && groupId == "") || (ChatManager.onGoingChatUserJid == groupId && groupId != "") { if !CallManager.isOngoingCall() { self.playSound() @@ -591,6 +625,11 @@ extension AppDelegate : LocalNotificationDelegate { title = userName var message = chatMessage.messageTextContent if chatMessage.isMessageRecalled == true { +// if let chat = ChatManager.getRechtChat(jid: groupId.isEmpty ? jid : groupId) { +// if chat.isPrivateChat { +// return +// } +// } message = "This message was deleted" } else { switch chatMessage.messageType{ @@ -605,7 +644,7 @@ extension AppDelegate : LocalNotificationDelegate { } } var isCarbon = false - if FlyDefaults.hideNotificationContent{ + if isHideNotificationContent { let (messageCount, chatCount) = ChatManager.getUNreadMessageAndChatCount() var titleContent = emptyString() if chatCount == 1{ @@ -613,7 +652,7 @@ extension AppDelegate : LocalNotificationDelegate { }else{ titleContent = "\(messageCount) messages from \(chatCount) chats" } - title = FlyDefaults.appName + " (\(titleContent))" + title = APP_NAME + " (\(titleContent))" message = "New Message" }else{ if groupId.isEmpty{ @@ -625,7 +664,7 @@ extension AppDelegate : LocalNotificationDelegate { } } - if chatMessage.senderUserJid == FlyDefaults.myJid{ + if chatMessage.senderUserJid == AppUtils.getMyJid() { isCarbon = true } if isCarbon { @@ -636,6 +675,14 @@ extension AppDelegate : LocalNotificationDelegate { message = ChatUtils.getMentionTextContent(message: message, isMessageSentByMe: chatMessage.isMessageSentByMe, mentionedUsers: chatMessage.mentionedUsersIds).string } + if let chat = ChatManager.getRechtChat(jid: groupId.isEmpty ? jid : groupId) { + if chat.isPrivateChat { + title = APP_NAME + let (messageCount, _) = ChatManager.getUnreadPrivateChatMessageAndChatCount() + message = "\(messageCount) new message" + } + } + executeOnMainThread { self.showCustomNotificationView(title: title , message: message, chatMessage: chatMessage) } @@ -651,11 +698,11 @@ extension AppDelegate : MissedCallNotificationDelegate { if (current is CallLogViewController) { //Application Badge Count var appBadgeCount = UIApplication.shared.applicationIconBadgeNumber - appBadgeCount = appBadgeCount - FlyDefaults.unreadMissedCallCount + appBadgeCount = appBadgeCount - CallLogManager.getUnreadMissedCallCount() UIApplication.shared.applicationIconBadgeNumber = appBadgeCount //CallLogs Badge Count - FlyDefaults.unreadMissedCallCount = 0 - NotificationCenter.default.post(name: NSNotification.Name("updateUnReadMissedCallCount"), object: FlyDefaults.unreadMissedCallCount) + CallLogManager.resetUnreadMissedCallCount() + NotificationCenter.default.post(name: NSNotification.Name("updateUnReadMissedCallCount"), object: CallLogManager.getUnreadMissedCallCount()) } var callMode = "" @@ -715,7 +762,7 @@ extension AppDelegate { self.playSound() - if FlyDefaults.vibrationEnable { + if CommonDefaults.vibrationEnable { AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate)) } } @@ -757,6 +804,9 @@ extension AppDelegate { if (current is ProfileViewController) { return } + if (current is PrivateChatFingerPrintPINViewController) { + return + } if (current is CallViewController) { (current as! CallViewController).showCallOverlay() } @@ -766,14 +816,14 @@ extension AppDelegate { print("Tap on a Notification View \(message)") - if FlyDefaults.isBlockedByAdmin { + if ContactManager.isBlockedByAdmin() { navigateToBlockedScreen() } else { let messageId = message.messageId let message = FlyMessenger.getMessageOfId(messageId: messageId) pushChatId = message?.chatUserJid ?? "" - if !FlyDefaults.showAppLock { + if !CommonDefaults.showAppLock { pushChatId = nil navigateToChatScreen(chatId: message?.chatUserJid ?? "", completionHandler: {}) } @@ -784,7 +834,7 @@ extension AppDelegate { if let message = sender?.view?.accessibilityElements as? [String] { print("Tap on a Call View \(message)") pushChatId = "media-call" - if FlyDefaults.isBlockedByAdmin { + if ContactManager.isBlockedByAdmin() { navigateToBlockedScreen() } else { @@ -804,7 +854,7 @@ extension AppDelegate { func playSound() { - if !(FlyDefaults.selectedNotificationSoundName[NotificationSoundKeys.name.rawValue]?.contains("None") ?? false) && FlyDefaults.notificationSoundEnable { + if !(CommonDefaults.selectedNotificationSoundName[NotificationSoundKeys.name.rawValue]?.contains("None") ?? false) && CommonDefaults.notificationSoundEnable { guard let path = Bundle.main.path(forResource: "wheep", ofType:"mp3") else { return } diff --git a/MirrorflyUIkit/Controllers/Delegates/SceneDelegate.swift b/MirrorflyUIkit/Controllers/Delegates/SceneDelegate.swift index ecfeed1..8381ccb 100755 --- a/MirrorflyUIkit/Controllers/Delegates/SceneDelegate.swift +++ b/MirrorflyUIkit/Controllers/Delegates/SceneDelegate.swift @@ -23,11 +23,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). BackupManager.shared.backupDelegate = self - if FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable { - FlyDefaults.showAppLock = true + if CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable { + CommonDefaults.showAppLock = true } - if FlyDefaults.isBlockedByAdmin { + if ContactManager.isBlockedByAdmin() { navigateToBlockedScreen() } else if Utility.getBoolFromPreference(key: isProfileSaved) { let navigationController : UINavigationController @@ -48,7 +48,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } self.window?.rootViewController = navigationController self.window?.makeKeyAndVisible() - }else if Utility.getBoolFromPreference(key: isLoggedIn) && FlyDefaults.myMobileNumber != "" { + }else if Utility.getBoolFromPreference(key: isLoggedIn) && ContactManager.getMyProfile().mobileNumber != "" { let storyboard = UIStoryboard(name: "Profile", bundle: nil) let initialViewController = storyboard.instantiateViewController(withIdentifier: "ProfileViewController") as! ProfileViewController self.window?.rootViewController = UINavigationController(rootViewController: initialViewController) @@ -76,8 +76,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { @available(iOS 13.0, *) func sceneDidDisconnect(_ scene: UIScene) { - if FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable { - FlyDefaults.showAppLock = true + if CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable { + CommonDefaults.showAppLock = true } // Called as the scene is being released by the system. // This occurs shortly after the scene enters the background, or when its session is discarded. @@ -87,14 +87,18 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { @available(iOS 13.0, *) func sceneDidBecomeActive(_ scene: UIScene) { - print("#scene sceneDidBecomeActive \(FlyDefaults.isLoggedIn)") - if FlyDefaults.isBlockedByAdmin { +// print("#scene sceneDidBecomeActive \(FlyDefaults.isLoggedIn)") + if ContactManager.isBlockedByAdmin() { navigateToBlockedScreen() return } let current = UIApplication.shared.keyWindow?.getTopViewController() - if (current is AuthenticationPINViewController || current is FingerPrintPINViewController) { - if let vc = current as? FingerPrintPINViewController { + if (current is AuthenticationPINViewController || current is FingerPrintPINViewController || current is PrivateChatAuthenticationPINViewController || current is PrivateChatFingerPrintPINViewController) { + if let vc = current as? FingerPrintPINViewController { + if vc.isSystemCancel { + vc.authenticationWithTouchID() + } + } else if let vc = current as? PrivateChatFingerPrintPINViewController { if vc.isSystemCancel { vc.authenticationWithTouchID() } @@ -106,7 +110,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { setupRemoteConfig() ForceUpdateChecker(listener: self).checkIsNeedUpdate() NotificationCenter.default.removeObserver(self, name: NSNotification.Name(didEnterBackground), object: nil) - if FlyDefaults.isBackupCompleted { + if CommonDefaults.isBackupCompleted { iCloudmanager().checkAutoBackupSchedule() } else { iCloudmanager().uploadBackupFile(fileUrl: BackupManager.shared.getBackupFilePath()?.absoluteString ?? emptyString()) @@ -127,13 +131,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { func sceneWillEnterForeground(_ scene: UIScene) { NetworkReachability.shared.startMonitoring() - if (FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable) { - let secondsDifference = Calendar.current.dateComponents([.minute, .second], from: FlyDefaults.appBackgroundTime, to: Date()) + if (CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable) { + let secondsDifference = Calendar.current.dateComponents([.minute, .second], from: CommonDefaults.appBackgroundTime, to: Date()) if secondsDifference.second ?? 0 > 32 || secondsDifference.minute ?? 0 > 0 { - FlyDefaults.showAppLock = true + CommonDefaults.showAppLock = true + CommonDefaults.appLockOnPrivateChat = false + CommonDefaults.privateChatOnChatScreen = false } } - print("#scene sceneWillEnterForeground \(FlyDefaults.isLoggedIn)") +// print("#scene sceneWillEnterForeground \(FlyDefaults.isLoggedIn)") // Called as the scene transitions from the background to the foreground. // Use this method to undo the changes made on entering the background. } @@ -141,10 +147,24 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { @available(iOS 13.0, *) func sceneDidEnterBackground(_ scene: UIScene) { print("#scene sceneDidEnterBackground") - FlyDefaults.appBackgroundTime = Date() + CommonDefaults.appBackgroundTime = Date() postNotificationdidEnterBackground = NotificationCenter.default postNotificationdidEnterBackground?.post(name: Notification.Name(didEnterBackground), object: nil) + if CommonDefaults.isInPrivateChat { + if CommonDefaults.appLockOnPrivateChat || CommonDefaults.privateChatOnChatScreen { + CommonDefaults.showPrivateLockRecent = false + } else { + CommonDefaults.showPrivateLockRecent = true + } + if let controller = UIApplication.shared.keyWindow?.getTopViewController() { + if controller.isKind(of: UIAlertController.self) || controller.isKind(of: UIActivityViewController.self) || controller.isKind(of: GroupInfoOptionsViewController.self) { + controller.dismiss(animated: false) + } + } + } else { + CommonDefaults.showPrivateLockRecent = false + } // Called as the scene transitions from the foreground to the background. // Use this method to save data, release shared resources, and store enough scene-specific state information // to restore the scene back to its current state. @@ -160,7 +180,6 @@ extension SceneDelegate { Utility.saveInPreference(key: isLoggedIn, value: false) ChatManager.disconnect() ChatManager.shared.resetFlyDefaults() - FlyDefaults.isBlockedByAdmin = false if CallManager.isOngoingCall() { CallManager.disconnectCall() } diff --git a/MirrorflyUIkit/Controllers/DeleteMyAccount/DMAReasonVC.swift b/MirrorflyUIkit/Controllers/DeleteMyAccount/DMAReasonVC.swift index 48fb5fc..226da52 100644 --- a/MirrorflyUIkit/Controllers/DeleteMyAccount/DMAReasonVC.swift +++ b/MirrorflyUIkit/Controllers/DeleteMyAccount/DMAReasonVC.swift @@ -56,7 +56,6 @@ class DMAReasonVC: UIViewController { ContactManager.shared.deleteMyAccountRequest(reason: reason, feedback: feedBack) { isSuccess, error, data in let message = data["message"] as? String ?? "" if isSuccess{ - FlyDefaults.hideLastSeen = false CallLogManager().deleteCallLogs() Utility.saveInPreference(key: firstTimeSandboxContactSyncDone, value: false) AppAlert.shared.showToast(message: "Your MirrorFly account has been deleted.") diff --git a/MirrorflyUIkit/Controllers/DeleteMyAccount/DeleteMyAccountVC.swift b/MirrorflyUIkit/Controllers/DeleteMyAccount/DeleteMyAccountVC.swift index 9f71bdc..d5ed0ba 100644 --- a/MirrorflyUIkit/Controllers/DeleteMyAccount/DeleteMyAccountVC.swift +++ b/MirrorflyUIkit/Controllers/DeleteMyAccount/DeleteMyAccountVC.swift @@ -47,7 +47,7 @@ class DeleteMyAccountVC: UIViewController, UITextFieldDelegate { } }) mobileNumberField.keyboardType = .phonePad - if let accountNumber = FlyDefaults.myMobileNumber.components(separatedBy: " ").last?.replacingOccurrences(of: "+", with: ""){ + if let accountNumber = ContactManager.getMyProfile().mobileNumber.components(separatedBy: " ").last?.replacingOccurrences(of: "+", with: ""){ accountNumberCount = accountNumber.count } } @@ -71,8 +71,8 @@ class DeleteMyAccountVC: UIViewController, UITextFieldDelegate { } if !mobileNumber.isEmpty{ - let accountCountryCode = FlyDefaults.myMobileNumber.replacingOccurrences(of: mobileNumber, with: "").replacingOccurrences(of: "+", with: "").replacingOccurrences(of: " ", with: "") - let accountNumber = FlyDefaults.myMobileNumber.substring(from: accountCountryCode.count).replacingOccurrences(of: "+", with: "").replacingOccurrences(of: " ", with: "") + let accountCountryCode = ContactManager.getMyProfile().mobileNumber.replacingOccurrences(of: mobileNumber, with: "").replacingOccurrences(of: "+", with: "").replacingOccurrences(of: " ", with: "") + let accountNumber = ContactManager.getMyProfile().mobileNumber.substring(from: accountCountryCode.count).replacingOccurrences(of: "+", with: "").replacingOccurrences(of: " ", with: "") if mobileNumber == accountNumber{ diff --git a/MirrorflyUIkit/Controllers/DeleteMyAccountVC.swift b/MirrorflyUIkit/Controllers/DeleteMyAccountVC.swift index 1791bc2..2952ebf 100644 --- a/MirrorflyUIkit/Controllers/DeleteMyAccountVC.swift +++ b/MirrorflyUIkit/Controllers/DeleteMyAccountVC.swift @@ -48,7 +48,7 @@ class DeleteMyAccountVC: UIViewController, UITextFieldDelegate { } }) mobileNumberField.keyboardType = .phonePad - if let accountNumber = FlyDefaults.myMobileNumber.components(separatedBy: " ").last?.replacingOccurrences(of: "+", with: ""){ + if let accountNumber = ContactManager.getMyProfile().mobileNumber.components(separatedBy: " ").last?.replacingOccurrences(of: "+", with: ""){ accountNumberCount = accountNumber.count } } @@ -72,8 +72,8 @@ class DeleteMyAccountVC: UIViewController, UITextFieldDelegate { } if !mobileNumber.isEmpty{ - let accountCountryCode = FlyDefaults.myMobileNumber.replacingOccurrences(of: mobileNumber, with: "").replacingOccurrences(of: "+", with: "").replacingOccurrences(of: " ", with: "") - let accountNumber = FlyDefaults.myMobileNumber.substring(from: accountCountryCode.count).replacingOccurrences(of: "+", with: "").replacingOccurrences(of: " ", with: "") + let accountCountryCode = ContactManager.getMyProfile().mobileNumber.replacingOccurrences(of: mobileNumber, with: "").replacingOccurrences(of: "+", with: "").replacingOccurrences(of: " ", with: "") + let accountNumber = ContactManager.getMyProfile().mobileNumber.substring(from: accountCountryCode.count).replacingOccurrences(of: "+", with: "").replacingOccurrences(of: " ", with: "") if mobileNumber == accountNumber{ if accountCountryCode == countryDialCode{ diff --git a/MirrorflyUIkit/Controllers/ForwardMessages/ForwardViewController.swift b/MirrorflyUIkit/Controllers/ForwardMessages/ForwardViewController.swift index a233ae9..6a8f4f7 100755 --- a/MirrorflyUIkit/Controllers/ForwardMessages/ForwardViewController.swift +++ b/MirrorflyUIkit/Controllers/ForwardMessages/ForwardViewController.swift @@ -61,6 +61,9 @@ class ForwardViewController: UIViewController { print("value \(isFirstPageLoaded)") } } + + var hidePrivateChatUsers: Bool = false + var isFromPrivateChat: Bool = false override func viewDidLoad() { super.viewDidLoad() @@ -191,7 +194,7 @@ class ForwardViewController: UIViewController { } func isParticipantExist(index: Int) -> (doesExist : Bool, message : String) { - return GroupManager.shared.isParticiapntExistingIn(groupJid: getRecentChat[index].jid, participantJid: FlyDefaults.myJid) + return GroupManager.shared.isParticiapntExistingIn(groupJid: getRecentChat[index].jid, participantJid: AppUtils.getMyJid()) } func getLastMesssage() -> [ChatMessage]? { @@ -285,6 +288,8 @@ class ForwardViewController: UIViewController { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { self?.navigationController?.modalPresentationStyle = .fullScreen guard let viewController = vc else { return } + viewController.isFromForward = true + viewController.isFromPrivateChat = self?.isFromPrivateChat ?? false self?.navigationController?.pushViewController(viewController, animated: true) self?.stopLoading() } @@ -766,6 +771,21 @@ extension ForwardViewController : UITableViewDelegate, UITableViewDataSource { sendButton?.alpha = selectedMessages.count == 0 ? 0.4 : 1.0 } } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if segmentSelectedIndex == 1 { + let recentChatDetails = isSearchEnabled == true ? getRecentChat.filter({$0.profileType == .groupChat && $0.isBlockedByAdmin == false })[indexPath.row] : getAllRecentChat.filter({$0.profileType == .groupChat && $0.isBlockedByAdmin == false})[indexPath.row] + if recentChatDetails.isPrivateChat && hidePrivateChatUsers { + return 0 + } + } else if segmentSelectedIndex == 2 { + let recentChatDetails = isSearchEnabled == true ? getRecentChat[indexPath.row] : getAllRecentChat[indexPath.row] + if recentChatDetails.isPrivateChat && hidePrivateChatUsers { + return 0 + } + } + return UITableView.automaticDimension + } } // SearchBar Delegate Method @@ -1533,7 +1553,7 @@ extension ForwardViewController { if ChatManager.shared.isBusyStatusEnabled() && ContactManager.shared.getUserProfileDetails(for: jid)?.profileChatType == .singleChat { let alertController = UIAlertController.init(title: "Disable busy Status. Do you want to continue?" , message: "", preferredStyle: .alert) let forwardAction = UIAlertAction(title: "Yes", style: .default) {_ in - ChatManager.shared.enableDisableBusyStatus(!FlyDefaults.isUserBusyStatusEnabled) + ChatManager.shared.enableDisableBusyStatus(!ChatManager.shared.isBusyStatusEnabled()) completion(true) } let cancelAction = UIAlertAction(title: "No", style: .cancel) { [weak controller] (action) in diff --git a/MirrorflyUIkit/Controllers/Image/ImageEditController.swift b/MirrorflyUIkit/Controllers/Image/ImageEditController.swift index 4dbc3ad..bd1f9d5 100755 --- a/MirrorflyUIkit/Controllers/Image/ImageEditController.swift +++ b/MirrorflyUIkit/Controllers/Image/ImageEditController.swift @@ -83,7 +83,7 @@ class ImageEditController: UIViewController { backgroundQueue.async { [weak self] in _ = self?.getAssetsImageInfo(assets: self!.selectedAssets) } - searchGroupMembers = groupMembers.filter({$0.profileDetail?.isBlockedByAdmin == false || $0.memberJid != FlyDefaults.myJid}).sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }) + searchGroupMembers = groupMembers.filter({$0.profileDetail?.isBlockedByAdmin == false || $0.memberJid != AppUtils.getMyJid()}).sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }) setupUI() } @@ -290,7 +290,7 @@ class ImageEditController: UIViewController { mentionView.isHidden = !isMention mentionSearch = mentionRanges.compactMap({$0.0}).joined(separator: "") if mentionSearch.isNotEmpty { - let sortedMembers = groupMembers.filter({$0.profileDetail?.isBlockedByAdmin == false || $0.memberJid != FlyDefaults.myJid}).sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }) + let sortedMembers = groupMembers.filter({$0.profileDetail?.isBlockedByAdmin == false || $0.memberJid != AppUtils.getMyJid()}).sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }) let getGroupMembers = sortedMembers.filter{ $0.displayName.lowercased().contains(mentionSearch.lowercased())} searchGroupMembers = getGroupMembers mentionTableView.reloadData() @@ -881,7 +881,7 @@ extension ImageEditController : UITextViewDelegate { func setGroupmention(range: NSRange) { resetGroupMention() - searchGroupMembers = groupMembers.sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }).filter({$0.memberJid != FlyDefaults.myJid || $0.profileDetail?.isBlockedByAdmin == false}) + searchGroupMembers = groupMembers.sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }).filter({$0.memberJid != AppUtils.getMyJid() || $0.profileDetail?.isBlockedByAdmin == false}) mentionTableView.reloadData() isMention = true mentionRange = range @@ -1236,7 +1236,7 @@ extension ImageEditController { func getGroupMember() { if getProfileDetails.profileChatType == .groupChat { groupMembers = [GroupParticipantDetail]() - groupMembers = GroupManager.shared.getGroupMemebersFromLocal(groupJid: getProfileDetails.jid).participantDetailArray.filter({$0.memberJid != FlyDefaults.myJid}) + groupMembers = GroupManager.shared.getGroupMemebersFromLocal(groupJid: getProfileDetails.jid).participantDetailArray.filter({$0.memberJid != AppUtils.getMyJid()}) print("getGrouMember \(groupMembers.count)") searchGroupMembers = mentionArrayFilter().sorted(by: { $0.displayName.lowercased() < $1.displayName.lowercased() }) mentionTableView.reloadData() @@ -1336,11 +1336,11 @@ extension ImageEditController { // } func mentionArrayFilter() -> [GroupParticipantDetail] { - groupMembers.filter({ $0.memberJid != FlyDefaults.myJid && $0.profileDetail?.isBlockedByAdmin == false }) + groupMembers.filter({ $0.memberJid != AppUtils.getMyJid() && $0.profileDetail?.isBlockedByAdmin == false }) } func mentionArraySearchFilter() -> [GroupParticipantDetail] { - groupMembers.filter({ $0.displayName.lowercased().contains(mentionSearch.lowercased()) && $0.memberJid != FlyDefaults.myJid && $0.profileDetail?.isBlockedByAdmin == false }) + groupMembers.filter({ $0.displayName.lowercased().contains(mentionSearch.lowercased()) && $0.memberJid != AppUtils.getMyJid() && $0.profileDetail?.isBlockedByAdmin == false }) } } diff --git a/MirrorflyUIkit/Controllers/Language Selection/LanguageSelectionViewController.swift b/MirrorflyUIkit/Controllers/Language Selection/LanguageSelectionViewController.swift index 2c7273f..95b4c67 100644 --- a/MirrorflyUIkit/Controllers/Language Selection/LanguageSelectionViewController.swift +++ b/MirrorflyUIkit/Controllers/Language Selection/LanguageSelectionViewController.swift @@ -68,7 +68,7 @@ extension LanguageSelectionViewController: UITableViewDataSource, UITableViewDel let cell : LanguageSelectionTableViewCell = tableView.dequeueReusableCell(withIdentifier: Identifiers.LanguageSelectionTableViewCell, for: indexPath) as! LanguageSelectionTableViewCell //cell.selectedImageView.isHidden = true cell.languageLabel.text = self.languageArray[indexPath.row].name - if checkedRow == indexPath.row || self.languageArray[indexPath.row].name == FlyDefaults.selectedLanguage { + if checkedRow == indexPath.row || self.languageArray[indexPath.row].name == CommonDefaults.selectedLanguage { cell.selectedImageView.isHidden = false } else { cell.selectedImageView.isHidden = true @@ -84,8 +84,8 @@ extension LanguageSelectionViewController: UITableViewDataSource, UITableViewDel func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { checkedRow = indexPath.row self.languageSelectionTable.reloadData() - FlyDefaults.selectedLanguage = self.languageArray[indexPath.row].name ?? "" - FlyDefaults.targetLanguageCode = self.languageArray[indexPath.row].language ?? "" + CommonDefaults.selectedLanguage = self.languageArray[indexPath.row].name ?? "" + CommonDefaults.targetLanguageCode = self.languageArray[indexPath.row].language ?? "" self.navigationController?.popViewController(animated: true) } } diff --git a/MirrorflyUIkit/Controllers/MainTabBarController.swift b/MirrorflyUIkit/Controllers/MainTabBarController.swift index e7dd185..bf42f7f 100755 --- a/MirrorflyUIkit/Controllers/MainTabBarController.swift +++ b/MirrorflyUIkit/Controllers/MainTabBarController.swift @@ -22,6 +22,8 @@ class MainTabBarController: UITabBarController{ var avilableFeatures = ChatManager.getAvailableFeatures() static var tabBarDelegagte : TabBarDelegate? = nil + + static var privateChatTabBarDelegate : PrivateChatSwitchDelegate? = nil override func viewDidLoad() { super.viewDidLoad() @@ -30,6 +32,7 @@ class MainTabBarController: UITabBarController{ tabViewControllers = vcs } MainTabBarController.tabBarDelegagte = self + MainTabBarController.privateChatTabBarDelegate = self shouldShowCallTab = avilableFeatures.isOneToOneCallEnabled || avilableFeatures.isGroupCallEnabled if !shouldShowCallTab{ setupUI() @@ -52,49 +55,78 @@ class MainTabBarController: UITabBarController{ func navigateToAuthentication() { - if (FlyDefaults.appLockenable || FlyDefaults.appFingerprintenable) { - let secondsDifference = Calendar.current.dateComponents([.minute, .second], from: FlyDefaults.appBackgroundTime, to: Date()) + if (CommonDefaults.appLockenable || CommonDefaults.appFingerprintenable) { + let secondsDifference = Calendar.current.dateComponents([.minute, .second], from: CommonDefaults.appBackgroundTime, to: Date()) if secondsDifference.second ?? 0 > 32 || secondsDifference.minute ?? 0 > 0 { - FlyDefaults.showAppLock = true + CommonDefaults.showAppLock = true + CommonDefaults.appLockOnPrivateChat = false + CommonDefaults.privateChatOnChatScreen = false } } - if FlyDefaults.appFingerprintenable && FlyDefaults.appLockenable && FlyDefaults.showAppLock { - - let current = UIApplication.shared.keyWindow?.getTopViewController() - if (current is AuthenticationPINViewController || current is FingerPrintPINViewController) { - if let vc = current as? FingerPrintPINViewController { - vc.authenticationWithTouchID() + if CommonDefaults.appFingerprintenable && CommonDefaults.appLockenable && CommonDefaults.showAppLock { + if CommonDefaults.showPrivateLockRecent { + showLockScreen() + } else { + let current = UIApplication.shared.keyWindow?.getTopViewController() + if (current is AuthenticationPINViewController || current is FingerPrintPINViewController) { + if let vc = current as? FingerPrintPINViewController { + vc.authenticationWithTouchID() + } + return + } + + if !CommonDefaults.faceOrFingerAuthenticationFails { + let initialViewController = FingerPrintPINViewController(nibName: "FingerPrintPINViewController", bundle: nil) + let navigationController = UINavigationController(rootViewController: initialViewController) + self.navigationController?.setNavigationBarHidden(true, animated: true) + self.navigationController?.pushViewController(initialViewController, animated: false) + } else { + let initialViewController = AuthenticationPINViewController(nibName: "AuthenticationPINViewController", bundle: nil) + initialViewController.login = true + self.navigationController?.setNavigationBarHidden(true, animated: true) + self.navigationController?.pushViewController(initialViewController, animated: false) } - return } - - if !FlyDefaults.faceOrFingerAuthenticationFails { - let initialViewController = FingerPrintPINViewController(nibName: "FingerPrintPINViewController", bundle: nil) - let navigationController = UINavigationController(rootViewController: initialViewController) - self.navigationController?.setNavigationBarHidden(true, animated: true) - self.navigationController?.pushViewController(initialViewController, animated: false) + } + else if CommonDefaults.appLockenable && CommonDefaults.appFingerprintenable == false && CommonDefaults.showAppLock { + if CommonDefaults.showPrivateLockRecent { + showLockScreen() } else { + let current = UIApplication.shared.keyWindow?.getTopViewController() + if (current is AuthenticationPINViewController || current is FingerPrintPINViewController) { + if let vc = current as? FingerPrintPINViewController { + vc.authenticationWithTouchID() + } + return + } + let initialViewController = AuthenticationPINViewController(nibName: "AuthenticationPINViewController", bundle: nil) initialViewController.login = true self.navigationController?.setNavigationBarHidden(true, animated: true) self.navigationController?.pushViewController(initialViewController, animated: false) } + } else if CommonDefaults.showPrivateLockRecent { + if !pushNotificationSelected { + showLockScreen() + } } - else if FlyDefaults.appLockenable && FlyDefaults.appFingerprintenable == false && FlyDefaults.showAppLock { - - let current = UIApplication.shared.keyWindow?.getTopViewController() - if (current is AuthenticationPINViewController || current is FingerPrintPINViewController) { - if let vc = current as? FingerPrintPINViewController { - vc.authenticationWithTouchID() - } - return + } + + func showLockScreen() { + let current = UIApplication.shared.keyWindow?.getTopViewController() + if (current is PrivateChatAuthenticationPINViewController || current is PrivateChatFingerPrintPINViewController) { + if let vc = current as? PrivateChatFingerPrintPINViewController { + vc.authenticationWithTouchID() } - - let initialViewController = AuthenticationPINViewController(nibName: "AuthenticationPINViewController", bundle: nil) - initialViewController.login = true - self.navigationController?.setNavigationBarHidden(true, animated: true) - self.navigationController?.pushViewController(initialViewController, animated: false) + return + } + if CommonDefaults.appFingerprintenable { + let vc = PrivateChatFingerPrintPINViewController(nibName: "PrivateChatFingerPrintPINViewController", bundle: nil) + self.navigationController?.pushViewController(vc, animated: false) + } else { + let vc = PrivateChatAuthenticationPINViewController(nibName:"PrivateChatAuthenticationPINViewController", bundle: nil) + self.navigationController?.pushViewController(vc, animated: true) } } @@ -129,13 +161,13 @@ class MainTabBarController: UITabBarController{ } func saveMyJidAsContacts() { - let profileData = ProfileDetails(jid: FlyDefaults.myJid) - profileData.name = FlyDefaults.myName - profileData.nickName = FlyDefaults.myNickName - profileData.mobileNumber = FlyDefaults.myMobileNumber - profileData.email = FlyDefaults.myEmail - profileData.status = FlyDefaults.myStatus - profileData.image = FlyDefaults.myImageUrl + let profileData = ProfileDetails(jid: AppUtils.getMyJid()) + profileData.name = ContactManager.getMyProfile().name + profileData.nickName = ContactManager.getMyProfile().nickName + profileData.mobileNumber = ContactManager.getMyProfile().mobileNumber + profileData.email = ContactManager.getMyProfile().email + profileData.status = ContactManager.getMyProfile().status + profileData.image = ContactManager.getMyProfile().image // FlyDatabaseController.shared.rosterManager.saveContact(profileDetailsArray: [profileData], chatType: .singleChat, contactType: .live, saveAsTemp: false, calledBy: "") } @@ -160,7 +192,7 @@ class MainTabBarController: UITabBarController{ func updateUnReadMissedCallBadgeCount() { if let item : UITabBarItem = chatTabBars?.items?[2] { - let missedCallCount = FlyDefaults.unreadMissedCallCount + let missedCallCount = CallLogManager.getUnreadMissedCallCount() item.badgeValue = (missedCallCount == 0) ? nil : "\(missedCallCount)" } } @@ -178,10 +210,8 @@ extension MainTabBarController : ConnectionEventDelegate { } func onConnected() { - if FlyDefaults.isFriendsListSyncPending { - ContactManager.shared.getRegisteredUsers(fromServer: true){isSuccess,_,_ in - FlyDefaults.isFriendsListSyncPending = !isSuccess - } + if ContactSyncManager.getFriendListSyncStatus() { + ContactSyncManager.getRegisterdUsers() } } @@ -231,6 +261,13 @@ extension MainTabBarController : TabBarDelegate{ } +extension MainTabBarController: PrivateChatSwitchDelegate { + func moveToRecentInTabBar() { + self.selectedIndex = 0 + NotificationCenter.default.post(name: Notification.Name("PrivateChatSwitch"), object: nil) + } +} + public protocol TabBarDelegate { func removeTabAt(index : Int) @@ -241,3 +278,8 @@ public protocol TabBarDelegate { } +public protocol PrivateChatSwitchDelegate { + + func moveToRecentInTabBar() + +} diff --git a/MirrorflyUIkit/Controllers/OTPViewController.swift b/MirrorflyUIkit/Controllers/OTPViewController.swift index c91ef84..90a2c7d 100755 --- a/MirrorflyUIkit/Controllers/OTPViewController.swift +++ b/MirrorflyUIkit/Controllers/OTPViewController.swift @@ -103,7 +103,6 @@ class OTPViewController: UIViewController { let phoneNumber = countryCode + mobileNumber if mobileNumber.count >= minimumMobileNumber { if phoneNumberKit.isValidPhoneNumber(phoneNumber) { - FlyDefaults.myMobileNumber = phoneNumber if mobileNumber.isValidMobileNumber(mobileNumber: mobileNumber) { if NetworkReachability.shared.isConnected { startLoading(withText: pleaseWait) diff --git a/MirrorflyUIkit/Controllers/Password View Controller/AppLockPasswordViewController.swift b/MirrorflyUIkit/Controllers/Password View Controller/AppLockPasswordViewController.swift index c21ac88..7d693d1 100644 --- a/MirrorflyUIkit/Controllers/Password View Controller/AppLockPasswordViewController.swift +++ b/MirrorflyUIkit/Controllers/Password View Controller/AppLockPasswordViewController.swift @@ -13,7 +13,12 @@ class AppLockPasswordViewController: UIViewController, UITextFieldDelegate { var appLockPassword : String? var fingerPINisOn : Bool = false - + + var isFromPrivateChat: Bool = false + var isChangePin: Bool = false + var isFromPrivateRecentChat: Bool = false + + var privateChatDelegate: PrivateChatDelegate? @IBOutlet weak var scrollview: UIScrollView! @@ -73,15 +78,27 @@ class AppLockPasswordViewController: UIViewController, UITextFieldDelegate { } else if enterNewPassword.text ?? "" == confirmNewPassword.text ?? "" { print("saved") - if fingerPINisOn == true{ - FlyDefaults.appFingerprintenable = true + if isFromPrivateChat { + CommonDefaults.appLockPassword = confirmNewPassword.text ?? "" + CommonDefaults.passwordAuthenticationAttemps = 0 + } else { + if fingerPINisOn == true{ + CommonDefaults.appFingerprintenable = true + } + CommonDefaults.appLockPassword = confirmNewPassword.text ?? "" + CommonDefaults.passwordAuthenticationAttemps = 0 + if !isChangePin { + CommonDefaults.appLockenable = true + CommonDefaults.appLockPasswordDate = Date() + } } - FlyDefaults.appLockenable = true - FlyDefaults.appLockPassword = confirmNewPassword.text ?? "" - FlyDefaults.appLockPasswordDate = Date() - FlyDefaults.passwordAuthenticationAttemps = 0 self.showToastWithMessage(message: SuccessMessage.PINsetsuccessfully) self.navigationController?.popViewController(animated: true) + if !isChangePin { + self.privateChatDelegate?.onPasswordSet() + } else { + self.privateChatDelegate?.pinChanged() + } } } @@ -105,7 +122,7 @@ class AppLockPasswordViewController: UIViewController, UITextFieldDelegate { self.showToastWithMessage(message: ErrorMessage.passwordShouldbeSame) return false } - else if enterNewPassword.text == FlyDefaults.appLockPassword { + else if enterNewPassword.text == CommonDefaults.appLockPassword { self.showToastWithMessage(message: ErrorMessage.oldPINnewPINsholdnotSame) return false } diff --git a/MirrorflyUIkit/Controllers/Profile/ImageViewerViewController.swift b/MirrorflyUIkit/Controllers/Profile/ImageViewerViewController.swift index 8dadff7..7fa9f8a 100755 --- a/MirrorflyUIkit/Controllers/Profile/ImageViewerViewController.swift +++ b/MirrorflyUIkit/Controllers/Profile/ImageViewerViewController.swift @@ -44,7 +44,7 @@ class ImageViewerViewController: UIViewController { // } func setImage(imageURL: String) { - let urlString = "\(FlyDefaults.baseURL)\(media)/\(imageURL)?mf=\(FlyDefaults.authtoken)" + let urlString = ChatManager.getImageUrl(imageName: imageURL) let url = URL(string: urlString) imageView.sd_setImage(with: url, placeholderImage: #imageLiteral(resourceName: "ic_profile_placeholder")) } diff --git a/MirrorflyUIkit/Controllers/Profile/View/ProfileViewController.swift b/MirrorflyUIkit/Controllers/Profile/View/ProfileViewController.swift index ba97999..81f30f7 100755 --- a/MirrorflyUIkit/Controllers/Profile/View/ProfileViewController.swift +++ b/MirrorflyUIkit/Controllers/Profile/View/ProfileViewController.swift @@ -81,7 +81,7 @@ class ProfileViewController: UIViewController,ProfileViewControllerProtocol { nameTextField.adjustsFontSizeToFitWidth = false hideKeyboardWhenTappedAround() print(getMobileNumber) - mobileNumberLabel.text = FlyDefaults.myMobileNumber + mobileNumberLabel.text = ContactManager.getMyProfile().mobileNumber statusLabel.text = inMirrorfly.localized profileImage.layer.masksToBounds = false profileImage.layer.cornerRadius = profileImage.frame.height/2 @@ -101,13 +101,13 @@ class ProfileViewController: UIViewController,ProfileViewControllerProtocol { } @objc override func willCometoForeground() { - print("ProfileViewController ABCXYZ willCometoForeground ============ ") - print("ProfileViewController ABCXYZ willCometoForeground \(profileDetails?.image) ") - print("ProfileViewController ABCXYZ willCometoForeground \(FlyDefaults.myName)") - print("ProfileViewController ABCXYZ willCometoForeground \(FlyDefaults.myEmail)") - print("ProfileViewController ABCXYZ willCometoForeground \(FlyDefaults.myImageUrl)") +// print("ProfileViewController ABCXYZ willCometoForeground ============ ") +// print("ProfileViewController ABCXYZ willCometoForeground \(profileDetails?.image) ") +// print("ProfileViewController ABCXYZ willCometoForeground \(FlyDefaults.myName)") +// print("ProfileViewController ABCXYZ willCometoForeground \(FlyDefaults.myEmail)") +// print("ProfileViewController ABCXYZ willCometoForeground \(FlyDefaults.myImageUrl)") - if FlyDefaults.myName.isEmpty || FlyDefaults.myEmail.isEmpty { + if ContactManager.getMyProfile().name.isEmpty || ContactManager.getMyProfile().email.isEmpty { print("ProfileViewController ABCXYZ willCometoForeground if ") DispatchQueue.main.async { [weak self] in self?.stopLoading() @@ -119,8 +119,8 @@ class ProfileViewController: UIViewController,ProfileViewControllerProtocol { } } else { DispatchQueue.main.async { [weak self] in - if let localPath = (self?.profileDetails?.image.isEmpty ?? false || self?.profileDetails?.image == nil) ? FlyDefaults.myProfileImageUrl : self?.profileDetails?.image { - print("image",FlyDefaults.myProfileImageUrl) + if let localPath = (self?.profileDetails?.image.isEmpty ?? false || self?.profileDetails?.image == nil) ? ContactManager.getMyProfile().image : self?.profileDetails?.image { + print("image",ContactManager.getMyProfile().image) print("profileImage",self?.profileDetails?.image) if FileManager.default.fileExists(atPath: localPath) { let url = URL.init(fileURLWithPath: localPath) @@ -139,13 +139,13 @@ class ProfileViewController: UIViewController,ProfileViewControllerProtocol { let tempName = self?.nameTextField.text ?? "" let tempEmail = self?.emailTextField.text ?? "" if tempName.isEmpty { - self?.nameTextField.text = FlyDefaults.myName + self?.nameTextField.text = ContactManager.getMyProfile().name } if tempEmail.isEmpty { - self?.emailTextField.text = FlyDefaults.myEmail + self?.emailTextField.text = ContactManager.getMyProfile().email } - self?.mobileNumberLabel.text = self?.mobileNumberLabel.text?.isEmpty ?? false ? FlyDefaults.myMobileNumber : self?.mobileNumberLabel.text + self?.mobileNumberLabel.text = self?.mobileNumberLabel.text?.isEmpty ?? false ? ContactManager.getMyProfile().mobileNumber : self?.mobileNumberLabel.text } } } @@ -187,10 +187,10 @@ class ProfileViewController: UIViewController,ProfileViewControllerProtocol { extension ProfileViewController { func getProfile() { - print( FlyDefaults.myXmppUsername) - if(FlyDefaults.isProfileUpdated) { + print( ChatManager.getXMPPDetails().XMPPUsername) + if(CommonDefaults.isProfileUpdated) { do { - let JID = FlyDefaults.myXmppUsername + "@" + FlyDefaults.xmppDomain + let JID = ChatManager.getXMPPDetails().XMPPUsername + "@" + ChatManager.getXMPPDetails().XMPPDomain try ContactManager.shared.getUserProfile(for: JID, fetchFromServer: true, saveAsFriend: true) { [weak self] isSuccess, flyError, flyData in var data = flyData @@ -199,7 +199,7 @@ extension ProfileViewController { print(data.getData() as! ProfileDetails) self?.profileDetails = data.getData() as? ProfileDetails let mobileNumber = self?.profileDetails?.mobileNumber ?? "" - FlyDefaults.myImageToken = self?.profileDetails?.image ?? "" +// FlyDefaults.myImageToken = self?.profileDetails?.image ?? "" if(self?.profileDetails?.image != "") { self?.setImage(imageURL: self?.profileDetails?.image ?? "", completionHandler: { _ in DispatchQueue.main.asyncAfter(deadline: .now() + 5) { @@ -215,7 +215,7 @@ extension ProfileViewController { self?.emailTextField.text = self?.profileDetails?.email self?.getUserMobileNumber = self?.profileDetails!.mobileNumber ?? "" if mobileNumber.isEmpty || mobileNumber.count < 6 { - self?.mobileNumberLabel.text = FlyDefaults.myMobileNumber + self?.mobileNumberLabel.text = ContactManager.getMyProfile().mobileNumber } else { let mobileNumberWithoutCountryCode = AppUtils.shared.mobileNumberParse(phoneNo: mobileNumber) self?.mobileNumberLabel.text = mobileNumberWithoutCountryCode @@ -243,7 +243,7 @@ extension ProfileViewController { func setImage(imageURL: String,completionHandler: @escaping (Bool?)-> Void) { profileImage.sd_imageIndicator = SDWebImageActivityIndicator.white - let urlString = "\(FlyDefaults.baseURL)\(media)/\(imageURL)?mf=\(FlyDefaults.authtoken)" + let urlString = ChatManager.getImageUrl(imageName: imageURL) let url = URL(string: urlString) profileImage.sd_setImage(with: url, placeholderImage: #imageLiteral(resourceName: "ic_profile_placeholder"), completed: { [weak self]image,error,_,imageUrl in self?.profileImage.stopAnimating() @@ -252,19 +252,20 @@ extension ProfileViewController { } private func saveMyProfileDataToUserDefaults(profile : FlyProfile){ - FlyDefaults.myName = profile.name - FlyDefaults.myImageUrl = profile.image - FlyDefaults.myImageToken = profile.image - FlyDefaults.myMobileNumber = profile.mobileNumber - FlyDefaults.myStatus = profile.status - FlyDefaults.myEmail = profile.email + // Commented private flydefaults profile saved inside SDK +// FlyDefaults.myName = profile.name +// FlyDefaults.myImageUrl = profile.image +// FlyDefaults.myImageToken = profile.image +// FlyDefaults.myMobileNumber = profile.mobileNumber +// FlyDefaults.myStatus = profile.status +// FlyDefaults.myEmail = profile.email } func updateProfile(profileDetails: ProfileDetails) { executeOnMainThread { [weak self] in self?.profileDetails = profileDetails let mobileNumber = self?.profileDetails?.mobileNumber ?? "" - FlyDefaults.myImageToken = self?.profileDetails?.image ?? "" +// FlyDefaults.myImageToken = self?.profileDetails?.image ?? "" if(self?.profileDetails?.image != "") { self?.setImage(imageURL: self?.profileDetails?.image ?? "", completionHandler: { _ in DispatchQueue.main.asyncAfter(deadline: .now() + 5) { @@ -280,7 +281,7 @@ extension ProfileViewController { self?.emailTextField.text = self?.profileDetails?.email self?.getUserMobileNumber = self?.profileDetails!.mobileNumber ?? "" if mobileNumber.isEmpty || mobileNumber.count < 6 { - self?.mobileNumberLabel.text = FlyDefaults.myMobileNumber + self?.mobileNumberLabel.text = ContactManager.getMyProfile().mobileNumber } else { let mobileNumberWithoutCountryCode = AppUtils.shared.mobileNumberParse(phoneNo: mobileNumber) self?.mobileNumberLabel.text = mobileNumberWithoutCountryCode @@ -296,7 +297,7 @@ extension ProfileViewController { print("ProfileViewController ABCXYZ updateMyProfile") if NetworkReachability.shared.isConnected { - let JID = FlyDefaults.myXmppUsername + "@" + FlyDefaults.xmppDomain + let JID = ChatManager.getXMPPDetails().XMPPUsername + "@" + ChatManager.getXMPPDetails().XMPPDomain if isSaveButtonTapped == true { startLoading(withText: pleaseWait) } @@ -308,7 +309,7 @@ extension ProfileViewController { guard let mobileNumber = mobileNumberLabel.text else { return } - myProfile.mobileNumber = getPhoneNumberToUpdate(phoneNumber: mobileNumber.isNotEmpty ? mobileNumber : FlyDefaults.myMobileNumber) + myProfile.mobileNumber = getPhoneNumberToUpdate(phoneNumber: mobileNumber.isNotEmpty ? mobileNumber : ContactManager.getMyProfile().mobileNumber) guard let nickName = nameTextField.text else { return @@ -377,7 +378,7 @@ extension ProfileViewController { var data = flyData if isSuccess { print(data.getMessage() as! String) - FlyDefaults.myProfileImageUrl = "" +// FlyDefaults.myProfileImageUrl = "" } else{ print(data.getMessage() as! String) } @@ -441,7 +442,7 @@ extension ProfileViewController { extension ProfileViewController: UITextFieldDelegate{ @objc func textFieldDidChange(_ textField: UITextField) { - if(FlyDefaults.isProfileUpdated) { + if(CommonDefaults.isProfileUpdated) { if(nameTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) != profileDetails?.nickName || emailTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) != profileDetails?.email || statusLabel.text != profileDetails?.status) { saveButton.setTitle(updateAndContinue.localized, for: .normal) } @@ -458,13 +459,14 @@ extension ProfileViewController: UITextFieldDelegate{ func getUserNameInitial() { guard let name = nameTextField.text else { - if FileManager.default.fileExists(atPath: FlyDefaults.myProfileImageUrl) { - let url = URL.init(fileURLWithPath: FlyDefaults.myProfileImageUrl) + let imageUrl = ContactManager.getMyProfile().image + if FileManager.default.fileExists(atPath: imageUrl) { + let url = URL.init(fileURLWithPath: imageUrl) let data = NSData(contentsOf: url as URL) let image = UIImage(data: data! as Data) profileImage.image = image } else { - setImage(imageURL: FlyDefaults.myProfileImageUrl, completionHandler: { [weak self] _ in + setImage(imageURL: imageUrl, completionHandler: { [weak self] _ in DispatchQueue.main.asyncAfter(deadline: .now() + 5) { self?.stopLoading() } @@ -478,13 +480,14 @@ extension ProfileViewController: UITextFieldDelegate{ profileImage.image = ipimage.generateImage() } else { - if FileManager.default.fileExists(atPath: FlyDefaults.myProfileImageUrl) { - let url = URL.init(fileURLWithPath: FlyDefaults.myProfileImageUrl) + let imageUrl = ContactManager.getMyProfile().image + if FileManager.default.fileExists(atPath: imageUrl) { + let url = URL.init(fileURLWithPath: imageUrl) let data = NSData(contentsOf: url as URL) let image = UIImage(data: data! as Data) profileImage.image = image } else { - setImage(imageURL: FlyDefaults.myProfileImageUrl, completionHandler: { [weak self] _ in + setImage(imageURL: imageUrl, completionHandler: { [weak self] _ in DispatchQueue.main.asyncAfter(deadline: .now() + 5) { self?.stopLoading() } @@ -736,7 +739,7 @@ extension ProfileViewController: StatusDelegate { func userSelectedStatus(selectedStatus: String) { statusLabel.text = selectedStatus - if(FlyDefaults.isProfileUpdated) { + if(CommonDefaults.isProfileUpdated) { if(nameTextField.text != profileDetails?.nickName || emailTextField.text != profileDetails?.email || statusLabel.text != profileDetails?.status) { saveButton.setTitle(updateAndContinue.localized, for: .normal) } @@ -765,8 +768,8 @@ extension ProfileViewController: CropperViewControllerDelegate { let str = AppUtils.shared.getRandomString(length: 15) let fileName = str ?? "" profileImageLocalPath = AppUtils.shared.saveInDirectory(with: profileImage.image?.jpegData(compressionQuality: 1.0), fileName: fileName + jpg) ?? "" - FlyDefaults.myProfileImageUrl = profileImageLocalPath - print("fileName--\( FlyDefaults.myProfileImageUrl)") +// FlyDefaults.myProfileImageUrl = profileImageLocalPath +// print("fileName--\( FlyDefaults.myProfileImageUrl)") print("localPath--\( profileImageLocalPath)") DispatchQueue.main.async { [weak self] in self?.updateMyProfile() @@ -836,7 +839,7 @@ extension ProfileViewController: ProfileEventsDelegate { func userProfileFetched(for jid: String, profileDetails: MirrorFlySDK.ProfileDetails?) { if let details = profileDetails { - if details.jid == FlyDefaults.myJid { + if details.jid == AppUtils.getMyJid() { print("#profile update: userProfileFetched \(details.image)") updateProfile(profileDetails: details) } @@ -868,7 +871,7 @@ extension ProfileViewController: ProfileEventsDelegate { } func userUpdatedTheirProfile(for jid: String, profileDetails: MirrorFlySDK.ProfileDetails) { - if profileDetails.jid == FlyDefaults.myJid { + if profileDetails.jid == AppUtils.getMyJid() { print("#profile update: userUpdatedTheirProfile \(profileDetails.image)") updateProfile(profileDetails: profileDetails) } diff --git a/MirrorflyUIkit/Controllers/Profile/ViewModel/ProfileViewModel.swift b/MirrorflyUIkit/Controllers/Profile/ViewModel/ProfileViewModel.swift index 575c016..93ad4af 100755 --- a/MirrorflyUIkit/Controllers/Profile/ViewModel/ProfileViewModel.swift +++ b/MirrorflyUIkit/Controllers/Profile/ViewModel/ProfileViewModel.swift @@ -56,10 +56,10 @@ class ProfileViewModel { func contactSync() { return let apiService = ApiService() - let params = ["licenseKey": FlyDefaults.licenseKey] - let url = FlyDefaults.baseURL + "contacts/sandbox/" + syncContacts + let params = ["licenseKey": ChatManager.getAppConfigDetails().licenseKey] + let url = ChatManager.getAppConfigDetails().baseURL + "contacts/sandbox/" + syncContacts let headers: HTTPHeaders - let authtoken = FlyDefaults.authtoken + let authtoken = ChatManager.getAppConfigDetails().authtoken headers = [ FlyConstants.authorization: authtoken, "content-type": "application/json"] print(headers) diff --git a/MirrorflyUIkit/Controllers/RecentChat/RecentChatViewController.swift b/MirrorflyUIkit/Controllers/RecentChat/RecentChatViewController.swift index dc8b630..229f87c 100755 --- a/MirrorflyUIkit/Controllers/RecentChat/RecentChatViewController.swift +++ b/MirrorflyUIkit/Controllers/RecentChat/RecentChatViewController.swift @@ -47,6 +47,12 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { @IBOutlet weak var chatActionMessageButton: UIButton! @IBOutlet weak var chatActionAudioCallButton: UIButton! @IBOutlet weak var chatActionVideoCallButton: UIButton! + + @IBOutlet weak var contactFloatView: UIView! + @IBOutlet weak var contactFloatButton: UIButton! + + var onlyPrivateChatAvailableView = UIView() + var onlyPrivateChatAvailableViewLabel = UILabel() @IBOutlet weak var chatTagsCollectionView: UICollectionView! var longPressCount = 0 @@ -69,11 +75,17 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { private var messageTxt: String? var tappedProfile : ProfileDetails? = nil var getArchiveChat: [RecentChat] = [] + var getPrivateChats: [RecentChat] = [] var showArchivedChat = false { didSet{ chatTagsCollectionView.isHidden = self.getChatTags.isEmpty ? true : showArchivedChat } } + var showPrivateChat = false { + didSet{ + chatTagsCollectionView.isHidden = self.getChatTags.isEmpty ? true : showPrivateChat + } + } var chatPageSize = 40 var totalPages = 2 var totalUsers = 0 @@ -98,21 +110,25 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { var selectedChatTag: ChatTagsModel! { didSet { if !isSearchEnabled { - if selectedChatTag?.tagId == FlyDefaults.myJid || selectedChatTag == nil { + if selectedChatTag?.tagId == AppUtils.getMyJid() || selectedChatTag == nil { getRecentChatList() } else { getRecentChatForSelectedChatTag(chatTag: selectedChatTag) } + setUpPullForPrivateChat() recentChatTableView?.reloadData() } } } var selectedTagIndex = 0 + let privateChatHeaderHeight = 64 + var privateChatHeaderView = UIView() + var releaseForPrivateChatHeaderView = UIView() override func viewDidLoad() { super.viewDidLoad() - if ENABLE_CHAT_HISTORY { + if ENABLE_CHAT_HISTORY && NetStatus.shared.isConnected { self.startLoading(withText: "") } getAllChatTags() @@ -151,6 +167,120 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { }.disposed(by: disposeBag) } + + func setUpPullForPrivateChat() { + if showPrivateChat { + return + } + let privateView = UIView() + privateView.frame = CGRect(x: 0, y: 0, width: 0, height: privateChatHeaderHeight) + let headerContentView = UIView(frame: privateChatHeaderView.bounds) + headerContentView.backgroundColor = Color.color_D0D8EB + headerContentView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + + let stack = UIStackView(frame: CGRect(x: 8, y: 5, width: headerContentView.bounds.width, height: headerContentView.bounds.height-10)) + stack.autoresizingMask = [.flexibleWidth, .flexibleHeight] + stack.distribution = .fillProportionally + stack.axis = .horizontal + stack.spacing = 10 + + let image = UIImageView() + image.image = UIImage(named: "app_icon") + image.cornerRadius(radius: 27, width: 0.5, color: .clear) + image.contentMode = .center + image.backgroundColor = Color.color_AFBDDF + let imageViewWidthConstraint = NSLayoutConstraint(item: image, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 54) + let imageViewHeightConstraint = NSLayoutConstraint(item: image, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 54) + image.addConstraints([imageViewWidthConstraint, imageViewHeightConstraint]) + stack.addArrangedSubview(image) + + let label = UILabel(frame: headerContentView.bounds) + label.text = "Private Chats" + label.font = .init(name: "SFUIDisplay-Medium", size: 16) + label.textColor = .black + label.autoresizingMask = [.flexibleWidth, .flexibleHeight] + + stack.addArrangedSubview(label) + headerContentView.addSubview(stack) + privateView.addSubview(headerContentView) + + privateView.isUserInteractionEnabled = true + let tap = UITapGestureRecognizer(target: self, action: #selector(privateChatTapped)) + privateView.addGestureRecognizer(tap) + + let releaseView = UIView(frame: privateView.bounds) + //releaseView = UIView(frame: privateView.bounds) + releaseView.backgroundColor = Color.color_D0D8EB + releaseView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + + let releaseHeaderContentView = UIView(frame: privateView.bounds) + releaseHeaderContentView.backgroundColor = Color.color_D0D8EB + releaseHeaderContentView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + + let releaseStack = UIStackView(frame: CGRect(x: 8, y: 0, width: releaseHeaderContentView.bounds.width, height: releaseHeaderContentView.bounds.height)) + releaseStack.autoresizingMask = [.flexibleWidth, .flexibleHeight] + releaseStack.distribution = .fillProportionally + releaseStack.axis = .horizontal + releaseStack.spacing = 10 + + let releaseImage = UIImageView() + releaseImage.image = UIImage(named: "private_down") + releaseImage.cornerRadius(radius: 27, width: 0.5, color: .clear) + releaseImage.contentMode = .center + let releaseImageViewWidthConstraint = NSLayoutConstraint(item: releaseImage, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 54) + let releaseImageViewHeightConstraint = NSLayoutConstraint(item: releaseImage, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 54) + releaseImage.addConstraints([releaseImageViewWidthConstraint, releaseImageViewHeightConstraint]) + releaseStack.addArrangedSubview(releaseImage) + + let releaseLabel = UILabel(frame: releaseHeaderContentView.bounds) + releaseLabel.text = "Release for Private Messages" + releaseLabel.font = .init(name: "SFUIDisplay-Medium", size: 16) + releaseLabel.textColor = .black + releaseLabel.autoresizingMask = [.flexibleWidth, .flexibleHeight] + + releaseStack.addArrangedSubview(releaseLabel) + releaseHeaderContentView.addSubview(releaseStack) + releaseView.addSubview(releaseHeaderContentView) + + privateView.addSubview(releaseView) + privateView.isHidden = true + releaseView.isHidden = false + + ChatManager.getPrivateChatList { isSuccess, error, data in + if isSuccess { + let list = data["data"] as? [RecentChat] ?? [] + if list.count > 0 { + self.recentChatTableView?.tableHeaderView = privateView + self.recentChatTableView?.contentInset.top = -1 * privateView.frame.size.height + } else { + self.recentChatTableView?.tableHeaderView = nil + self.recentChatTableView?.contentInset.top = 0 + } + } + } + + self.privateChatHeaderView = privateView + self.releaseForPrivateChatHeaderView = releaseView + } + + @objc func privateChatTapped(sender: UITapGestureRecognizer) { + self.view.endEditing(true) + showLockScreen() + } + + func showLockScreen() { + if CommonDefaults.appFingerprintenable { + let vc = PrivateChatFingerPrintPINViewController(nibName: "PrivateChatFingerPrintPINViewController", bundle: nil) + vc.isFromPrivateRecentChat = true + vc.privateChatDelegate = self + self.navigationController?.pushViewController(vc, animated: false) + } else { + let vc = PrivateChatAuthenticationPINViewController(nibName:"PrivateChatAuthenticationPINViewController", bundle: nil) + vc.isFromPrivateRecentChat = true + vc.privateChatDelegate = self + self.navigationController?.pushViewController(vc, animated: true) + } + } func setupDelegate() { chatManager.connectionDelegate = self @@ -174,12 +304,18 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + NotificationCenter.default.addObserver(self, selector: #selector(self.privateChatSwitchNotification(notification:)), name: Notification.Name("PrivateChatSwitch"), object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedNotification(notification:)), name: Notification.Name("PrivateChatAlertView"), object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(self.privateChatAuthorized(notification:)), name: Notification.Name("PrivateRecentChatAuthenticated"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(networkChange(_:)), name: Notification.Name(NetStatus.networkNotificationObserver), object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground), + name: NSNotification.Name(didBecomeActive), object: nil) navigationController?.setNavigationBarHidden(true, animated: animated) + //CommonDefaults.isInPrivateChat = showPrivateChat ? true : false getAllChatTags() getRecentChatList() - + setUpPullForPrivateChat() if ENABLE_CONTACT_SYNC{ getContactList() }else{ @@ -189,11 +325,9 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { ChatManager.shared.availableFeaturesDelegate = self availableFeatures = ChatManager.getAvailableFeatures() searchBar?.isHidden = !(availableFeatures.isRecentChatSearchEnabled) ? true : false - if !FlyDefaults.showAppLock { + if !CommonDefaults.showAppLock { openChat(jid: pushChatId ?? "") } - - getProfile() } override func viewDidAppear(_ animated: Bool) { @@ -211,22 +345,73 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { ChatManager.shared.adminBlockDelegate = nil ChatManager.shared.availableFeaturesDelegate = nil chatManager.archiveEventsDelegate = nil + self.recentChatTableView?.tableHeaderView = nil NotificationCenter.default.removeObserver(self, name: Notification.Name(NetStatus.networkNotificationObserver), object: nil) } override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) NotificationCenter.default.removeObserver(self, name: NSNotification.Name(FlyConstants.contactSyncState), object: nil) + NotificationCenter.default.removeObserver(self, name: Notification.Name("PrivateChatAlertView"), object: nil) + NotificationCenter.default.removeObserver(self, name: Notification.Name("PrivateRecentChatAuthenticated"), object: nil) } - + + @objc func willEnterForeground() { + self.view.removeLaunchSubview() + } + override func willCometoForeground() { + self.view.removeLaunchSubview() getRecentChatList() + setUpPullForPrivateChat() if !ENABLE_CONTACT_SYNC && isSearchEnabled{ resetDataAndFetchUsersList() } - if !FlyDefaults.showAppLock { - openChat(jid: pushChatId ?? "") + if !CommonDefaults.showAppLock { + if showPrivateChat && CommonDefaults.appLockOnPrivateChat && !CommonDefaults.showPrivateLockRecent{ + showLockScreen() + CommonDefaults.appLockOnPrivateChat = false + } else if showPrivateChat && CommonDefaults.appLockOnPrivateChat && !pushNotificationSelected && !CommonDefaults.privateChatOnChatScreen { + showLockScreen() + } else { + let current = UIApplication.shared.keyWindow?.getTopViewController() + if (current is RecentChatViewController) { + openChat(jid: pushChatId ?? "") + } + } } +// else if showPrivateChat && CommonDefaults.appLockOnPrivateChat && !pushNotificationSelected && !CommonDefaults.privateChatOnChatScreen && CommonDefaults.showPrivateLockChat { +// showLockScreen() +// } + + } + + override func didMoveToBackground() { + let current = UIApplication.shared.keyWindow?.getTopViewController() + if (current is RecentChatViewController) { + CommonDefaults.appLockOnPrivateChat = showPrivateChat ? true : false + CommonDefaults.privateChatOnChatScreen = false + self.recentChatTableView?.tableHeaderView = nil + if showPrivateChat { + self.view.addLaunchSubview() + } + } + } + + + + @objc func methodOfReceivedNotification(notification: Notification) { + updatePrivateChatView() + } + + @objc func privateChatSwitchNotification(notification: Notification) { + updatePrivateChatView() + NotificationCenter.default.removeObserver(self, name: Notification.Name("PrivateChatSwitch"), object: nil) + } + + @objc func privateChatAuthorized(notification: Notification) { + updatePrivateChatView() + recentChatTableView?.reloadData() } private func configTableView() { @@ -267,7 +452,7 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { let touchPoint = gestureRecognizer.location(in: recentChatTableView) if let indexPath = recentChatTableView?.indexPathForRow(at: touchPoint) { if let cell = recentChatTableView?.cellForRow(at: indexPath) as? RecentChatTableViewCell { - if selectionRecentChatList.filter({$0.jid == (showArchivedChat ? getArchiveChat[indexPath.row].jid : getRecentChat[indexPath.row].jid) }).count == 0 { + if selectionRecentChatList.filter({$0.jid == (showArchivedChat ? getArchiveChat[indexPath.row].jid : showPrivateChat ? getPrivateChats[indexPath.row].jid : getRecentChat[indexPath.row].jid) }).count == 0 { cell.contentView.backgroundColor = Color.recentChatSelectionColor isCellLongPressed = true recentChatTableView?.selectRow(at: indexPath, animated: true, scrollPosition: .none) @@ -275,6 +460,9 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { if showArchivedChat { getArchiveChat[indexPath.row].isSelected = !getArchiveChat[indexPath.row].isSelected selectionRecentChatList.insert(getArchiveChat[indexPath.row], at: 0) + } else if showPrivateChat { + getPrivateChats[indexPath.row].isSelected = !getPrivateChats[indexPath.row].isSelected + selectionRecentChatList.insert(getPrivateChats[indexPath.row], at: 0) } else { getRecentChat[indexPath.row].isSelected = !getRecentChat[indexPath.row].isSelected selectionRecentChatList.insert(getRecentChat[indexPath.row], at: 0) @@ -301,7 +489,7 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { closeKeyboard() let buttonTag = sender.tag currentIndex = buttonTag - if showArchivedChat ? getArchiveChat[currentIndex].isBlockedByAdmin && getArchiveChat[currentIndex].isGroup : getRecentChat[currentIndex].isBlockedByAdmin && getRecentChat[currentIndex].isGroup { + if showPrivateChat ? getPrivateChats[currentIndex].isBlockedByAdmin && getPrivateChats[currentIndex].isGroup : showArchivedChat ? getArchiveChat[currentIndex].isBlockedByAdmin && getArchiveChat[currentIndex].isGroup : getRecentChat[currentIndex].isBlockedByAdmin && getRecentChat[currentIndex].isGroup { showGroupBlockedView() } else if isSearchEnabled == true{ self.profilePopupContainer?.isHidden = true @@ -363,7 +551,7 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { @IBAction func call(_ sender: Any) { - let profile = showArchivedChat ? getArchiveChat[currentIndex] : getRecentChat[currentIndex] + let profile = showPrivateChat ? getPrivateChats[currentIndex] : showArchivedChat ? getArchiveChat[currentIndex] : getRecentChat[currentIndex] let callType = CallType.Audio if !NetworkReachability.shared.isConnected { @@ -424,7 +612,7 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { @IBAction func videoCall(_ sender: Any) { - let profile = showArchivedChat ? getArchiveChat[currentIndex] : getRecentChat[currentIndex] + let profile = showPrivateChat ? getPrivateChats[currentIndex] : showArchivedChat ? getArchiveChat[currentIndex] : getRecentChat[currentIndex] let callType = CallType.Video if !NetworkReachability.shared.isConnected { @@ -482,7 +670,7 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { } @IBAction func userInfo(_ sender: Any) { - let profile = showArchivedChat ? getArchiveChat[currentIndex] : getRecentChat[currentIndex] + let profile = showPrivateChat ? getPrivateChats[currentIndex] : showArchivedChat ? getArchiveChat[currentIndex] : getRecentChat[currentIndex] if profile.profileType == .singleChat{ if let vc = UIStoryboard.init(name: Storyboards.chat, bundle: Bundle.main).instantiateViewController(withIdentifier: Identifiers.contactInfoViewController) as? ContactInfoViewController { vc.contactJid = profile.jid @@ -515,6 +703,8 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { @IBAction func headerArchiveBackAction(_ sender: UIButton) { hideArchiveHeader() //recentChatTableView?.reloadData() + emptyMessageView?.isHidden = true + showOnlyPrivateChatAvailableView(isShow: false) getAllChatTags() getRecentChatList() } @@ -540,7 +730,7 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { message: contactAccessMessage, settingstitle: settings, cancelTitle: cancelUppercase) - FlyDefaults.isContactPermissionSkipped = false + ContactSyncManager.updateContactPermission(isSkipped: false) } else { self?.navigateTo(identifier: Identifiers.createNewGroup) } @@ -657,7 +847,7 @@ class RecentChatViewController: UIViewController, UIGestureRecognizerDelegate { self?.selectionCountLabel?.isHidden = true self?.showHeaderView() self?.isCellLongPressed = false - if self?.getArchiveChat.count == 0 { + if self?.getArchiveChat.count == 0 && !(self?.showPrivateChat ?? false) { self?.hideArchiveHeader() } self?.getRecentChatList() @@ -831,9 +1021,9 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate func numberOfSections(in tableView: UITableView) -> Int { if isSearchEnabled == true { return 3 - } else if getRecentChat.count > 0 && getArchiveChat.count > 0 && !showArchivedChat { + } else if getRecentChat.count > 0 && getArchiveChat.count > 0 && !showArchivedChat && !showPrivateChat { return 2 - } else if getRecentChat.count > 0 || getArchiveChat.count > 0 || showArchivedChat { + } else if getRecentChat.count > 0 || getArchiveChat.count > 0 || showArchivedChat || getPrivateChats.count > 0 || showPrivateChat { return 1 } else { return 0 @@ -854,19 +1044,21 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate break } case false: - if getRecentChat.count > 0 && getArchiveChat.count > 0 && showArchivedChat == false { + if getRecentChat.count > 0 && getArchiveChat.count > 0 && showArchivedChat == false && showPrivateChat == false { switch section { - case FlyDefaults.isArchivedChatEnabled ? 0 : 1: + case ChatManager.isArchivedSettingsEnabled() ? 0 : 1: return 1 - case FlyDefaults.isArchivedChatEnabled ? 1 : 0: + case ChatManager.isArchivedSettingsEnabled() ? 1 : 0: return getRecentChat.count default: break } - } else if getArchiveChat.count > 0 && showArchivedChat == false { + } else if getArchiveChat.count > 0 && showArchivedChat == false && showPrivateChat == false { return 1 } else if getArchiveChat.count > 0 && showArchivedChat == true { return getArchiveChat.count + } else if getPrivateChats.count > 0 && showPrivateChat == true { + return getPrivateChats.count } else { return getRecentChat.count } @@ -916,15 +1108,15 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate var cell: RecentChatTableViewCell! switch isSearchEnabled { case false: - if getRecentChat.count > 0 && getArchiveChat.count > 0 && showArchivedChat == false { + if getRecentChat.count > 0 && getArchiveChat.count > 0 && showArchivedChat == false && showPrivateChat == false { switch indexPath.section { - case FlyDefaults.isArchivedChatEnabled ? 0 : 1: + case ChatManager.isArchivedSettingsEnabled() ? 0 : 1: let cell = tableView.dequeueReusableCell(withIdentifier: Identifiers.ArchiveChatTableViewCell, for: indexPath) as! ArchiveChatTableViewCell - let count = FlyDefaults.isArchivedChatEnabled ? getArchiveChat.filter { chat in return chat.unreadMessageCount > 0 ? true : false }.count : getArchiveChat.count + let count = ChatManager.isArchivedSettingsEnabled() ? getArchiveChat.filter { chat in return chat.unreadMessageCount > 0 ? true : false }.count : getArchiveChat.count cell.chatCountLabel.isHidden = count == 0 ? true : false cell.chatCountLabel.text = String(count) return cell - case FlyDefaults.isArchivedChatEnabled ? 1 : 0: + case ChatManager.isArchivedSettingsEnabled() ? 1 : 0: cell = tableView.dequeueReusableCell(withIdentifier: Identifiers.recentChatCell, for: indexPath) as? RecentChatTableViewCell if getRecentChat.count > indexPath.row { let recentChat = getRecentChat[indexPath.row] @@ -945,9 +1137,9 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate default: break } - } else if getArchiveChat.count > 0 && showArchivedChat == false { + } else if getArchiveChat.count > 0 && showArchivedChat == false && showPrivateChat == false { let cell = tableView.dequeueReusableCell(withIdentifier: Identifiers.ArchiveChatTableViewCell, for: indexPath) as! ArchiveChatTableViewCell - let count = FlyDefaults.isArchivedChatEnabled ? getArchiveChat.reduce(0, {$0 + $1.unreadMessageCount}) : getArchiveChat.count + let count = ChatManager.isArchivedSettingsEnabled() ? getArchiveChat.reduce(0, {$0 + $1.unreadMessageCount}) : getArchiveChat.count cell.chatCountLabel.isHidden = count == 0 ? true : false cell.chatCountLabel.text = String(count) return cell @@ -968,6 +1160,23 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate cell.setChatTimeTextColor(lastMessageTime: recentChat.lastMessageTime, unreadCount: recentChat.unreadMessageCount) return cell } + } else if showPrivateChat == true { + cell = tableView.dequeueReusableCell(withIdentifier: Identifiers.recentChatCell, for: indexPath) as? RecentChatTableViewCell + if getPrivateChats.count > indexPath.row { + let recentChat = getPrivateChats[indexPath.row] + let name = getUserName(jid: recentChat.jid, name: recentChat.profileName, nickName: recentChat.nickName, contactType: recentChat.isItSavedContact ? .live : .unknown) + let color = getColor(userName: name) + cell.setTextColorWhileSearch(searchText: searchBar?.text ?? "", recentChat: recentChat) + cell.setLastContentTextColor(searchText: searchBar?.text ?? "", recentChat: recentChat) + let chatMessage = getMessages(messageId: recentChat.lastMessageId) + let getGroupSenderName = ChatUtils.getGroupSenderName(messsage: chatMessage) + cell.setRecentChatMessage(recentChatMessage: recentChat, color: color, chatMessage: chatMessage, senderName: getGroupSenderName, fromArchive: showArchivedChat) + cell.archivedStatusLabel.isHidden = true + cell.profileImageButton?.tag = indexPath.row + cell.profileImageButton?.addTarget(self, action: #selector( imageButtonAction(_:)), for: .touchUpInside) + cell.setChatTimeTextColor(lastMessageTime: recentChat.lastMessageTime, unreadCount: recentChat.unreadMessageCount) + return cell + } } else { cell = tableView.dequeueReusableCell(withIdentifier: Identifiers.recentChatCell, for: indexPath) as? RecentChatTableViewCell if getRecentChat.count > indexPath.row { @@ -1003,6 +1212,9 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate cell.archivedStatusLabel.isHidden = !recentChat.isChatArchived cell.profileImageButton?.isUserInteractionEnabled = false cell.profileImageButton?.tag = indexPath.row + if recentChat.isPrivateChat { + cell.userMessageLabel?.text = "" + } // cell.profileImageButton?.addTarget(self, action: #selector( imageButtonAction(_:)), for: .touchUpInside) cell.setChatTimeTextColor(lastMessageTime: recentChat.lastMessageTime, unreadCount: recentChat.unreadMessageCount) return cell @@ -1140,23 +1352,27 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate case true: didSelectRow(tableView: tableView, indexPath: indexPath) case false: - if getRecentChat.count > 0 && getArchiveChat.count > 0 && showArchivedChat == false { - switch indexPath.section { - case FlyDefaults.isArchivedChatEnabled ? 0 : 1: - if isCellLongPressed == false { - updateArchiveChatView() - recentChatTableView?.reloadData() + if showPrivateChat { + didSelectRow(tableView: tableView, indexPath: indexPath) + } else { + if getRecentChat.count > 0 && getArchiveChat.count > 0 && showArchivedChat == false { + switch indexPath.section { + case ChatManager.isArchivedSettingsEnabled() ? 0 : 1: + if isCellLongPressed == false { + updateArchiveChatView() + recentChatTableView?.reloadData() + } + case ChatManager.isArchivedSettingsEnabled() ? 1 : 0: + didSelectRow(tableView: tableView, indexPath: indexPath) + default: + break } - case FlyDefaults.isArchivedChatEnabled ? 1 : 0: + } else if getArchiveChat.count > 0 { + updateArchiveChatView() + recentChatTableView?.reloadData() + } else { didSelectRow(tableView: tableView, indexPath: indexPath) - default: - break } - } else if getArchiveChat.count > 0 { - updateArchiveChatView() - recentChatTableView?.reloadData() - } else { - didSelectRow(tableView: tableView, indexPath: indexPath) } } } @@ -1166,12 +1382,15 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate if( isCellLongPressed ?? false) { if let cell = tableView.cellForRow(at: indexPath) as? RecentChatTableViewCell { if( longPressCount >= 1) { - if selectionRecentChatList.filter({$0.jid == (showArchivedChat ? getArchiveChat[indexPath.row].jid : getRecentChat[indexPath.row].jid) }).count == 0 { + if selectionRecentChatList.filter({$0.jid == (showArchivedChat ? getArchiveChat[indexPath.row].jid : showPrivateChat ? getPrivateChats[indexPath.row].jid : getRecentChat[indexPath.row].jid) }).count == 0 { cell.contentView.backgroundColor = Color.recentChatSelectionColor longPressCount += 1 if showArchivedChat { getArchiveChat[indexPath.row].isSelected = !getArchiveChat[indexPath.row].isSelected selectionRecentChatList.insert(getArchiveChat[indexPath.row], at: 0) + } else if showPrivateChat { + getPrivateChats[indexPath.row].isSelected = !getPrivateChats[indexPath.row].isSelected + selectionRecentChatList.insert(getPrivateChats[indexPath.row], at: 0) } else { getRecentChat[indexPath.row].isSelected = !getRecentChat[indexPath.row].isSelected selectionRecentChatList.insert(getRecentChat[indexPath.row], at: 0) @@ -1192,7 +1411,9 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate if !(isCellLongPressed ?? false) { if showArchivedChat && (!getArchiveChat.isEmpty && getArchiveChat[indexPath.row].profileType == .groupChat && getArchiveChat[indexPath.row].isBlockedByAdmin) { showGroupBlockedView() - } else if showArchivedChat == false && (!getRecentChat.isEmpty && getRecentChat[indexPath.row].profileType == .groupChat && getRecentChat[indexPath.row].isBlockedByAdmin) { + } else if showArchivedChat == false && showPrivateChat == false && (!getRecentChat.isEmpty && getRecentChat[indexPath.row].profileType == .groupChat && getRecentChat[indexPath.row].isBlockedByAdmin) { + showGroupBlockedView() + } else if showPrivateChat && (!getPrivateChats.isEmpty && getPrivateChats[indexPath.row].profileType == .groupChat && getPrivateChats[indexPath.row].isBlockedByAdmin) { showGroupBlockedView() } else if isSearchEnabled == true { if !ENABLE_CONTACT_SYNC { @@ -1217,7 +1438,7 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate if( isCellLongPressed ?? false) { if let cell = tableView.cellForRow(at: indexPath) as? RecentChatTableViewCell { if( longPressCount >= 1) { - let recentChatJid = showArchivedChat ? getArchiveChat[indexPath.row].jid : getRecentChat[indexPath.row].jid + let recentChatJid = showArchivedChat ? getArchiveChat[indexPath.row].jid : showPrivateChat ? getPrivateChats[indexPath.row].jid : getRecentChat[indexPath.row].jid if selectionRecentChatList.filter({$0.jid == recentChatJid}).count > 0 { selectionRecentChatList.enumerated().forEach { (index,selectedRecentChat) in if recentChatJid == selectedRecentChat.jid { @@ -1226,6 +1447,9 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate if showArchivedChat { getArchiveChat[indexPath.row].isSelected = !getArchiveChat[indexPath.row].isSelected selectionRecentChatList.remove(at: index) + } else if showPrivateChat { + getPrivateChats[indexPath.row].isSelected = !getPrivateChats[indexPath.row].isSelected + selectionRecentChatList.remove(at: index) } else { getRecentChat[indexPath.row].isSelected = !getRecentChat[indexPath.row].isSelected selectionRecentChatList.remove(at: index) @@ -1282,7 +1506,7 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate } func openChat(jid: String) { - if FlyDefaults.myJid != jid { + if AppUtils.getMyJid() != jid { if let profile = recentChatViewModel?.getRecentChat(jid: jid) { let vc = UIStoryboard.init(name: Storyboards.chat, bundle: Bundle.main).instantiateViewController(withIdentifier: Identifiers.chatViewParentController) as? ChatViewParentController let profileDetails = ProfileDetails(jid: profile.jid) @@ -1310,7 +1534,7 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate } func openChat(index: Int) { - let profile = showArchivedChat ? getArchiveChat[index] : getRecentChat[index] + let profile = showArchivedChat ? getArchiveChat[index] : showPrivateChat ? getPrivateChats[index] : getRecentChat[index] let vc = UIStoryboard.init(name: Storyboards.chat, bundle: Bundle.main).instantiateViewController(withIdentifier: Identifiers.chatViewParentController) as? ChatViewParentController let profileDetails = ProfileDetails(jid: profile.jid) profileDetails.name = profile.profileName @@ -1330,6 +1554,8 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate vc?.replyMessageObj = replyMessageObj vc?.replyJid = replyJid vc?.ismarkMessagesAsRead = true + vc?.isFromSearchSelect = isSearchEnabled + vc?.isFromPrivateChat = showPrivateChat vc?.navigationController?.modalPresentationStyle = .overFullScreen self.navigationController?.pushViewController(vc!, animated: true) } @@ -1405,8 +1631,10 @@ extension RecentChatViewController : UITableViewDataSource ,UITableViewDelegate default: break } + vc?.isFromSearchSelect = isSearchEnabled vc?.isStarredMessagePage = false vc?.searchMessageId = searchMessageId + vc?.isFromPrivateChat = showPrivateChat navigationController?.modalPresentationStyle = .overFullScreen navigationController?.pushViewController(vc!, animated: true) } @@ -1438,7 +1666,7 @@ extension RecentChatViewController { func getRecentChatList(fromAPI: Bool = false) { - if selectedChatTag?.tagId == FlyDefaults.myJid || selectedChatTag == nil { + if selectedChatTag?.tagId == AppUtils.getMyJid() || selectedChatTag == nil { recentChatListBuilder?.changeLimit(limit: getAllRecentChat.isEmpty ? 40 : ((getAllRecentChat.count < 40 ? 40 : getAllRecentChat.count))) recentChatListBuilder?.loadRecentChatList(completionHandler: { [weak self] isSuccess, error, data in @@ -1464,6 +1692,7 @@ extension RecentChatViewController { let name = getUserName(jid: recentChat.jid,name: recentChat.profileName, nickName: recentChat.nickName,contactType: recentChat.isItSavedContact ? .live : .unknown) return (name.range(of: weakSelf.searchBar?.text?.trim() ?? "", options: [.caseInsensitive, .diacriticInsensitive]) != nil && recentChat.isDeletedUser == false) }) + weakSelf.getRecentChat = (weakSelf.getRecentChat + archiveSearchChats).sorted { $0.lastMessageTime > $1.lastMessageTime } } DispatchQueue.main.async { [weak self] in @@ -1486,9 +1715,55 @@ extension RecentChatViewController { self?.showHideEmptyMessage() } } + + ChatManager.getPrivateChatList { [self] isSuccess, error, data in + if isSuccess { + self.getPrivateChats = data["data"] as? [RecentChat] ?? [] + + if showPrivateChat { + self.selectionRecentChatList = self.selectionRecentChatList.filter({ item in self.getPrivateChats.contains(where: { $0.jid == item.jid }) }) + longPressCount = self.selectionRecentChatList.count + selectionCountLabel?.text = String(longPressCount) + if self.selectionRecentChatList.count == 0 { + hideMultipleSelectionView() + } + } + self.selectionRecentChatList.enumerated().forEach { (index,selectedRecentChat) in + self.getPrivateChats.filter({$0.jid == selectedRecentChat.jid}).first?.isSelected = selectedRecentChat.isSelected + } + + if self.isSearchEnabled { + getRecentChat = getRecentChat.filter { chat in + return getPrivateChats.contains { privateChat in + privateChat.jid == chat.jid + } + } + + getRecentChat = searchBar?.text?.trim().isEmpty ?? false ? getAllRecentChat : getAllRecentChat.filter({ recentChat -> Bool in + let name = getUserName(jid: recentChat.jid,name: recentChat.profileName, nickName: recentChat.nickName,contactType: recentChat.isItSavedContact ? .live : .unknown) + return (name.range(of: searchBar?.text?.trim() ?? "", options: [.caseInsensitive, .diacriticInsensitive]) != nil && recentChat.isDeletedUser == false) + }) + let archiveSearchChats = getArchiveChat.filter({ recentChat -> Bool in + let name = getUserName(jid: recentChat.jid,name: recentChat.profileName, nickName: recentChat.nickName,contactType: recentChat.isItSavedContact ? .live : .unknown) + return (name.range(of: searchBar?.text?.trim() ?? "", options: [.caseInsensitive, .diacriticInsensitive]) != nil && recentChat.isDeletedUser == false) + }) + + getRecentChat = (getRecentChat + archiveSearchChats).sorted { $0.lastMessageTime > $1.lastMessageTime } + + } + +// executeOnMainThread { +// self.setUpPullForPrivateChat() +// } + self.showHideEmptyMessage() + } + } - if showArchivedChat && getArchiveChat.count == 0 { + if (showArchivedChat && getArchiveChat.count == 0) && !showPrivateChat { hideArchiveHeader() + } else if (showPrivateChat && getPrivateChats.count == 0) { + //self.recentChatTableView?.tableHeaderView = nil + //self.recentChatTableView?.contentInset.top = 0 } executeOnMainThread { self.recentChatTableView?.reloadData() @@ -1512,7 +1787,7 @@ extension RecentChatViewController { self.getOverallUnreadCount() } } else { - self.selectedChatTag = ChatTagsModel(tagId: FlyDefaults.myJid, tagname: "All", taginfo: "", isRecommentedTag: false, memberIdList: [], currentUserId: FlyDefaults.myJid) + self.selectedChatTag = ChatTagsModel(tagId: AppUtils.getMyJid(), tagname: "All", taginfo: "", isRecommentedTag: false, memberIdList: [], currentUserId: AppUtils.getMyJid()) self.getRecentChatList() return } @@ -1534,8 +1809,35 @@ extension RecentChatViewController { self?.showHideEmptyMessage() } } - if showArchivedChat && getArchiveChat.count == 0 { + + ChatManager.getPrivateChatList { [self] isSuccess, error, data in + if isSuccess { + self.getPrivateChats = data["data"] as? [RecentChat] ?? [] + + if showPrivateChat { + self.selectionRecentChatList = self.selectionRecentChatList.filter({ item in self.getPrivateChats.contains(where: { $0.jid == item.jid }) }) + longPressCount = self.selectionRecentChatList.count + selectionCountLabel?.text = String(longPressCount) + if self.selectionRecentChatList.count == 0 { + hideMultipleSelectionView() + } + } + self.selectionRecentChatList.enumerated().forEach { (index,selectedRecentChat) in + self.getPrivateChats.filter({$0.jid == selectedRecentChat.jid}).first?.isSelected = selectedRecentChat.isSelected + } + +// executeOnMainThread { +// self.setUpPullForPrivateChat() +// } + self.showHideEmptyMessage() + } + } + + if (showArchivedChat && getArchiveChat.count == 0) && !showPrivateChat { hideArchiveHeader() + } else if (showPrivateChat && getPrivateChats.count == 0) { + //self.recentChatTableView?.tableHeaderView = nil + //self.recentChatTableView?.contentInset.top = 0 } recentChatTableView?.reloadData() @@ -1568,6 +1870,8 @@ extension RecentChatViewController: UISearchBarDelegate { func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String){ if searchText.trim().count > 0 { isSearchEnabled = true + self.recentChatTableView?.tableHeaderView = nil + self.recentChatTableView?.contentInset.top = 0 scrollToTableViewTop() hideMultipleSelectionView() clearSelectedColor() @@ -1612,8 +1916,8 @@ extension RecentChatViewController: UISearchBarDelegate { DispatchQueue.global(qos: .userInitiated).async { - self.searchedMessages = ChatManager.shared.searchMessage(text: searchText.trim()) DispatchQueue.main.async {[weak self] in + self?.searchedMessages = ChatManager.shared.searchMessage(text: searchText.trim()).filter { !ChatManager.isPrivateChat(jid: $0.chatUserJid) } self?.recentChatTableView?.reloadData() self?.showHideEmptyMessage() } @@ -1627,11 +1931,14 @@ extension RecentChatViewController: UISearchBarDelegate { func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { refreshRecentChatMessages() + setUpPullForPrivateChat() } func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { scrollToTableViewTop() getRecentChatList() + self.recentChatTableView?.tableHeaderView = nil + self.recentChatTableView?.contentInset.top = 0 searchBar.setShowsCancelButton(true, animated: true) } @@ -1644,8 +1951,8 @@ extension RecentChatViewController: UISearchBarDelegate { extension RecentChatViewController { func setProfile() { if currentIndex > -1{ - let profile = showArchivedChat ? getArchiveChat[currentIndex] : getRecentChat[currentIndex] - let urlString = "\(FlyDefaults.baseURL)\(media)/\(profile.profileImage ?? "")?mf=\(FlyDefaults.authtoken)" + let profile = showPrivateChat ? getPrivateChats[currentIndex] : showArchivedChat ? getArchiveChat[currentIndex] : getRecentChat[currentIndex] + let urlString = ChatManager.getImageUrl(imageName: profile.profileImage ?? "") let isDeletedUser = profile.isDeletedUser username?.text = getUserName(jid: profile.jid,name: profile.profileName, nickName: profile.nickName, contactType: isDeletedUser ? .deleted : (profile.isItSavedContact ? .live : .unknown)) let url = URL(string: urlString) @@ -1751,7 +2058,7 @@ extension RecentChatViewController { } func isParticipantExist(groupJid: String) -> (doesExist : Bool, message : String) { - return GroupManager.shared.isParticiapntExistingIn(groupJid: groupJid, participantJid: FlyDefaults.myJid) + return GroupManager.shared.isParticiapntExistingIn(groupJid: groupJid, participantJid: AppUtils.getMyJid()) } func getPlaceholder(name: String, color: UIColor)->UIImage { @@ -1782,17 +2089,92 @@ extension RecentChatViewController { noNewMsgText?.isHidden = false noNewMsgText?.text = noResultFound noNewMsgText?.textColor = .lightGray + descriptionMessageText?.isHidden = true + showOnlyPrivateChatAvailableView(isShow: false) } else { - emptyMessageView?.isHidden = (getRecentChat.count == 0 && getArchiveChat.count == 0) ? false : true - emptyImage?.isHidden = false - noNewMsgText?.isHidden = false - noNewMsgText?.text = noNewMessage - noNewMsgText?.textColor = .black - descriptionMessageText?.isHidden = false + if showPrivateChat { + emptyMessageView?.isHidden = getPrivateChats.count == 0 ? false : true + emptyImage?.isHidden = false + noNewMsgText?.isHidden = false + noNewMsgText?.text = noPrivateMessage + noNewMsgText?.textColor = .black + descriptionMessageText?.isHidden = true + showOnlyPrivateChatAvailableView(isShow: false) + } else if getRecentChat.count == 0 && getArchiveChat.count == 0 && getPrivateChats.count != 0 { + emptyMessageView?.isHidden = getPrivateChats.count == 0 ? true : false + emptyImage?.isHidden = false + noNewMsgText?.isHidden = false + noNewMsgText?.text = noPrivateMessage + noNewMsgText?.textColor = .black + descriptionMessageText?.isHidden = true + showOnlyPrivateChatAvailableView(isShow: true) + } else { + emptyMessageView?.isHidden = (getRecentChat.count == 0 && getArchiveChat.count == 0) ? false : true + emptyImage?.isHidden = false + noNewMsgText?.isHidden = false + noNewMsgText?.text = noNewMessage + noNewMsgText?.textColor = .black + descriptionMessageText?.isHidden = false + showOnlyPrivateChatAvailableView(isShow: false) + } + } + } + } + + func showOnlyPrivateChatAvailableView(isShow: Bool) { + + if isShow { + if getPrivateChats.count > 0 { + self.recentChatTableView?.tableHeaderView = nil + } + } + + if let bounds = emptyMessageView?.bounds { + onlyPrivateChatAvailableView.frame = CGRect(x: 0, y: 0, width: bounds.width, height: bounds.height) + + let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: bounds.width, height: 70)) + imageView.image = UIImage(named: "privateChat_enable") + imageView.image = imageView.image?.withRenderingMode(.alwaysTemplate) + imageView.tintColor = Color.color_AFBDDF + imageView.contentMode = .scaleAspectFit + onlyPrivateChatAvailableView.addSubview(imageView) + + onlyPrivateChatAvailableViewLabel = UILabel(frame: CGRect(x: 0, y: 80, width: bounds.width, height: bounds.height - 70)) + onlyPrivateChatAvailableViewLabel.numberOfLines = 0 + onlyPrivateChatAvailableViewLabel.textAlignment = .center + onlyPrivateChatAvailableViewLabel.attributedText = attributedText() + onlyPrivateChatAvailableViewLabel.isUserInteractionEnabled = true + let tap = UITapGestureRecognizer(target: self, action: #selector(onlyPrivateChatTapped)) + onlyPrivateChatAvailableViewLabel.addGestureRecognizer(tap) + onlyPrivateChatAvailableView.backgroundColor = .white + onlyPrivateChatAvailableView.addSubview(onlyPrivateChatAvailableViewLabel) + + if isShow { + emptyMessageView?.addSubview(onlyPrivateChatAvailableView) + } else { + onlyPrivateChatAvailableView.removeFromSuperview() } } } + + + @objc func onlyPrivateChatTapped(sender: UITapGestureRecognizer) { + let textRange = ("All Chats are Locked\n\nUnlock Your Private Chat" as NSString).range(of: "Unlock Your Private Chat") + if sender.didTapAttributedTextInLabel(label: onlyPrivateChatAvailableViewLabel, inRange: textRange) { + showLockScreen() + } + } + + func attributedText() -> NSAttributedString { + let paragraph = NSMutableParagraphStyle() + paragraph.alignment = .center + let string = "All Chats are Locked\n\nUnlock Your Private Chat" as NSString + let attributedString = NSMutableAttributedString(string: string as String, attributes: [NSAttributedString.Key.font:UIFont(name: "SFUIDisplay-Regular", size: 17), .paragraphStyle: paragraph]) + let boldFontAttribute = [NSAttributedString.Key.font: UIFont(name: "SFUIDisplay-Medium", size: 18), NSAttributedString.Key.foregroundColor : Color.primaryAppColor] + attributedString.addAttributes(boldFontAttribute as [NSAttributedString.Key : Any], range: string.range(of: "Unlock Your Private Chat")) + return attributedString + } private func getisBlockedMe(jid: String) -> Bool { return ChatManager.getContact(jid: jid)?.isBlockedMe ?? false @@ -1825,9 +2207,6 @@ extension RecentChatViewController : ConnectionEventDelegate { } func onConnected() { - - getProfile() - if !Utility.getBoolFromPreference(key: "oneTimeSync") { ContactSyncManager.shared.syncContacts(){ isSuccess,_,_ in if isSuccess { @@ -1882,12 +2261,21 @@ extension RecentChatViewController : MessageEventsDelegate { getRecentChatList() } else { - - if let index = getRecentChat.firstIndex(where: { pd in pd.jid == toJid }) { - if let recentChat = ChatManager.getRechtChat(jid: toJid) { - getRecentChat[index] = recentChat - let indexPath = IndexPath(item: index, section: 0) - recentChatTableView?.reloadRows(at: [indexPath], with: .fade) + if showPrivateChat { + if let index = getPrivateChats.firstIndex(where: { pd in pd.jid == toJid }) { + if let recentChat = ChatManager.getRechtChat(jid: toJid) { + getPrivateChats[index] = recentChat + let indexPath = IndexPath(item: index, section: 0) + recentChatTableView?.reloadRows(at: [indexPath], with: .fade) + } + } + } else { + if let index = getRecentChat.firstIndex(where: { pd in pd.jid == toJid }) { + if let recentChat = ChatManager.getRechtChat(jid: toJid) { + getRecentChat[index] = recentChat + let indexPath = IndexPath(item: index, section: 0) + recentChatTableView?.reloadRows(at: [indexPath], with: .fade) + } } } self.getOverallUnreadCount() @@ -1939,7 +2327,7 @@ extension RecentChatViewController : ProfileEventsDelegate { object: nil, userInfo: profile as [AnyHashable: Any]) - let section = showArchivedChat ? 0 : getArchiveChat.count > 0 ? FlyDefaults.isArchivedChatEnabled ? 1 : 0 : 0 + let section = showArchivedChat ? 0 : getArchiveChat.count > 0 ? ChatManager.isArchivedSettingsEnabled() ? 1 : 0 : 0 // reloadRecentChatRow(index : index, section : section) } } @@ -1985,7 +2373,7 @@ extension RecentChatViewController : ProfileEventsDelegate { } else { getRecentChat[indexofJid] = recentChat } - let section = showArchivedChat ? 0 : getArchiveChat.count > 0 ? FlyDefaults.isArchivedChatEnabled ? 1 : 0 : 0 + let section = showArchivedChat ? 0 : getArchiveChat.count > 0 ? ChatManager.isArchivedSettingsEnabled() ? 1 : 0 : 0 reloadRecentChatRow(index : indexofJid, section : section) setProfile() } @@ -2008,7 +2396,7 @@ extension RecentChatViewController : ProfileEventsDelegate { } else { getRecentChat[indexofJid] = recentChat } - let section = showArchivedChat ? 0 : getArchiveChat.count > 0 ? FlyDefaults.isArchivedChatEnabled ? 1 : 0 : 0 + let section = showArchivedChat ? 0 : getArchiveChat.count > 0 ? ChatManager.isArchivedSettingsEnabled() ? 1 : 0 : 0 reloadRecentChatRow(index : indexofJid, section : section) setProfile() } @@ -2038,7 +2426,7 @@ extension RecentChatViewController : ProfileEventsDelegate { NotificationCenter.default.post(name: Notification.Name(FlyConstants.contactSyncState), object: nil, userInfo: profile as [AnyHashable : Any]) - let section = showArchivedChat ? 0 : getArchiveChat.count > 0 ? FlyDefaults.isArchivedChatEnabled ? 1 : 0 : 0 + let section = showArchivedChat ? 0 : getArchiveChat.count > 0 ? ChatManager.isArchivedSettingsEnabled() ? 1 : 0 : 0 reloadRecentChatRow(index : index, section : section) if profilePopupContainer?.isHidden == false && currentIndex == index { @@ -2173,7 +2561,7 @@ extension RecentChatViewController : GroupEventsDelegate { NotificationCenter.default.post(name: Notification.Name(FlyConstants.contactSyncState), object: nil, userInfo: groupProfile as [AnyHashable : Any]) - let section = self?.showArchivedChat ?? false ? 0 : self?.getArchiveChat.count ?? 0 > 0 ? FlyDefaults.isArchivedChatEnabled ? 1 : 0 : 0 + let section = self?.showArchivedChat ?? false ? 0 : self?.getArchiveChat.count ?? 0 > 0 ? ChatManager.isArchivedSettingsEnabled() ? 1 : 0 : 0 self?.reloadRecentChatRow(index : index, section : section) if self?.profilePopupContainer?.isHidden == false && self?.currentIndex == index { @@ -2303,13 +2691,31 @@ extension RecentChatViewController { extension RecentChatViewController : UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { - + + if showPrivateChat == false && getPrivateChats.count > 0 && isSearchEnabled == false && showArchivedChat == false { + if getRecentChat.count == 0 && getArchiveChat.count == 0 && getPrivateChats.count != 0 { + + } else { + if scrollView.contentOffset.y < 0 { + executeOnMainThread { + self.privateChatHeaderView.isHidden = false + //self.releaseForPrivateChatHeaderView.isHidden = false + } + } else if scrollView.contentOffset.y > privateChatHeaderView.frame.size.height { + executeOnMainThread { + self.privateChatHeaderView.isHidden = true + self.releaseForPrivateChatHeaderView.isHidden = false + } + } + } + } + let position = scrollView.contentOffset.y print("#scroll #load recentChatList loading done \(position) :: \(recentChatTableView!.contentSize.height) :: \(scrollView.frame.size.height)") if !isSearchEnabled{ if (position > (recentChatTableView!.contentSize.height/5)){ - if isRecentLoadingDone{ + if isRecentLoadingDone || selectedTagIndex != 0 { print("#scroll #load recentChatList loading done ") return } @@ -2328,7 +2734,7 @@ extension RecentChatViewController : UIScrollViewDelegate { }else{ if position > (recentChatTableView?.contentSize.height ?? 300)-200 - scrollView.frame.size.height { - if isPaginationCompleted(){ + if isPaginationCompleted() || selectedTagIndex != 0 { print("#fetch Pagination Done") return } @@ -2340,9 +2746,28 @@ extension RecentChatViewController : UIScrollViewDelegate { } } } + + func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) { + if showPrivateChat == false && getPrivateChats.count > 0 && isSearchEnabled == false && showArchivedChat == false { + if getRecentChat.count == 0 && getArchiveChat.count == 0 && getPrivateChats.count != 0 { + + } else { + if scrollView.contentOffset.y < 0 { + UIView.animate(withDuration: 0.25, animations: { + self.recentChatTableView?.contentInset.top = 0 + self.releaseForPrivateChatHeaderView.isHidden = true + }) + } else if scrollView.contentOffset.y > privateChatHeaderView.frame.size.height { + UIView.animate(withDuration: 0.25, animations: { + self.recentChatTableView?.contentInset.top = -1 * self.privateChatHeaderView.frame.size.height + }) + } + } + } + } func loadNextSetOfData() { - if showArchivedChat == false { + if showArchivedChat == false && showPrivateChat == false { print("#scroll loadNextSetOfData") recentChatListBuilder?.changeLimit(limit: 40) recentChatListBuilder?.nextSetOfData(completionHandler: { [weak self] isSuccess, error, data in @@ -2357,7 +2782,7 @@ extension RecentChatViewController : UIScrollViewDelegate { self?.isRecentLoadingInProgress = false if self?.isSearchEnabled == false { var indexPaths = [IndexPath]() - let section = FlyDefaults.isArchivedChatEnabled && (self?.getArchiveChat.count ?? 0 > 0) ? 1 : 0 + let section = ChatManager.isArchivedSettingsEnabled() && (self?.getArchiveChat.count ?? 0 > 0) ? 1 : 0 let numberOfRows = (self?.recentChatTableView?.numberOfRows(inSection: section) ?? 0) for item in numberOfRows...(numberOfRows + recentChatList.count - 1){ indexPaths.append(IndexPath(row: item, section: section)) @@ -2521,22 +2946,58 @@ extension RecentChatViewController { func hideArchiveHeader() { showArchivedChat = false + showPrivateChat = false headerBackButton.isHidden = true searchView.isHidden = false createGroupButton.isHidden = false pinChatButton.isHidden = false muteChatButton.isHidden = false headerLabel.text = "Chats" + archiveChatButton.isHidden = false + readUnreadButton.isHidden = false + CommonDefaults.isInPrivateChat = false + contactFloatButton.isHidden = false + contactFloatView.isHidden = false } func updateArchiveChatView() { + self.recentChatTableView?.tableHeaderView = nil + if getPrivateChats.count > 0 { + self.recentChatTableView?.contentInset.top = 0 + } showArchivedChat = true + showPrivateChat = false headerBackButton.isHidden = false searchView.isHidden = true createGroupButton.isHidden = true pinChatButton.isHidden = true + archiveChatButton.isHidden = false + readUnreadButton.isHidden = true // muteChatButton.isHidden = true headerLabel.text = "Archive Chats" + CommonDefaults.isInPrivateChat = false + contactFloatButton.isHidden = false + contactFloatView.isHidden = false + } + + func updatePrivateChatView() { + self.recentChatTableView?.tableHeaderView = nil + if getPrivateChats.count > 0 { + self.recentChatTableView?.contentInset.top = 0 + } + showArchivedChat = false + showPrivateChat = true + headerBackButton.isHidden = false + searchView.isHidden = true + createGroupButton.isHidden = true + pinChatButton.isHidden = true + archiveChatButton.isHidden = true + readUnreadButton.isHidden = false + // muteChatButton.isHidden = true + headerLabel.text = "Private Chats" + CommonDefaults.isInPrivateChat = true + contactFloatButton.isHidden = true + contactFloatView.isHidden = true } } @@ -2604,6 +3065,8 @@ extension RecentChatViewController : UICollectionViewDelegate, UICollectionViewD func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { selectedChatTag = getChatTags[indexPath.item] selectedTagIndex = indexPath.item + emptyMessageView?.isHidden = true + showOnlyPrivateChatAvailableView(isShow: false) collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) self.chatTagsCollectionView.reloadData() } @@ -2618,15 +3081,17 @@ extension RecentChatViewController : UICollectionViewDelegate, UICollectionViewD if self.getChatTags.count > 0 { //Add Default tag "All" var chatTagModel = ChatTagsModel() - chatTagModel.tagId = FlyDefaults.myJid - chatTagModel.currentUserId = FlyDefaults.myJid + chatTagModel.tagId = AppUtils.getMyJid() + chatTagModel.currentUserId = AppUtils.getMyJid() chatTagModel.isRecommentedTag = false chatTagModel.tagname = "All" chatTagModel.memberIdList = [] self.getChatTags.insert(chatTagModel, at: 0) self.chatTagsCollectionView.isHidden = self.showArchivedChat ? true : false + self.chatTagsCollectionView.isHidden = self.showPrivateChat ? true : false } self.chatTagsCollectionView.reloadData() + self.setUpPullForPrivateChat() self.recentChatTableView?.reloadData() } } @@ -2639,11 +3104,11 @@ extension RecentChatViewController : UICollectionViewDelegate, UICollectionViewD getRecentChat.removeAll() for memberID in chatTag.memberIdList { if let member = ChatManager.getRecentChatOf(jid: memberID) { - if !member.isChatArchived { + if !member.isChatArchived && !member.isPrivateChat { getRecentChat.append(member) } getRecentChat = getRecentChat.sorted(by: { $0.lastMessageTime < $1.lastMessageTime}).reversed() - + getRecentChat = getRecentChat.sorted(by: { $0.isChatPinned && !$1.isChatPinned }) self.selectionRecentChatList.enumerated().forEach { (index,selectedRecentChat) in self.getRecentChat.filter({$0.jid == selectedRecentChat.jid}).first?.isSelected = selectedRecentChat.isSelected } @@ -2666,7 +3131,7 @@ extension RecentChatViewController : UICollectionViewDelegate, UICollectionViewD for chatTag in getChatTags { - if chatTag.tagId != FlyDefaults.myJid { + if chatTag.tagId != AppUtils.getMyJid() { let removeSet = Set(jids) @@ -2683,17 +3148,21 @@ extension RecentChatViewController : UICollectionViewDelegate, UICollectionViewD } } -extension RecentChatViewController { - - func getProfile() { - do { - let JID = FlyDefaults.myXmppUsername + "@" + FlyDefaults.xmppDomain - try ContactManager.shared.getUserProfile(for: JID, fetchFromServer: true, saveAsFriend: true) { [weak self] isSuccess, flyError, flyData in - if(isSuccess) { - } - } - } catch { - print("Error") - } +extension RecentChatViewController: PrivateChatDelegate { + + func onPasswordSet() { + + } + func onPrivateChatAlertSelected(option: String) { + + } + func onPrivateChatAuthenticated() { + updatePrivateChatView() + recentChatTableView?.reloadData() + } + + func pinChanged() { + updatePrivateChatView() + recentChatTableView?.reloadData() } } diff --git a/MirrorflyUIkit/Controllers/Settings/AppLock/AppLockViewController.swift b/MirrorflyUIkit/Controllers/Settings/AppLock/AppLockViewController.swift index 19bb783..d29879e 100644 --- a/MirrorflyUIkit/Controllers/Settings/AppLock/AppLockViewController.swift +++ b/MirrorflyUIkit/Controllers/Settings/AppLock/AppLockViewController.swift @@ -36,9 +36,9 @@ class AppLockViewController: UIViewController { } override func viewWillAppear(_ animated: Bool) { - if FlyDefaults.appLockPassword == "" { - FlyDefaults.appLockenable = false - FlyDefaults.appFingerprintenable = false + if CommonDefaults.appLockPassword == "" { + CommonDefaults.appLockenable = false + CommonDefaults.appFingerprintenable = false } AppLockTableview.reloadData() @@ -68,8 +68,8 @@ extension AppLockViewController: UITableViewDelegate,UITableViewDataSource { cell.helpTextView.addGestureRecognizer(tap) cell.formaImageView.isUserInteractionEnabled = true cell.formaImageView.addGestureRecognizer(formaImageViewTap) - cell.switchOutlet.isOn = FlyDefaults.appLockenable - cell.separaterView.isHidden = FlyDefaults.appLockenable ? false : true + cell.switchOutlet.isOn = CommonDefaults.appLockenable + cell.separaterView.isHidden = CommonDefaults.appLockenable ? false : true cell.switchOutlet.addTarget(self, action:#selector(AppLockViewController.categorySwitchValueChanged(_:)), for: .valueChanged) break case .fingerPrintID: @@ -77,7 +77,7 @@ extension AppLockViewController: UITableViewDelegate,UITableViewDataSource { cell.helpTextLabel.text = useFingerPrintIDorFaceID cell.helpTextView.isHidden = true cell.separaterView.isHidden = true - cell.switchOutlet.isOn = FlyDefaults.appFingerprintenable + cell.switchOutlet.isOn = CommonDefaults.appFingerprintenable cell.switchOutlet.addTarget(self, action:#selector(AppLockViewController.categorySwitchFingerPrintValueChanged(_:)), for: .valueChanged) @@ -114,7 +114,7 @@ extension AppLockViewController: UITableViewDelegate,UITableViewDataSource { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { switch AppLockSettingsArray[indexPath.row]{ case.pinlock: - if FlyDefaults.appLockenable { + if CommonDefaults.appLockenable { return selectedCellHeight } else { @@ -133,9 +133,11 @@ extension AppLockViewController: UITableViewDelegate,UITableViewDataSource { } @objc func categorySwitchValueChanged(_ sender : UISwitch!){ - if !FlyDefaults.appLockenable { - if FlyDefaults.appLockPassword != "" { - FlyDefaults.appLockenable = true + if !CommonDefaults.appLockenable { + if CommonDefaults.appLockPassword != "" { + CommonDefaults.appLockenable = true + CommonDefaults.appLockPasswordDate = Date() + CommonDefaults.passwordAuthenticationAttemps = 0 } else { let vc = AppLockPasswordViewController(nibName:Identifiers.appLockPasswordViewController, bundle: nil) @@ -160,16 +162,15 @@ extension AppLockViewController: UITableViewDelegate,UITableViewDataSource { AppAlert.shared.showToast(message: ErrorMessage.pleaseEnablefingerPrintonYourdevice) } - if !FlyDefaults.appFingerprintenable && context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error){ + if !CommonDefaults.appFingerprintenable && context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error){ - if FlyDefaults.appLockPassword != "" && FlyDefaults.appLockenable == true{ - FlyDefaults.appLockenable = true + if CommonDefaults.appLockPassword != "" && CommonDefaults.appLockenable == true{ + CommonDefaults.appLockenable = true let vc = AuthenticationPINViewController(nibName:Identifiers.authenticationPINViewController, bundle: nil) self.navigationController?.pushViewController(vc, animated: true) vc.fingerPrintEnable = true } - - else if FlyDefaults.appLockPassword == "" && FlyDefaults.appLockenable == false || FlyDefaults.appLockPassword != "" && FlyDefaults.appLockenable == false{ + else if CommonDefaults.appLockPassword == "" && CommonDefaults.appLockenable == false { AppAlert.shared.showAlert(view: self, title: warning, message: biometricAuthentication, buttonTitle: okButton) AppAlert.shared.onAlertAction = { [weak self] (result) -> Void in @@ -180,10 +181,11 @@ extension AppLockViewController: UITableViewDelegate,UITableViewDataSource { } } + } else if CommonDefaults.appLockPassword != "" && CommonDefaults.appLockenable == false { + AppAlert.shared.showAlert(view: self, title: warning, message: pinAuthentication, buttonTitle: okButton) } } - - else if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) && FlyDefaults.appFingerprintenable == true { + else if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) && CommonDefaults.appFingerprintenable == true { let vc = AuthenticationPINViewController(nibName:Identifiers.authenticationPINViewController, bundle: nil) self.navigationController?.pushViewController(vc, animated: true) vc.fingerPrintLogout = true diff --git a/MirrorflyUIkit/Controllers/Settings/BlockedContacts/BlockedContactsViewController.swift b/MirrorflyUIkit/Controllers/Settings/BlockedContacts/BlockedContactsViewController.swift index 425f219..ac0f552 100644 --- a/MirrorflyUIkit/Controllers/Settings/BlockedContacts/BlockedContactsViewController.swift +++ b/MirrorflyUIkit/Controllers/Settings/BlockedContacts/BlockedContactsViewController.swift @@ -10,7 +10,6 @@ import MirrorFlySDK class BlockedContactsViewController: UIViewController { - @IBOutlet weak var noBlockedContactsLabel: UILabel! @IBOutlet weak var blockedContactsTableView: UITableView! { didSet { blockedContactsTableView.register(UINib(nibName: "BlockedContactTableViewCell", bundle: nil), forCellReuseIdentifier: "BlockedContactTableViewCell") @@ -23,8 +22,8 @@ class BlockedContactsViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() getUsersIBlocked() - noBlockedContactsLabel.text = "No Blocked Contacts found" - noBlockedContactsLabel.font = UIFont.font14px_appSemibold() + noContactsLabel.text = "No Blocked Contacts found" + noContactsLabel.font = UIFont.font14px_appSemibold() } override func viewDidAppear(_ animated: Bool) { @@ -53,10 +52,10 @@ class BlockedContactsViewController: UIViewController { if let blocked = data["data"] as? [ProfileDetails] { if blocked.isEmpty { self?.blockedContactsTableView.isHidden = true - self?.noBlockedContactsLabel.isHidden = false + self?.noContactsLabel.isHidden = false } else { self?.blockedContactsTableView.isHidden = false - self?.noBlockedContactsLabel.isHidden = true + self?.noContactsLabel.isHidden = true self?.blockedList = blocked } } @@ -79,7 +78,7 @@ class BlockedContactsViewController: UIViewController { } if self?.blockedList.isEmpty ?? true { self?.blockedContactsTableView.isHidden = true - self?.noBlockedContactsLabel.isHidden = false + self?.noContactsLabel.isHidden = false } self?.blockedContactsTableView.reloadData() AppAlert.shared.showToast(message: "\(name) has been Unblocked") @@ -108,7 +107,7 @@ class BlockedContactsViewController: UIViewController { extension BlockedContactsViewController: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - noBlockedContactsLabel.isHidden = blockedList.count != 0 + noContactsLabel.isHidden = blockedList.count != 0 return blockedList.count } diff --git a/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationAlertViewController.swift b/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationAlertViewController.swift index be6611c..00db95b 100644 --- a/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationAlertViewController.swift +++ b/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationAlertViewController.swift @@ -53,14 +53,14 @@ extension NotificationAlertViewController : UITableViewDelegate,UITableViewDataS case .NotificationSound: cell.lblTitle.text = self.NotificationList[indexPath.row].rawValue cell.helpTextLabel.text = playSoundsForIncomingMessages - cell.selectedImageView.image = FlyDefaults.notificationSoundEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) + cell.selectedImageView.image = CommonDefaults.notificationSoundEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) cell.separaterView.isHidden = true cell.helpTextView.isHidden = true case .NotificationPopUP: cell.lblTitle.text = self.NotificationList[indexPath.row].rawValue cell.helpTextLabel.text = showingPopUpforIncomingMessages - cell.selectedImageView.image = FlyDefaults.notificationPopUPEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) + cell.selectedImageView.image = CommonDefaults.notificationPopUPEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) cell.separaterView.isHidden = true cell.helpTextView.isHidden = true @@ -68,14 +68,14 @@ extension NotificationAlertViewController : UITableViewDelegate,UITableViewDataS case .Vibration: cell.lblTitle.text = self.NotificationList[indexPath.row].rawValue cell.helpTextLabel.text = vibrateWhenANewMessageArrivesWhileApplicationArrives - cell.selectedImageView.image = FlyDefaults.vibrationEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) + cell.selectedImageView.image = CommonDefaults.vibrationEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) cell.separaterView.isHidden = true cell.helpTextView.isHidden = true case .MuteNotification: cell.lblTitle.text = self.NotificationList[indexPath.row].rawValue cell.helpTextLabel.text = thisWillMuteAllNotificationsAlertsForIncomingMessages - cell.selectedImageView.image = FlyDefaults.muteNotificationEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) + cell.selectedImageView.image = CommonDefaults.muteNotificationEnable ? UIImage(named: ImageConstant.ic_selected) : UIImage(named: ImageConstant.Translate_Unselected) cell.separaterView.isHidden = true cell.helpTextView.isHidden = true @@ -92,41 +92,41 @@ extension NotificationAlertViewController : UITableViewDelegate,UITableViewDataS switch self.NotificationList[indexPath.row]{ case .NotificationSound: - FlyDefaults.notificationSoundEnable = !FlyDefaults.notificationSoundEnable - if FlyDefaults.notificationSoundEnable == true { - FlyDefaults.muteNotificationEnable = false - FlyDefaults.notificationPopUPEnable = true + CommonDefaults.notificationSoundEnable = !CommonDefaults.notificationSoundEnable + if CommonDefaults.notificationSoundEnable == true { + CommonDefaults.muteNotificationEnable = false + CommonDefaults.notificationPopUPEnable = true } break case .NotificationPopUP: - FlyDefaults.notificationPopUPEnable = !FlyDefaults.notificationPopUPEnable - if FlyDefaults.notificationPopUPEnable == false { - FlyDefaults.vibrationEnable = false - FlyDefaults.notificationSoundEnable = false - FlyDefaults.muteNotificationEnable = false + CommonDefaults.notificationPopUPEnable = !CommonDefaults.notificationPopUPEnable + if CommonDefaults.notificationPopUPEnable == false { + CommonDefaults.vibrationEnable = false + CommonDefaults.notificationSoundEnable = false + CommonDefaults.muteNotificationEnable = false } - else if FlyDefaults.notificationPopUPEnable == true { + else if CommonDefaults.notificationPopUPEnable == true { } break case .Vibration: //AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate)) - FlyDefaults.vibrationEnable = !FlyDefaults.vibrationEnable - if FlyDefaults.vibrationEnable == true { - FlyDefaults.muteNotificationEnable = false - FlyDefaults.notificationPopUPEnable = true + CommonDefaults.vibrationEnable = !CommonDefaults.vibrationEnable + if CommonDefaults.vibrationEnable == true { + CommonDefaults.muteNotificationEnable = false + CommonDefaults.notificationPopUPEnable = true } case .MuteNotification: - FlyDefaults.muteNotificationEnable = !FlyDefaults.muteNotificationEnable - if FlyDefaults.muteNotificationEnable == true { - FlyDefaults.vibrationEnable = false - FlyDefaults.notificationSoundEnable = false - FlyDefaults.notificationPopUPEnable = true + CommonDefaults.muteNotificationEnable = !CommonDefaults.muteNotificationEnable + if CommonDefaults.muteNotificationEnable == true { + CommonDefaults.vibrationEnable = false + CommonDefaults.notificationSoundEnable = false + CommonDefaults.notificationPopUPEnable = true } else { - FlyDefaults.notificationSoundEnable = true - FlyDefaults.notificationPopUPEnable = true + CommonDefaults.notificationSoundEnable = true + CommonDefaults.notificationPopUPEnable = true } break diff --git a/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationToneList/NotificationTonesListViewController.swift b/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationToneList/NotificationTonesListViewController.swift index 1e0f935..c5d9e42 100644 --- a/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationToneList/NotificationTonesListViewController.swift +++ b/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationToneList/NotificationTonesListViewController.swift @@ -37,7 +37,7 @@ class NotificationTonesListViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - selectedNotificationSoundName = FlyDefaults.selectedNotificationSoundName + selectedNotificationSoundName = CommonDefaults.selectedNotificationSoundName soundList = notificationViewModel.getSystemSounds() if let id = soundList.filter({ $0 == selectedNotificationSoundName }).first { @@ -56,14 +56,14 @@ class NotificationTonesListViewController: UIViewController { @IBAction func cancelAction(_ sender: UIButton) { AudioServicesDisposeSystemSoundID(SystemSoundID(defaultSoundId)) player?.stop() - selectedNotificationSoundName = FlyDefaults.selectedNotificationSoundName + selectedNotificationSoundName = CommonDefaults.selectedNotificationSoundName self.dismiss(animated: false) } @IBAction func saveAction(_ sender: UIButton) { AudioServicesDisposeSystemSoundID(SystemSoundID(defaultSoundId)) player?.stop() - FlyDefaults.selectedNotificationSoundName = selectedNotificationSoundName + CommonDefaults.selectedNotificationSoundName = selectedNotificationSoundName self.dismiss(animated: false) } diff --git a/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationsViewController.swift b/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationsViewController.swift index 065f40b..1f34863 100644 --- a/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationsViewController.swift +++ b/MirrorflyUIkit/Controllers/Settings/Notifications/NotificationsViewController.swift @@ -60,7 +60,7 @@ extension NotificationsViewController : UITableViewDelegate,UITableViewDataSourc case .notificationTone: cell.titlelabel.text = self.NotificationList[indexPath.row].rawValue - cell.detailLabel.text = FlyDefaults.selectedNotificationSoundName[NotificationSoundKeys.name.rawValue] + cell.detailLabel.text = CommonDefaults.selectedNotificationSoundName[NotificationSoundKeys.name.rawValue] break case .notificationNotWorking: diff --git a/MirrorflyUIkit/Controllers/Settings/SettingsViewController.swift b/MirrorflyUIkit/Controllers/Settings/SettingsViewController.swift index 5646f8b..818ae7a 100644 --- a/MirrorflyUIkit/Controllers/Settings/SettingsViewController.swift +++ b/MirrorflyUIkit/Controllers/Settings/SettingsViewController.swift @@ -62,7 +62,7 @@ class SettingsViewController : BaseViewController { AppAlert.shared.onAlertAction = { [weak self] (result) -> Void in if result == 0 { - if FlyDefaults.appLockenable == true{ + if CommonDefaults.appLockenable == true{ let secondView = AuthenticationPINViewController(nibName: "AuthenticationPINViewController", bundle: nil) secondView.logout = true self?.navigationController?.pushViewController(secondView, animated: true) @@ -116,7 +116,7 @@ extension SettingsViewController : UITableViewDelegate, UITableViewDataSource { case "Starred Messages": if let vc = UIStoryboard(name: "Chat", bundle: nil).instantiateViewController(withIdentifier: "ChatViewParentController") as? ChatViewParentController { vc.isStarredMessagePage = true - vc.getProfileDetails = ChatManager.profileDetaisFor(jid: FlyDefaults.myJid) + vc.getProfileDetails = ChatManager.profileDetaisFor(jid: AppUtils.getMyJid()) self.navigationController?.pushViewController(vc, animated: true) } break diff --git a/MirrorflyUIkit/Controllers/UserProfile/UserProfileViewController.swift b/MirrorflyUIkit/Controllers/UserProfile/UserProfileViewController.swift index cf8a5ce..3b864ae 100644 --- a/MirrorflyUIkit/Controllers/UserProfile/UserProfileViewController.swift +++ b/MirrorflyUIkit/Controllers/UserProfile/UserProfileViewController.swift @@ -80,7 +80,7 @@ class UserProfileViewController : UIViewController { profileImage?.layer.borderWidth = 0.5 profileImage?.layer.borderColor = Color.groupIconBackgroundGray?.cgColor profileImage?.clipsToBounds = true - try? ContactManager.shared.getUserProfile(for: FlyDefaults.myJid, fetchFromServer: false, saveAsFriend: false, completionHandler: { isSuccess, error, flyData in + try? ContactManager.shared.getUserProfile(for: AppUtils.getMyJid(), fetchFromServer: false, saveAsFriend: false, completionHandler: { isSuccess, error, flyData in var data = flyData if(isSuccess) { if let pd = data.getData() as? ProfileDetails { @@ -134,9 +134,9 @@ class UserProfileViewController : UIViewController { func setImage(imageURL: String,completionHandler: @escaping (Bool?)-> Void) { //let apiService = ApiService() profileImage?.sd_imageIndicator = SDWebImageActivityIndicator.white - let urlString = "\(FlyDefaults.baseURL)\(media)/\(imageURL)?mf=\(FlyDefaults.authtoken)" + let urlString = ChatManager.getImageUrl(imageName: imageURL) let url = URL(string: urlString) - if url != URL(string: FlyDefaults.myProfileImageUrl) { + if url != URL(string: ContactManager.getMyProfile().image) { let placeholder = UIImage(named: "ic_profile_placeholder") profileImage?.sd_setImage(with: url, placeholderImage: placeholder, options: [.continueInBackground,.decodeFirstFrameOnly,.highPriority,.scaleDownLargeImages], progress: nil){ (image, responseError, isFromCache, imageUrl) in @@ -176,7 +176,7 @@ class UserProfileViewController : UIViewController { } func checkToEnableButton(name : String){ - enableSaveButton(enable: !(name.trim().lowercased() == FlyDefaults.myName.lowercased())) + enableSaveButton(enable: !(name.trim().lowercased() == ContactManager.getMyProfile().name.lowercased())) } } @@ -185,11 +185,11 @@ class UserProfileViewController : UIViewController { extension UserProfileViewController { func getProfile() { - print( FlyDefaults.myXmppUsername) + print(ChatManager.getXMPPDetails().XMPPUsername) - if(FlyDefaults.isProfileUpdated) { + if(CommonDefaults.isProfileUpdated) { do { - let JID = FlyDefaults.myXmppUsername + "@" + FlyDefaults.xmppDomain + let JID = ChatManager.getXMPPDetails().XMPPUsername + "@" + ChatManager.getXMPPDetails().XMPPDomain try ContactManager.shared.getUserProfile(for: JID, fetchFromServer: true, saveAsFriend: true) { [weak self] isSuccess, flyError, flyData in var data = flyData @@ -232,7 +232,7 @@ extension UserProfileViewController { // MARK: Update Profile func updateMyProfile(isRemovedProfileImage: Bool) { if NetworkReachability.shared.isConnected { - let JID = FlyDefaults.myXmppUsername + "@" + FlyDefaults.xmppDomain + let JID = ChatManager.getXMPPDetails().XMPPUsername + "@" + ChatManager.getXMPPDetails().XMPPDomain startLoading(withText: pleaseWait) var myProfile = FlyProfile(jid: JID) guard let email = emailTextField?.text else { @@ -256,7 +256,7 @@ extension UserProfileViewController { myProfile.status = status if(isImagePicked) { myProfile.image = profileImageLocalPath - FlyDefaults.myProfileImageUrl = profileImageLocalPath +// FlyDefaults.myProfileImageUrl = profileImageLocalPath if profileImageLocalPath.isEmpty && profileDetails?.image != "" { myProfile.image = profileDetails?.image ?? "" isImagePicked = false @@ -270,6 +270,7 @@ extension UserProfileViewController { if isRemovedProfileImage == false { AppAlert.shared.showToast(message: profileUpdateSuccess.localized) } + self?.profileImage?.sd_setImage(with: URL(string: myProfile.image)) print("getProfile() updateMyProfile") self?.getProfile() Utility.saveInPreference(key: isProfileSaved, value: true) @@ -323,7 +324,7 @@ extension UserProfileViewController { guard let email = emailTextField?.text else {return} guard let mobileNumber = mobileNumberLabel?.text else {return} - if userName.trim().lowercased() == FlyDefaults.myName.lowercased() { + if userName.trim().lowercased() == ContactManager.getMyProfile().name.lowercased() { return } @@ -358,7 +359,7 @@ extension UserProfileViewController { extension UserProfileViewController: UITextFieldDelegate { @objc func textFieldDidChange(_ textField: UITextField) { - if(FlyDefaults.isProfileUpdated) { + if(CommonDefaults.isProfileUpdated) { if(nameTextField?.text?.trimmingCharacters(in: .whitespacesAndNewlines) != profileDetails?.nickName || statusLabel?.text != profileDetails?.status) { saveButton?.setTitle(save.localized, for: .normal) } @@ -631,7 +632,7 @@ extension UserProfileViewController: UIImagePickerControllerDelegate,UINavigatio extension UserProfileViewController: StatusDelegate { func userSelectedStatus(selectedStatus: String) { statusLabel?.text = selectedStatus - if(FlyDefaults.isProfileUpdated) { + if(CommonDefaults.isProfileUpdated) { if(nameTextField?.text != profileDetails?.nickName || emailTextField?.text != profileDetails?.email || statusLabel?.text != profileDetails?.status) { saveButton?.setTitle(save.localized, for: .normal) } @@ -663,7 +664,7 @@ extension UserProfileViewController: CropperViewControllerDelegate { let str = AppUtils.shared.getRandomString(length: 15) let fileName = str ?? "" profileImageLocalPath = AppUtils.shared.saveInDirectory(with: profileImage?.image?.jpegData(compressionQuality: 1.0), fileName: fileName + jpg) ?? "" - FlyDefaults.myProfileImageUrl = profileImageLocalPath +// FlyDefaults.myProfileImageUrl = profileImageLocalPath print("localPath--\( profileImageLocalPath)") DispatchQueue.main.async { [weak self] in self?.updateMyProfile(isRemovedProfileImage: false) @@ -777,7 +778,7 @@ extension UserProfileViewController : ProfileEventsDelegate { } func userProfileFetched(for jid: String, profileDetails: MirrorFlySDK.ProfileDetails?) { - if profileDetails?.jid == FlyDefaults.myJid { + if profileDetails?.jid == AppUtils.getMyJid() { executeOnMainThread { self.updateChanges(profileDetails: profileDetails) } @@ -809,7 +810,7 @@ extension UserProfileViewController : ProfileEventsDelegate { } func userUpdatedTheirProfile(for jid: String, profileDetails: MirrorFlySDK.ProfileDetails) { - if profileDetails.jid == FlyDefaults.myJid { + if profileDetails.jid == AppUtils.getMyJid() { executeOnMainThread { self.updateChanges(profileDetails: profileDetails) } diff --git a/MirrorflyUIkit/Controllers/VerifyOTPViewController.swift b/MirrorflyUIkit/Controllers/VerifyOTPViewController.swift index 2bd1019..e5f1b78 100755 --- a/MirrorflyUIkit/Controllers/VerifyOTPViewController.swift +++ b/MirrorflyUIkit/Controllers/VerifyOTPViewController.swift @@ -234,17 +234,17 @@ class VerifyOTPViewController: UIViewController guard let profileUpdateStatus = result?["isProfileUpdated"] as? Int else{ return } - FlyDefaults.isLoggedIn = true + ChatManager.updateAppLoggedIn(isLoggedin: true) Utility.saveInPreference(key: isLoggedIn, value: true) Utility.saveInPreference(key: username, value: userName) Utility.saveInPreference(key: password, value: userPassword) - FlyDefaults.myXmppPassword = userPassword - FlyDefaults.myXmppUsername = userName - FlyDefaults.myMobileNumber = self?.getMobileNumber ?? "" - FlyDefaults.isProfileUpdated = profileUpdateStatus == 1 +// FlyDefaults.myXmppPassword = userPassword +// FlyDefaults.myXmppUsername = userName +// FlyDefaults.myMobileNumber = self?.getMobileNumber ?? "" + CommonDefaults.isProfileUpdated = profileUpdateStatus == 1 AppAlert.shared.showToast(message: SuccessMessage.successAuth) self?.isAuthorizedSuccess = true - self?.verifyOTPViewModel.initializeChatCredentials(username: userName, secretKey: userPassword) + self?.verifyOTPViewModel.initializeChatCredentials() self?.startLoading(withText: pleaseWait) } } diff --git a/MirrorflyUIkit/Controllers/VerifyOTPViewModel.swift b/MirrorflyUIkit/Controllers/VerifyOTPViewModel.swift index d9aad01..dac1372 100755 --- a/MirrorflyUIkit/Controllers/VerifyOTPViewModel.swift +++ b/MirrorflyUIkit/Controllers/VerifyOTPViewModel.swift @@ -23,7 +23,7 @@ class VerifyOTPViewModel : NSObject } func validateUser(params: NSDictionary, completionHandler: @escaping (VerifyToken?, Error?)-> Void) { - let Baseurl = FlyDefaults.baseURL + let Baseurl = ChatManager.getAppConfigDetails().baseURL let url = Baseurl + verifyUser print("verifyOTPViewModel.validateUser \(url)") apiService.post(withEndPoint: url, params: params as? Parameters, headers: nil).responseJSON { (response) in @@ -51,7 +51,7 @@ class VerifyOTPViewModel : NSObject print(deviceToken, mobileNumber) voipToken = voipToken.isEmpty ? deviceToken : voipToken - if FlyDefaults.baseURL.isEmpty { + if ChatManager.getAppConfigDetails().baseURL.isEmpty { ChatManager.initializeSDK(licenseKey: LICENSE_KEY) { licenseSuccess, error, data in if licenseSuccess { try! ChatManager.registerApiService(for: uniqueIdentifier, deviceToken: deviceToken, voipDeviceToken: voipToken, isExport: ISEXPORT, isForceRegister: isForceRegister, userType: userType) { isSuccess, flyError, flyData in @@ -104,9 +104,9 @@ class VerifyOTPViewModel : NSObject } } - func initializeChatCredentials(username: String, secretKey: String){ - FlyDefaults.isLoggedIn = true - RootViewController.sharedInstance.initCallSDK() - VOIPManager.sharedInstance.updateDeviceToken() + func initializeChatCredentials() { + ChatManager.updateAppLoggedIn(isLoggedin: true) + RootViewController.sharedInstance.initCallSDK() + VOIPManager.sharedInstance.updateDeviceToken() } } diff --git a/MirrorflyUIkit/Group Info Options/Controller/GroupInfoOptionsViewController.swift b/MirrorflyUIkit/Group Info Options/Controller/GroupInfoOptionsViewController.swift index 9a6e127..93dec75 100644 --- a/MirrorflyUIkit/Group Info Options/Controller/GroupInfoOptionsViewController.swift +++ b/MirrorflyUIkit/Group Info Options/Controller/GroupInfoOptionsViewController.swift @@ -129,7 +129,7 @@ extension GroupInfoOptionsViewController: UITableViewDelegate, UITableViewDataSo } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if userJid != FlyDefaults.myJid { + if userJid != AppUtils.getMyJid() { if indexPath.row == 0 { self.delegate?.navigateToChat(userJid: userJid) dismiss(animated: true, completion: nil) diff --git a/MirrorflyUIkit/Group Info/Controller/GroupInfoViewController.swift b/MirrorflyUIkit/Group Info/Controller/GroupInfoViewController.swift index 8d49ba3..a2ac5c1 100644 --- a/MirrorflyUIkit/Group Info/Controller/GroupInfoViewController.swift +++ b/MirrorflyUIkit/Group Info/Controller/GroupInfoViewController.swift @@ -75,6 +75,7 @@ class GroupInfoViewController: UIViewController { } override func viewWillAppear(_ animated: Bool) { + handleBackgroundAndForground() self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false isGroupInfoUpdated = false refreshData() @@ -82,7 +83,8 @@ class GroupInfoViewController: UIViewController { if groupInfoViewModel.isBlockedByAdmin(groupJid: groupID) { navigateOnGroupBlock() } - + NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground), + name: NSNotification.Name(didBecomeActive), object: nil) availableFeatures = ChatManager.getAvailableFeatures() } @@ -101,6 +103,20 @@ class GroupInfoViewController: UIViewController { ChatManager.shared.adminBlockDelegate = nil ChatManager.shared.availableFeaturesDelegate = nil } + + override func willCometoForeground() { + self.view.removeLaunchSubview() + } + + @objc func willEnterForeground() { + self.view.removeLaunchSubview() + } + + override func didMoveToBackground() { + if ChatManager.isPrivateChat(jid: groupID) { + self.view.addLaunchSubview() + } + } private func setUpUI() { setUpStatusBar() @@ -119,6 +135,7 @@ class GroupInfoViewController: UIViewController { tableView?.register(UINib(nibName: Identifiers.groupMembersTableViewCell, bundle: .main), forCellReuseIdentifier: Identifiers.groupMembersTableViewCell) tableView?.register(UINib(nibName: Identifiers.viewAllMediaCell , bundle: .main), forCellReuseIdentifier: Identifiers.viewAllMediaCell) + tableView?.register(UINib(nibName: Identifiers.privateChatCell , bundle: .main), forCellReuseIdentifier: Identifiers.privateChatCell) } private func setupConfiguration() { @@ -177,6 +194,27 @@ class GroupInfoViewController: UIViewController { } showActionSheet() } + + @objc func didTapPrivateChat(_ sender: UITapGestureRecognizer) { + if let jid = profileDetails?.jid { + if let recent = ChatManager.getRechtChat(jid: jid) { + if recent.isChatArchived { + AppAlert.shared.showAlert(view: self, title: nil, message: unarchiveForPrivateLock, buttonOneTitle: "Unarchive", buttonTwoTitle: okButton) + AppAlert.shared.onAlertAction = { [weak self] (result) -> + Void in + if result == 0 { + ChatManager.shared.updateArchiveUnArchiveChats(toUser: jid, archiveStatus: false) + self?.refreshData() + } + } + } else { + let vc = PrivateChatEnableController(nibName: "PrivateChatEnableController", bundle: nil) + vc.chatJid = jid + self.navigationController?.pushViewController(vc, animated: true) + } + } + } + } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == Identifiers.viewUserImageController { @@ -189,12 +227,13 @@ class GroupInfoViewController: UIViewController { func getGroupMembers() { // groupMembers = [GroupParticipantDetail]() - let getGroupMembers = GroupManager.shared.getGroupMemebersFromLocal(groupJid: groupID).participantDetailArray.filter({$0.memberJid != FlyDefaults.myJid}) + let myJid = try? FlyUtils.getMyJid() + let getGroupMembers = GroupManager.shared.getGroupMemebersFromLocal(groupJid: groupID).participantDetailArray.filter({$0.memberJid != myJid}) //if groupMembers != getGroupMembers { groupMembers = getGroupMembers - let myJid = GroupManager.shared.getGroupMemebersFromLocal(groupJid: groupID).participantDetailArray.filter({$0.memberJid == FlyDefaults.myJid}) + let myMember = GroupManager.shared.getGroupMemebersFromLocal(groupJid: groupID).participantDetailArray.filter({$0.memberJid == myJid}) groupMembers = groupMembers.sorted(by: { $0.profileDetail?.name.lowercased() ?? "" < $1.profileDetail?.name.lowercased() ?? "" }) - groupMembers.insert(contentsOf: myJid, at: 0) + groupMembers.append(contentsOf: myMember) //} if groupMembers != getGroupMembers { @@ -208,13 +247,13 @@ class GroupInfoViewController: UIViewController { func checkMemberExist() { let isExistMember = self.groupInfoViewModel.isParticiapntExistingIn(groupJid: groupID, - participantJid: FlyDefaults.myJid) + participantJid: AppUtils.getMyJid()) self.isExistMember = isExistMember.doesExist } func isAdminMemberGroup() { - - let isAdminMember = self.groupInfoViewModel.isGroupAdminMember(participantJid: FlyDefaults.myJid, + let myJid = try? FlyUtils.getMyJid() + let isAdminMember = self.groupInfoViewModel.isGroupAdminMember(participantJid: AppUtils.getMyJid(), groupJid: groupID) self.isAdminMember = isAdminMember.isAdmin @@ -235,7 +274,7 @@ class GroupInfoViewController: UIViewController { var data = flyData if isSuccess { print(data.getMessage() as! String) - FlyDefaults.myProfileImageUrl = "" +// FlyDefaults.myProfileImageUrl = "" } else { print(data.getMessage() as! String) } @@ -273,26 +312,26 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { func numberOfSections(in tableView: UITableView) -> Int { if ((availableFeatures.isViewAllMediasEnabled) && (availableFeatures.isReportEnabled) && (availableFeatures.isDeleteChatEnabled)){ - return 7 + return 8 }else if (!(availableFeatures.isViewAllMediasEnabled) && !(availableFeatures.isReportEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == false)){ - return 4 - }else if (!(availableFeatures.isViewAllMediasEnabled) && !(availableFeatures.isReportEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == true)){ return 5 + }else if (!(availableFeatures.isViewAllMediasEnabled) && !(availableFeatures.isReportEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == true)){ + return 6 } else if((availableFeatures.isViewAllMediasEnabled) && !(availableFeatures.isReportEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == false)) || (!(availableFeatures.isViewAllMediasEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == false) && (availableFeatures.isReportEnabled)) || (!(availableFeatures.isViewAllMediasEnabled) && !(availableFeatures.isReportEnabled) && (availableFeatures.isDeleteChatEnabled)) { - return 5 - }else if((availableFeatures.isViewAllMediasEnabled) && !(availableFeatures.isReportEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == true)) || (!(availableFeatures.isViewAllMediasEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == true) && (availableFeatures.isReportEnabled)) { return 6 + }else if((availableFeatures.isViewAllMediasEnabled) && !(availableFeatures.isReportEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == true)) || (!(availableFeatures.isViewAllMediasEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == true) && (availableFeatures.isReportEnabled)) { + return 7 } else if(!(availableFeatures.isViewAllMediasEnabled) && (availableFeatures.isReportEnabled) && (availableFeatures.isDeleteChatEnabled)) || ((availableFeatures.isViewAllMediasEnabled) && !(availableFeatures.isReportEnabled) && (availableFeatures.isDeleteChatEnabled)) || ((availableFeatures.isViewAllMediasEnabled) && (availableFeatures.isReportEnabled) && (!(availableFeatures.isDeleteChatEnabled) && isExistMember == false)) { - return 6 - }else { return 7 + }else { + return 8 } } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if section == 3 { + if section == 4 { return groupMembers.count } else { return 1 @@ -301,7 +340,7 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - if indexPath.section == 2 { + if indexPath.section == 3 { if isExistMember == false { return 0 } else if isAdminMember == false { @@ -357,6 +396,18 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { cell.muteSwitch?.isEnabled = ChatManager.shared.isUserUnArchived(jid: profileDetails?.jid ?? "") return cell } else if indexPath.section == 2 { + let cell = (tableView.dequeueReusableCell(withIdentifier: Identifiers.privateChatCell, for: indexPath) as? PrivateChatCell)! + if let recent = ChatManager.getRechtChat(jid: profileDetails?.jid ?? "") { + if recent.isChatArchived { + cell.chatLabel.textColor = .gray + } else { + cell.chatLabel.textColor = .label + } + } + let tap = UITapGestureRecognizer(target: self, action: #selector(self.didTapPrivateChat(_:))) + cell.addGestureRecognizer(tap) + return cell + } else if indexPath.section == 3 { let cell = (tableView.dequeueReusableCell(withIdentifier: Identifiers.groupOptionsTableViewCell, for: indexPath) as? GroupOptionsTableViewCell)! cell.optionImageview.image = UIImage(named: "add_user") cell.optionLabel.textColor = Color.userNameTextColor @@ -365,12 +416,12 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { tableView.endUpdates() return cell - } else if indexPath.section == 3 { + } else if indexPath.section == 4 { let groupMembers = groupMembers[indexPath.row] let cell = (tableView.dequeueReusableCell(withIdentifier: Identifiers.groupMembersTableViewCell, for: indexPath) as? GroupMembersTableViewCell)! cell.getGroupInfo(groupInfo: groupMembers) return cell - } else if indexPath.section == 4 { + } else if indexPath.section == 5 { if availableFeatures.isViewAllMediasEnabled { let cell = (tableView.dequeueReusableCell(withIdentifier: Identifiers.viewAllMediaCell, for: indexPath) as? ViewAllMediaCell)! return cell @@ -393,7 +444,7 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { } return cell } - } else if indexPath.section == 5 { + } else if indexPath.section == 6 { if availableFeatures.isViewAllMediasEnabled && availableFeatures.isReportEnabled { let cell = (tableView.dequeueReusableCell(withIdentifier: Identifiers.groupOptionsTableViewCell, for: indexPath) as? GroupOptionsTableViewCell)! cell.optionImageview.image = UIImage(named: ImageConstant.ic_group_report) @@ -413,7 +464,7 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { } return cell } - } else if indexPath.section == 6 { + } else if indexPath.section == 7 { let cell = (tableView.dequeueReusableCell(withIdentifier: Identifiers.groupOptionsTableViewCell, for: indexPath) as? GroupOptionsTableViewCell)! if isExistMember == true { cell.optionImageview.image = UIImage(named: "leave_group") @@ -430,7 +481,7 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.section == 2 { + if indexPath.section == 3 { if self.isAdminMember == true { let contactPermissionStatus = CNContactStore.authorizationStatus(for: CNEntityType.contacts) if contactPermissionStatus == .denied { @@ -439,7 +490,7 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { message: contactAccessMessage, settingstitle: settings, cancelTitle: cancelUppercase) - FlyDefaults.isContactPermissionSkipped = false + ContactSyncManager.updateContactPermission(isSkipped: false) } else { let storyboard = UIStoryboard.init(name: Storyboards.main, bundle: nil) let controller = storyboard.instantiateViewController(withIdentifier: Identifiers.addParticipants) as! AddParticipantsViewController @@ -451,9 +502,9 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { } else { AppAlert.shared.showToast(message: adminAccess) } - } else if indexPath.section == 3 { + } else if indexPath.section == 4 { let groupMembers = groupMembers[indexPath.row] - if groupMembers.memberJid != FlyDefaults.myJid { + if groupMembers.memberJid != AppUtils.getMyJid() { let storyboard = UIStoryboard.init(name: Storyboards.chat, bundle: nil) optionsController = storyboard.instantiateViewController(withIdentifier: Identifiers.groupInfoOptionsViewController) as! GroupInfoOptionsViewController if let optionsController = optionsController { @@ -468,7 +519,7 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { self.present(optionsController, animated: true, completion: nil) } } - } else if indexPath.section == 4 { + } else if indexPath.section == 5 { if availableFeatures.isViewAllMediasEnabled { let storyboard = UIStoryboard.init(name: Storyboards.chat, bundle: nil) let viewAllMediaVC = storyboard.instantiateViewController(withIdentifier: Identifiers.viewAllMediaVC) as! ViewAllMediaController @@ -526,7 +577,7 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { } } } - } else if indexPath.section == 5 { + } else if indexPath.section == 6 { if availableFeatures.isViewAllMediasEnabled && availableFeatures.isReportEnabled { showReportOptions() }else { @@ -579,7 +630,7 @@ extension GroupInfoViewController: UITableViewDelegate, UITableViewDataSource { } } } - } else if indexPath.section == 6 { + } else if indexPath.section == 7 { if isExistMember == true { AppAlert.shared.showAlert(view: self, title: exitGroup, @@ -639,7 +690,7 @@ extension GroupInfoViewController: ContactImageCellDelegate { return } startLoading(withText: pleaseWait) - groupInfoViewModel.leaveFromGroup(groupID: groupID,userJid: FlyDefaults.myJid) { + groupInfoViewModel.leaveFromGroup(groupID: groupID,userJid: AppUtils.getMyJid()) { [weak self] success in self?.stopLoading() if success { @@ -758,6 +809,7 @@ extension GroupInfoViewController: GroupInfoOptionsDelegate { controller.contactJid = userJid controller.isFromGroupInfo = true controller.groupId = groupID + controller.isFromContactInfo = true self.navigationController?.pushViewController(controller, animated: true) } @@ -767,6 +819,7 @@ extension GroupInfoViewController: GroupInfoOptionsDelegate { let controller = storyboard.instantiateViewController(withIdentifier: Identifiers.chatViewParentController) as! ChatViewParentController controller.getProfileDetails = profile.profileDetail controller.isFromGroupInfo = true + controller.groupIdForPrivateChat = groupID let color = getColor(userName: profile.profileDetail?.name ?? "") controller.contactColor = color groupInfoDelegate?.didComefromGroupInfo() diff --git a/MirrorflyUIkit/Group Info/Views/GroupMembersTableViewCell.swift b/MirrorflyUIkit/Group Info/Views/GroupMembersTableViewCell.swift index 24e4e24..100dc79 100644 --- a/MirrorflyUIkit/Group Info/Views/GroupMembersTableViewCell.swift +++ b/MirrorflyUIkit/Group Info/Views/GroupMembersTableViewCell.swift @@ -67,7 +67,7 @@ class GroupMembersTableViewCell: UITableViewCell { let blockedMe = profileDetails?.isBlockedMe ?? false let isBlockedMyAdmin = profileDetails?.isBlockedByAdmin ?? false - if profileDetails?.contactType == .deleted || blockedMe || isBlockedMyAdmin || (IS_LIVE && ENABLE_CONTACT_SYNC && profileDetails?.isItSavedContact == false && groupInfo.memberJid != FlyDefaults.myJid){ + if profileDetails?.contactType == .deleted || blockedMe || isBlockedMyAdmin || (IS_LIVE && ENABLE_CONTACT_SYNC && profileDetails?.isItSavedContact == false && groupInfo.memberJid != AppUtils.getMyJid()){ userImageView?.image = UIImage(named: "ic_profile_placeholder") ?? UIImage() statusLabel.text = "" } @@ -75,26 +75,29 @@ class GroupMembersTableViewCell: UITableViewCell { userImageView?.image = UIImage(named: "ic_profile_placeholder") ?? UIImage() } - if groupInfo.memberJid == FlyDefaults.myJid { + if groupInfo.memberJid == AppUtils.getMyJid() { nameLabel.text = "You" nickNameLabel.text = "" - setUsersImage(userName: FlyDefaults.myName, groupInfo: groupInfo) + setUsersImage(userName: ContactManager.getMyProfile().name, groupInfo: groupInfo) } } } func setUsersImage(userName: String, groupInfo: GroupParticipantDetail) { + let urlString = ChatManager.getImageUrl(imageName: groupInfo.profileDetail?.image ?? "") + // let urlString = ChatManager.makeImageUrl(media: media, imageName: groupInfo.profileDetail?.image ?? "") + let imageURL = URL(string: urlString) + var placeholderImage: UIImage - if let profileDetail = groupInfo.profileDetail { - let profileImage = profileDetail.thumbImage.isEmpty ? profileDetail.image : profileDetail.thumbImage - if profileImage.isEmpty { - userImageView?.image = ChatUtils.getPlaceholder(name: userName, userColor: ChatUtils.getColorForUser(userName: userName), userImage: userImageView) - } else { - userImageView?.loadFlyImage(imageURL: profileImage, name: userName, - chatType: profileDetail.profileChatType, - jid: profileDetail.jid) - } + if (imageURL != nil) { + placeholderImage = ChatUtils.getPlaceholder(name: userName, userColor: ChatUtils.getColorForUser(userName: userName), + userImage: userImageView) + userImageView?.sd_setImage(with: imageURL, placeholderImage: placeholderImage) + } else { + userImageView?.loadFlyImage(imageURL: groupInfo.profileDetail?.image ?? "", name: userName, + chatType: groupInfo.profileDetail?.profileChatType ?? .singleChat, + jid: groupInfo.profileDetail?.jid ?? "") } } } diff --git a/MirrorflyUIkit/Mirrorfly.entitlements b/MirrorflyUIkit/Mirrorfly.entitlements new file mode 100755 index 0000000..c97be71 --- /dev/null +++ b/MirrorflyUIkit/Mirrorfly.entitlements @@ -0,0 +1,12 @@ + + + + + aps-environment + development + com.apple.security.application-groups + + group.com.mirror.fly + + + diff --git a/MirrorflyUIkit/Storyboards/Base.lproj/Main.storyboard b/MirrorflyUIkit/Storyboards/Base.lproj/Main.storyboard index 3bd09e0..275bcfe 100755 --- a/MirrorflyUIkit/Storyboards/Base.lproj/Main.storyboard +++ b/MirrorflyUIkit/Storyboards/Base.lproj/Main.storyboard @@ -2351,6 +2351,8 @@ + + @@ -4232,7 +4234,7 @@