From a499c35e96fab888c8a19db266e7b846a622c35d Mon Sep 17 00:00:00 2001 From: Frank Rotermund Date: Mon, 28 Oct 2024 13:57:15 +0100 Subject: [PATCH] feat: show happy birthday (MESSENGER-6570) --- Config/BWIBuildSettings.swift | 2 +- .../20221027_BwM_Bday_scaled.svg | 274 ------------------ .../BWI/birthday_cake.imageset/Contents.json | 2 +- .../BWI/birthday_cake.imageset/web_dark.svg | 29 ++ Riot/Assets/de.lproj/Localizable.strings | 4 +- Riot/Assets/en.lproj/Localizable.strings | 6 +- .../Settings/Shared/RiotSharedSettings.swift | 2 +- .../Home/AllChats/AllChatsCoordinator.swift | 2 + .../AllChats/AllChatsViewController.swift | 41 +++ 9 files changed, 80 insertions(+), 282 deletions(-) delete mode 100644 Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/20221027_BwM_Bday_scaled.svg create mode 100644 Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/web_dark.svg diff --git a/Config/BWIBuildSettings.swift b/Config/BWIBuildSettings.swift index c4846c1d5..1bd4b8b47 100644 --- a/Config/BWIBuildSettings.swift +++ b/Config/BWIBuildSettings.swift @@ -590,7 +590,7 @@ class BWIBuildSettings: NSObject { var bwiEnableRegisterInfo = false var bwiShowHappyBirthdayCampaign = false - var bwiHappyBirthdayCampaignIdentifier: String = "2022" + var bwiHappyBirthdayCampaignIdentifier: String = "2024" var bwiDisableSecuritySettingsUntrustedDevices = true diff --git a/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/20221027_BwM_Bday_scaled.svg b/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/20221027_BwM_Bday_scaled.svg deleted file mode 100644 index 046eb8d06..000000000 --- a/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/20221027_BwM_Bday_scaled.svg +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/Contents.json b/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/Contents.json index 23da91cb0..8808d0834 100644 --- a/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/Contents.json +++ b/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "20221027_BwM_Bday_scaled.svg", + "filename" : "web_dark.svg", "idiom" : "universal" } ], diff --git a/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/web_dark.svg b/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/web_dark.svg new file mode 100644 index 000000000..a3e7bb135 --- /dev/null +++ b/Riot/Assets/Images.xcassets/BWI/birthday_cake.imageset/web_dark.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Riot/Assets/de.lproj/Localizable.strings b/Riot/Assets/de.lproj/Localizable.strings index 76df430d9..c18980736 100644 --- a/Riot/Assets/de.lproj/Localizable.strings +++ b/Riot/Assets/de.lproj/Localizable.strings @@ -119,8 +119,8 @@ // /* BWI: Happy Birthday Campaign*/ -"HAPPY_BIRTHDAY" = "🎈 HAPPY BIRTHDAY 2.0 🎈"; -"HAPPY_BIRTHDAY_BODY" = "Schon wieder ist ein Jahr vorbei, der BwMessenger wird 2.\nDanke für Deine Treue - jetzt und in Zukunft.\nGratuliere uns zum 2.0 mit Deiner Sterne-Bewertung im App Store."; +"HAPPY_BIRTHDAY" = "🥳 HAPPY BIRTHDAY 🥳"; +"HAPPY_BIRTHDAY_BODY" = "Danke für Deine Treue - jetzt und in Zukunft. Gratuliere dem BwMessenger zum 4. Geburtstag und schenke uns deine Sternebewertung im App Store."; "HAPPY_BIRTHDAY_BUTTON_GIVE_STARS" = "Sterne schenken"; "HAPPY_BIRTHDAY_BUTTON_DISMISS" = "X"; diff --git a/Riot/Assets/en.lproj/Localizable.strings b/Riot/Assets/en.lproj/Localizable.strings index e343edeb6..a1f178927 100644 --- a/Riot/Assets/en.lproj/Localizable.strings +++ b/Riot/Assets/en.lproj/Localizable.strings @@ -186,7 +186,7 @@ "KEY_VERIFICATION_REQUEST_FROM_USER" = "%@ wants to verify"; /* BWI: Happy Birthday Campaign*/ -"HAPPY_BIRTHDAY" = "🎈 HAPPY BIRTHDAY 2.0 🎈"; -"HAPPY_BIRTHDAY_BODY" = "Another year has passed, BwMessenger turns 2.\nThank you for your loyalty - now and in the future.\nMake us present on 2.0 with your star rating in the App Store."; -"HAPPY_BIRTHDAY_BUTTON_GIVE_STARS" = "Donate Stars"; +"HAPPY_BIRTHDAY" = "🥳 HAPPY BIRTHDAY 🥳"; +"HAPPY_BIRTHDAY_BODY" = "Thank you for your loyalty - now and in the future. Congratulate BwMessenger on its 4th anniversary and give us your star rating on the App Store."; +"HAPPY_BIRTHDAY_BUTTON_GIVE_STARS" = "Give Stars"; "HAPPY_BIRTHDAY_BUTTON_DISMISS" = "X"; diff --git a/Riot/Managers/Settings/Shared/RiotSharedSettings.swift b/Riot/Managers/Settings/Shared/RiotSharedSettings.swift index 01d381523..ac45c4a50 100644 --- a/Riot/Managers/Settings/Shared/RiotSharedSettings.swift +++ b/Riot/Managers/Settings/Shared/RiotSharedSettings.swift @@ -286,7 +286,7 @@ class RiotSharedSettings: NSObject { guard let birthdayCampaignDict = notificationsDict["should_show_ios_birthday_campaign"] as? [String : Any] else { return true } - return (birthdayCampaignDict["2022"] as? Bool) ?? true + return (birthdayCampaignDict[campaign] as? Bool) ?? true } @discardableResult diff --git a/Riot/Modules/Home/AllChats/AllChatsCoordinator.swift b/Riot/Modules/Home/AllChats/AllChatsCoordinator.swift index 2200881e2..7dbbd0e7f 100644 --- a/Riot/Modules/Home/AllChats/AllChatsCoordinator.swift +++ b/Riot/Modules/Home/AllChats/AllChatsCoordinator.swift @@ -720,6 +720,8 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol { self.allChatsViewController.bwiCheckForFederationAnnouncementPromt() // bwi: 5660 introduce federation self.allChatsViewController.presentFederationIntroductionSheet() + // bwi: 6570 Show birthday + self.allChatsViewController.bwiCheckForBirthdayScreen() } } diff --git a/Riot/Modules/Home/AllChats/AllChatsViewController.swift b/Riot/Modules/Home/AllChats/AllChatsViewController.swift index f09e16817..a52cda91f 100644 --- a/Riot/Modules/Home/AllChats/AllChatsViewController.swift +++ b/Riot/Modules/Home/AllChats/AllChatsViewController.swift @@ -356,6 +356,7 @@ class AllChatsViewController: HomeViewController { let viewController = UIHostingController(rootView: IntroduceFederationView().environmentObject(BWIThemeService.shared)) viewController.isModalInPresentation = true + present(viewController, animated: true) { notificationService.setShowFederationIntroductionFlag(false) } @@ -517,6 +518,8 @@ class AllChatsViewController: HomeViewController { self.bwiCheckForFederationAnnouncementPromt() // bwi: 5660 introduce federation self.presentFederationIntroductionSheet() + // bwi: 6570 Show birthday + self.bwiCheckForBirthdayScreen() })) alert.addAction(UIAlertAction(title: BWIL10n.bwiAnalyticsAlertOkButton, @@ -528,6 +531,8 @@ class AllChatsViewController: HomeViewController { self.bwiCheckForFederationAnnouncementPromt() // bwi: 5660 introduce federation self.presentFederationIntroductionSheet() + // bwi: 6570 Show birthday + self.bwiCheckForBirthdayScreen() })) self.present(alert, animated: true) @@ -554,11 +559,39 @@ class AllChatsViewController: HomeViewController { let viewController = UIHostingController(rootView: FederationAnnouncementView().environmentObject(BWIThemeService.shared)) viewController.isModalInPresentation = true + present(viewController, animated: true) { notificationService.setShowFederationAnnouncementFlag(false) } } + // bwi #6570: check if birthday screen was shown for this session + func bwiCheckForBirthdayScreen() { + guard let session = self.mainSession else { + return + } + + guard BWIBuildSettings.shared.bwiShowHappyBirthdayCampaign else { + return + } + + let sharedSettings = RiotSharedSettings(session: session) + let campaign = BWIBuildSettings.shared.bwiHappyBirthdayCampaignIdentifier + + if sharedSettings.happyBirthdayCampaign(for: campaign) { + let viewController = HappyBirthdayViewController.makeViewController() + + present(viewController, animated: true) + + sharedSettings.setHappyBirthdayCampaign(campaign, enabled: false) { + } failure: { error in + if let error = error { + MXLog.debug("[HappyBirthdayCampaign] could not set flag in account data. Error: \(error)") + } + } + } + } + // MARK: - Actions @objc private func showSpaceSelectorAction(sender: AnyObject) { @@ -1100,10 +1133,18 @@ extension AllChatsViewController { } } +//extension AllChatsViewController: UIPopoverPresentationControllerDelegate { +// func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { +// // bwi: show matomo consent alert again +// MXLog.debug("Dismissed: \(presentationController)") +// } +//} + // MARK: - UIAdaptivePresentationControllerDelegate extension AllChatsViewController: UIAdaptivePresentationControllerDelegate { func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { + // bwi: show matomo consent alert again if showMatomoConsentAlertOnCloseModal { showMatomoConsentAlertOnCloseModal = false