1
This commit is contained in:
1 parent
26f4da1b7c
commit
712d1b53df
29 files changed
+1029
-1138
No files matched your search
@@ -8,6 +8,7 @@ import androidx.compose.runtime.*
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.utun.chat.data.InviteData
|
||||
import com.utun.chat.data.LogManager
|
||||
import com.utun.chat.data.NativeLib
|
||||
import com.utun.chat.headless.HeadlessService
|
||||
import com.utun.chat.ui.screens.*
|
||||
@@ -30,6 +31,7 @@ class MainActivity : ComponentActivity() {
|
||||
var qrResult by remember { mutableStateOf<String?>(null) }
|
||||
var showJoinDialog by remember { mutableStateOf(false) }
|
||||
var joinAutoLink by remember { mutableStateOf<String?>(null) }
|
||||
var inviteLinkText by remember { mutableStateOf<String?>(null) }
|
||||
|
||||
BackHandler(enabled = screen != Screen.ChannelList) {
|
||||
when (screen) {
|
||||
@@ -57,6 +59,16 @@ class MainActivity : ComponentActivity() {
|
||||
onSelectChannel = { ch -> vm.selectChannel(ch); screen = Screen.Chat },
|
||||
onCreateChannel = { vm.createChannel("general", "channel_1") },
|
||||
onJoinChannel = { showJoinDialog = true; joinAutoLink = null },
|
||||
onInviteClick = { ch ->
|
||||
val chId = ch.id.toLongOrNull()
|
||||
if (chId == null) {
|
||||
LogManager.addLog("ERROR", "INVITE", "channel id is not numeric: ${ch.id}")
|
||||
} else {
|
||||
val link = NativeLib.encodeInviteLink(chId)
|
||||
if (link != null) inviteLinkText = link
|
||||
else LogManager.addLog("ERROR", "INVITE", "encodeInviteLink returned null for ch=$chId")
|
||||
}
|
||||
},
|
||||
onSettings = { screen = Screen.Settings },
|
||||
onLogs = { screen = Screen.Logs },
|
||||
onRefresh = { vm.requestRefresh() }
|
||||
@@ -128,6 +140,10 @@ class MainActivity : ComponentActivity() {
|
||||
onDismiss = { showJoinDialog = false }
|
||||
)
|
||||
}
|
||||
|
||||
inviteLinkText?.let { link ->
|
||||
InviteLinkDialog(link = link, onDismiss = { inviteLinkText = null })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,8 @@ object NativeLib {
|
||||
|
||||
fun getMyNodeId(): Long = nativeGetMyNodeId()
|
||||
|
||||
fun encodeInviteLink(channelId: Long): String? = nativeEncodeInviteLink(channelId)
|
||||
|
||||
fun ping() { nativePing() }
|
||||
fun isResponsive(): Boolean = nativeIsResponsive()
|
||||
|
||||
@@ -130,6 +132,7 @@ object NativeLib {
|
||||
private external fun nativeRegenerateKeys()
|
||||
private external fun nativeClearDatabase(): Boolean
|
||||
private external fun nativeGetMyNodeId(): Long
|
||||
private external fun nativeEncodeInviteLink(channelId: Long): String?
|
||||
private external fun nativeRestart(configText: String): Boolean
|
||||
private external fun nativePing()
|
||||
private external fun nativeIsResponsive(): Boolean
|
||||
|
||||
+3
-1
@@ -33,6 +33,7 @@ fun ChannelListScreen(
|
||||
onSelectChannel: (Channel) -> Unit,
|
||||
onCreateChannel: () -> Unit,
|
||||
onJoinChannel: () -> Unit,
|
||||
onInviteClick: (Channel) -> Unit,
|
||||
onSettings: () -> Unit,
|
||||
onLogs: () -> Unit,
|
||||
onRefresh: () -> Unit = {}
|
||||
@@ -87,7 +88,8 @@ fun ChannelListScreen(
|
||||
Box(Modifier.width(4.dp).fillMaxHeight().background(barColor))
|
||||
Row(Modifier.fillMaxWidth().padding(12.dp)) {
|
||||
Box(Modifier.size(44.dp), contentAlignment = Alignment.Center) {
|
||||
Surface(shape = MaterialTheme.shapes.small) {
|
||||
Surface(shape = MaterialTheme.shapes.small,
|
||||
modifier = Modifier.clickable { onInviteClick(ch) }) {
|
||||
Text("#", fontSize = 22.sp, modifier = Modifier.padding(8.dp))
|
||||
}
|
||||
if (badgeText.isNotEmpty()) {
|
||||
|
||||
Reference in new issue
Block a user