diff --git a/gradle.properties b/gradle.properties index 741ddd2c..7311015f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,6 @@ org.jetbrains.compose.experimental.uikit.enabled=true android.defaults.buildfeatures.buildconfig=true # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental -compose.version=1.5.12 +compose.version=1.6.0-rc02 kotlin.version=1.9.22 multiplatform.version=1.9.22 diff --git a/resources/common/jni-c-toxcore.dll b/resources/common/jni-c-toxcore.dll index 19119ef9..63a84e94 100755 Binary files a/resources/common/jni-c-toxcore.dll and b/resources/common/jni-c-toxcore.dll differ diff --git a/resources/common/jni-c-toxcore_noise.dll b/resources/common/jni-c-toxcore_noise.dll index 306d7ecb..67b77f8c 100755 Binary files a/resources/common/jni-c-toxcore_noise.dll and b/resources/common/jni-c-toxcore_noise.dll differ diff --git a/resources/common/libjni-c-toxcore.jnilib b/resources/common/libjni-c-toxcore.jnilib index 32fefda4..538b5edb 100644 Binary files a/resources/common/libjni-c-toxcore.jnilib and b/resources/common/libjni-c-toxcore.jnilib differ diff --git a/resources/common/libjni-c-toxcore.so b/resources/common/libjni-c-toxcore.so index 2a68244e..09223bad 100755 Binary files a/resources/common/libjni-c-toxcore.so and b/resources/common/libjni-c-toxcore.so differ diff --git a/resources/common/libjni-c-toxcore_arm64.jnilib b/resources/common/libjni-c-toxcore_arm64.jnilib index 80c388c3..7329a423 100755 Binary files a/resources/common/libjni-c-toxcore_arm64.jnilib and b/resources/common/libjni-c-toxcore_arm64.jnilib differ diff --git a/resources/common/libjni-c-toxcore_noise.jnilib b/resources/common/libjni-c-toxcore_noise.jnilib index 27847da1..487dd12f 100644 Binary files a/resources/common/libjni-c-toxcore_noise.jnilib and b/resources/common/libjni-c-toxcore_noise.jnilib differ diff --git a/resources/common/libjni-c-toxcore_noise.so b/resources/common/libjni-c-toxcore_noise.so index 1c47c51b..f74940c3 100755 Binary files a/resources/common/libjni-c-toxcore_noise.so and b/resources/common/libjni-c-toxcore_noise.so differ diff --git a/resources/common/libjni-c-toxcore_raspi.so b/resources/common/libjni-c-toxcore_raspi.so index 4cb205f5..90d2b415 100644 Binary files a/resources/common/libjni-c-toxcore_raspi.so and b/resources/common/libjni-c-toxcore_raspi.so differ diff --git a/src/main/java/com/zoffcc/applications/trifa/TRIFAGlobals.java b/src/main/java/com/zoffcc/applications/trifa/TRIFAGlobals.java index d7b66ea2..81539864 100644 --- a/src/main/java/com/zoffcc/applications/trifa/TRIFAGlobals.java +++ b/src/main/java/com/zoffcc/applications/trifa/TRIFAGlobals.java @@ -31,7 +31,7 @@ public class TRIFAGlobals static String global_my_status_message = ""; static boolean bootstrapping = false; static long global_self_last_went_online_timestamp = -1; - static long global_self_last_went_offline_timestamp = -1; + static long global_self_last_went_offline_timestamp = 0; // bootstrap again after 30 seconds offline final static int TOX_BOOTSTRAP_AGAIN_AFTER_OFFLINE_MILLIS = 30 * 1000; diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index d63eb553..0f946fd0 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -233,7 +233,7 @@ const val MAX_EMOJI_POP_SEARCH_LEN = 20 const val MAX_EMOJI_POP_RESULT = 15 const val MAX_ONE_ON_ONE_MESSAGES_TO_SHOW = 20000 const val MAX_GROUP_MESSAGES_TO_SHOW = 20000 -const val SNACKBAR_TOAST_MS_DURATION: Long = 1000 +const val SNACKBAR_TOAST_MS_DURATION: Long = 1200 var emojis_cat_all_gropued: ArrayList>> = ArrayList() var emojis_cat_all_cat_names: ArrayList = ArrayList() var emojis_cat_all_cat_emoji: ArrayList = ArrayList() diff --git a/src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt b/src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt index 46ab8a8f..ffdf612b 100644 --- a/src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt +++ b/src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt @@ -1406,7 +1406,7 @@ class MainActivity fun android_tox_callback_self_connection_status_cb_method(a_TOX_CONNECTION: Int) { global_self_connection_status = a_TOX_CONNECTION - // Log.i(TAG, "android_tox_callback_self_connection_status_cb_method: " + a_TOX_CONNECTION) + Log.i(TAG, "android_tox_callback_self_connection_status_cb_method: " + a_TOX_CONNECTION) update_savedata_file_wrapper() if (a_TOX_CONNECTION == TOX_CONNECTION.TOX_CONNECTION_TCP.value) { @@ -1420,6 +1420,7 @@ class MainActivity { global_self_last_went_offline_timestamp = System.currentTimeMillis() set_tox_online_state("offline") + Log.i(TAG, "android_tox_callback_self_connection_status_cb_method: setting global_self_last_went_offline_timestamp") if (avstatestore.state.call_with_friend_pubkey_get() != null) { val fnum = tox_friend_by_public_key(avstatestore.state.call_with_friend_pubkey_get()) diff --git a/src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt b/src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt index ebbd6672..7d7c03c3 100644 --- a/src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt +++ b/src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape @@ -36,6 +37,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.LayoutDirection +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.vanniktech.emoji.emojiInformation @@ -102,13 +104,15 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float .background(color = if (!isMyMessage) ChatColorsConfig.OTHERS_MESSAGE else ChatColorsConfig.MY_MESSAGE) .padding(start = 10.dp, top = 5.dp, end = 10.dp, bottom = 5.dp), ) { - Column { + Column(Modifier.randomDebugBorder().padding(all = 0.dp), + verticalArrangement = Arrangement.spacedBy(0.dp)) { if(!isMyMessage) { Row(verticalAlignment = Alignment.Bottom) { Text( text = message.user.name, style = MaterialTheme.typography.body1.copy( fontWeight = FontWeight.SemiBold, + lineHeight = TextUnit.Unspecified, letterSpacing = 0.sp, fontSize = 14.sp ), @@ -116,8 +120,7 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float ) } } - Spacer(Modifier.size(3.dp)) - SelectionContainer() + SelectionContainer(modifier = Modifier.padding(all = 0.dp)) { var msg_fontsize = MSG_TEXT_FONT_SIZE_MIXED try @@ -133,8 +136,10 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float } Text( text = message.text, + modifier = Modifier.randomDebugBorder(), style = MaterialTheme.typography.body1.copy( fontSize = ((msg_fontsize * ui_scale).toDouble()).sp, + lineHeight = TextUnit.Unspecified, letterSpacing = 0.sp ) ) @@ -174,7 +179,7 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float HelperGeneric.loadImageBitmap(File(message.filename_fullpath)) }, painterFor = { remember { BitmapPainter(it) } }, contentDescription = "Image", - modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp). + modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp * ui_scale). combinedClickable( onClick = { show_file_in_explorer_or_open(message.filename_fullpath) }, onLongClick = { show_containing_dir_in_explorer(message.filename_fullpath) })) @@ -182,7 +187,7 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float else { Icon( - modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp). + modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp * ui_scale). combinedClickable( onClick = { show_file_in_explorer_or_open(message.filename_fullpath) }, onLongClick = { show_containing_dir_in_explorer(message.filename_fullpath) }), @@ -195,7 +200,7 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float else { Icon( - modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp), + modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp * ui_scale), imageVector = Icons.Default.BrokenImage, contentDescription = "failed", tint = MaterialTheme.colors.primary @@ -242,7 +247,7 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float HelperGeneric.loadImageBitmap(File(message.filename_fullpath)) }, painterFor = { remember { BitmapPainter(it) } }, contentDescription = "Image", - modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp). + modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp * ui_scale). combinedClickable( onClick = { show_file_in_explorer_or_open(message.filename_fullpath) }, onLongClick = { show_containing_dir_in_explorer(message.filename_fullpath) })) @@ -250,7 +255,7 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float else { Icon( - modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp). + modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp * ui_scale). combinedClickable( onClick = { show_file_in_explorer_or_open(message.filename_fullpath) }, onLongClick = { show_containing_dir_in_explorer(message.filename_fullpath) }), @@ -283,15 +288,15 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float } } } - Spacer(Modifier.size(4.dp)) Row( horizontalArrangement = Arrangement.End, - modifier = Modifier.align(Alignment.End) + modifier = Modifier.randomDebugBorder().padding(all = 0.dp).align(Alignment.End) ) { Text( + modifier = Modifier.padding(all = 0.dp), text = timeToString(message.timeMs), textAlign = TextAlign.End, - style = MaterialTheme.typography.subtitle1.copy(fontSize = 10.sp), + style = MaterialTheme.typography.subtitle1.copy(fontSize = 10.sp, lineHeight = TextUnit.Unspecified), color = ChatColorsConfig.TIME_TEXT ) } @@ -299,7 +304,7 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float } Box(Modifier.size(10.dp)) } - if(isMyMessage) { + if (isMyMessage) { Column { Triangle(false, ChatColorsConfig.MY_MESSAGE) } diff --git a/src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt b/src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt index edc94c30..df0a1ff8 100644 --- a/src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt +++ b/src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt @@ -39,6 +39,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.LayoutDirection +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.vanniktech.emoji.emojiInformation @@ -93,7 +94,8 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, .background(color = if (!isMyMessage) ChatColorsConfig.OTHERS_MESSAGE else ChatColorsConfig.MY_MESSAGE) .padding(start = 10.dp, top = 5.dp, end = 10.dp, bottom = 5.dp), ) { - Column { + Column(Modifier.randomDebugBorder().padding(all = 0.dp), + verticalArrangement = Arrangement.spacedBy(0.dp)) { if(!isMyMessage) { Row(verticalAlignment = Alignment.Bottom) { // println("NNN:" + groupmessage.user.name + "CCC:" +groupmessage.user.color.luminance()) @@ -102,6 +104,7 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, style = MaterialTheme.typography.body1.copy( shadow = if (groupmessage.user.color.luminance() > NGC_PEER_LUMINANCE_THRESHOLD_FOR_SHADOW) Shadow(Color.Black, offset = Offset.Zero, blurRadius = 2.4f) else Shadow(), fontWeight = FontWeight.SemiBold, + lineHeight = TextUnit.Unspecified, letterSpacing = 0.sp, fontSize = 14.sp ), @@ -109,8 +112,7 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, ) } } - Spacer(Modifier.size(3.dp)) - SelectionContainer() + SelectionContainer(modifier = Modifier.padding(all = 0.dp)) { var msg_fontsize = MSG_TEXT_FONT_SIZE_MIXED try @@ -126,8 +128,10 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, } Text( text = groupmessage.text, + modifier = Modifier.randomDebugBorder(), style = MaterialTheme.typography.body1.copy( fontSize = ((msg_fontsize * ui_scale).toDouble()).sp, + lineHeight = TextUnit.Unspecified, letterSpacing = 0.sp ) ) @@ -142,7 +146,7 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, loadImageBitmap(File(groupmessage.filename_fullpath)) }, painterFor = { remember { BitmapPainter(it) } }, contentDescription = "Image", - modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp). + modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp * ui_scale). combinedClickable( onClick = { show_file_in_explorer_or_open(groupmessage.filename_fullpath) }, onLongClick = { show_containing_dir_in_explorer(groupmessage.filename_fullpath) })) @@ -150,7 +154,7 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, else { Icon( - modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp). + modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp * ui_scale). combinedClickable( onClick = { show_file_in_explorer_or_open(groupmessage.filename_fullpath) }, onLongClick = { show_containing_dir_in_explorer(groupmessage.filename_fullpath) }), @@ -163,17 +167,16 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, else { Icon( - modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp), + modifier = Modifier.size(IMAGE_PREVIEW_SIZE.dp * ui_scale), imageVector = Icons.Default.BrokenImage, contentDescription = "failed", tint = MaterialTheme.colors.primary ) } } - Spacer(Modifier.size(4.dp)) Row( horizontalArrangement = Arrangement.End, - modifier = Modifier.align(Alignment.End) + modifier = Modifier.randomDebugBorder().padding(all = 0.dp).align(Alignment.End) ) { if (groupmessage.was_synced) { @@ -189,9 +192,10 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, Spacer(modifier = Modifier.width(10.dp)) } Text( + modifier = Modifier.padding(all = 0.dp), text = timeToString(groupmessage.timeMs), textAlign = TextAlign.End, - style = MaterialTheme.typography.subtitle1.copy(fontSize = 10.sp), + style = MaterialTheme.typography.subtitle1.copy(fontSize = 10.sp, lineHeight = TextUnit.Unspecified), color = ChatColorsConfig.TIME_TEXT ) } @@ -199,7 +203,7 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, } Box(Modifier.size(10.dp)) } - if(isMyMessage) { + if (isMyMessage) { Column { Triangle(false, ChatColorsConfig.MY_MESSAGE) } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/ui/AddGroup.kt b/src/main/kotlin/org/briarproject/briar/desktop/ui/AddGroup.kt index ba582788..fa793cd4 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/ui/AddGroup.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/ui/AddGroup.kt @@ -1,6 +1,7 @@ package org.briarproject.briar.desktop.ui import SnackBarToast +import androidx.compose.desktop.ui.tooling.preview.Preview import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -27,10 +28,14 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.zoffcc.applications.trifa.HelperGeneric import com.zoffcc.applications.trifa.HelperGeneric.update_savedata_file_wrapper import com.zoffcc.applications.trifa.HelperGroup.hex_to_bytes import com.zoffcc.applications.trifa.MainActivity +import com.zoffcc.applications.trifa.MainActivity.Companion.tox_group_get_chat_id import com.zoffcc.applications.trifa.MainActivity.Companion.tox_group_join +import com.zoffcc.applications.trifa.MainActivity.Companion.tox_group_new +import com.zoffcc.applications.trifa.MainActivity.Companion.tox_group_self_set_name import com.zoffcc.applications.trifa.RandomNameGenerator import com.zoffcc.applications.trifa.TRIFAGlobals import com.zoffcc.applications.trifa.TRIFAGlobals.UINT32_MAX_JAVA @@ -42,9 +47,11 @@ import java.nio.ByteBuffer import java.util.* @Composable +@Preview fun AddGroup() = Box { var join_group_id by remember { mutableStateOf("") } var join_group_button_enabled by remember { mutableStateOf(false) } + var new_public_group_name by remember { mutableStateOf("") } Column { Row(modifier = Modifier.fillMaxWidth()) { Spacer(modifier = Modifier.width(30.dp)) @@ -102,6 +109,7 @@ fun AddGroup() = Box { } else { // some error on joining group + SnackBarToast("Error joining the Group") } }, colors = ButtonDefaults.buttonColors(), enabled = join_group_button_enabled) { Text("join Group") @@ -146,6 +154,7 @@ fun AddGroup() = Box { } else { // some error on joining group + SnackBarToast("Error joining the Public Information Group") } }, colors = ButtonDefaults.buttonColors()) { Text("join the Public Information Group") @@ -162,6 +171,81 @@ fun AddGroup() = Box { text ="Joining a Tox Public group for the first time can take a long time, even up to 30 minutes") } Spacer(modifier = Modifier.height(30.dp)) + Row { + Spacer(modifier = Modifier.width(50.dp)) + Text("or") + } + Row(modifier = Modifier.fillMaxWidth()) { + Spacer(modifier = Modifier.width(30.dp)) + TextField(singleLine = true, + textStyle = TextStyle(fontSize = 14.sp), + modifier = Modifier.padding(0.dp).width(400.dp), + colors = TextFieldDefaults.textFieldColors(backgroundColor = Color.White), + keyboardOptions = KeyboardOptions( + capitalization = KeyboardCapitalization.None, + autoCorrect = false, + ), value = new_public_group_name, placeholder = { + Text("enter Group Name", fontSize = 13.sp) + }, onValueChange = { + new_public_group_name = it + }) + Spacer(modifier = Modifier.width(30.dp)) + Button( + onClick = { + // HINT: create a new public Group + val my_peername = RandomNameGenerator.getFullName(Random()) + val new_group_num = tox_group_new( + ToxVars.TOX_GROUP_PRIVACY_STATE.TOX_GROUP_PRIVACY_STATE_PUBLIC.value, + new_public_group_name, + my_peername) + + update_savedata_file_wrapper() + + if ((new_group_num >= 0) && (new_group_num < UINT32_MAX_JAVA)) + { + // HINT: Group was created + var group_identifier: String = "" + val groupid_buf: ByteBuffer = ByteBuffer.allocateDirect(TRIFAGlobals.GROUP_ID_LENGTH * 2) + if (tox_group_get_chat_id(new_group_num, groupid_buf) == 0) + { + val groupid_buffer = ByteArray(TRIFAGlobals.GROUP_ID_LENGTH) + groupid_buf.clear() + groupid_buf.get(groupid_buffer, 0, TRIFAGlobals.GROUP_ID_LENGTH) + group_identifier = HelperGeneric.bytesToHex(groupid_buffer, 0, TRIFAGlobals.GROUP_ID_LENGTH).lowercase() + } + + try + { + tox_group_self_set_name(new_group_num, my_peername) + update_savedata_file_wrapper() + } catch (_: Exception) + { + } + + try + { + val new_privacy_state = MainActivity.tox_group_get_privacy_state(new_group_num) + val group_name = new_public_group_name + val group_num_peers = MainActivity.tox_group_peer_count(new_group_num) + groupstore.add(item = GroupItem(numPeers = group_num_peers.toInt(), + name = group_name!!, isConnected = 0, + groupId = group_identifier.lowercase(), + privacyState = new_privacy_state)) + } catch (_: Exception) + { + } + new_public_group_name = "" + SnackBarToast("You created new public Group") + } else + { + // some error on joining group + SnackBarToast("Error creating new public Group") + } + }, colors = ButtonDefaults.buttonColors(), enabled = new_public_group_name.isNotEmpty()) { + Text("Create new public Group") + } + } + Spacer(modifier = Modifier.height(30.dp)) } }