taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

commit 2b289b130bf782c63de6d04546080f941053cac4
parent 842b4208444826e73764faaa0b64829c305420c8
Author: Iván Ávalos <avalos@disroot.org>
Date:   Fri,  5 Dec 2025 14:14:47 +0100

[wallet] render ToS despite non-regular sectioning

Diffstat:
Mwallet/src/main/java/net/taler/wallet/withdraw/TosAdapter.kt | 3++-
Mwallet/src/main/java/net/taler/wallet/withdraw/TosSection.kt | 13++++++++-----
Mwallet/src/main/res/values/strings.xml | 1+
3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/TosAdapter.kt b/wallet/src/main/java/net/taler/wallet/withdraw/TosAdapter.kt @@ -67,10 +67,11 @@ class TosAdapter( fun bind(item: TosSection) { sectionTitle.text = item.title + ?: v.context.getString(R.string.exchange_tos) showSection(item, item.expanded) val onClickListener = View.OnClickListener { val transition = ChangeBounds() - transition.setDuration(200L) + transition.duration = 200L if (!item.expanded) beginDelayedTransition(v as ViewGroup, transition) item.expanded = !item.expanded showSection(item, item.expanded) diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/TosSection.kt b/wallet/src/main/java/net/taler/wallet/withdraw/TosSection.kt @@ -26,15 +26,16 @@ import org.commonmark.node.Text import java.text.ParseException data class TosSection( - val title: String, + val title: String?, val node: Node, var expanded: Boolean = false ) @Throws(ParseException::class) internal fun parseTos(markwon: Markwon, text: String): List<TosSection> { - var node: Node? = - markwon.parse(text).firstChild ?: throw ParseException("Invalid markdown", 0) + val rootNode: Node = markwon.parse(text) + var node: Node? = rootNode.firstChild + ?: throw ParseException("Invalid markdown", 0) var lastHeading: String? = null var section = Document() val sections = ArrayList<TosSection>() @@ -49,9 +50,11 @@ internal fun parseTos(markwon: Markwon, text: String): List<TosSection> { } // start new section with new heading (stripped of markup) lastHeading = getNodeText(node) - if (lastHeading.isBlank()) throw ParseException("Empty heading", 0) + if (lastHeading.isBlank()) { + return listOf(TosSection(null, rootNode, true)) + } } else if (lastHeading == null) { - throw ParseException("The exchange ToS does not follow the correct format", 0) + return listOf(TosSection(null, rootNode, true)) } else { section.appendChild(node) } diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml @@ -414,6 +414,7 @@ GNU Taler is immune to many types of fraud such as credit card data theft, phish <string name="exchange_reload">Reload information</string> <string name="exchange_settings_summary">Manage the payment service providers known to this wallet</string> <string name="exchange_settings_title">Providers</string> + <string name="exchange_tos">Terms of service</string> <string name="exchange_tos_accept">Accept terms of service</string> <string name="exchange_tos_forget">Reject terms of service</string> <string name="exchange_tos_view">Review terms of service</string>