<commit_before>//
//  ViewController.swift
//  VideoSampleCaptureRender
//
//  Created by <NAME> on 3/10/16.
//  Copyright © 2016 Twilio. All rights reserved.
//

import UIKit

class ViewController: UIViewController, UITextFieldDelegate {
    
    // Twilio Access Token - Generate a demo Access Token at https://www.twilio.com/user/account/video/dev-tools/testing-tools
    let twilioAccessToken = "TWILIO_ACCESS_TOKEN"
    
    // Storyboard's outlets
    @IBOutlet weak var spinner: UIActivityIndicatorView!
    @IBOutlet weak var statusMessage: UILabel!
    @IBOutlet weak var inviteeTextField: UITextField!
    @IBOutlet weak var disconnectButton: UIButton!
    
    // Key Twilio ConversationsClient SDK objects
    var client: TwilioConversationsClient?
    var localMedia: TWCLocalMedia?
    var camera: TWCCameraCapturer?
    var conversation: TWCConversation?
    var outgoingInvite: TWCOutgoingInvite?
    var remoteVideoRenderer: TWCVideoViewRenderer?
    
    // Video containers used to display local camera track and remote Participant's camera track
    var localVideoContainer: UIView?
    var remoteVideoContainer: UIView?
    
    // If set to true, the remote video renderer (of type TWCVideoViewRenderer) will not automatically handle rotation of the remote party's video track. Instead, you should respond to the 'renderer:orientiationDidChange:' method in your TWCVideoViewRendererDelegate.
    let applicationHandlesRemoteVideoFrameRotation = false
    
    // ConversationsClient status - used to dynamically update our UI
    enum ConversationsClientStatus: Int {
        case None = 0
        case FailedToListen
        case Listening
        case Connecting
        case Connected
    }
    // Default status to None
    var clientStatus: ConversationsClientStatus = .None
    
    func updateClientStatus(status: ConversationsClientStatus, animated: Bool) {
        self.clientStatus = status
        
        // Update UI elements when the ConversationsClient status changes
        switch self.clientStatus {
        case .None:
            break
        case .FailedToListen:
            spinner.stopAnimating()
            self.statusMessage.hidden = false
            self.statusMessage.text = "Failure while attempting to listen for Conversation Invites."
            self.view.bringSubviewToFront(self.statusMessage)
        case .Listening:
            spinner.stopAnimating()
            self.disconnectButton.hidden = true
            self.inviteeTextField.hidden = false
        case .Connecting:
            self.spinner.startAnimating()
            self.inviteeTextField.hidden = true
        case .Connected:
            self.spinner.stopAnimating()
            self.inviteeTextField.hidden = true
            self.view.endEditing(true)
            self.disconnectButton.hidden = false
        }
        // Update UI Layout, optionally animated
        self.view.setNeedsLayout()
        if animated {
            UIView.animateWithDuration(0.2) { () -> Void in
                self.view.layoutIfNeeded()
            }
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // self.view is loaded from Main.storyboard, however the local and remote video containers are created programmatically
        
        // Video containers
        self.remoteVideoContainer = UIView(frame: self.view.frame)
        self.view.addSubview(self.remoteVideoContainer!)
        self.remoteVideoContainer!.backgroundColor = UIColor.blackColor()
        self.localVideoContainer = UIView(frame: self.view.frame)
        self.view.addSubview(self.localVideoContainer!)
        self.localVideoContainer!.backgroundColor = UIColor.blackColor()
        
        // Entry text field for the identity to invite to a Conversation (the invitee)
        inviteeTextField.alpha = 0.5
        inviteeTextField.hidden = true
        inviteeTextField.autocorrectionType = .No
        inviteeTextField.returnKeyType = .Send
        self.view.bringSubviewToFront(self.inviteeTextField)
        self.inviteeTextField.delegate = self
        
        // Spinner - shown when attempting to listen for Invites and when sending an Invite
        self.view.addSubview(spinner)
        spinner.startAnimating()
        self.view.bringSubviewToFront(self.spinner)
        
        // Status message - used to display errors
        statusMessage.hidden = true
        
        // Disconnect button
        self.view.bringSubviewToFront(self.disconnectButton)
        self.disconnectButton.hidden = true
        
        // Start listening for Invites
        TwilioConversationsClient.setLogLevel(.Error)
        self.listenForInvites()
    }<commit_msg>text entry field is a little easier to read<commit_after>//
//  ViewController.swift
//  VideoSampleCaptureRender
//
//  Created by <NAME> on 3/10/16.
//  Copyright © 2016 Twilio. All rights reserved.
//

import UIKit

class ViewController: UIViewController, UITextFieldDelegate {
    
    // Twilio Access Token - Generate a demo Access Token at https://www.twilio.com/user/account/video/dev-tools/testing-tools
    let twilioAccessToken = "TWILIO_ACCESS_TOKEN"
    
    // Storyboard's outlets
    @IBOutlet weak var spinner: UIActivityIndicatorView!
    @IBOutlet weak var statusMessage: UILabel!
    @IBOutlet weak var inviteeTextField: UITextField!
    @IBOutlet weak var disconnectButton: UIButton!
    
    // Key Twilio ConversationsClient SDK objects
    var client: TwilioConversationsClient?
    var localMedia: TWCLocalMedia?
    var camera: TWCCameraCapturer?
    var conversation: TWCConversation?
    var outgoingInvite: TWCOutgoingInvite?
    var remoteVideoRenderer: TWCVideoViewRenderer?
    
    // Video containers used to display local camera track and remote Participant's camera track
    var localVideoContainer: UIView?
    var remoteVideoContainer: UIView?
    
    // If set to true, the remote video renderer (of type TWCVideoViewRenderer) will not automatically handle rotation of the remote party's video track. Instead, you should respond to the 'renderer:orientiationDidChange:' method in your TWCVideoViewRendererDelegate.
    let applicationHandlesRemoteVideoFrameRotation = false
    
    // ConversationsClient status - used to dynamically update our UI
    enum ConversationsClientStatus: Int {
        case None = 0
        case FailedToListen
        case Listening
        case Connecting
        case Connected
    }
    // Default status to None
    var clientStatus: ConversationsClientStatus = .None
    
    func updateClientStatus(status: ConversationsClientStatus, animated: Bool) {
        self.clientStatus = status
        
        // Update UI elements when the ConversationsClient status changes
        switch self.clientStatus {
        case .None:
            break
        case .FailedToListen:
            spinner.stopAnimating()
            self.statusMessage.hidden = false
            self.statusMessage.text = "Failure while attempting to listen for Conversation Invites."
            self.view.bringSubviewToFront(self.statusMessage)
        case .Listening:
            spinner.stopAnimating()
            self.disconnectButton.hidden = true
            self.inviteeTextField.hidden = false
        case .Connecting:
            self.spinner.startAnimating()
            self.inviteeTextField.hidden = true
        case .Connected:
            self.spinner.stopAnimating()
            self.inviteeTextField.hidden = true
            self.view.endEditing(true)
            self.disconnectButton.hidden = false
        }
        // Update UI Layout, optionally animated
        self.view.setNeedsLayout()
        if animated {
            UIView.animateWithDuration(0.2) { () -> Void in
                self.view.layoutIfNeeded()
            }
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // self.view is loaded from Main.storyboard, however the local and remote video containers are created programmatically
        
        // Video containers
        self.remoteVideoContainer = UIView(frame: self.view.frame)
        self.view.addSubview(self.remoteVideoContainer!)
        self.remoteVideoContainer!.backgroundColor = UIColor.blackColor()
        self.localVideoContainer = UIView(frame: self.view.frame)
        self.view.addSubview(self.localVideoContainer!)
        self.localVideoContainer!.backgroundColor = UIColor.blackColor()
        
        // Entry text field for the identity to invite to a Conversation (the invitee)
        inviteeTextField.alpha = 0.9
        inviteeTextField.hidden = true
        inviteeTextField.autocorrectionType = .No
        inviteeTextField.returnKeyType = .Send
        self.view.bringSubviewToFront(self.inviteeTextField)
        self.inviteeTextField.delegate = self
        
        // Spinner - shown when attempting to listen for Invites and when sending an Invite
        self.view.addSubview(spinner)
        spinner.startAnimating()
        self.view.bringSubviewToFront(self.spinner)
        
        // Status message - used to display errors
        statusMessage.hidden = true
        
        // Disconnect button
        self.view.bringSubviewToFront(self.disconnectButton)
        self.disconnectButton.hidden = true
        
        // Start listening for Invites
        TwilioConversationsClient.setLogLevel(.Error)
        self.listenForInvites()
    }
{'fraction_non_alphanumeric': 0.06761339550657058, 'fraction_numerical': 0.002967359050445104, 'mean_word_length': 2.483573274270949, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7477745', 'n_tokens_mistral': 2495, 'n_tokens_neox': 2437, 'n_words': 654}