<commit_before>//
//  EditorViewController.swift
//  Edhita
//
//  Created by <NAME> on 10/7/14.
//  Copyright (c) 2014 tnantoka. All rights reserved.
//

import UIKit

class EditorViewController: UIViewController, EDHFinderListViewControllerDelegate, MFMailComposeViewControllerDelegate {

    let kToolbarIconSize: CGFloat = 30.0

    var fullscreenItem: UIBarButtonItem!
    var reloadItem: UIBarButtonItem!
    var shareItem: UIBarButtonItem!
    var modeControl: UISegmentedControl!
    var editorView: EditorView!

    var finderItem: EDHFinderItem? {
        didSet {
            self.configureView()
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.edgesForExtendedLayout = .None
        
        self.editorView = EditorView(frame: self.view.bounds)
        self.view.addSubview(self.editorView)
        
        // Toolbar
        self.fullscreenItem = UIBarButtonItem(image: nil, style: .Plain, target: self, action: "fullscreenItemDidTap:")
        self.reloadItem = self.barButtonItem(icon: FAKIonIcons.refreshbeforeionRefreshingIconWithSize(self.kToolbarIconSize), action: "reloadItemDidTap:")
        self.shareItem = self.barButtonItem(icon: FAKIonIcons.shareIconWithSize(self.kToolbarIconSize), action: "shareItemDidTap:")
        let settingsItem = self.barButtonItem(icon: FAKIonIcons.gearAIconWithSize(self.kToolbarIconSize), action: "settingsItemDidTap:")
        let flexibleItem = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil)

        self.toolbarItems = [
            self.fullscreenItem,
            flexibleItem,
            self.reloadItem,
            flexibleItem,
            shareItem,
            flexibleItem,
            settingsItem
        ]
        
        // Right
        self.modeControl = UISegmentedControl(items: [
            NSLocalizedString("Editor", comment: ""),
            NSLocalizedString("Browser", comment: ""),
            NSLocalizedString("Dual", comment: ""),
            ])
        self.modeControl.addTarget(self, action: "modeControlDidChange:", forControlEvents: .ValueChanged)
        self.modeControl.selectedSegmentIndex = 0

        let modeItem = UIBarButtonItem(customView: self.modeControl)
        self.navigationItem.rightBarButtonItem = modeItem

        // Init
        self.finderItem = nil
    }
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        
        self.navigationController?.setToolbarHidden(false, animated: true)

        let notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.addObserver(self, selector: "handleKeyboardWillShowNotification:", name: UIKeyboardWillShowNotification, object: nil)
        notificationCenter.addObserver(self, selector: "handleKeyboardWillHideNotification:", name: UIKeyboardWillHideNotification, object: nil)

        self.modeControlDidChange(self.modeControl)
        self.updateFullscreenItem()
    }

    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)

        let notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
        notificationCenter.removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
        super.didRotateFromInterfaceOrientation(fromInterfaceOrientation)

        // TODO: Should use UISplitViewControllerDelegate
        self.splitViewController?.preferredDisplayMode = .Automatic
        self.updateFullscreenItem()
    }
    
    // MARK: - Actions<commit_msg>Fix deprication warning<commit_after>//
//  EditorViewController.swift
//  Edhita
//
//  Created by <NAME> on 10/7/14.
//  Copyright (c) 2014 tnantoka. All rights reserved.
//

import UIKit

class EditorViewController: UIViewController, EDHFinderListViewControllerDelegate, MFMailComposeViewControllerDelegate {

    let kToolbarIconSize: CGFloat = 30.0

    var fullscreenItem: UIBarButtonItem!
    var reloadItem: UIBarButtonItem!
    var shareItem: UIBarButtonItem!
    var modeControl: UISegmentedControl!
    var editorView: EditorView!

    var finderItem: EDHFinderItem? {
        didSet {
            self.configureView()
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.edgesForExtendedLayout = .None
        
        self.editorView = EditorView(frame: self.view.bounds)
        self.view.addSubview(self.editorView)
        
        // Toolbar
        self.fullscreenItem = UIBarButtonItem(image: nil, style: .Plain, target: self, action: "fullscreenItemDidTap:")
        self.reloadItem = self.barButtonItem(icon: FAKIonIcons.refreshbeforeionRefreshingIconWithSize(self.kToolbarIconSize), action: "reloadItemDidTap:")
        self.shareItem = self.barButtonItem(icon: FAKIonIcons.shareIconWithSize(self.kToolbarIconSize), action: "shareItemDidTap:")
        let settingsItem = self.barButtonItem(icon: FAKIonIcons.gearAIconWithSize(self.kToolbarIconSize), action: "settingsItemDidTap:")
        let flexibleItem = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil)

        self.toolbarItems = [
            self.fullscreenItem,
            flexibleItem,
            self.reloadItem,
            flexibleItem,
            shareItem,
            flexibleItem,
            settingsItem
        ]
        
        // Right
        self.modeControl = UISegmentedControl(items: [
            NSLocalizedString("Editor", comment: ""),
            NSLocalizedString("Browser", comment: ""),
            NSLocalizedString("Dual", comment: ""),
            ])
        self.modeControl.addTarget(self, action: "modeControlDidChange:", forControlEvents: .ValueChanged)
        self.modeControl.selectedSegmentIndex = 0

        let modeItem = UIBarButtonItem(customView: self.modeControl)
        self.navigationItem.rightBarButtonItem = modeItem

        // Init
        self.finderItem = nil
    }
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        
        self.navigationController?.setToolbarHidden(false, animated: true)

        let notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.addObserver(self, selector: "handleKeyboardWillShowNotification:", name: UIKeyboardWillShowNotification, object: nil)
        notificationCenter.addObserver(self, selector: "handleKeyboardWillHideNotification:", name: UIKeyboardWillHideNotification, object: nil)

        self.modeControlDidChange(self.modeControl)
        self.updateFullscreenItem()
    }

    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)

        let notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
        notificationCenter.removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
        super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)

        // TODO: Should use UISplitViewControllerDelegate
        self.splitViewController?.preferredDisplayMode = .Automatic
        self.updateFullscreenItem()
    }
    
    // MARK: - Actions
{'fraction_non_alphanumeric': 0.08451430043803143, 'fraction_numerical': 0.0033496521515073434, 'mean_word_length': 3.151336898395722, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5315901', 'n_tokens_mistral': 2136, 'n_tokens_neox': 2074, 'n_words': 378}