Show if token is activated

This commit is contained in:
partisan 2025-05-25 11:37:36 +02:00
parent e8549c8841
commit b2b839cf72
2 changed files with 16 additions and 6 deletions

View file

@ -66,11 +66,18 @@ class DonateFragment : Fragment() {
Toast.makeText(context, getString(R.string.donate_token_copied), Toast.LENGTH_SHORT).show()
}
// Show token entry section
// If already donated, update UI to show activation message and hide token entry controls
if (prefs.isDonationActivated) {
binding.postDonatePrompt.text = getString(R.string.donate_token_activated)
binding.openTokenSection.visibility = View.GONE
binding.tokenSection.visibility = View.GONE
} else {
// Show token entry section button if not activated
binding.openTokenSection.setOnClickListener {
binding.tokenSection.visibility = View.VISIBLE
binding.openTokenSection.visibility = View.GONE
}
}
binding.verifyButton.setOnClickListener {
var token = binding.tokenInput.text.toString().trim()
@ -173,8 +180,10 @@ class DonateFragment : Fragment() {
if (activateResult == "success") {
prefs.isDonationActivated = true
activity?.runOnUiThread {
val remaining = (result?.toIntOrNull() ?: 1) - 1
binding.resultText.text =
getString(R.string.donate_token_activated, result)
getString(R.string.donate_token_activated) + "\n" +
getString(R.string.donate_token_left, remaining.toString())
}
} else {
activity?.runOnUiThread {

View file

@ -64,7 +64,8 @@
<string name="donate_token_check_failed">❌ Could not check token</string>
<string name="donate_token_invalid">❌ Invalid or expired token</string>
<string name="donate_activation_failed">❌ Activation failed</string>
<string name="donate_token_activated">✅ Token activated! You had %1$s activations left.</string>
<string name="donate_token_activated">✅ Token activated!</string>
<string name="donate_token_left">You have %1$s activations left.</string>
<string name="donate_token_already_activated">✅ Already activated</string>
<string name="donate_toast_reminder">Make sure to include your token in the donation message to get rewarded 😊</string>
</resources>