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

updates and fixes #89

Merged
merged 6 commits into from
Dec 26, 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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.6.0-dev1347
compose.version=1.5.11
kotlin.version=1.9.21
multiplatform.version=1.9.21
12 changes: 6 additions & 6 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,9 @@ fun App()
load_messages_for_friend(contacts.selectedContactPubkey)
GlobalScope.launch { globalstore.try_clear_unread_message_count() }
ChatAppWithScaffold(focusRequester = focusRequester, contactList = contacts, ui_scale = ui_scale)
LaunchedEffect(contacts.selectedContactPubkey) {
focusRequester.requestFocus()
}
//LaunchedEffect(contacts.selectedContactPubkey) {
// focusRequester.requestFocus()
//}
}
}
}
Expand Down Expand Up @@ -1032,9 +1032,9 @@ fun App()
load_groupmessages_for_friend(groups.selectedGroupId)
GlobalScope.launch { globalstore.try_clear_unread_group_message_count() }
GroupAppWithScaffold(focusRequester = groupfocusRequester, groupList = groups, ui_scale = ui_scale)
LaunchedEffect(groups.selectedGroupId) {
groupfocusRequester.requestFocus()
}
//LaunchedEffect(groups.selectedGroupId) {
// groupfocusRequester.requestFocus()
//}
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,6 @@ class MainActivity
tox_service_fg!!.tox_thread_start_fg()
}

try
{
Thread.currentThread().name = "t_main"
} catch (_: Exception)
{
}

try
{
toxdatastore.updateToxID(my_tox_id_temp)
Expand Down
30 changes: 30 additions & 0 deletions src/main/kotlin/com/zoffcc/applications/trifa/TrifaToxService.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.zoffcc.applications.trifa

import avstatestore
import avstatestorecallstate
import com.zoffcc.applications.sorm.BootstrapNodeEntryDB
import com.zoffcc.applications.sorm.BootstrapNodeEntryDB.bootstrap_node_list
import com.zoffcc.applications.sorm.BootstrapNodeEntryDB.get_tcprelay_nodelist_from_db
Expand Down Expand Up @@ -83,6 +84,13 @@ class TrifaToxService
{
override fun run()
{
try
{
Thread.currentThread().name = "t_tox_iter"
} catch (_: Exception)
{
}

com.zoffcc.applications.sorm.OrmaDatabase.init()
// ------ correct startup order ------
orma = com.zoffcc.applications.sorm.OrmaDatabase()
Expand Down Expand Up @@ -334,6 +342,13 @@ class TrifaToxService
{
override fun run()
{
try
{
Thread.currentThread().name = "t_a_play"
} catch (_: Exception)
{
}

try
{
tox_a_queue_stop_trigger = true
Expand Down Expand Up @@ -450,6 +465,10 @@ class TrifaToxService
// -- play incoming bytes --
// -- play incoming bytes --
sleep(20)
if (avstatestorecallstate.state.call_state != AVState.CALL_STATUS.CALL_STATUS_CALLING)
{
sleep(200)
}
}
} catch (_: Exception)
{
Expand All @@ -467,6 +486,13 @@ class TrifaToxService
{
override fun run()
{
try
{
Thread.currentThread().name = "t_ngc_a_play"
} catch (_: Exception)
{
}

try
{
val sleep_millis: Long = 40
Expand Down Expand Up @@ -607,6 +633,10 @@ class TrifaToxService
// -- play incoming bytes --
// -- play incoming bytes --
sleep(20)
if ((HelperGeneric.ngc_video_packet_last_incoming_ts + 5000) < System.currentTimeMillis())
{
sleep(200)
}
}
} catch (_: Exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ data class globalstore_state(
val contacts_unread_group_message_count: Int = 0
)

private val globalstore_state_lock = Any()

interface GlobalStore {
fun updateMinimized(value: Boolean)
fun updateFocused(value: Boolean)
Expand Down Expand Up @@ -72,19 +74,23 @@ fun CoroutineScope.createGlobalStore(): GlobalStore {

override fun try_clear_unread_message_count()
{
var unread_count = 0
try
{
unread_count = TrifaToxService.orma!!.selectFromMessage()
.directionEq(TRIFAGlobals.TRIFA_MSG_DIRECTION.TRIFA_MSG_DIRECTION_RECVD.value)
.is_newEq(true).count()
Log.i(TAG, "try_clear_unread_message_count:unread_count=" + unread_count)
}
catch (e: Exception)
{
e.printStackTrace()
synchronized(globalstore_state_lock) {
var unread_count = 0
try
{
unread_count = TrifaToxService.orma!!.selectFromMessage()
.directionEq(TRIFAGlobals.TRIFA_MSG_DIRECTION.TRIFA_MSG_DIRECTION_RECVD.value)
.is_newEq(true).count()
if (unread_count > 0)
{
Log.i(TAG, "try_clear_unread_message_count:unread_count=" + unread_count)
}
} catch (e: Exception)
{
e.printStackTrace()
}
mutableStateFlow.value = state.copy(contacts_unread_message_count = unread_count)
}
mutableStateFlow.value = state.copy(contacts_unread_message_count = unread_count)
}

override fun hard_clear_unread_message_count()
Expand Down
12 changes: 0 additions & 12 deletions src/main/kotlin/com/zoffcc/applications/trifa2/ChatApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,6 @@ fun ChatApp(focusRequester: FocusRequester, displayTextField: Boolean = true, se
{
SnackBarToast("Sending Message failed")
}
/*
val res = tox_friend_send_message(friend_num, TOX_MESSAGE_TYPE.TOX_MESSAGE_TYPE_NORMAL.value, text)
if (res >= 0)
{
val msg_id_db = sent_message_to_db(selectedContactPubkey, timestamp, text)
messagestore.send(MessageAction.SendMessage(UIMessage(direction = TRIFAGlobals.TRIFA_MSG_DIRECTION.TRIFA_MSG_DIRECTION_SENT.value, user = myUser, timeMs = timestamp, text = text, toxpk = selectedContactPubkey!!, trifaMsgType = TRIFAGlobals.TRIFA_MSG_TYPE.TRIFA_MSG_TYPE_TEXT.value, msgDatabaseId = msg_id_db, filename_fullpath = null)))
}
else
{
SnackBarToast("Sending Message failed")
}
*/
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.zoffcc.applications.trifa.Log
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource

@Composable
internal fun GroupMessages(ui_scale: Float, selectedGroupId: String?) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/com/zoffcc/applications/trifa2/Messages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.zoffcc.applications.trifa.Log
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource

@Composable
internal fun Messages(ui_scale: Float, selectedContactPubkey: String?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand All @@ -33,7 +32,6 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource

/**
* Display the avatar for a [ContactItem]. If it has an avatar image, display that, otherwise
Expand Down
Loading