Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ 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)]()
values.forEach { title in
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":
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion MirrorflyShareKit/SharKitVerifyOtpViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions MirrorflyShareKit/ShareKitBaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions MirrorflyShareKit/ShareKitExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion MirrorflyShareKit/ShareKitUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))"
Expand Down
4 changes: 2 additions & 2 deletions MirrorflyShareKit/ShareKitViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,7 +56,7 @@ class ShareKitViewModel {
}

func isLoggedIn() -> Bool {
return FlyDefaults.isLoggedIn
return ChatManager.getAppLoggedIn()
}

func clearModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Loading