diff --git a/CHANGES.rst b/CHANGES.rst index d3a374cdf..9a554bff9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,7 @@ Changes to be released in next version 🙌 Improvements * MXRoomSummary: Adapt room summary changes on MatrixSDK (#4360). * EncryptionKeyManager: Create keys for room last message data type. + * Integrated FLEX for debug builds. 🐛 Bugfix * diff --git a/Podfile b/Podfile index 6b7502835..a7e2997d4 100644 --- a/Podfile +++ b/Podfile @@ -69,6 +69,8 @@ abstract_target 'RiotPods' do pod 'SwiftBase32', '~> 0.9.0' pod 'SwiftJWT', '~> 3.6.200' + pod 'FLEX', '~> 4.4.1', :configurations => ['Debug'] + target 'RiotTests' do inherit! :search_paths end diff --git a/Riot/Modules/Application/AppCoordinator.swift b/Riot/Modules/Application/AppCoordinator.swift index 58dac41bb..9eac2416e 100755 --- a/Riot/Modules/Application/AppCoordinator.swift +++ b/Riot/Modules/Application/AppCoordinator.swift @@ -17,6 +17,10 @@ import Foundation import Intents +#if DEBUG +import FLEX +#endif + /// The AppCoordinator is responsible of screen navigation and data injection at root application level. It decides if authentication or home screen should be shown and inject data needed for these flows, it changes the navigation stack on deep link, displays global warning. /// This class should avoid to contain too many data management code not related to screen navigation logic. For example `MXSession` or push notification management should be handled in dedicated classes and report only navigation changes to the AppCoordinator. final class AppCoordinator: NSObject, AppCoordinatorType { @@ -49,10 +53,14 @@ final class AppCoordinator: NSObject, AppCoordinatorType { // MARK: - Setup - init(router: RootRouterType) { + init(router: RootRouterType, window: UIWindow) { self.rootRouter = router self.customSchemeURLParser = CustomSchemeURLParser() self.userSessionsService = UserSessionsService() + + super.init() + + setupFlexDebuggerOnWindow(window) } // MARK: - Public methods @@ -119,6 +127,21 @@ final class AppCoordinator: NSObject, AppCoordinatorType { return canOpenLink } + + private func setupFlexDebuggerOnWindow(_ window: UIWindow) { + #if DEBUG + let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(showFlexDebugger)) + tapGestureRecognizer.numberOfTouchesRequired = 2 + tapGestureRecognizer.numberOfTapsRequired = 2 + window.addGestureRecognizer(tapGestureRecognizer) + #endif + } + + @objc private func showFlexDebugger() { + #if DEBUG + FLEXManager.shared.showExplorer() + #endif + } } // MARK: - LegacyAppDelegateDelegate diff --git a/Riot/Modules/Application/AppDelegate.swift b/Riot/Modules/Application/AppDelegate.swift index 5a54a63b0..5ab09997b 100644 --- a/Riot/Modules/Application/AppDelegate.swift +++ b/Riot/Modules/Application/AppDelegate.swift @@ -55,8 +55,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - // Setup window let window = UIWindow(frame: UIScreen.main.bounds) self.window = window @@ -64,7 +62,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Create AppCoordinator self.rootRouter = RootRouter(window: window) - let appCoordinator = AppCoordinator(router: self.rootRouter) + let appCoordinator = AppCoordinator(router: self.rootRouter, window: window) appCoordinator.start() self.legacyAppDelegate.delegate = appCoordinator