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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Keyboard language management dialog now respects `Use English language` preference ([#238])
- Fixed incorrect sorting in keyboard language selection dialog ([#239])

## [1.4.0] - 2025-08-22
### Added
Expand Down Expand Up @@ -87,6 +88,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#222]: https://github.com/FossifyOrg/Keyboard/issues/222
[#230]: https://github.com/FossifyOrg/Keyboard/issues/230
[#238]: https://github.com/FossifyOrg/Keyboard/issues/238
[#239]: https://github.com/FossifyOrg/Keyboard/issues/239

[Unreleased]: https://github.com/FossifyOrg/Keyboard/compare/1.4.0...HEAD
[1.4.0]: https://github.com/FossifyOrg/Keyboard/compare/1.3.0...1.4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.fossify.commons.views.MyAppCompatCheckbox
import org.fossify.keyboard.R
import org.fossify.keyboard.extensions.getKeyboardLanguageText
import org.fossify.keyboard.helpers.Config

typealias LanguageItem = Pair<Int, String>

internal class ManageKeyboardLanguagesAdapter(
private val config: Config,
private var languagesList: List<Int>,
private var languagesList: List<LanguageItem>,
) : RecyclerView.Adapter<ManageKeyboardLanguagesAdapter.MyViewHolder>() {
private val selectedLanguages = config.selectedLanguages

Expand All @@ -28,14 +29,14 @@ internal class ManageKeyboardLanguagesAdapter(
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val item = languagesList[position]
holder.languageCheckboxItem.apply {
text = context.getKeyboardLanguageText(item)
isChecked = selectedLanguages.contains(item)
text = item.second
isChecked = selectedLanguages.contains(item.first)

setOnClickListener {
if (isChecked) {
selectedLanguages.add(item)
selectedLanguages.add(item.first)
} else {
selectedLanguages.remove(item)
selectedLanguages.remove(item.first)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.fossify.keyboard.R
import org.fossify.keyboard.adapters.ManageKeyboardLanguagesAdapter
import org.fossify.keyboard.databinding.DialogManageKeyboardLanguagesBinding
import org.fossify.keyboard.extensions.config
import org.fossify.keyboard.extensions.getKeyboardLanguageText
import org.fossify.keyboard.helpers.SUPPORTED_LANGUAGES

class ManageKeyboardLanguagesDialog(
Expand All @@ -15,7 +16,11 @@ class ManageKeyboardLanguagesDialog(
) {
init {
val binding = DialogManageKeyboardLanguagesBinding.inflate(activity.layoutInflater)
val adapter = ManageKeyboardLanguagesAdapter(activity.config, SUPPORTED_LANGUAGES)
val languageItems = SUPPORTED_LANGUAGES.map {
it to activity.getKeyboardLanguageText(it)
}.sortedBy { it.second }

val adapter = ManageKeyboardLanguagesAdapter(activity.config, languageItems)
binding.keyboardLanguageList.adapter = adapter

activity.getAlertDialogBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ fun Context.getKeyboardLanguagesRadioItems(): ArrayList<RadioItem> {
}

return selectedLanguagesRadioItems
.sortedBy { it.title }
.toMutableList() as ArrayList<RadioItem>
}

fun Context.getKeyboardLanguageText(language: Int): String {
Expand Down
Loading