Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/La-casa-del-bordadito/llms.txt

Use this file to discover all available pages before exploring further.

La Casa del Bordadito includes a full in-app messaging system so customers can reach support staff without leaving the app. Conversations are stored in Firebase Realtime Database, unread counts update in real time, and users who are offline receive a OneSignal push notification so no message is ever missed.

Starting a chat

1

Open support contacts

Navigate to the Cuenta tab, find the Configuración section, and tap Soporte Chat. This launches ListaChatActivity.
2

Select a support user

ListaChatActivity lists only users whose esSoporte flag is true in Realtime Database. If you are yourself a support user, the full user list is shown instead so you can reply to any customer. A search bar filters by name in real time using an ordered Realtime DB query.
3

Open the conversation

Tapping a contact opens ChatActivity, which loads all messages for the conversation from Chats/{chatRuta} and starts a ValueEventListener that refreshes the list on every new message.

Chat data model

class Chat {
    var idMensaje: String = ""
    var tipoMensaje: String = ""   // "TEXTO" or "IMAGEN"
    var mensaje: String = ""
    var emisorUid: String = ""
    var receptorUid: String = ""
    var tiempo: Long = 0
}

Sample Realtime Database message node

{
  "idMensaje": "-NxKq8_abc123",
  "tipoMensaje": "TEXTO",
  "mensaje": "¡Hola! ¿A qué hora abre el café?",
  "emisorUid": "userUID_cliente",
  "receptorUid": "userUID_soporte",
  "tiempo": 1718200500000
}
FieldTypeDescription
idMensajeStringAuto-generated Realtime DB push key
tipoMensajeStringTEXTO for plain text; IMAGEN for a Firebase Storage URL
mensajeStringMessage text, or a Storage download URL when tipoMensaje is IMAGEN
emisorUidStringUID of the sender
receptorUidStringUID of the recipient
tiempoLongSystem.currentTimeMillis() at send time

Firebase Realtime Database paths

Message storage

Chats/{chatRuta}/{messageId}
chatRuta is computed by Constantes.rutaChat(uid1, uid2), which sorts the two UIDs alphabetically and joins them with an underscore:
fun rutaChat(receptorUid: String, emisorUid: String): String {
    val arrayUid = arrayOf(receptorUid, emisorUid)
    Arrays.sort(arrayUid)
    return "${arrayUid[0]}_${arrayUid[1]}"
}
This guarantees the same path is used regardless of which participant opens the conversation, preventing duplicate threads.

Unread counts

ChatsUnreadCount/{recipientUid}/{senderUid}
  • Incremented on every outgoing message, but only if the recipient’s chattingWith field does not already equal the sender’s UID (i.e. the recipient is not actively viewing this conversation).
  • Reset to 0 when the recipient opens ChatActivity via marcarComoLeido().

Message types

TEXTO

Plain text entered in the message field. Sent by tapping the send FAB. The message is trimmed before validation — empty strings show a toast instead of sending.

IMAGEN

Image selected from the device gallery (or camera on supported versions). The file is uploaded to Firebase Storage under ImagenesChat/{timestamp}, and the resulting download URL is stored as the mensaje value with tipoMensaje = "IMAGEN".

In-app notification popup

When a new message arrives from a conversation that is not currently open, MainActivity shows a PopupWindow at the top of the screen displaying the sender’s name and the message preview. The popup auto-dismisses after 4 seconds.

Push notifications

For users who are offline (or not actively viewing the sender’s chat), a OneSignal push notification is sent via FcmUtil.enviarNotificacionAUsuario. The notification is skipped when:
  • chattingWith == senderUid — recipient is already in this conversation.
  • online == true — recipient is active in the app and will see the in-app popup instead.

Online and presence fields

Two fields on the Usuarios/{uid} node control notification routing:
FieldTypeDescription
onlineBooleantrue while the user has the app in the foreground
chattingWithStringUID of the contact whose chat is currently open; "" when no chat is active
chattingWith is set in ChatActivity.onResume() and cleared in onPause(), ensuring it always reflects the currently viewed conversation.

Block system

Either participant can block the other. Blocks are stored under Usuarios/{uid}/usuariosBloqueados/{blockedUid} in Realtime Database. ChatActivity listens to both the current user’s block list and the other user’s block list simultaneously.
When a block is active, all send controls (text field, send FAB, attachment FAB) are hidden and replaced by a banner message. The exact text depends on who initiated the block:
  • You blocked the other user"Has bloqueado a este usuario"
  • The other user blocked you"Has sido bloqueado por soporte"
ChatActivity listens to both block nodes simultaneously, so the UI updates the moment either participant blocks or unblocks the other.

Build docs developers (and LLMs) love