     
     @IBAction func actionButtonTapped(sender: UIButton) {
         // heading
+        view.endEditing(true)
         let dialog = ZAlertView(title: "More Actions", message: nil, alertType: .MultipleChoice)
         
 

                else
                {
                    TSMessage.showNotificationWithTitle("Flashing successful", subtitle: "Please wait while your device is being flashed with Tinker firmware...", type: .Success)
                    //                                                self.deviceIDsBeingFlashed[device.id] = defaultFlashingTime
                    //                                                self.flashingTimer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "flashingTimerFunc:", userInfo: nil, repeats: true)
                    //                        device.isFlashing = true
                    //                        self.deviceIDflashingDict[device.id] = kDefaultCoreFlashingTime
                    //                        self.photonSelectionTableView.reloadData()
                    
                }
            })
            
        case .Photon:
            Mixpanel.sharedInstance().track("Tinker: Reflash Tinker", properties: ["device":"Photon"])
            
            let bundle = NSBundle.mainBundle()
            let path = bundle.pathForResource("photon-tinker", ofType: "bin")
            //                                        var error:NSError?
            if let binary: NSData? = NSData.dataWithContentsOfMappedFile(path!) as? NSData // fix deprecation
            {
                let filesDict = ["tinker.bin" : binary!]
                self.device!.flashFiles(filesDict, completion: { (error:NSError?) -> Void in
                    if let e=error
                    {
                        TSMessage.showNotificationWithTitle("Flashing error", subtitle: "Error flashing device: \(e.localizedDescription)", type: .Error)
                    }
                    else
                    {
                        TSMessage.showNotificationWithTitle("Flashing successful", subtitle: "Please wait while your device is being flashed with Tinker firmware...", type: .Success)
                        //                            device.isFlashing = true
                        //                            self.deviceIDflashingDict[device.id] = kDefaultPhotonFlashingTime
                        //                            self.photonSelectionTableView.reloadData()
                        
                    }
                })
                
            }
        case .Electron:
            Mixpanel.sharedInstance().track("Tinker: Reflash Tinker", properties: ["device":"Electron"])
            // TODO: support flashing tinker to Electron
            //                                TSMessage.showNotificationWithTitle("Not supported", subtitle: "Operation not supported yet, coming soon.", type: .Warning)
            
            
            // heading
            let areYouSureAlert = UIAlertController(title: "Flashing Tinker to Electron", message: "Flashing Tinker to Electron will consume X KB of data from your data plan, are you sure you want to continue?", preferredStyle: .Alert)
            
            let noAction = UIAlertAction(title: "No", style: .Cancel, handler: {
                (alert: UIAlertAction!) -> Void in
            })
            
            let yesAction = UIAlertAction(title: "Yes", style: .Default, handler: {
                (alert: UIAlertAction!) -> Void in
                // check if this works otherwise put binary
                let bundle = NSBundle.mainBundle()
                let path = bundle.pathForResource("electron-tinker", ofType: "bin")
                //                                        var error:NSError?
                if let binary: NSData? = NSData.dataWithContentsOfMappedFile(path!) as? NSData // fix deprecation
                {
                    let filesDict = ["tinker.bin" : binary!]
                    self.device!.flashFiles(filesDict, completion: { (error:NSError?) -> Void in
                        if let e=error
                        {
                            TSMessage.showNotificationWithTitle("Flashing error", subtitle: "Error flashing device: \(e.localizedDescription)", type: .Error)
                        }
                        else
                        {
                            TSMessage.showNotificationWithTitle("Flashing successful", subtitle: "Please wait while Electron is being flashed with Tinker firmware...", type: .Success)
                            //                                device.isFlashing = true
                            //                                self.deviceIDflashingDict[device.id] = kDefaultPhotonFlashingTime
                            //                                self.photonSelectionTableView.reloadData()
                            
                        }
                    })
                    
                }
            })
            areYouSureAlert.addAction(yesAction)
            areYouSureAlert.addAction(noAction)
            self.presentViewController(areYouSureAlert, animated: true, completion: nil)
            
        default:
            TSMessage.showNotificationWithTitle("Reflash Tinker", subtitle: "Cannot reflash Tinker to a non-Particle device", type: .Warning)
            
            
        }

    
    // 2
    func reflashTinker() {

        if !self.device!.connected {
            TSMessage.showNotificationWithTitle("Device offline", subtitle: "Device must be online to be flashed", type: .Error)
            return
        }
        
        func flashTinkerBinary(binaryFilename : String?)
        {
            let bundle = NSBundle.mainBundle()
            let path = bundle.pathForResource(binaryFilename, ofType: "bin")
            let binary = NSData(contentsOfURL: NSURL(fileURLWithPath: path!))
            let filesDict = ["tinker.bin" : binary!]
            self.device!.flashFiles(filesDict, completion: { (error:NSError?) -> Void in
                if let e=error
                {
                    TSMessage.showNotificationWithTitle("Flashing error", subtitle: "Error flashing device: \(e.localizedDescription)", type: .Error)
                }
                else
                {
                    TSMessage.showNotificationWithTitle("Flashing successful", subtitle: "Please wait while your device is being flashed with Tinker firmware...", type: .Success)
                }
            })
        }
        
        
        switch (self.device!.type)
