<commit_before>//
//  ShareViewController.swift
//  Share
//
//  Created by <EMAIL> on 10/03/16.
//  Copyright © 2016 Philips. All rights reserved.
//

import UIKit
import Social

class ShareViewController: SLComposeServiceViewController {
    let maxCharacters = 200;
    
    override func presentationAnimationDidFinish() {
        super.presentationAnimationDidFinish()
        charactersRemaining = maxCharacters;
        placeholder = "Text you want to share"
    }

    override func configurationItems() -> [AnyObject]! {
        // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
        let item = SLComposeSheetConfigurationItem()
        item.title = "Change this"
        
        return [item]
    }

    override func loadPreviewView() -> UIView! {
        return super.loadPreviewView()
    }
    
    override func isContentValid() -> Bool {
        // Do validation of contentText and/or NSExtensionContext attachments here
        let characterCount = textView.text.characters.count
        charactersRemaining = maxCharacters - characterCount
        if charactersRemaining.integerValue < 0 {
            return false
        }
        return true
    }

    override func didSelectPost() {
        // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
    
        // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
        self.extensionContext!.completeRequestReturningItems([], completionHandler: nil)
    }
    
    override func didSelectCancel() {
        super.didSelectCancel()
    }
}<commit_msg>Use core data from share extension<commit_after>//
//  ShareViewController.swift
//  Share
//
//  Created by <EMAIL> on 10/03/16.
//  Copyright © 2016 Philips. All rights reserved.
//

import UIKit
import Social

class ShareViewController: SLComposeServiceViewController {
    let maxCharacters = 200;
    
    lazy var storage : Storage = {
       return Storage()
    }()
    
    lazy var factory : DataFactory = {
        return DataFactory()
    }()
    
    override func presentationAnimationDidFinish() {
        super.presentationAnimationDidFinish()
        charactersRemaining = maxCharacters;
        placeholder = "Text you want to share"
        
    }

    override func configurationItems() -> [AnyObject]! {
        // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
        let item = SLComposeSheetConfigurationItem()
        item.title = "Change this"
        
        return [item]
    }

    override func loadPreviewView() -> UIView! {
        return super.loadPreviewView()
    }
    
    override func isContentValid() -> Bool {
        // Do validation of contentText and/or NSExtensionContext attachments here
        let characterCount = textView.text.characters.count
        charactersRemaining = maxCharacters - characterCount
        if charactersRemaining.integerValue < 0 {
            return false
        }
        return true
    }

    override func didSelectPost() {
        storage.prepare()
        // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
        factory.createNote(NSDate(), text: contentText)
        // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
        self.extensionContext!.completeRequestReturningItems([], completionHandler: nil)
    }
    
    override func didSelectCancel() {
        super.didSelectCancel()
    }
}
{'fraction_non_alphanumeric': 0.07447916666666667, 'fraction_numerical': 0.007291666666666667, 'mean_word_length': 2.6201696512723847, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '3373486', 'n_tokens_mistral': 1005, 'n_tokens_neox': 950, 'n_words': 321}