Skip to content

Commit

Permalink
Merge pull request #360 from henrikth93/henrikth93-#352
Browse files Browse the repository at this point in the history
My first commit
  • Loading branch information
andrewtavis committed Oct 16, 2023
2 parents 86da6eb + 2105368 commit 861efbf
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 32 deletions.
1 change: 1 addition & 0 deletions Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var proxy: UITextDocumentProxy!
// MARK: Display Variables

// Variables for the keyboard and its appearance.
public var usingExpandedKeyboard = false;
var keyboard = [[String]]()
var allKeys = [String]()
let specialKeys = [
Expand Down
21 changes: 18 additions & 3 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class KeyboardViewController: UIInputViewController {
@IBOutlet var stackView2: UIStackView!
@IBOutlet var stackView3: UIStackView!


private var tipView: ToolTipView?

/// Changes the height of `stackViewNum` depending on device type and size.
Expand Down Expand Up @@ -1591,6 +1592,18 @@ 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 && UIScreen.main.bounds.width > 768) {
usingExpandedKeyboard = true;
}
else
{
usingExpandedKeyboard = false;
}
}

setKeyboard()
setCommaAndPeriodKeysConditionally()
setCommandBackground()
Expand Down Expand Up @@ -1620,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.
Expand Down Expand Up @@ -1910,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
)
Expand Down Expand Up @@ -2454,7 +2468,8 @@ class KeyboardViewController: UIInputViewController {
capsLockPossible = true

case "123", ".?123":
changeKeyboardToNumberKeys()
(usingExpandedKeyboard) == true ? changeKeyboardToSymbolKeys() : changeKeyboardToNumberKeys()


case "#+=":
changeKeyboardToSymbolKeys()
Expand Down
15 changes: 11 additions & 4 deletions Keyboards/LanguageKeyboards/English/ENInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions Keyboards/LanguageKeyboards/German/DEInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions Keyboards/LanguageKeyboards/Italian/ITInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions Keyboards/LanguageKeyboards/Portuguese/PTInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions Keyboards/LanguageKeyboards/Russian/RUInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 12 additions & 3 deletions Keyboards/LanguageKeyboards/Spanish/ESInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions Keyboards/LanguageKeyboards/Swedish/SVInterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ 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 (usingExpandedKeyboard) {
letterKeys = SwedishKeyboardConstants.letterKeysPadExpanded
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)
Expand Down

0 comments on commit 861efbf

Please sign in to comment.