Skip to content

Commit

Permalink
Merge pull request #484 from Jag-Marcel/add-back-english-keyboard
Browse files Browse the repository at this point in the history
Add back English keyboard
  • Loading branch information
andrewtavis authored Aug 16, 2024
2 parents 300e5b6 + dc554ed commit 60192f3
Show file tree
Hide file tree
Showing 22 changed files with 338 additions and 38 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).

# [Upcoming] Scribe-iOS 3.2.0

### ⌨️ New Keyboards

- Adds an English keyboard ([#7](https://github.com/scribe-org/Scribe-iOS/issues/7)).

### ✨ New Features

- Scribe commands can now be triggered directly on a selected word by pressing the Scribe key and then choosing which command to use ([#141](https://github.com/scribe-org/Scribe-iOS/issues/141)).
Expand All @@ -31,6 +35,10 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).

- Localization strings for English, German, Swedish and Spanish have been added for all remaining app texts ([Scribe-i18n#28](https://github.com/scribe-org/Scribe-i18n/issues/28)).

### 🐞 Bug Fixes

- The plural command now reacts to the capitalization of the input word when a word that's already plural is entered.

# Scribe-iOS 3.1.0

### ✨ New Features
Expand Down
2 changes: 1 addition & 1 deletion Keyboards/KeyboardsBase/Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Extensions for Scribe keyboards.
* Extensions with helper functions for Scribe keyboards.
*
* Copyright (C) 2024 Scribe
*
Expand Down
2 changes: 2 additions & 0 deletions Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var controllerLanguageAbbr = String()

// Dictionary for accessing language abbreviations.
let languagesAbbrDict = [
"English": "en",
"French": "fr",
"German": "de",
"Italian": "it",
Expand Down Expand Up @@ -194,6 +195,7 @@ func getControllerLanguageAbbr() -> String {
// Dictionary for accessing keyboard abbreviations and layouts.
let keyboardLayoutDict: [String: () -> Void] = [
// Layouts for French checked within setFRKeyboardLayout.
"English": setENKeyboardLayout,
"French": setFRKeyboardLayout,
"German": setDEKeyboardLayout,
"Italian": setITKeyboardLayout,
Expand Down
14 changes: 12 additions & 2 deletions Keyboards/KeyboardsBase/KeyboardKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ class KeyboardKey: UIButton {
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarReturnKeyWidth).isActive = true
} else if ["123", ".?123", "return", "hideKeyboard"].contains(key) {
if key == "return"
&& (controllerLanguage == "Portuguese" || controllerLanguage == "Italian" || commandState == .translate)
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
)
&& row == 1
&& DeviceType.isPad {
layer.setValue(true, forKey: "isSpecial")
Expand All @@ -303,7 +308,12 @@ class KeyboardKey: UIButton {
widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true
} else if ["123", ".?123", "return", "hideKeyboard"].contains(key) {
if key == "return"
&& (controllerLanguage == "Portuguese" || controllerLanguage == "Italian" || commandState == .translate)
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
)
&& row == 1
&& DeviceType.isPad {
layer.setValue(true, forKey: "isSpecial")
Expand Down
130 changes: 114 additions & 16 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ class KeyboardViewController: UIInputViewController {

if prefix.isNumeric {
completionWords = numericAutosuggestions
} else if ["French", "German", "Spanish"].contains(controllerLanguage) && pronounAutosuggestionTenses.keys.contains(prefix.lowercased()) {
} else if ["English", "French", "German", "Spanish"].contains(controllerLanguage) && pronounAutosuggestionTenses.keys.contains(prefix.lowercased()) {
getPronounAutosuggestions()
} else {
// We have to consider these different cases as the key always has to match.
Expand Down Expand Up @@ -1264,6 +1264,15 @@ class KeyboardViewController: UIInputViewController {
.genitiveDefinite, .genitiveIndefinite, .genitiveDemonstrative
].contains(deCaseDeclensionState) {
formsDisplayDimensions = .view2x2
} else if controllerLanguage == "English" {
switch enConjugationState {
case .present, .presCont, .past, .future, .conditional:
formsDisplayDimensions = .view2x2
case .presSimp, .presPerf, .presPerfCont:
formsDisplayDimensions = .view1x2
case .pastCont:
formsDisplayDimensions = .view3x1
}
} else if commandState == .displayInformation {
formsDisplayDimensions = .view1x1
} else {
Expand Down Expand Up @@ -1423,7 +1432,7 @@ class KeyboardViewController: UIInputViewController {
conjugationStateFxn = conjugationFxn
}

if !["Russian", "Swedish"].contains(controllerLanguage) {
if !["English", "Russian", "Swedish"].contains(controllerLanguage) {
formFPS = conjugationStateFxn() + "FPS"
formSPS = conjugationStateFxn() + "SPS"
formTPS = conjugationStateFxn() + "TPS"
Expand Down Expand Up @@ -1451,6 +1460,24 @@ class KeyboardViewController: UIInputViewController {
formTopRight = swedishTenses[1]
formBottomLeft = swedishTenses[2]
formBottomRight = swedishTenses[3]
} else if controllerLanguage == "English" {
if formsDisplayDimensions == .view2x2 {
let englishTenses = enGetConjugationState()

formTopLeft = englishTenses[0]
formTopRight = englishTenses[1]
formBottomLeft = englishTenses[2]
formBottomRight = englishTenses[3]
} else if formsDisplayDimensions == .view1x2 {
let englishTenses = enGetConjugationState()

formLeft = englishTenses[0]
formRight = englishTenses[1]
} else if formsDisplayDimensions == .view3x1 {
formTop = "presPart"
formMiddle = "pastSimpCont"
formBottom = "pastSimpPluralCont"
}
}
}

Expand Down Expand Up @@ -1481,25 +1508,40 @@ class KeyboardViewController: UIInputViewController {
}

// Assign labels that have been set by SetConjugationLabels function.
// Other labels not assigned as they're not used in conjugation at this time.
formLblFPS.setTitle(" " + (formLabelsDict["FPS"] ?? ""), for: .normal)
formLblSPS.setTitle(" " + (formLabelsDict["SPS"] ?? ""), for: .normal)
formLblTPS.setTitle(" " + (formLabelsDict["TPS"] ?? ""), for: .normal)
formLblFPP.setTitle(" " + (formLabelsDict["FPP"] ?? ""), for: .normal)
formLblSPP.setTitle(" " + (formLabelsDict["SPP"] ?? ""), for: .normal)
formLblTPP.setTitle(" " + (formLabelsDict["TPP"] ?? ""), for: .normal)

formLblTop.setTitle(" " + (formLabelsDict["Top"] ?? ""), for: .normal)
formLblMiddle.setTitle(" " + (formLabelsDict["Middle"] ?? ""), for: .normal)
formLblBottom.setTitle(" " + (formLabelsDict["Bottom"] ?? ""), for: .normal)

formLblTL.setTitle(" " + (formLabelsDict["TL"] ?? ""), for: .normal)
formLblTR.setTitle(" " + (formLabelsDict["TR"] ?? ""), for: .normal)
formLblBL.setTitle(" " + (formLabelsDict["BL"] ?? ""), for: .normal)
formLblBR.setTitle(" " + (formLabelsDict["BR"] ?? ""), for: .normal)

if formsDisplayDimensions == .view3x2 {
formLblLeft.setTitle(" " + (formLabelsDict["Left"] ?? ""), for: .normal)
formLblRight.setTitle(" " + (formLabelsDict["Right"] ?? ""), for: .normal)

switch formsDisplayDimensions {
case .view3x2:
allConjugations = [formFPS, formSPS, formTPS, formFPP, formSPP, formTPP]
allConjugationBtns = get3x2FormDisplayButtons()
} else {
case .view3x1:
allConjugations = [formTop, formMiddle, formBottom]
allConjugationBtns = get3x1FormDisplayButtons()
case .view2x2:
allConjugations = [formTopLeft, formTopRight, formBottomLeft, formBottomRight]
allConjugationBtns = get2x2FormDisplayButtons()
case .view1x2:
allConjugations = [formLeft, formRight]
allConjugationBtns = get1x2FormDisplayButtons()
case .view1x1:
break
}

// Populate conjugation view buttons.
Expand All @@ -1511,8 +1553,28 @@ class KeyboardViewController: UIInputViewController {
styleBtn(btn: allConjugationBtns[index], title: invalidCommandMsg, radius: keyCornerRadius)
} else {
conjugationToDisplay = conjugationsToDisplay[index]
if inputWordIsCapitalized && deConjugationState != .indicativePerfect {
conjugationToDisplay = conjugationToDisplay.capitalized
if controllerLanguage == "English" {
if index == 0 && allConjugations[index] == "presTPS" {
let simple = LanguageDBManager.shared.queryVerb(of: verbToConjugate, with: ["presSimp"])
conjugationToDisplay = simple[0] + "/" + conjugationToDisplay
} else if index == 1 && allConjugations[index] == "presPart" {
if enConjugationState == .present {
conjugationToDisplay = "am/are/is " + conjugationToDisplay
} else {
conjugationToDisplay = "was/were " + conjugationToDisplay
}
} else if index == 3 && allConjugations[index] == "presPerfTPS" {
conjugationToDisplay = "have/" + conjugationToDisplay
} else if index == 3 && allConjugations[index] == "presPerfTPSCont" {
conjugationToDisplay = "have/" + conjugationToDisplay
}
}
if inputWordIsCapitalized {
if controllerLanguage == "English", conjugationToDisplay.count(of: " ") > 0 {
conjugationToDisplay = conjugationToDisplay.capitalize()
} else if deConjugationState != .indicativePerfect {
conjugationToDisplay = conjugationToDisplay.capitalized
}
}
styleBtn(btn: allConjugationBtns[index], title: conjugationToDisplay, radius: keyCornerRadius)
}
Expand Down Expand Up @@ -1653,7 +1715,9 @@ class KeyboardViewController: UIInputViewController {
}
if DeviceType.isPhone
&& key == "a"
&& (controllerLanguage == "Portuguese"
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
|| (
Expand All @@ -1671,7 +1735,8 @@ class KeyboardViewController: UIInputViewController {
&& key == "a"
&& !usingExpandedKeyboard
&& (
controllerLanguage == "Portuguese"
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
) {
Expand All @@ -1681,7 +1746,9 @@ class KeyboardViewController: UIInputViewController {
if DeviceType.isPad
&& key == "@"
&& !usingExpandedKeyboard
&& (controllerLanguage == "Portuguese"
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate) {
leftPadding = keyWidth / 3
Expand All @@ -1690,7 +1757,9 @@ class KeyboardViewController: UIInputViewController {
if DeviceType.isPad
&& key == ""
&& !usingExpandedKeyboard
&& (controllerLanguage == "Portuguese"
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| commandState == .translate) {
leftPadding = keyWidth / 3
addPadding(to: stackView1, width: leftPadding, key: "")
Expand Down Expand Up @@ -1786,7 +1855,9 @@ class KeyboardViewController: UIInputViewController {
}
if DeviceType.isPhone
&& key == "l"
&& (controllerLanguage == "Portuguese"
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
|| (
Expand Down Expand Up @@ -2402,19 +2473,46 @@ class KeyboardViewController: UIInputViewController {
loadKeys()

case "formTopLeft":
returnConjugation(keyPressed: sender, requestedForm: formTopLeft)
if controllerLanguage == "English" && enConjugationState == .present {
enConjugationState = .presSimp
conjViewShiftButtonsState = .bothInactive
} else {
returnConjugation(keyPressed: sender, requestedForm: formTopLeft)
}
loadKeys()

case "formTopRight":
returnConjugation(keyPressed: sender, requestedForm: formTopRight)
if controllerLanguage == "English" {
if enConjugationState == .present {
enConjugationState = .presCont
conjViewShiftButtonsState = .bothInactive
} else if enConjugationState == .past {
enConjugationState = .pastCont
conjViewShiftButtonsState = .bothInactive
} else {
returnConjugation(keyPressed: sender, requestedForm: formTopRight)
}
} else {
returnConjugation(keyPressed: sender, requestedForm: formTopRight)
}
loadKeys()

case "formBottomLeft":
returnConjugation(keyPressed: sender, requestedForm: formBottomLeft)
if controllerLanguage == "English" && enConjugationState == .present {
enConjugationState = .presPerf
conjViewShiftButtonsState = .bothInactive
} else {
returnConjugation(keyPressed: sender, requestedForm: formBottomLeft)
}
loadKeys()

case "formBottomRight":
returnConjugation(keyPressed: sender, requestedForm: formBottomRight)
if controllerLanguage == "English" && enConjugationState == .present {
enConjugationState = .presPerfCont
conjViewShiftButtonsState = .bothInactive
} else {
returnConjugation(keyPressed: sender, requestedForm: formBottomRight)
}
loadKeys()

case "formLeft":
Expand Down
4 changes: 2 additions & 2 deletions Keyboards/KeyboardsBase/LanguageDBManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ extension LanguageDBManager {
word = ?
"""
let args = [word]
let outputCols = ["suggestion_0", "suggestion_1", "suggestion_2"]
let outputCols = ["autosuggestion_0", "autosuggestion_1", "autosuggestion_2"]

return queryDBRow(query: query, outputCols: outputCols, args: StatementArguments(args))
}
Expand All @@ -267,7 +267,7 @@ extension LanguageDBManager {
WHERE
word = ?
"""
let outputCols = ["emoji_0", "emoji_1", "emoji_2"]
let outputCols = ["emoji_keyword_0", "emoji_keyword_1", "emoji_keyword_2"]
let args = [word]

return queryDBRow(query: query, outputCols: outputCols, args: StatementArguments(args))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ var formLabelsDict = [
"SPP": "",
"TPP": "",
"Top": "",
"Bottom": "",
"Middle": "",
"Bottom": "",
"TL": "",
"TR": "",
"BL": "",
Expand Down
Loading

0 comments on commit 60192f3

Please sign in to comment.