<commit_before>//
//  ShareUtilities.swift
//  PartyUP
//
//  Created by <NAME> on 2015-12-12.
//  Copyright © 2015 Sandcastle Application Development. All rights reserved.
//

import UIKit
import Social
import Flurry_iOS_SDK

func presentShareActionsOn(presenting: UIViewController,
		atOrigin origin: UIView,
        withPrompt prompt: String,
	withMessage message: String = NSLocalizedString("Lets Party!\n", comment: "Recruitment default text"),
					url: NSURL? = NSURL(string: "http://partyuptonight.com"),
				  image: UIImage? = UIImage(named: "BlackLogo")) {
	let sheet = UIAlertController(title: prompt, message: nil, preferredStyle: .ActionSheet)
	let services = ["Facebook" : SLServiceTypeFacebook, "Twitter" : SLServiceTypeTwitter]

	for (title, service) in services {
		sheet.addAction(UIAlertAction(title: title, style: .Default, handler:
			{ (action) in
				if SLComposeViewController.isAvailableForServiceType(service){
					let shareSheet:SLComposeViewController = SLComposeViewController(forServiceType: service)
					shareSheet.setInitialText(message)
					shareSheet.addURL(url)
					shareSheet.addImage(image)
					presenting.presentViewController(shareSheet, animated: true) {
						Flurry.logEvent(prompt, withParameters: ["service" : title])
					}
				} else {
					let alert = UIAlertController(
						title: NSLocalizedString("Accounts", comment: "Share login alert title"),
						message: NSLocalizedString("Please login to a \(title) account to share.", comment: "Share login alert message"), preferredStyle: UIAlertControllerStyle.Alert)
					alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Share login alert action"), style: UIAlertActionStyle.Default, handler: nil))
					presenting.presentViewController(alert, animated: true, completion: nil)
				}
		}))
	}
	sheet.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: "Share sheet cancel action"), style: .Cancel, handler: nil))
    
    if let pop = sheet.popoverPresentationController {
        pop.sourceView = origin
        pop.sourceRect = origin.bounds
    }
    
	presenting.presentViewController(sheet, animated: true, completion: nil)
}
<commit_msg>Break out the share composition controller creation from the share activity sheet so that it can be called from anywhere.<commit_after>//
//  ShareUtilities.swift
//  PartyUP
//
//  Created by <NAME> on 2015-12-12.
//  Copyright © 2015 Sandcastle Application Development. All rights reserved.
//

import UIKit
import Social
import Flurry_iOS_SDK

func presentShareSheetOn(presenting: UIViewController,
	viaService service: String,
	withMessage message: String,
	url: NSURL?,
	image: UIImage?) {
	if SLComposeViewController.isAvailableForServiceType(service) {
		let shareSheet:SLComposeViewController = SLComposeViewController(forServiceType: service)
		shareSheet.setInitialText(message)
		shareSheet.addURL(url)
		shareSheet.addImage(image)
		presenting.presentViewController(shareSheet, animated: true, completion:  nil)
	} else {
		let alert = UIAlertController(
			title: NSLocalizedString("Accounts", comment: "Share login alert title"),
			message: NSLocalizedString("Please login to a \(service.componentsSeparatedByString(".").last!) account to share.", comment: "Share login alert message"), preferredStyle: UIAlertControllerStyle.Alert)
		alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Share login alert action"), style: .Default, handler: nil))
		presenting.presentViewController(alert, animated: true, completion: nil)
	}
}


func presentShareActionsOn(presenting: UIViewController,
		atOrigin origin: UIView,
        withPrompt prompt: String,
	withMessage message: String = NSLocalizedString("Lets Party!\n", comment: "Recruitment default text"),
					url: NSURL? = NSURL(string: "http://partyuptonight.com"),
				  image: UIImage? = UIImage(named: "BlackLogo")) {
	let sheet = UIAlertController(title: prompt, message: nil, preferredStyle: .ActionSheet)
	let services = ["Facebook" : SLServiceTypeFacebook, "Twitter" : SLServiceTypeTwitter]

	for (title, service) in services {
		sheet.addAction(UIAlertAction(title: title, style: .Default) { _ in
			presentShareSheetOn(presenting, viaService: service, withMessage: message, url: url, image: image)
			Flurry.logEvent(prompt, withParameters: ["service" : title])
		})
	}
	sheet.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: "Share sheet cancel action"), style: .Cancel, handler: nil))
    
    if let pop = sheet.popoverPresentationController {
        pop.sourceView = origin
        pop.sourceRect = origin.bounds
    }
    
	presenting.presentViewController(sheet, animated: true, completion: nil)
}

{'fraction_non_alphanumeric': 0.10725686316237497, 'fraction_numerical': 0.005107469674398808, 'mean_word_length': 5.010230179028133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '637222', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1303, 'n_words': 357}