From 5ae18e98388568f0ca251a8abbfcb8d947da896c Mon Sep 17 00:00:00 2001 From: henrikth93 Date: Sun, 17 Sep 2023 23:24:37 +0200 Subject: [PATCH 1/3] My first commit Made some changes - I am not completely done - but this is a first draft. --- .../KeyboardsBase/InterfaceVariables.swift | 3 ++- .../KeyboardsBase/KeyboardViewController.swift | 17 +++++++++++++++++ .../Swedish/SVInterfaceVariables.swift | 15 ++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Keyboards/KeyboardsBase/InterfaceVariables.swift b/Keyboards/KeyboardsBase/InterfaceVariables.swift index 1a083081..e66bd089 100644 --- a/Keyboards/KeyboardsBase/InterfaceVariables.swift +++ b/Keyboards/KeyboardsBase/InterfaceVariables.swift @@ -10,7 +10,8 @@ import UIKit var proxy: UITextDocumentProxy! // MARK: Display Variables - +public var hasHomeButton = false; +public var isWideEnough = false; // Variables for the keyboard and its appearance. var keyboard = [[String]]() var allKeys = [String]() diff --git a/Keyboards/KeyboardsBase/KeyboardViewController.swift b/Keyboards/KeyboardsBase/KeyboardViewController.swift index 5b12dc90..389f2fcd 100644 --- a/Keyboards/KeyboardsBase/KeyboardViewController.swift +++ b/Keyboards/KeyboardsBase/KeyboardViewController.swift @@ -1591,6 +1591,23 @@ class KeyboardViewController: UIInputViewController { } catch {} } + //Check if ipad device meets the criteria for expanded keyboard + if DeviceType.isPad { + //Check if device has home button, this will be used later to determine if we should use expanded keypad or not. + if #available(iOS 13.0, *), keyboardView.safeAreaInsets.bottom > 0 { + hasHomeButton = true; + } + else + { + hasHomeButton = false; + } //If the width is below 768 px we should not use the expanded keys + if #available(iOS 13.0, *), UIScreen.main.bounds.width > 768 { + isWideEnough = true; + } + else { + isWideEnough = false; + } + setKeyboard() setCommaAndPeriodKeysConditionally() setCommandBackground() diff --git a/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift b/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift index 8e95b512..a674a333 100644 --- a/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift @@ -98,9 +98,18 @@ func getSVKeys() { rightKeyChars = ["å", "ä", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = SwedishKeyboardConstants.letterKeysPad - numberKeys = SwedishKeyboardConstants.numberKeysPad - symbolKeys = SwedishKeyboardConstants.symbolKeysPad + //if the iPad is wide enough, and has no home button, use the expanded keys + if (!hasHomeButton && isWideEnough) { + letterKeys = SwedishKeyboardConstants.letterKeysPadExpanded + numberKeys = SwedishKeyboardConstants.numberKeysPad + symbolKeys = SwedishKeyboardConstants.symbolKeysPadExpanded + } + else + { + letterKeys = SwedishKeyboardConstants.letterKeysPad + numberKeys = SwedishKeyboardConstants.numberKeysPad + symbolKeys = SwedishKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) From 28935af0f47371b9e6bdd80813c9811793c412f8 Mon Sep 17 00:00:00 2001 From: henrikth93 Date: Thu, 21 Sep 2023 08:51:41 +0200 Subject: [PATCH 2/3] Changed the code to use ternary statements instead of if/else --- .../KeyboardsBase/InterfaceVariables.swift | 4 +-- .../KeyboardViewController.swift | 34 +++++++++---------- .../English/ENInterfaceVariables.swift | 15 +++++--- .../French/FR-AZERTYInterfaceVariables.swift | 15 +++++--- .../French/FR-QWERTYInterfaceVariables.swift | 14 ++++++-- .../German/DEInterfaceVariables.swift | 14 ++++++-- .../Italian/ITInterfaceVariables.swift | 14 ++++++-- .../Portuguese/PTInterfaceVariables.swift | 14 ++++++-- .../Russian/RUInterfaceVariables.swift | 14 ++++++-- .../Spanish/ESInterfaceVariables.swift | 15 ++++++-- .../Swedish/SVInterfaceVariables.swift | 7 ++-- 11 files changed, 110 insertions(+), 50 deletions(-) diff --git a/Keyboards/KeyboardsBase/InterfaceVariables.swift b/Keyboards/KeyboardsBase/InterfaceVariables.swift index e66bd089..e65b56fa 100644 --- a/Keyboards/KeyboardsBase/InterfaceVariables.swift +++ b/Keyboards/KeyboardsBase/InterfaceVariables.swift @@ -10,9 +10,9 @@ import UIKit var proxy: UITextDocumentProxy! // MARK: Display Variables -public var hasHomeButton = false; -public var isWideEnough = false; + // Variables for the keyboard and its appearance. +public var usingExpandedKeyboard = false; var keyboard = [[String]]() var allKeys = [String]() let specialKeys = [ diff --git a/Keyboards/KeyboardsBase/KeyboardViewController.swift b/Keyboards/KeyboardsBase/KeyboardViewController.swift index 389f2fcd..90be48e3 100644 --- a/Keyboards/KeyboardsBase/KeyboardViewController.swift +++ b/Keyboards/KeyboardsBase/KeyboardViewController.swift @@ -17,6 +17,7 @@ class KeyboardViewController: UIInputViewController { @IBOutlet var stackView1: UIStackView! @IBOutlet var stackView2: UIStackView! @IBOutlet var stackView3: UIStackView! + @IBOutlet var stackView4: UIStackView! //Used for expanded keyboard private var tipView: ToolTipView? @@ -1592,21 +1593,16 @@ class KeyboardViewController: UIInputViewController { } //Check if ipad device meets the criteria for expanded keyboard - if DeviceType.isPad { - //Check if device has home button, this will be used later to determine if we should use expanded keypad or not. - if #available(iOS 13.0, *), keyboardView.safeAreaInsets.bottom > 0 { - hasHomeButton = true; - } - else - { - hasHomeButton = false; - } //If the width is below 768 px we should not use the expanded keys - if #available(iOS 13.0, *), UIScreen.main.bounds.width > 768 { - isWideEnough = true; - } - else { - isWideEnough = false; - } + if DeviceType.isPad { + //Check if device has home button, this will be used later to determine if we should use expanded keypad or not. + if #available(iOS 13.0, *), (keyboardView.safeAreaInsets.bottom <= 0 && UIScreen.main.bounds.width > 768) { + usingExpandedKeyboard = true; + } + else + { + usingExpandedKeyboard = false; + } + } setKeyboard() setCommaAndPeriodKeysConditionally() @@ -1637,7 +1633,8 @@ class KeyboardViewController: UIInputViewController { } } else { letterKeyWidth = (UIScreen.main.bounds.width - 6) / CGFloat(letterKeys[0].count) * 0.9 - numSymKeyWidth = (UIScreen.main.bounds.width - 6) / CGFloat(numberKeys[0].count) * 0.9 + //If we are using expanded keys the numberKeys array is empty, we use symbolKeys + numSymKeyWidth = (UIScreen.main.bounds.width - 6) / CGFloat( (usingExpandedKeyboard) == true ? symbolKeys[0].count: numberKeys[0].count) * 0.9 } // Derive keyboard given current states and set widths. @@ -1927,7 +1924,7 @@ class KeyboardViewController: UIInputViewController { } else { widthOfSpacing = ( (UIScreen.main.bounds.width - 6.0) - - (CGFloat(numberKeys[0].count) * numSymKeyWidth) + - (CGFloat((usingExpandedKeyboard) == true ? symbolKeys[0].count : numberKeys[0].count) * numSymKeyWidth) ) / (CGFloat(letterKeys[0].count) - 1.0 ) @@ -2471,7 +2468,8 @@ class KeyboardViewController: UIInputViewController { capsLockPossible = true case "123", ".?123": - changeKeyboardToNumberKeys() + (usingExpandedKeyboard) == true ? changeKeyboardToSymbolKeys() : changeKeyboardToNumberKeys() + case "#+=": changeKeyboardToSymbolKeys() diff --git a/Keyboards/LanguageKeyboards/English/ENInterfaceVariables.swift b/Keyboards/LanguageKeyboards/English/ENInterfaceVariables.swift index c312d7bf..77977551 100644 --- a/Keyboards/LanguageKeyboards/English/ENInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/English/ENInterfaceVariables.swift @@ -98,10 +98,17 @@ func getENKeys() { rightKeyChars = ["p", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = EnglishKeyboardConstants.letterKeysPad - numberKeys = EnglishKeyboardConstants.numberKeysPad - symbolKeys = EnglishKeyboardConstants.symbolKeysPad - + if (usingExpandedKeyboard) + { + letterKeys = EnglishKeyboardConstants.letterKeysPadExpanded; + symbolKeys = EnglishKeyboardConstants.symbolKeysPadExpanded; + } + else + { + letterKeys = EnglishKeyboardConstants.letterKeysPad + numberKeys = EnglishKeyboardConstants.numberKeysPad + symbolKeys = EnglishKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) letterKeys[0].append("delete") diff --git a/Keyboards/LanguageKeyboards/French/FR-AZERTYInterfaceVariables.swift b/Keyboards/LanguageKeyboards/French/FR-AZERTYInterfaceVariables.swift index 0128e836..77612141 100644 --- a/Keyboards/LanguageKeyboards/French/FR-AZERTYInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/French/FR-AZERTYInterfaceVariables.swift @@ -96,10 +96,17 @@ func getFRKeys() { rightKeyChars = ["p", "m", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = FrenchKeyboardConstants.letterKeysPad - numberKeys = FrenchKeyboardConstants.numberKeysPad - symbolKeys = FrenchKeyboardConstants.symbolKeysPad - + if (usingExpandedKeyboard) + { + letterKeys = FrenchKeyboardConstants.letterKeysPadExpanded; + symbolKeys = FrenchKeyboardConstants.symbolKeysPadExpanded; + } + else + { + letterKeys = FrenchKeyboardConstants.letterKeysPad + numberKeys = FrenchKeyboardConstants.numberKeysPad + symbolKeys = FrenchKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) letterKeys[0].append("delete") diff --git a/Keyboards/LanguageKeyboards/French/FR-QWERTYInterfaceVariables.swift b/Keyboards/LanguageKeyboards/French/FR-QWERTYInterfaceVariables.swift index 5fcb55ad..c74c2d55 100644 --- a/Keyboards/LanguageKeyboards/French/FR-QWERTYInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/French/FR-QWERTYInterfaceVariables.swift @@ -94,9 +94,17 @@ func getFRQWERTYKeys() { rightKeyChars = ["p", "m", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = FrenchQWERTYKeyboardConstants.letterKeysPad - numberKeys = FrenchQWERTYKeyboardConstants.numberKeysPad - symbolKeys = FrenchQWERTYKeyboardConstants.symbolKeysPad + if (usingExpandedKeyboard) + { + letterKeys = FrenchQWERTYKeyboardConstants.letterKeysPadExpanded; + symbolKeys = FrenchQWERTYKeyboardConstants.symbolKeysPadExpanded; + } + else + { + letterKeys = FrenchQWERTYKeyboardConstants.letterKeysPad + numberKeys = FrenchQWERTYKeyboardConstants.numberKeysPad + symbolKeys = FrenchQWERTYKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) diff --git a/Keyboards/LanguageKeyboards/German/DEInterfaceVariables.swift b/Keyboards/LanguageKeyboards/German/DEInterfaceVariables.swift index 2c7e9bed..f88d9a0c 100644 --- a/Keyboards/LanguageKeyboards/German/DEInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/German/DEInterfaceVariables.swift @@ -99,9 +99,17 @@ func getDEKeys() { rightKeyChars = ["ü", "ä", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = GermanKeyboardConstants.letterKeysPad - numberKeys = GermanKeyboardConstants.numberKeysPad - symbolKeys = GermanKeyboardConstants.symbolKeysPad + if (usingExpandedKeyboard) + { + letterKeys = GermanKeyboardConstants.letterKeysPadExpanded; + symbolKeys = GermanKeyboardConstants.symbolKeysPadExpanded; + } + else + { + letterKeys = GermanKeyboardConstants.letterKeysPad + numberKeys = GermanKeyboardConstants.numberKeysPad + symbolKeys = GermanKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) diff --git a/Keyboards/LanguageKeyboards/Italian/ITInterfaceVariables.swift b/Keyboards/LanguageKeyboards/Italian/ITInterfaceVariables.swift index 690cbc3e..10196e8f 100644 --- a/Keyboards/LanguageKeyboards/Italian/ITInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/Italian/ITInterfaceVariables.swift @@ -96,9 +96,17 @@ func getITKeys() { rightKeyChars = ["p", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = ItalianKeyboardConstants.letterKeysPad - numberKeys = ItalianKeyboardConstants.numberKeysPad - symbolKeys = ItalianKeyboardConstants.symbolKeysPad + if (usingExpandedKeyboard) + { + letterKeys = ItalianKeyboardConstants.letterKeysPadExpanded; + symbolKeys = ItalianKeyboardConstants.symbolKeysPadExpanded; + } + else + { + letterKeys = ItalianKeyboardConstants.letterKeysPad + numberKeys = ItalianKeyboardConstants.numberKeysPad + symbolKeys = ItalianKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) diff --git a/Keyboards/LanguageKeyboards/Portuguese/PTInterfaceVariables.swift b/Keyboards/LanguageKeyboards/Portuguese/PTInterfaceVariables.swift index f8cf9f42..0ca49084 100644 --- a/Keyboards/LanguageKeyboards/Portuguese/PTInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/Portuguese/PTInterfaceVariables.swift @@ -95,9 +95,17 @@ func getPTKeys() { rightKeyChars = ["p", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = PortugueseKeyboardConstants.letterKeysPad - numberKeys = PortugueseKeyboardConstants.numberKeysPad - symbolKeys = PortugueseKeyboardConstants.symbolKeysPad + if (usingExpandedKeyboard) + { + letterKeys = PortugueseKeyboardConstants.letterKeysPadExpanded; + symbolKeys = PortugueseKeyboardConstants.symbolKeysPadExpanded; + } + else + { + letterKeys = PortugueseKeyboardConstants.letterKeysPad + numberKeys = PortugueseKeyboardConstants.numberKeysPad + symbolKeys = PortugueseKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) diff --git a/Keyboards/LanguageKeyboards/Russian/RUInterfaceVariables.swift b/Keyboards/LanguageKeyboards/Russian/RUInterfaceVariables.swift index 5385f3f1..47620d9a 100644 --- a/Keyboards/LanguageKeyboards/Russian/RUInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/Russian/RUInterfaceVariables.swift @@ -90,9 +90,17 @@ func getRUKeys() { rightKeyChars = ["х", "э", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = RussianKeyboardConstants.letterKeysPad - numberKeys = RussianKeyboardConstants.numberKeysPad - symbolKeys = RussianKeyboardConstants.symbolKeysPad + if(usingExpandedKeyboard) + { + letterKeys = RussianKeyboardConstants.letterKeysPadExpanded; + letterKeys = RussianKeyboardConstants.symbolKeysPadExpanded; + } + else + { + letterKeys = RussianKeyboardConstants.letterKeysPad + numberKeys = RussianKeyboardConstants.numberKeysPad + symbolKeys = RussianKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) diff --git a/Keyboards/LanguageKeyboards/Spanish/ESInterfaceVariables.swift b/Keyboards/LanguageKeyboards/Spanish/ESInterfaceVariables.swift index bbeb32ae..207baa34 100644 --- a/Keyboards/LanguageKeyboards/Spanish/ESInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/Spanish/ESInterfaceVariables.swift @@ -97,9 +97,18 @@ func getESKeys() { rightKeyChars = ["p", "ñ", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - letterKeys = SpanishKeyboardConstants.letterKeysPad - numberKeys = SpanishKeyboardConstants.numberKeysPad - symbolKeys = SpanishKeyboardConstants.symbolKeysPad + //if the iPad is wide enough, and has no home button, use the expanded keys + if(usingExpandedKeyboard) + { + letterKeys = SpanishKeyboardConstants.letterKeysPadExpanded; + symbolKeys = SpanishKeyboardConstants.symbolKeysPadExpanded; + } + else + { + letterKeys = SpanishKeyboardConstants.letterKeysPad + numberKeys = SpanishKeyboardConstants.numberKeysPad + symbolKeys = SpanishKeyboardConstants.symbolKeysPad + } // If the iPad is too small to have a numbers row. letterKeys.removeFirst(1) diff --git a/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift b/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift index a674a333..41f98389 100644 --- a/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift @@ -98,10 +98,9 @@ func getSVKeys() { rightKeyChars = ["å", "ä", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } else { - //if the iPad is wide enough, and has no home button, use the expanded keys - if (!hasHomeButton && isWideEnough) { + //if the iPad is wide enough, and has no home button, use the expanded keys + if (usingExpandedKeyboard) { letterKeys = SwedishKeyboardConstants.letterKeysPadExpanded - numberKeys = SwedishKeyboardConstants.numberKeysPad symbolKeys = SwedishKeyboardConstants.symbolKeysPadExpanded } else @@ -112,7 +111,7 @@ func getSVKeys() { } // If the iPad is too small to have a numbers row. - letterKeys.removeFirst(1) + //letterKeys.removeFirst(1) letterKeys[0].append("delete") allKeys = Array(letterKeys.joined()) + Array(numberKeys.joined()) + Array(symbolKeys.joined()) From 210536838977dca651d536c24d5a71fcb7fde50b Mon Sep 17 00:00:00 2001 From: henrikth93 Date: Fri, 22 Sep 2023 19:55:54 +0200 Subject: [PATCH 3/3] Uncommented a line that removes the numbers row --- Keyboards/KeyboardsBase/KeyboardViewController.swift | 2 +- Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Keyboards/KeyboardsBase/KeyboardViewController.swift b/Keyboards/KeyboardsBase/KeyboardViewController.swift index 90be48e3..eba25a8c 100644 --- a/Keyboards/KeyboardsBase/KeyboardViewController.swift +++ b/Keyboards/KeyboardsBase/KeyboardViewController.swift @@ -17,7 +17,7 @@ class KeyboardViewController: UIInputViewController { @IBOutlet var stackView1: UIStackView! @IBOutlet var stackView2: UIStackView! @IBOutlet var stackView3: UIStackView! - @IBOutlet var stackView4: UIStackView! //Used for expanded keyboard + private var tipView: ToolTipView? diff --git a/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift b/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift index 41f98389..9bdd6fa5 100644 --- a/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift @@ -111,7 +111,7 @@ func getSVKeys() { } // If the iPad is too small to have a numbers row. - //letterKeys.removeFirst(1) + letterKeys.removeFirst(1) letterKeys[0].append("delete") allKeys = Array(letterKeys.joined()) + Array(numberKeys.joined()) + Array(symbolKeys.joined())