Skip to content
Draft
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 .github/workflows/build-test-auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
pull_request:
paths:
- 'app/src/main/java**'
- 'app/src/main/assets/**'
- 'app/src/main/res/xml/**'
- 'app/src/test/**'
workflow_dispatch:

jobs:
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_br.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!
@
#
$
% ‰
¨ ´ ` ~ ^
&
*
(
)

@
#
$$$
_ % ‰
- – ⁻ — ·
+ = ± ⁺
( ⁽ < { [
) ⁾ > } ]
/ \ |

* † ‡ ★
"
'
:
;
!
?
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_ch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
+
"
*
ç
% ‰
&
/
(
)
=

@
#
$$$
_ % ‰
- – ⁻ — ·
+ ± ⁺
( ⁽ < { [
) ⁾ > } ]
/

* † ‡ ★
"
'
:
;
!
?
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_de.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!
"
§
$
% ‰
&
/
(
)
=

@
#
$$$
_ % ‰
- – ⁻ — ·
+ ± ⁺
( ⁽ < { [
) ⁾ > } ]
/

* † ‡ ★
"
'
:
;
!
?
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_es.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!
"
·
$
% ‰
&
/
(
)
=

@
#
$$$
_ % ‰
- – ⁻ —
+ ± ⁺
( ⁽ < { [
) ⁾ > } ]
/

* † ‡ ★
"
'
:
;
!
?
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_iso.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!
"
#
$
% ‰
&
/
(
)
=

@
#
$$$
_ % ‰
- – ⁻ — ·
+ ± ⁺
( ⁽ < { [
) ⁾ > } ]
/

* † ‡ ★
"
'
:
;
!
?
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_it.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!
"
£
$
% ‰
&
/
(
)
=

@
#
$$$
_ % ‰
- – ⁻ — ·
+ ± ⁺
( ⁽ < { [
) ⁾ > } ]
/

* † ‡ ★
"
'
:
;
!
?
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_nordic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!
"
#
¤
% ‰
&
/
(
)
=

@
#
$$$
_ % ‰
- – ⁻ — ·
+ ± ⁺
( ⁽ < { [
) ⁾ > } ]
/

* † ‡ ★
"
'
:
;
!
?
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_tr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!
'
^
+
% ‰
&
/
(
)
=

@
#
$$$
_ % ‰
- – ⁻ — ·
+ ± ⁺
( ⁽ < { [
) ⁾ > } ]
/

* † ‡ ★
"
'
:
;
!
?
28 changes: 28 additions & 0 deletions app/src/main/assets/layouts/symbols/symbols_uk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!
"
£
$
% ‰
^
&
*
(
)

@
#
$$$
_ % ‰
- – ⁻ — ·
+ = ± ⁺
( ⁽ < { [
) ⁾ > } ]
/ \ |

* † ‡ ★
"
'
:
;
!
?
40 changes: 40 additions & 0 deletions app/src/main/java/helium314/keyboard/latin/AppUpgrade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,46 @@ private object AppUpgrade {
remove("narrow_key_gaps")
}
}
if (oldVersion <= 4004) {
// region-specific SYMBOLS layouts were added to many subtypes in method.xml; extend
// stored subtype prefs the same way so they keep matching the resource subtypes, and
// so existing additional subtypes of these locales get the regional symbols page too
val regionalSymbols = mapOf(
"de" to "symbols_de", "de-DE" to "symbols_de",
"de-CH" to "symbols_ch", "fr-CH" to "symbols_ch", "it-CH" to "symbols_ch",
"sv" to "symbols_nordic", "da" to "symbols_nordic", "nb" to "symbols_nordic",
"fi" to "symbols_nordic", "et-EE" to "symbols_nordic",
"en-GB" to "symbols_uk",
"es" to "symbols_es", "ca" to "symbols_es", "gl-ES" to "symbols_es", "eu-ES" to "symbols_es",
"it" to "symbols_it",
"is" to "symbols_iso", "pt-PT" to "symbols_iso", "es-419" to "symbols_iso",
"es-US" to "symbols_iso", "hr" to "symbols_iso", "sr-Latn" to "symbols_iso", "sl" to "symbols_iso",
"sr" to "symbols_iso",
"pt-BR" to "symbols_br",
"tr" to "symbols_tr",
)
fun SettingsSubtype.withRegionalSymbols(): SettingsSubtype {
val regional = regionalSymbols[locale.toLanguageTag()] ?: return this
if (layoutName(LayoutType.SYMBOLS) != null) return this // explicitly chosen symbols layout, keep it
return withLayout(LayoutType.SYMBOLS, regional)
}
listOf(Settings.PREF_ENABLED_SUBTYPES, Settings.PREF_ADDITIONAL_SUBTYPES).forEach { key ->
if (!prefs.contains(key)) return@forEach
val value = prefs.getString(key, "")!!
val new = value.split(Separators.SETS).filter { it.isNotEmpty() }
.joinToString(Separators.SETS) { it.toSettingsSubtype().withRegionalSymbols().toPref() }
if (new != value) prefs.edit { putString(key, new) }
}
(prefs.all.keys.filter { it.startsWith(Settings.PREF_SAVED_APP_SUBTYPE_PREFIX) } + Settings.PREF_SELECTED_SUBTYPE).forEach { key ->
if (!prefs.contains(key)) return@forEach
val value = prefs.getString(key, "")!!
if (value.isEmpty()) return@forEach
val new = value.toSettingsSubtype().withRegionalSymbols().toPref()
if (new != value) prefs.edit { putString(key, new) }
}
// subtypes were already loaded from the not-yet-migrated prefs in SubtypeSettings.init
SubtypeSettings.reloadEnabledSubtypes(context)
}
upgradeToolbarPrefs(prefs)
LayoutUtilsCustom.onLayoutFileChanged() // just to be sure
prefs.edit { putInt(Settings.PREF_VERSION_CODE, BuildConfig.VERSION_CODE) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object Defaults {
const val PREF_LANGUAGE_SWITCH_KEY = "internal"
const val PREF_SHOW_EMOJI_KEY = false
const val PREF_VARIABLE_TOOLBAR_DIRECTION = true
const val PREF_ADDITIONAL_SUBTYPES = "de${Separators.SET}${ExtraValue.KEYBOARD_LAYOUT_SET}=MAIN:qwerty${Separators.SETS}" +
const val PREF_ADDITIONAL_SUBTYPES = "de${Separators.SET}${ExtraValue.KEYBOARD_LAYOUT_SET}=MAIN:qwerty|SYMBOLS:symbols_de${Separators.SETS}" +
"fr${Separators.SET}${ExtraValue.KEYBOARD_LAYOUT_SET}=MAIN:qwertz${Separators.SETS}" +
"hu${Separators.SET}${ExtraValue.KEYBOARD_LAYOUT_SET}=MAIN:qwerty"
const val PREF_ENABLE_SPLIT_KEYBOARD = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object SubtypeSettings {
val match = enabledFromSettings.firstOrNull {
!it.isAdditionalSubtype(context.prefs())
&& it.locale == subtype.locale()
&& it.mainLayoutName() == subtype.mainLayoutNameOrQwerty()
&& (it.mainLayoutName() ?: SubtypeLocaleUtils.QWERTY) == subtype.mainLayoutNameOrQwerty()
}
// the match is done on locale and main layout name, like in loadEnabledSubtypes
if (match == null || !removeEnabledSubtype(prefs, match)) {
Expand All @@ -103,13 +103,27 @@ object SubtypeSettings {
val subtype = enabledSubtypes.firstOrNull { it.toSettingsSubtype() == selectedSubtype }
if (subtype != null) {
return subtype
} else if (enabledSubtypes.isNotEmpty()) {
Log.w(TAG, "selected subtype $selectedSubtype / ${prefs.getString(Settings.PREF_SELECTED_SUBTYPE, Defaults.PREF_SELECTED_SUBTYPE)} not found")
}
if (enabledSubtypes.isNotEmpty())
// the stored selected subtype may be stale when extra values of a resource subtype
// changed in method.xml, so match on locale and main layout like loadEnabledSubtypes
// does, and heal the pref so exact matching works again (prefer resource subtypes,
// because a stale pref that gets here is a resource subtype serialization)
val sameLocaleAndLayout = enabledSubtypes.filter {
it.locale() == selectedSubtype.locale
&& it.mainLayoutNameOrQwerty() == (selectedSubtype.mainLayoutName() ?: SubtypeLocaleUtils.QWERTY)
}
val fuzzyMatch = sameLocaleAndLayout.firstOrNull { !isAdditionalSubtype(it) } ?: sameLocaleAndLayout.firstOrNull()
if (fuzzyMatch != null) {
setSelectedSubtype(prefs, fuzzyMatch)
return fuzzyMatch
}
if (enabledSubtypes.isNotEmpty()) {
Log.w(TAG, "selected subtype $selectedSubtype / ${prefs.getString(Settings.PREF_SELECTED_SUBTYPE, Defaults.PREF_SELECTED_SUBTYPE)} not found")
return enabledSubtypes.first()
}
val defaultSubtypes = getDefaultEnabledSubtypes()
return defaultSubtypes.firstOrNull { it.locale() == selectedSubtype.locale && it.mainLayoutName() == it.mainLayoutName() }
return defaultSubtypes.firstOrNull { it.locale() == selectedSubtype.locale && it.mainLayoutNameOrQwerty() == (selectedSubtype.mainLayoutName() ?: SubtypeLocaleUtils.QWERTY) }
?: defaultSubtypes.firstOrNull { it.locale() == selectedSubtype.locale }
?: defaultSubtypes.firstOrNull { it.locale().language == selectedSubtype.locale.language }
?: defaultSubtypes.first()
}
Expand Down Expand Up @@ -250,6 +264,7 @@ object SubtypeSettings {
private fun loadEnabledSubtypes(context: Context) {
val prefs = context.prefs()
val settingsSubtypes = createSettingsSubtypes(prefs.getString(Settings.PREF_ENABLED_SUBTYPES, Defaults.PREF_ENABLED_SUBTYPES)!!)
val stale = mutableMapOf<SettingsSubtype, SettingsSubtype>()
for (settingsSubtype in settingsSubtypes) {
if (settingsSubtype.isAdditionalSubtype(prefs)) {
enabledSubtypes.add(settingsSubtype.toAdditionalSubtype())
Expand Down Expand Up @@ -278,6 +293,15 @@ object SubtypeSettings {
}

enabledSubtypes.add(subtype)
if (subtype.toSettingsSubtype() != settingsSubtype)
stale[settingsSubtype] = subtype.toSettingsSubtype()
}
if (stale.isNotEmpty()) {
// extra values of a resource subtype changed in method.xml (e.g. a SYMBOLS layout was
// added) -> store the current serialization, because exact-match consumers like
// getSelectedSubtype and changeAdditionalSubtype would keep working on stale strings
val current = createSettingsSubtypes(prefs.getString(Settings.PREF_ENABLED_SUBTYPES, Defaults.PREF_ENABLED_SUBTYPES)!!)
prefs.edit { putString(Settings.PREF_ENABLED_SUBTYPES, createPrefSubtypes(current.map { stale[it] ?: it })) }
}
}

Expand Down
Loading