Fix setting title with format and search term

This commit is contained in:
Markus Fisch
2025-09-29 22:18:30 +02:00
parent 6bb72672a3
commit a366157977
4 changed files with 8 additions and 10 deletions
@@ -204,12 +204,10 @@ class CameraActivity : AppCompatActivity() {
if (searchTerm != null || restrictFormat != null) {
title = getString(
R.string.scan_format,
prettifyFormatName(
listOfNotNull(
restrictFormat,
searchTerm
).joinToString(",")
)
listOfNotNull(
searchTerm,
restrictFormat?.prettifyFormatName(),
).joinToString(", ")
)
} else {
setTitle(R.string.scan_code)
@@ -109,7 +109,7 @@ class ScansAdapter(context: Context, cursor: Cursor) :
contentView.setCompoundDrawablesWithIntrinsicBounds(
icon, 0, 0, 0
)
formatView.text = prettifyFormatName(cursor.getString(formatIndex))
formatView.text = cursor.getString(formatIndex).prettifyFormatName()
}
val selected = selections[cursor.getLong(idIndex)] != null
view.post {
@@ -139,7 +139,7 @@ class ScansAdapter(context: Context, cursor: Cursor) :
)
}
fun prettifyFormatName(format: String) = format.replace("_", " ")
fun String.prettifyFormatName() = replace("_", " ")
private fun formatDateTime(rfc: String): String {
try {
@@ -253,7 +253,7 @@ class DecodeFragment : Fragment() {
formatView.text = resources.getQuantityString(
R.plurals.barcode_info,
bytes.size,
prettifyFormatName(format),
format.prettifyFormatName(),
bytes.size
)
hexView.showIf(prefs.showHexDump) { v ->
@@ -103,7 +103,7 @@ class EncodeFragment : Fragment() {
val formatAdapter = ArrayAdapter(
ac,
android.R.layout.simple_spinner_item,
formats.map { prettifyFormatName(it.name) }
formats.map { it.name.prettifyFormatName() }
)
formatAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item