<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import Foundation
import Shared

@available(iOS 11.0, *)
class ContentBlockerSettingsTableView: SettingsTableViewController {
    // The first section header gets a More Info link
    override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        if section == 0 {
            return super.tableView(tableView, viewForFooterInSection: section)
        }

        // TODO: Get a dedicated string for this.
        let title = NSLocalizedString("More Info…", tableName: "SendAnonymousUsageData", comment: "Re-using more info label from 'anonymous usage data' item for showing a 'More Info' link on the Tracking Protection settings screen.")

        var attributes = [String: AnyObject]()
        attributes[NSFontAttributeName] = UIFont.systemFont(ofSize: 12, weight: UIFontWeightRegular)
        attributes[NSForegroundColorAttributeName] = UIConstants.HighlightBlue

        let button = UIButton()
        button.setAttributedTitle(NSAttributedString(string: title, attributes: attributes), for: .normal)
        button.contentHorizontalAlignment = .left
        // Top and left insets are needed to match the table row style.
        button.contentEdgeInsets = UIEdgeInsets(top: 8, left: 16, bottom: 0, right: 0)
        button.addTarget(self, action: #selector(moreInfoTapped), for: .touchUpInside)
        return button
    }

    func moreInfoTapped() {
        let viewController = SettingsContentViewController()
        viewController.url = SupportUtils.URLForTopic("tracking-protection-ios")
        navigationController?.pushViewController(viewController, animated: true)
    }
}

@available(iOS 11.0, *)
extension BlockingStrength {
    var settingTitle: String {
        switch self {
        case .basic:
            return Strings.TrackingProtectionOptionBlockListTypeBasic
        case .strict:
            return Strings.TrackingProtectionOptionBlockListTypeStrict
        }
    }

    var subtitle: String {
        switch self {
        case .basic:
            return Strings.TrackingProtectionOptionBlockListTypeBasicDescription
        case .strict:
            return Strings.TrackingProtectionOptionBlockListTypeStrictDescription
        }
    }

    static func accessibilityId(for strength: BlockingStrength) -> String {<commit_msg>Bug 1443413 - [RTL] Tracking Protection settings - More Info link should be right aligned (#3713)<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import Foundation
import Shared

@available(iOS 11.0, *)
class ContentBlockerSettingsTableView: SettingsTableViewController {
    // The first section header gets a More Info link
    override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        if section == 0 {
            return super.tableView(tableView, viewForFooterInSection: section)
        }

        // TODO: Get a dedicated string for this.
        let title = NSLocalizedString("More Info…", tableName: "SendAnonymousUsageData", comment: "Re-using more info label from 'anonymous usage data' item for showing a 'More Info' link on the Tracking Protection settings screen.")

        var attributes = [String: AnyObject]()
        attributes[NSFontAttributeName] = UIFont.systemFont(ofSize: 12, weight: UIFontWeightRegular)
        attributes[NSForegroundColorAttributeName] = UIConstants.HighlightBlue

        let button = UIButton()
        button.setAttributedTitle(NSAttributedString(string: title, attributes: attributes), for: .normal)
        button.addTarget(self, action: #selector(moreInfoTapped), for: .touchUpInside)

        let footer = UIView()
        footer.addSubview(button)
        button.snp.makeConstraints { (make) in
            make.top.equalTo(footer).offset(8)
            make.bottom.equalTo(footer).offset(8)
            make.leading.equalTo(footer).offset(16)
        }

        return footer
    }

    func moreInfoTapped() {
        let viewController = SettingsContentViewController()
        viewController.url = SupportUtils.URLForTopic("tracking-protection-ios")
        navigationController?.pushViewController(viewController, animated: true)
    }
}

@available(iOS 11.0, *)
extension BlockingStrength {
    var settingTitle: String {
        switch self {
        case .basic:
            return Strings.TrackingProtectionOptionBlockListTypeBasic
        case .strict:
            return Strings.TrackingProtectionOptionBlockListTypeStrict
        }
    }

    var subtitle: String {
        switch self {
        case .basic:
            return Strings.TrackingProtectionOptionBlockListTypeBasicDescription
        case .strict:
            return Strings.TrackingProtectionOptionBlockListTypeStrictDescription
        }
    }

    static func accessibilityId(for strength: BlockingStrength) -> String {
{'fraction_non_alphanumeric': 0.0794995187680462, 'fraction_numerical': 0.008854667949951878, 'mean_word_length': 3.146847565841979, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '534782', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1328, 'n_words': 400}