Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ let languagesAbbrDict = [
"English": "en",
"French": "fr",
"German": "de",
"Indonesian": "id",
"Italian": "it",
"Norwegian": "nb",
"Portuguese": "pt",
Expand All @@ -157,6 +158,7 @@ let languagesStringDict = [
"English": NSLocalizedString("app._global.english", value: "English", comment: ""),
"French": NSLocalizedString("app._global.french", value: "French", comment: ""),
"German": NSLocalizedString("app._global.german", value: "German", comment: ""),
"Indonesian": NSLocalizedString("app._global.indonesian", value: "Indonesian", comment: ""),
"Italian": NSLocalizedString("app._global.italian", value: "Italian", comment: ""),
"Portuguese": NSLocalizedString("app._global.portuguese", value: "Portuguese", comment: ""),
"Russian": NSLocalizedString("app._global.russian", value: "Russian", comment: ""),
Expand Down Expand Up @@ -196,6 +198,7 @@ let keyboardLayoutDict: [String: () -> Void] = [
"English": setENKeyboardLayout,
"French": setFRKeyboardLayout,
"German": setDEKeyboardLayout,
"Indonesian": setIDKeyboardLayout,
"Italian": setITKeyboardLayout,
"Portuguese": setPTKeyboardLayout,
"Russian": setRUKeyboardLayout,
Expand Down
57 changes: 39 additions & 18 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ class KeyboardViewController: UIInputViewController {
rightAutoPartition.backgroundColor = .clear
}

// Toggles visibility of the Conjugate and Plural buttons.
func hideConjugateAndPluralKeys(state: Bool) {
conjugateKey.isHidden = state
pluralKey.isHidden = state
}

// Logic to create notification tooltip.
func createInformationStateDatasource(text: NSMutableAttributedString, backgroundColor: UIColor) -> ToolTipViewDatasource {
let theme = ToolTipViewTheme(backgroundColor: backgroundColor, textFont: nil, textColor: keyCharColor, textAlignment: .center, cornerRadius: 10, masksToBounds: true)
Expand Down Expand Up @@ -643,6 +649,10 @@ class KeyboardViewController: UIInputViewController {
deactivateBtn(btn: padEmojiKey1)
deactivateBtn(btn: padEmojiKey2)

if controllerLanguage == "Indonesian" {
hideConjugateAndPluralKeys(state: false)
}

if autoAction0Visible {
allowUndo = false
firstCompletionIsHighlighted = false
Expand Down Expand Up @@ -916,12 +926,14 @@ class KeyboardViewController: UIInputViewController {
/// Sets up all buttons that are associated with Scribe commands.
func setCommandBtns() {
setBtn(btn: translateKey, color: commandKeyColor, name: "Translate", canBeCapitalized: false, isSpecial: false)
setBtn(btn: conjugateKey, color: commandKeyColor, name: "Conjugate", canBeCapitalized: false, isSpecial: false)
setBtn(btn: pluralKey, color: commandKeyColor, name: "Plural", canBeCapitalized: false, isSpecial: false)

activateBtn(btn: translateKey)
activateBtn(btn: conjugateKey)
activateBtn(btn: pluralKey)

if controllerLanguage != "Indonesian" {
setBtn(btn: conjugateKey, color: commandKeyColor, name: "Conjugate", canBeCapitalized: false, isSpecial: false)
setBtn(btn: pluralKey, color: commandKeyColor, name: "Plural", canBeCapitalized: false, isSpecial: false)
activateBtn(btn: conjugateKey)
activateBtn(btn: pluralKey)
}
}

/// Hides all emoji dividers based on conditions determined by the keyboard state.
Expand Down Expand Up @@ -1210,6 +1222,7 @@ class KeyboardViewController: UIInputViewController {
/// Sets up all buttons and labels for the conjugation view given constraints to determine the dimensions.
func setConjugationBtns() {
// Add swipe functionality to the conjugation and declension views.
guard controllerLanguage != "Indonesian" else { return }
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(shiftLeft))
keyboardView.addGestureRecognizer(swipeRight)
let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(shiftRight))
Expand Down Expand Up @@ -1716,15 +1729,15 @@ class KeyboardViewController: UIInputViewController {
(
commandState != .translate
&& (
["English", "Portuguese", "Italian"].contains(controllerLanguage)
["English", "Indonesian", "Italian", "Portuguese"].contains(controllerLanguage)
|| (
["German", "Spanish", "Swedish"].contains(controllerLanguage)
&& disableAccentCharacters
)
)
) || (
commandState == .translate
&& ["en", "pt", "it"].contains(getControllerTranslateLangCode())
&& ["en", "in", "it", "pt"].contains(getControllerTranslateLangCode())
)) {
leftPadding = keyWidth / 4
addPadding(to: stackView1, width: leftPadding, key: "a")
Expand All @@ -1735,10 +1748,10 @@ class KeyboardViewController: UIInputViewController {
&& (
(
commandState != .translate
&& ["English", "Portuguese", "Italian"].contains(controllerLanguage)
&& ["English", "Indonesian", "Italian", "Portuguese"].contains(controllerLanguage)
) || (
commandState == .translate
&& ["en", "pt", "it"].contains(getControllerTranslateLangCode())
&& ["en", "in", "it", "pt"].contains(getControllerTranslateLangCode())
)) {
leftPadding = keyWidth / 3
addPadding(to: stackView1, width: leftPadding, key: "a")
Expand All @@ -1749,10 +1762,10 @@ class KeyboardViewController: UIInputViewController {
&& (
(
commandState != .translate
&& ["English", "Portuguese", "Italian"].contains(controllerLanguage)
&& ["English", "Italian", "Portuguese"].contains(controllerLanguage)
) || (
commandState == .translate
&& ["en", "pt", "it"].contains(getControllerTranslateLangCode())
&& ["en", "it", "pt"].contains(getControllerTranslateLangCode())
)) {
leftPadding = keyWidth / 3
addPadding(to: stackView1, width: leftPadding, key: "@")
Expand Down Expand Up @@ -1873,15 +1886,15 @@ class KeyboardViewController: UIInputViewController {
(
commandState != .translate
&& (
["English", "Portuguese", "Italian"].contains(controllerLanguage)
["English", "Indonesian", "Italian", "Portuguese"].contains(controllerLanguage)
|| (
["German", "Spanish", "Swedish"].contains(controllerLanguage)
&& disableAccentCharacters
)
)
) || (
commandState == .translate
&& ["en", "pt", "it"].contains(getControllerTranslateLangCode())
&& ["en", "in", "it", "pt"].contains(getControllerTranslateLangCode())
)) {
rightPadding = keyWidth / 4
addPadding(to: stackView1, width: rightPadding, key: "l")
Expand Down Expand Up @@ -2020,7 +2033,9 @@ class KeyboardViewController: UIInputViewController {
setCommaAndPeriodKeysConditionally()
setCommandBackground()
setCommandBtns()
setConjugationBtns()
if controllerLanguage != "Indonesian" {
setConjugationBtns()
}

// Clear annotation state if a keyboard state change dictates it.
if !annotationState {
Expand Down Expand Up @@ -2131,8 +2146,12 @@ class KeyboardViewController: UIInputViewController {

if commandState == .selectCommand {
styleBtn(btn: translateKey, title: translateKeyLbl, radius: commandKeyCornerRadius)
styleBtn(btn: conjugateKey, title: conjugateKeyLbl, radius: commandKeyCornerRadius)
styleBtn(btn: pluralKey, title: pluralKeyLbl, radius: commandKeyCornerRadius)
if controllerLanguage == "Indonesian" {
hideConjugateAndPluralKeys(state: true)
} else {
styleBtn(btn: conjugateKey, title: conjugateKeyLbl, radius: commandKeyCornerRadius)
styleBtn(btn: pluralKey, title: pluralKeyLbl, radius: commandKeyCornerRadius)
}

scribeKey.toEscape()
scribeKey.setFullCornerRadius()
Expand All @@ -2141,9 +2160,11 @@ class KeyboardViewController: UIInputViewController {
commandBar.hide()
hideAutoActionPartitions()
} else {
deactivateBtn(btn: conjugateKey)
if controllerLanguage != "Indonesian" {
deactivateBtn(btn: conjugateKey)
deactivateBtn(btn: pluralKey)
}
deactivateBtn(btn: translateKey)
deactivateBtn(btn: pluralKey)

deactivateBtn(btn: phoneEmojiKey0)
deactivateBtn(btn: phoneEmojiKey1)
Expand Down
8 changes: 6 additions & 2 deletions Keyboards/KeyboardsBase/LanguageDBManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ class LanguageDBManager {
try database?.read { db in
if let row = try Row.fetchOne(db, sql: query, arguments: args) {
for col in outputCols {
outputValues.append(row[col])
if let stringValue = row[col] as? String {
outputValues.append(stringValue)
} else {
outputValues.append("") // default to empty string if NULL or wrong type
}
}
}
}
Expand All @@ -79,7 +83,7 @@ class LanguageDBManager {
)
} catch {}

if outputValues == [String]() {
if outputValues.isEmpty {
// Append an empty string so that we can check for it and trigger commandState = .invalid.
outputValues.append("")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later

/**
* Variables associated with commands for the Indonesian Scribe keyboard.
*/
Loading
Loading