diff --git a/app/src/main/java/cz/skaut/srs/ticketsreader/api/dto/TicketCheckInfo.kt b/app/src/main/java/cz/skaut/srs/ticketsreader/api/dto/TicketCheckInfo.kt index 4cbf26c..790b930 100644 --- a/app/src/main/java/cz/skaut/srs/ticketsreader/api/dto/TicketCheckInfo.kt +++ b/app/src/main/java/cz/skaut/srs/ticketsreader/api/dto/TicketCheckInfo.kt @@ -6,11 +6,27 @@ import kotlinx.serialization.Serializable @Serializable data class TicketCheckInfo( + /** Jméno účastníka. */ @SerialName("attendee_name") val attendeeName: String, + + /** Věk účastníka. */ @SerialName("attendee_age") val attendeeAge: Int, + + /** Odkaz na fotku účastníka. */ @SerialName("attendee_photo") val attendeePhoto: String? = null, + + /** Má účastník propojený účet? */ + @SerialName("attendee_member") val attendeeMember: Boolean, + + /** Role účastníka. */ val roles: Array, + + /** Podakce účastníka. */ val subevents: Array, + + /** Má účastník podakci? */ @SerialName("has_subevent") val hasSubevent: Boolean, + + /** Seznam časů kontroly vstupenky. */ @SerialName("subevent_checks") val subeventChecks: Array, ) diff --git a/app/src/main/java/cz/skaut/srs/ticketsreader/processor/TicketQrProcessor.kt b/app/src/main/java/cz/skaut/srs/ticketsreader/processor/TicketQrProcessor.kt index 0694029..20dbaa2 100644 --- a/app/src/main/java/cz/skaut/srs/ticketsreader/processor/TicketQrProcessor.kt +++ b/app/src/main/java/cz/skaut/srs/ticketsreader/processor/TicketQrProcessor.kt @@ -70,21 +70,32 @@ class TicketQrProcessor(context: FragmentActivity) : QrProcessor(context) { val tvSubevents: TextView = dialogView.findViewById(R.id.dialog_ticket_tv_subevents_text) val tvChecks: TextView = dialogView.findViewById(R.id.dialog_ticket_tv_checks_text) + val messages: MutableList = mutableListOf() + if (!ticketInfo.hasSubevent) { tvStatus.text = context.getString(R.string.dialog_ticket_status_invalid) tvStatus.setTextColor(Color.RED) - tvMessage.text = context.getString(R.string.dialog_ticket_message_missing_subevent) - } else if (ticketInfo.subeventChecks.isNotEmpty()) { - tvStatus.text = context.getString(R.string.dialog_ticket_status_used) - tvStatus.setTextColor(COLOR_ORANGE.toInt()) - tvMessage.text = context.getString(R.string.dialog_ticket_message_used) + messages.add(context.getString(R.string.dialog_ticket_message_missing_subevent)) } else { - tvStatus.text = context.getString(R.string.dialog_ticket_status_valid) - tvStatus.setTextColor(Color.GREEN) - tvMessage.text = null + if (ticketInfo.subeventChecks.isNotEmpty()) { + tvStatus.text = context.getString(R.string.dialog_ticket_status_used) + tvStatus.setTextColor(COLOR_ORANGE.toInt()) + messages.add(context.getString(R.string.dialog_ticket_message_used)) + } else { + tvStatus.text = context.getString(R.string.dialog_ticket_status_valid) + tvStatus.setTextColor(Color.GREEN) + } + + if (!ticketInfo.attendeeMember) { + messages.add(context.getString(R.string.dialog_ticket_message_not_member)) + } + if (ticketInfo.attendeeAge < 18) { + messages.add(context.getString(R.string.dialog_ticket_message_not_adult)) + } } - tvMessage.visibility = if (tvMessage.text == null) TextView.GONE else TextView.VISIBLE + tvMessage.text = messages.joinToString("\n") + tvMessage.visibility = if (messages.isEmpty()) TextView.GONE else TextView.VISIBLE tvName.text = ticketInfo.attendeeName tvAge.text = ticketInfo.attendeeAge.toString() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f4f2ac5..68de2ef 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,6 +23,8 @@ Neplatná Vstupenka již byla dříve načtena. Účastník nemá kontrolovanou podakci. + Účastník nemá propojený účet. + Účastník je mladší 18 let. Chyba Neplatný QR kód vstupenky.