<commit_before>/**
 Copyright (c) 2016 <NAME>
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 **/

import UIKit
import MobileCoreServices
import CoreData
import AVFoundation
import Photos
import GoogleMobileAds

class MainViewController: UIViewController, UINavigationControllerDelegate, UITableViewDelegate, UITableViewDataSource {
    
    var videos = [Video]()
    
    @IBOutlet
    var tableView: UITableView!
    
    var selectedAsset: PHAsset?
    
    var bannerView: GADBannerView?
    
    let videoManager = VideoManager()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.title = "Video Info Viewer"
        
        let openButton = UIBarButtonItem()
        openButton.title = "Open"
        openButton.action = #selector(MainViewController.clickOpen(_:))
        openButton.target = self
        
        self.navigationItem.rightBarButtonItem = openButton
        
        self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
        
        self.loadVideos()
        
        setupAd()
    }
    
    override func viewDidAppear(animated:Bool) {
        super.viewDidAppear(animated)
        
        if let tracker = GAI.sharedInstance().defaultTracker {
            tracker.set(kGAIScreenName, value: "MainViewController")
            let builder: NSObject = GAIDictionaryBuilder.createScreenView().build()
            tracker.send(builder as! [NSObject : AnyObject])
        }
    }
    
    func loadVideos() {
        videos = videoManager.getVideos()
        self.tableView.reloadData()
    }
    
    func setupAd() {
        if let admobFile = NSBundle.mainBundle().URLForResource("admob", withExtension: "txt") {
            do {
                let adUnitId = try NSString(contentsOfURL: admobFile, encoding: NSUTF8StringEncoding)
                
                if adUnitId.length > 0 {
                    self.navigationController!.setToolbarHidden(false, animated: false)
                    bannerView = GADBannerView(adSize: kGADAdSizeBanner)
                    bannerView?.adUnitID = adUnitId as String
                    bannerView?.rootViewController = self
                    self.navigationController?.toolbar.addSubview(bannerView!)
                    let request = GADRequest()
                    request.testDevices = [kGADSimulatorID]
                    bannerView?.loadRequest(request)
                }
            } catch _ {
                print("Failed to load ad")
            }
        }
    }
    
    @IBAction func clickOpen(sender: UIBarButtonItem) {
        
        if checkPhotoAccess(sender) {
            let selectAlbumController = self.storyboard!.instantiateViewControllerWithIdentifier("selectAlbum") as!     SelectAlbumController
        
            selectAlbumController.didSelectAsset = didSelectAsset
        
            if let navController = parentViewController as? UINavigationController {
                navController.pushViewController(selectAlbumController, animated: true)
            }
        }
    }<commit_msg>Add another test device<commit_after>/**
 Copyright (c) 2016 <NAME>
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 **/

import UIKit
import MobileCoreServices
import CoreData
import AVFoundation
import Photos
import GoogleMobileAds

class MainViewController: UIViewController, UINavigationControllerDelegate, UITableViewDelegate, UITableViewDataSource {
    
    var videos = [Video]()
    
    @IBOutlet
    var tableView: UITableView!
    
    var selectedAsset: PHAsset?
    
    var bannerView: GADBannerView?
    
    let videoManager = VideoManager()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.title = "Video Info Viewer"
        
        let openButton = UIBarButtonItem()
        openButton.title = "Open"
        openButton.action = #selector(MainViewController.clickOpen(_:))
        openButton.target = self
        
        self.navigationItem.rightBarButtonItem = openButton
        
        self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
        
        self.loadVideos()
        
        setupAd()
    }
    
    override func viewDidAppear(animated:Bool) {
        super.viewDidAppear(animated)
        
        if let tracker = GAI.sharedInstance().defaultTracker {
            tracker.set(kGAIScreenName, value: "MainViewController")
            let builder: NSObject = GAIDictionaryBuilder.createScreenView().build()
            tracker.send(builder as! [NSObject : AnyObject])
        }
    }
    
    func loadVideos() {
        videos = videoManager.getVideos()
        self.tableView.reloadData()
    }
    
    func setupAd() {
        if let admobFile = NSBundle.mainBundle().URLForResource("admob", withExtension: "txt") {
            do {
                let adUnitId = try NSString(contentsOfURL: admobFile, encoding: NSUTF8StringEncoding)
                
                if adUnitId.length > 0 {
                    self.navigationController!.setToolbarHidden(false, animated: false)
                    bannerView = GADBannerView(adSize: kGADAdSizeBanner)
                    bannerView?.adUnitID = adUnitId as String
                    bannerView?.rootViewController = self
                    self.navigationController?.toolbar.addSubview(bannerView!)
                    let request = GADRequest()
                    request.testDevices = [kGADSimulatorID, "23797593a5ec6ac21a727ffb8abfd51c"]
                    bannerView?.loadRequest(request)
                }
            } catch _ {
                print("Failed to load ad")
            }
        }
    }
    
    @IBAction func clickOpen(sender: UIBarButtonItem) {
        
        if checkPhotoAccess(sender) {
            let selectAlbumController = self.storyboard!.instantiateViewControllerWithIdentifier("selectAlbum") as!     SelectAlbumController
        
            selectAlbumController.didSelectAsset = didSelectAsset
        
            if let navController = parentViewController as? UINavigationController {
                navController.pushViewController(selectAlbumController, animated: true)
            }
        }
    }
{'fraction_non_alphanumeric': 0.07136871508379888, 'fraction_numerical': 0.005307262569832402, 'mean_word_length': 2.286369894446994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '1675884', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1789, 'n_words': 464}