<commit_before>/*
Licensed Materials - Property of IBM
© Copyright IBM Corporation 2015. All Rights Reserved.
*/

import UIKit
import Security

class LoginViewController: SummitUIViewController, UITextFieldDelegate, UIAlertViewDelegate {

    @IBOutlet weak var loginBoxView: UIView!
    @IBOutlet weak var usernameTextField: UITextField!
    @IBOutlet weak var passwordTextField: UITextField!
    @IBOutlet weak var summitLogoImageView: UIImageView!
    @IBOutlet weak var loginButton: UIButton!
    @IBOutlet weak var signUpButton: UIButton!
    @IBOutlet weak var appNameLabel: UILabel!
    @IBOutlet weak var logoHolderTopSpace: NSLayoutConstraint!
    @IBOutlet weak var loginBoxViewBottomSpace: NSLayoutConstraint!
    
    var logoHolderOriginalTopSpace : CGFloat!
    var loginBoxViewOriginalBottomSpace : CGFloat!
    var kFourInchIphoneHeight : CGFloat = 568
    var kFourInchIphoneLogoHolderNewTopSpace : CGFloat = 30
    var kloginBoxViewPaddingFromKeyboard : CGFloat = 60
    var presentingVC : UIViewController!
    
    var noKeychainItems : Bool = true
    
    var wormhole : MMWormhole?
    
    
    /**
    This method calls the setUpLoginBoxView, setUpSignUpButton, setUpTextFields, and saveUIElementOriginalConstraints methods when the view loads
    */
    override func viewDidLoad() {
        super.viewDidLoad()

        self.wormhole = MMWormhole(applicationGroupIdentifier: GroupDataAccess.sharedInstance.groupAppID, optionalDirectory: nil)
        
        setUpLoginBoxView()
        setUpLoginButton()
        setUpSignUpButton()
        setUpTextFields()
        saveUIElementOriginalConstraints()
    }
   
    
    override func viewDidAppear(animated: Bool) {
        self.navigationItem.title = NSLocalizedString("LOGIN", comment:"")
        self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "Oswald-Regular", size: 22)!,  NSForegroundColorAttributeName: UIColor.whiteColor()]
    }
    
    
    /**
    This method calls the registerForKeyboardNotifications when the viewWillAppear
    
    - parameter animated:
    */
    override func viewWillAppear(animated: Bool) {
        self.registerForKeyboardNotifications()
        
        // Attempt to fetch login details from the keychain
        
        let usr : String? = KeychainWrapper.stringForKey("summit_username")
        let pswd : String? = KeychainWrapper.stringForKey("summit_password")
        
        if (usr != nil && pswd != nil) {<commit_msg>adds safe nil checking to LoginVC<commit_after>/*
Licensed Materials - Property of IBM
© Copyright IBM Corporation 2015. All Rights Reserved.
*/

import UIKit
import Security

class LoginViewController: SummitUIViewController, UITextFieldDelegate, UIAlertViewDelegate {

    @IBOutlet weak var loginBoxView: UIView!
    @IBOutlet weak var usernameTextField: UITextField!
    @IBOutlet weak var passwordTextField: UITextField!
    @IBOutlet weak var summitLogoImageView: UIImageView!
    @IBOutlet weak var loginButton: UIButton!
    @IBOutlet weak var signUpButton: UIButton!
    @IBOutlet weak var appNameLabel: UILabel!
    @IBOutlet weak var logoHolderTopSpace: NSLayoutConstraint!
    @IBOutlet weak var loginBoxViewBottomSpace: NSLayoutConstraint!
    
    var logoHolderOriginalTopSpace : CGFloat!
    var loginBoxViewOriginalBottomSpace : CGFloat!
    var kFourInchIphoneHeight : CGFloat = 568
    var kFourInchIphoneLogoHolderNewTopSpace : CGFloat = 30
    var kloginBoxViewPaddingFromKeyboard : CGFloat = 60
    var presentingVC : UIViewController!
    
    var noKeychainItems : Bool = true
    
    var wormhole : MMWormhole?
    
    
    /**
    This method calls the setUpLoginBoxView, setUpSignUpButton, setUpTextFields, and saveUIElementOriginalConstraints methods when the view loads
    */
    override func viewDidLoad() {
        super.viewDidLoad()

        if let groupAppID = GroupDataAccess.sharedInstance.groupAppID {
            
            self.wormhole = MMWormhole(applicationGroupIdentifier: groupAppID, optionalDirectory: nil)
            
        }
        
        setUpLoginBoxView()
        setUpLoginButton()
        setUpSignUpButton()
        setUpTextFields()
        saveUIElementOriginalConstraints()
        
    }
   
    override func viewDidAppear(animated: Bool) {
        self.navigationItem.title = NSLocalizedString("LOGIN", comment:"")
        self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "Oswald-Regular", size: 22)!,  NSForegroundColorAttributeName: UIColor.whiteColor()]
    }
    
    
    /**
    This method calls the registerForKeyboardNotifications when the viewWillAppear
    
    - parameter animated:
    */
    override func viewWillAppear(animated: Bool) {
        self.registerForKeyboardNotifications()
        
        // Attempt to fetch login details from the keychain
        
        let usr : String? = KeychainWrapper.stringForKey("summit_username")
        let pswd : String? = KeychainWrapper.stringForKey("summit_password")
        
        if (usr != nil && pswd != nil) {
{'fraction_non_alphanumeric': 0.06763379729464811, 'fraction_numerical': 0.005097039796118408, 'mean_word_length': 3.342127659574468, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3524317', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1406, 'n_words': 359}