From 729be6f02f8683266cb36acec87e2051abe7b4ab Mon Sep 17 00:00:00 2001 From: henrikth93 Date: Wed, 25 Oct 2023 20:39:51 +0200 Subject: [PATCH 1/3] Add new functionality that removes the remove accent key-option on certain languages --- Keyboards/KeyboardsBase/InterfaceVariables.swift | 1 + .../ParentTableViewCell/ParentTableViewCell.swift | 5 +++++ .../Components/TableViewTemplateViewController.swift | 2 +- Scribe/SettingsTab/SettingsTableData.swift | 10 ++++++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Keyboards/KeyboardsBase/InterfaceVariables.swift b/Keyboards/KeyboardsBase/InterfaceVariables.swift index 78edcfb9..30089ae6 100644 --- a/Keyboards/KeyboardsBase/InterfaceVariables.swift +++ b/Keyboards/KeyboardsBase/InterfaceVariables.swift @@ -125,6 +125,7 @@ let languagesAbbrDict = [ "Swedish": "sv", ] + /// Returns the abbreviation of the language for use in commands. func getControllerLanguageAbbr() -> String { guard let abbreviation = languagesAbbrDict[controllerLanguage] else { diff --git a/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift b/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift index 5130d719..801be115 100644 --- a/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift +++ b/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift @@ -133,6 +133,11 @@ extension ParentTableViewCell: UITableViewDelegate { case .appLang: break case .specificLang: if let viewController = parentViewController?.storyboard?.instantiateViewController(identifier: "TableViewTemplateViewController") as? TableViewTemplateViewController { + let accentKeyLanguages: [String] = ["Swedish", "German", "Spanish"]; //Languages where we can disable accent keys + if (accentKeyLanguages.firstIndex(of: section.sectionTitle) == nil) + { + SettingsTableData.languageSettingsData[0].section.remove(at: 1) //If there are no accent keys we remove the option. + } viewController.configureTable(for: SettingsTableData.languageSettingsData, parentSection: section) parentViewController?.navigationController?.pushViewController(viewController, animated: true) diff --git a/Scribe/Components/TableViewTemplateViewController.swift b/Scribe/Components/TableViewTemplateViewController.swift index 587ee0dd..ff4dfdbb 100644 --- a/Scribe/Components/TableViewTemplateViewController.swift +++ b/Scribe/Components/TableViewTemplateViewController.swift @@ -7,7 +7,7 @@ import UIKit class TableViewTemplateViewController: UIViewController { @IBOutlet var mainTable: UITableView! - var screenTitle: String = "" + var screenTitle: String = "" var tableData: [ParentTableCellModel] = [] var parentSection: Section? diff --git a/Scribe/SettingsTab/SettingsTableData.swift b/Scribe/SettingsTab/SettingsTableData.swift index cc268f53..26ac6b10 100644 --- a/Scribe/SettingsTab/SettingsTableData.swift +++ b/Scribe/SettingsTab/SettingsTableData.swift @@ -21,7 +21,7 @@ struct SettingsTableData { hasDynamicData: .installedKeyboards ), ] - + static var languageSettingsData: [ParentTableCellModel] = [ ParentTableCellModel( headingTitle: "Layout", @@ -32,12 +32,12 @@ struct SettingsTableData { hasToggle: true, sectionState: .none(.toggleCommaAndPeriod) ), - Section( + Section( sectionTitle: "Disable accent characters", imageString: "info.circle", hasToggle: true, sectionState: .none(.toggleAccentCharacters) - ), + ) ], hasDynamicData: nil ), @@ -54,7 +54,7 @@ struct SettingsTableData { hasDynamicData: nil ) ] - + static func getInstalledKeyboardsSections() -> [Section] { var installedKeyboards = [String]() @@ -86,3 +86,5 @@ struct SettingsTableData { return sections } } + + From d1dc9f461af1f180bf86c3e3dd909ba81eacc879 Mon Sep 17 00:00:00 2001 From: henrikth93 Date: Wed, 25 Oct 2023 20:45:55 +0200 Subject: [PATCH 2/3] Add functionality that removes the disable accent-key option from certain languages --- .../Components/ParentTableViewCell/ParentTableViewCell.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift b/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift index 5130d719..801be115 100644 --- a/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift +++ b/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift @@ -133,6 +133,11 @@ extension ParentTableViewCell: UITableViewDelegate { case .appLang: break case .specificLang: if let viewController = parentViewController?.storyboard?.instantiateViewController(identifier: "TableViewTemplateViewController") as? TableViewTemplateViewController { + let accentKeyLanguages: [String] = ["Swedish", "German", "Spanish"]; //Languages where we can disable accent keys + if (accentKeyLanguages.firstIndex(of: section.sectionTitle) == nil) + { + SettingsTableData.languageSettingsData[0].section.remove(at: 1) //If there are no accent keys we remove the option. + } viewController.configureTable(for: SettingsTableData.languageSettingsData, parentSection: section) parentViewController?.navigationController?.pushViewController(viewController, animated: true) From ec65b3797c7bf618889b7de4d12dc2bdc737be60 Mon Sep 17 00:00:00 2001 From: henrikth93 Date: Wed, 1 Nov 2023 22:05:16 +0100 Subject: [PATCH 3/3] Will add or remove the disable accent key-function depending on keyboard language --- .../ParentTableViewCell/ParentTableViewCell.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift b/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift index 801be115..c71306a1 100644 --- a/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift +++ b/Scribe/Components/ParentTableViewCell/ParentTableViewCell.swift @@ -134,9 +134,19 @@ extension ParentTableViewCell: UITableViewDelegate { case .specificLang: if let viewController = parentViewController?.storyboard?.instantiateViewController(identifier: "TableViewTemplateViewController") as? TableViewTemplateViewController { let accentKeyLanguages: [String] = ["Swedish", "German", "Spanish"]; //Languages where we can disable accent keys - if (accentKeyLanguages.firstIndex(of: section.sectionTitle) == nil) + let accentKeyOptionIndex = SettingsTableData.languageSettingsData[0].section.firstIndex(where: {s in s.sectionTitle.elementsEqual("Disable accent characters")}) ?? -1 + if (accentKeyLanguages.firstIndex(of: section.sectionTitle) == nil && accentKeyOptionIndex != -1) + { + let accentKeySettings = SettingsTableData.languageSettingsData[0].section.remove(at: accentKeyOptionIndex )//since there are no accent keys we can remove the option. + print(accentKeySettings) + } + else if (accentKeyLanguages.firstIndex(of: section.sectionTitle) != nil && accentKeyOptionIndex == -1) { - SettingsTableData.languageSettingsData[0].section.remove(at: 1) //If there are no accent keys we remove the option. + SettingsTableData.languageSettingsData[0].section.insert(Section( + sectionTitle: "Disable accent characters", + imageString: "info.circle", + hasToggle: true, + sectionState: .none(.toggleAccentCharacters)), at: 1) } viewController.configureTable(for: SettingsTableData.languageSettingsData, parentSection: section)