<commit_before>module BW
  class UIActivityViewController < ::UIActivityViewController
    class << self
      def new(options = {}, presenting_controller = nil, &block)
        options = {
          activities: nil,
          animated: true
        }.merge(options)

        if options[:item] || options[:items]
          items = Array(options[:item] || options[:items])
        else
          raise ArgumentError, "You must specify at least one item - #{options.inspect}"
        end

        vc = alloc.initWithActivityItems(items, applicationActivities:options[:activities])
        vc.excludedActivityTypes = BW::Constants.get("UIActivityType", Array(options[:excluded])) if options[:excluded]

        unless block.nil?
          block.weak! if BubbleWrap.use_weak_callbacks?
          vc.setCompletionHandler block
        end

        presenting_controller ||= App.window.rootViewController.presentedViewController # May be nil, but handles use case of container views
        presenting_controller ||= App.window.rootViewController

        presenting_controller.presentViewController(vc, animated:options[:animated], completion: lambda {})
        vc
      end

    end
  end

  # UIActivityTypes
  Constants.register(
    UIActivityTypePostToFacebook,
    UIActivityTypePostToTwitter,
    UIActivityTypePostToWeibo,
    UIActivityTypeMessage,
    UIActivityTypeMail,
    UIActivityTypePrint,
    UIActivityTypeCopyToPasteboard,
    UIActivityTypeAssignToContact,
    UIActivityTypeSaveToCameraRoll
  )

  # These constants are not iOS 6 compatable.
  # Define them but don't initialize them unless we're on iOS 7
  if defined?(UIActivityViewController::UIActivityTypeAddToReadingList).nil?
    Kernel.const_set('UIActivityTypeAddToReadingList', '')
    Kernel.const_set('UIActivityTypePostToFlickr', '')
    Kernel.const_set('UIActivityTypePostToVimeo', '')
    Kernel.const_set('UIActivityTypePostToTencentWeibo', '')
  end

  if Device.ios_version >= "7.0"
    Constants.register(
      Kernel.const_get('UIActivityTypeAddToReadingList'),
      Kernel.const_get('UIActivityTypePostToFlickr'),
      Kernel.const_get('UIActivityTypePostToVimeo'),
      Kernel.const_get('UIActivityTypePostToTencentWeibo'),
      Kernel.const_get('UIActivityTypeAirDrop')
    )
  end
end<commit_msg>Doh! Should be setting and getting constants on UIActivityViewController, not Kernel.<commit_after>module BW
  class UIActivityViewController < ::UIActivityViewController
    class << self
      def new(options = {}, presenting_controller = nil, &block)
        options = {
          activities: nil,
          animated: true
        }.merge(options)

        if options[:item] || options[:items]
          items = Array(options[:item] || options[:items])
        else
          raise ArgumentError, "You must specify at least one item - #{options.inspect}"
        end

        vc = alloc.initWithActivityItems(items, applicationActivities:options[:activities])
        vc.excludedActivityTypes = BW::Constants.get("UIActivityType", Array(options[:excluded])) if options[:excluded]

        unless block.nil?
          block.weak! if BubbleWrap.use_weak_callbacks?
          vc.setCompletionHandler block
        end

        presenting_controller ||= App.window.rootViewController.presentedViewController # May be nil, but handles use case of container views
        presenting_controller ||= App.window.rootViewController

        presenting_controller.presentViewController(vc, animated:options[:animated], completion: lambda {})
        vc
      end

    end
  end

  # UIActivityTypes
  Constants.register(
    UIActivityTypePostToFacebook,
    UIActivityTypePostToTwitter,
    UIActivityTypePostToWeibo,
    UIActivityTypeMessage,
    UIActivityTypeMail,
    UIActivityTypePrint,
    UIActivityTypeCopyToPasteboard,
    UIActivityTypeAssignToContact,
    UIActivityTypeSaveToCameraRoll
  )

  # These constants are not iOS 6 compatable.
  # Define them but don't initialize them unless we're on iOS 7
  if defined?(UIActivityViewController::UIActivityTypeAddToReadingList).nil?
    UIActivityViewController.const_set('UIActivityTypeAddToReadingList', '')
    UIActivityViewController.const_set('UIActivityTypePostToFlickr', '')
    UIActivityViewController.const_set('UIActivityTypePostToVimeo', '')
    UIActivityViewController.const_set('UIActivityTypePostToTencentWeibo', '')
    UIActivityViewController.const_set('UIActivityTypeAirDrop', '')
  end

  if Device.ios_version >= "7.0"
    Constants.register(
      UIActivityViewController.const_get('UIActivityTypeAddToReadingList'),
      UIActivityViewController.const_get('UIActivityTypePostToFlickr'),
      UIActivityViewController.const_get('UIActivityTypePostToVimeo'),
      UIActivityViewController.const_get('UIActivityTypePostToTencentWeibo'),
      UIActivityViewController.const_get('UIActivityTypeAirDrop')
    )
  end
end
{'fraction_non_alphanumeric': 0.08650306748466258, 'fraction_numerical': 0.0016359918200408998, 'mean_word_length': 3.965482233502538, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5037330', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1403, 'n_words': 252}