Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing old message receipt processing and some visual improvements #91

Merged
merged 4 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import SnackBarToast
import UIGroupMessage
import UIMessage
import User
import androidx.compose.ui.text.toUpperCase
import avstatestore
import avstatestorecallstate
import avstatestorevcapfpsstate
Expand All @@ -30,6 +29,7 @@ import com.zoffcc.applications.trifa.HelperFiletransfer.update_filetransfer_db_f
import com.zoffcc.applications.trifa.HelperFriend.add_friend_avatar_chunk
import com.zoffcc.applications.trifa.HelperFriend.add_pushurl_for_friend
import com.zoffcc.applications.trifa.HelperFriend.del_friend_avatar
import com.zoffcc.applications.trifa.HelperFriend.get_friend_name_from_num
import com.zoffcc.applications.trifa.HelperFriend.main_get_friend
import com.zoffcc.applications.trifa.HelperFriend.remove_pushurl_for_friend
import com.zoffcc.applications.trifa.HelperFriend.send_friend_msg_receipt_v2_wrapper
Expand Down Expand Up @@ -58,6 +58,7 @@ import com.zoffcc.applications.trifa.HelperGroup.sync_group_message_history
import com.zoffcc.applications.trifa.HelperGroup.tox_group_by_groupid__wrapper
import com.zoffcc.applications.trifa.HelperGroup.tox_group_by_groupnum__wrapper
import com.zoffcc.applications.trifa.HelperMessage.process_msgv3_high_level_ack
import com.zoffcc.applications.trifa.HelperMessage.update_message_in_db_read_rcvd_timestamp_rawmsgbytes
import com.zoffcc.applications.trifa.HelperMessage.update_single_message_from_ftid
import com.zoffcc.applications.trifa.HelperMessage.update_single_message_from_messge_id
import com.zoffcc.applications.trifa.TRIFAGlobals.AVATAR_INCOMING_MAX_BYTE_SIZE
Expand Down Expand Up @@ -1335,25 +1336,25 @@ class MainActivity
{
if (a_TOXAV_CALL_COMM_INFO == ToxVars.TOXAV_CALL_COMM_INFO.TOXAV_CALL_COMM_DECODER_CURRENT_BITRATE.value.toLong())
{
//Log.i(TAG, "call_comm_cb: fnum: " + friend_number
// Log.i(TAG, "call_comm_cb: fnum: " + friend_number
// + " DECODER_CURRENT_BITRATE = " + comm_number)
avstatestorevplayfpsstate.updateDecoderVBitrate(comm_number.toInt())
}
else if (a_TOXAV_CALL_COMM_INFO == ToxVars.TOXAV_CALL_COMM_INFO.TOXAV_CALL_COMM_ENCODER_CURRENT_BITRATE.value.toLong())
{
//Log.i(TAG, "call_comm_cb: fnum: " + friend_number
// Log.i(TAG, "call_comm_cb: fnum: " + friend_number
// + " ENCODER_CURRENT_BITRATE = " + comm_number)
avstatestorevcapfpsstate.updateEncoderVBitrate(comm_number.toInt())

}
else if (a_TOXAV_CALL_COMM_INFO == ToxVars.TOXAV_CALL_COMM_INFO.TOXAV_CALL_COMM_NETWORK_ROUND_TRIP_MS.value.toLong())
{
//Log.i(TAG, "call_comm_cb: fnum: " + friend_number
// Log.i(TAG, "call_comm_cb: fnum: " + friend_number
// + " NETWORK_ROUND_TRIP_MS = " + comm_number)
}
else if (a_TOXAV_CALL_COMM_INFO == ToxVars.TOXAV_CALL_COMM_INFO.TOXAV_CALL_COMM_PLAY_DELAY.value.toLong())
{
//Log.i(TAG, "call_comm_cb: fnum: " + friend_number
// Log.i(TAG, "call_comm_cb: fnum: " + friend_number
// + " PLAY_DELAY = " + comm_number)
}
else
Expand Down Expand Up @@ -1542,6 +1543,42 @@ class MainActivity
@JvmStatic
fun android_tox_callback_friend_read_receipt_cb_method(friend_number: Long, message_id: Long)
{
try
{
val toxpk = tox_friend_get_public_key(friend_number)!!.uppercase()
if ((toxpk == null) || (toxpk.equals("-1", true)))
{
Log.i(TAG, "android_tox_callback_friend_read_receipt_cb_method: tox pubkey error")
return
}

if (get_friend_msgv3_capability(toxpk) == 1L)
{
// HINT: friend has msgV3 capability, ignore normal read receipts
Log.i(TAG, "friend_read_receipt:msgV3:ignore low level ACK, friend:" + get_friend_name_from_num(friend_number));
return
}
// there can be older messages with same message_id for this friend! so always take the latest one! -------
val m = orma!!.selectFromMessage().message_idEq(message_id).
tox_friendpubkeyEq(toxpk).directionEq(1).orderByIdDesc().toList()[0]
// there can be older messages with same message_id for this friend! so always take the latest one! -------
Log.i(TAG, "friend_read_receipt:m=" + m);
Log.i(TAG, "friend_read_receipt:m:message_id=" + m.message_id + " text=" + m.text + " friendpubkey=" + m.tox_friendpubkey + " read=" + m.read + " direction=" + m.direction);
if (m != null)
{
Log.i(TAG,
"friend_read_receipt:friend:" + get_friend_name_from_num(friend_number) + " message:" + m.text +
" m=" + m);
m.rcvd_timestamp = System.currentTimeMillis()
m.read = true
update_message_in_db_read_rcvd_timestamp_rawmsgbytes(m)
// TODO: update message in UI
}
} catch (e: java.lang.Exception)
{
Log.i(TAG, "friend_read_receipt:EE:" + e.message)
e.printStackTrace()
}
}

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ fun ConnectionIndicator(
modifier: Modifier = Modifier.size(16.dp),
isConnected: Int,
) = Box(
modifier = modifier
.border(1.dp, Color.Black, CircleShape)
.background(getConnectionColor(isConnected), CircleShape)
modifier = if (isConnected == 0)
modifier
.background(getConnectionColor(isConnected), CircleShape)
else
modifier
.border(1.dp, Color.Black, CircleShape)
.background(getConnectionColor(isConnected), CircleShape)
)

fun getConnectionColor(connection_status : Int): Color {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private fun ContactItemViewInfo(contactItem: ContactItem) = Column(
) {
Text(
text = contactItem.name,
style = MaterialTheme.typography.body1,
style = if (contactItem.name.length > 14) MaterialTheme.typography.body1.copy(fontSize = 13.sp) else MaterialTheme.typography.body1,
maxLines = 1,
overflow = Ellipsis,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private fun GroupItemViewInfo(groupItem: GroupItem) = Column(
) {
Text(
text = groupItem.name,
style = MaterialTheme.typography.body1,
style = if (groupItem.name.length > 14) MaterialTheme.typography.body1.copy(fontSize = 13.sp) else MaterialTheme.typography.body1,
maxLines = 1,
overflow = Ellipsis,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private fun GrouppeerItemViewInfo(grouppeerItem: GroupPeerItem) = Column(
) {
Text(
text = grouppeerItem.name,
style = TextStyle(fontSize = 15.sp),
style = if (grouppeerItem.name.length > 14) MaterialTheme.typography.body1.copy(fontSize = 12.sp) else MaterialTheme.typography.body1,
maxLines = 1,
overflow = Ellipsis,
)
Expand Down
Loading