feat: Update keyboard height handling and enhance reply logging in ChatViewModel

This commit is contained in:
k1ngsterr1
2026-01-14 01:27:03 +05:00
parent d75897214b
commit 3c6f1cdd2f
2 changed files with 29 additions and 11 deletions

View File

@@ -927,7 +927,8 @@ fun ChatDetailScreen(
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 12.dp)
.padding(horizontal = 16.dp, vertical = 16.dp)
.padding(bottom = 12.dp)
.navigationBarsPadding(),
horizontalArrangement = Arrangement.spacedBy(12.dp),
verticalAlignment = Alignment.CenterVertically
@@ -945,7 +946,7 @@ fun ChatDetailScreen(
viewModel.setReplyMessages(selectedMsgs)
selectedMessages = emptySet()
}
.padding(vertical = 14.dp),
.padding(vertical = 16.dp),
contentAlignment = Alignment.Center
) {
Row(
@@ -981,7 +982,7 @@ fun ChatDetailScreen(
viewModel.setForwardMessages(selectedMsgs)
selectedMessages = emptySet()
}
.padding(vertical = 14.dp),
.padding(vertical = 16.dp),
contentAlignment = Alignment.Center
) {
Row(
@@ -1100,11 +1101,12 @@ fun ChatDetailScreen(
}
),
// padding для контента списка - минимальные отступы
// 🔥 Увеличиваем bottom padding когда активен selection mode (Reply/Forward панель)
contentPadding = PaddingValues(
start = 8.dp,
end = 8.dp,
top = 8.dp,
bottom = 80.dp // 🔥 Отступ снизу для инпута (увеличен)
bottom = if (isSelectionMode) 140.dp else 80.dp
),
reverseLayout = true
) {
@@ -1944,15 +1946,16 @@ private fun MessageInputBar(
val isKeyboardVisible = imeHeight > 0.dp
// 🔥 Запоминаем высоту клавиатуры когда она открыта
var savedKeyboardHeight by remember { mutableStateOf(280.dp) }
// Дефолт 320.dp - хорошая высота для большинства устройств
var savedKeyboardHeight by remember { mutableStateOf(320.dp) }
LaunchedEffect(imeHeight) {
if (imeHeight > 50.dp) {
if (imeHeight > 100.dp) {
savedKeyboardHeight = imeHeight
}
}
// Высота панели эмодзи = сохранённая высота клавиатуры
val emojiPanelHeight = savedKeyboardHeight
// Высота панели эмодзи = сохранённая высота клавиатуры (минимум 280.dp)
val emojiPanelHeight = maxOf(savedKeyboardHeight, 280.dp)
// Состояние отправки - можно отправить если есть текст ИЛИ есть reply
val canSend = remember(value, hasReply) { value.isNotBlank() || hasReply }

View File

@@ -932,7 +932,9 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
var replyBlobPlaintext = "" // Сохраняем plaintext для БД
if (replyMsgsToSend.isNotEmpty()) {
// Формируем JSON массив с цитируемыми сообщениями
android.util.Log.e("REPLY_DEBUG", "🔥 FORMING REPLY ATTACHMENT, count=${replyMsgsToSend.size}")
// Формируем JSON массив с цитируемыми сообщениями (как в RN)
val replyJsonArray = JSONArray()
replyMsgsToSend.forEach { msg ->
val replyJson = JSONObject().apply {
@@ -943,20 +945,26 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
put("attachments", JSONArray()) // Пустой массив вложений
}
replyJsonArray.put(replyJson)
android.util.Log.e("REPLY_DEBUG", " - Reply msg: id=${msg.messageId}, text='${msg.text.take(30)}'")
}
replyBlobPlaintext = replyJsonArray.toString() // 🔥 Сохраняем plaintext
android.util.Log.e("REPLY_DEBUG", " - Reply blob plaintext length: ${replyBlobPlaintext.length}")
android.util.Log.e("REPLY_DEBUG", " - Reply blob plaintext: ${replyBlobPlaintext.take(100)}")
// 🔥 Шифруем reply blob plainKeyAndNonce (как в React Native)
val encryptedReplyBlob = MessageCrypto.encryptReplyBlob(replyBlobPlaintext, plainKeyAndNonce)
android.util.Log.e("REPLY_DEBUG", " - Encrypted reply blob length: ${encryptedReplyBlob.length}")
android.util.Log.e("REPLY_DEBUG", " - Encrypted reply blob: ${encryptedReplyBlob.take(60)}")
val replyAttachmentId = "reply_${timestamp}"
messageAttachments.add(MessageAttachment(
id = UUID.randomUUID().toString().replace("-", "").take(8),
id = replyAttachmentId,
blob = encryptedReplyBlob,
type = AttachmentType.MESSAGES,
preview = ""
))
android.util.Log.e("REPLY_DEBUG", " ✅ Reply attachment added, id=$replyAttachmentId")
}
val packet = PacketMessage().apply {
@@ -973,14 +981,21 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
// 🔥 Log packet details before sending
Log.d(TAG, "📦 PACKET READY TO SEND:")
Log.d(TAG, " - messageId: $messageId")
Log.d(TAG, " - text: '$text'")
Log.d(TAG, " - attachments count: ${packet.attachments.size}")
android.util.Log.e("REPLY_DEBUG", "📦 PACKET READY TO SEND:")
android.util.Log.e("REPLY_DEBUG", " - messageId: $messageId")
android.util.Log.e("REPLY_DEBUG", " - text: '$text'")
android.util.Log.e("REPLY_DEBUG", " - attachments count: ${packet.attachments.size}")
packet.attachments.forEach { att ->
Log.d(TAG, " - attachment: type=${att.type}, id=${att.id}, blob.length=${att.blob.length}")
android.util.Log.e("REPLY_DEBUG", " - attachment: type=${att.type}, id=${att.id}, blob.length=${att.blob.length}")
}
// Отправляем пакет
ProtocolManager.send(packet)
Log.d(TAG, "✅ PACKET SENT via ProtocolManager.send()")
android.util.Log.e("REPLY_DEBUG", "✅ PACKET SENT via ProtocolManager.send()")
// 3. 🎯 UI обновление в Main потоке
withContext(Dispatchers.Main) {