 
 ///  Main manager class of Butterfly
 
-public class ButterflyManager: NSObject {
+open class ButterflyManager: NSObject {
     
     /// You can access instance variable `imageWillUpload` directly.
-    public var imageWillUpload: UIImage? {
+    open var imageWillUpload: UIImage? {
         return self.butterflyViewController?.imageWillUpload
     }
     
     /// Or instance variable `textWillUploader`.
-    public var textWillUpload: String? {
+    open var textWillUpload: String? {
         return self.butterflyViewController?.textWillUpload
     }
     
     /// Manager is listening shake event or not.
-    public var isListeningShake: Bool?
+    open var isListeningShake: Bool?
     
     /// Shared manager used by the extension across Butterfly.
-    public class var sharedManager: ButterflyManager {
+    open class var sharedManager: ButterflyManager {
         return instance
     }
     

    
    /// Unregister and stop listening shake event.
    /// Optional: you can just listen the specific one (viewController) you want.
    public func stopListeningShake() {
        NSNotificationCenter.defaultCenter().removeObserver(
            self,
            name: Notification.ButterflyDidShakingNotification,
            object: nil)
        isListeningShake = false
    }
    
    /// Begin handling shake event.
    func handleShake(notification: NSNotification) {
        
        let screenshot = takeScreenshot()
        

        butterflyViewController?.delegate = self
        butterflyViewController?.image = screenshot
        
        var presented = UIApplication.shared.keyWindow?.rootViewController
        
        while let vc = presented?.presentedViewController {
            presented = vc
        }
        
        let nav = UINavigationController.init(rootViewController: butterflyViewController!)
        nav.modalTransitionStyle = .crossDissolve
        
        if presented?.isKind(of: UINavigationController.self) == true {
            let rootvc: UIViewController = (presented as! UINavigationController).viewControllers[0] 
            if rootvc.isKind(of: ButterflyViewController.self) == false {
                presented?.present(nav, animated: true, completion: nil)
            }
        } else if presented?.isKind(of: ButterflyViewController.self) == false {
            presented?.present(nav, animated: true, completion: nil)
        }
    }
    
    fileprivate func currentDate() -> String! {
        let sec = Date().timeIntervalSinceNow
        let currentDate = Date(timeIntervalSinceNow: sec)
        
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyy/MM/dd HH/mm/ss"
        let string = dateFormatter.string(from: currentDate)
        return string
    }
    
