commit a8494312bf633feaf067e98710763e4541a0bcf4
parent 3f8d6cb9fd12032ec90e7bfe2bf3c6735dd2e947
Author: t3sserakt <t3sserakt@posteo.de>
Date: Mon, 30 Mar 2026 15:20:03 +0200
Fixed Lobby join.
Diffstat:
4 files changed, 43 insertions(+), 46 deletions(-)
diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/boundimpl/GnunetChatBoundService.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/boundimpl/GnunetChatBoundService.kt
@@ -37,7 +37,7 @@ class GnunetChatBoundService(
private var deathRecipient: IBinder.DeathRecipient? = null
@Volatile
- private var lastHandle: Long = 0L
+ private var lastHandle: ChatHandle = ChatHandle(0L)
@Volatile
private lateinit var messageCallback: ((ChatContext, ChatMessage) -> Unit)
@@ -66,7 +66,7 @@ class GnunetChatBoundService(
val dr = IBinder.DeathRecipient {
Log.w(TAG, "Remote binder died")
remoteRef.set(null)
- lastHandle = 0L
+ lastHandle.pointer = 0L
deathRecipient = null
}
deathRecipient = dr
@@ -77,7 +77,7 @@ class GnunetChatBoundService(
override fun onServiceDisconnected(name: ComponentName) {
Log.w(TAG, "Remote disconnected")
remoteRef.set(null)
- lastHandle = 0L
+ lastHandle.pointer = 0L
}
}
@@ -147,7 +147,7 @@ class GnunetChatBoundService(
}
deathRecipient = null
remoteRef.set(null)
- lastHandle = 0L
+ lastHandle.pointer = 0L
runCatching { appContext.unbindService(conn) }
.onFailure { Log.w(TAG, "unbindService failed", it) }
}
@@ -178,7 +178,7 @@ class GnunetChatBoundService(
if (handle.pointer == 0L) {
val real = remote.startChat(DEFAULT_APP_NAME, binderCallback)
handle.pointer = real
- lastHandle = real
+ lastHandle.pointer = real
handleReady[handle]?.complete(real)
handleReady.remove(handle)
drainPending(remote, real)
@@ -201,7 +201,7 @@ class GnunetChatBoundService(
try {
val remote = getOrBindRemote()
val h = remote.startChat("messengerApp", binderCallback)
- lastHandle = h
+ lastHandle.pointer = h
ch.pointer = h
deferred.complete(h)
drainPending(remote, h)
@@ -220,7 +220,7 @@ class GnunetChatBoundService(
remote.reset()
Log.i(TAG, "reset: successfully reset remote service")
- lastHandle = 0L
+ lastHandle.pointer = 0L
handleReady.clear()
synchronized(pendingAfterHandle) {
pendingAfterHandle.clear()
@@ -244,13 +244,13 @@ class GnunetChatBoundService(
}
val remote = remoteRef.get()
- val h = lastHandle.takeIf { it != 0L } ?: handle.pointer
+ val h = lastHandle.takeIf { it.pointer != 0L } ?: handle
when {
- remote != null && h != 0L -> {
+ remote != null && h.pointer != 0L -> {
ioScope.launch {
try {
- remote.iterateAccounts(h, bridge)
+ remote.iterateAccounts(h.pointer, bridge)
} catch (dead: DeadObjectException) {
Log.w(TAG, "iterateAccounts: binder died, queue & rebind")
synchronized(pendingAfterHandle) {
@@ -277,7 +277,7 @@ class GnunetChatBoundService(
}
}
- remote != null && h == 0L -> {
+ remote != null && h.pointer == 0L -> {
synchronized(pendingAfterHandle) {
pendingAfterHandle += { r, real ->
runCatching { r.iterateAccounts(real, bridge) }
@@ -400,7 +400,7 @@ class GnunetChatBoundService(
override fun isContactBlocked(contact: ChatContact): Boolean {
return runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.isContactBlocked(contact.toDto())
}
}
@@ -408,7 +408,7 @@ class GnunetChatBoundService(
override fun setContactBlocked(contact: ChatContact, isBlocked: Boolean) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.setContactBlocked(contact.toDto(), isBlocked)
}
}
@@ -498,7 +498,7 @@ class GnunetChatBoundService(
override fun setGroupName(group: ChatGroup, name: String) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.setGroupName(group.toDto(), name)
}
}
@@ -515,7 +515,7 @@ class GnunetChatBoundService(
override fun parseUri(uri: String): ChatUri {
return runBlocking {
- val uriDto = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val uriDto = withReadyRemote(lastHandle) { remote, _ ->
remote.parseUri(uri)
}
uriDto.toLocal()
@@ -524,7 +524,7 @@ class GnunetChatBoundService(
override fun destroyUri(uri: ChatUri) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.destroyUri(uri.toDto())
}
}
@@ -532,7 +532,7 @@ class GnunetChatBoundService(
override fun inviteContactToGroup(group: ChatGroup, contact: ChatContact) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.inviteContactToGroup(group.toDto(), contact.toDto())
}
}
@@ -540,7 +540,7 @@ class GnunetChatBoundService(
override fun getUserPointerForContext(context: ChatContext): String? {
return runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.getUserPointerForContext(context.toDto())
}
}
@@ -548,7 +548,7 @@ class GnunetChatBoundService(
override fun setUserPointerForContext(context: ChatContext, userPointer: String) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.setUserPointerForContext(context.toDto(), userPointer)
}
}
@@ -556,7 +556,7 @@ class GnunetChatBoundService(
override fun getSenderFromMessage(message: ChatMessage): ChatContact {
return runBlocking {
- val contactDto = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val contactDto = withReadyRemote(lastHandle) { remote, _ ->
remote.getSenderFromMessage(message.toDto())
}
contactDto.toLocal()
@@ -565,7 +565,7 @@ class GnunetChatBoundService(
override fun getGroupFromContext(context: ChatContext): ChatGroup? {
return runBlocking {
- val groupDto = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val groupDto = withReadyRemote(lastHandle) { remote, _ ->
remote.getGroupFromContext(context.toDto())
}
groupDto.toLocal()
@@ -574,7 +574,7 @@ class GnunetChatBoundService(
override fun getMessageForGroupContact(group: ChatGroup, contact: ChatContact): ChatMessage {
return runBlocking {
- val messageDto = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val messageDto = withReadyRemote(lastHandle) { remote, _ ->
remote.getMessageForGroupContact(group.toDto(), contact.toDto())
}
messageDto.toLocal(ChatContext(null, null, false, false))
@@ -583,7 +583,7 @@ class GnunetChatBoundService(
override fun getMessageKind(message: ChatMessage): MessageKind {
return runBlocking {
- val kind = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val kind = withReadyRemote(lastHandle) { remote, _ ->
remote.getMessageKind(message.toDto())
}
MessageKind.fromCode(kind)
@@ -592,7 +592,7 @@ class GnunetChatBoundService(
override fun isMessageRecent(message: ChatMessage): GnunetReturnValue {
return runBlocking {
- val result = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val result = withReadyRemote(lastHandle) { remote, _ ->
remote.isMessageRecent(message.toDto())
}
result.toGnunetReturn()
@@ -601,7 +601,7 @@ class GnunetChatBoundService(
override fun getMessageTimestamp(message: ChatMessage): Long {
return runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.getMessageTimestamp(message.toDto())
}
}
@@ -613,7 +613,7 @@ class GnunetChatBoundService(
message: ChatMessage
) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.setMessageForGroupContact(group.toDto(), contact.toDto(), message.toDto())
}
}
@@ -693,7 +693,7 @@ class GnunetChatBoundService(
override fun getContactContext(chatContact: ChatContact): ChatContext {
return runBlocking {
- val contextDto = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val contextDto = withReadyRemote(lastHandle) { remote, _ ->
remote.getContactContext(chatContact.toDto())
}
contextDto.toLocal()
@@ -702,7 +702,7 @@ class GnunetChatBoundService(
override fun getGroupContext(chatGroup: ChatGroup): ChatContext {
return runBlocking {
- val contextDto = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val contextDto = withReadyRemote(lastHandle) { remote, _ ->
remote.getGroupContext(chatGroup.toDto())
}
contextDto.toLocal()
@@ -711,7 +711,7 @@ class GnunetChatBoundService(
override fun getContactUserPointer(chatContact: ChatContact): String {
return runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.getContactUserPointer(chatContact.toDto())
}
}
@@ -719,7 +719,7 @@ class GnunetChatBoundService(
override fun setContactUserPointer(chatContact: ChatContact, userPointer: String) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.setContactUserPointer(chatContact.toDto(), userPointer)
}
}
@@ -727,7 +727,7 @@ class GnunetChatBoundService(
override fun getGroupUserPointer(chatGroup: ChatGroup): String {
return runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.getGroupUserPointer(chatGroup.toDto())
}
}
@@ -735,7 +735,7 @@ class GnunetChatBoundService(
override fun setGroupUserPointer(chatGroup: ChatGroup, userPointer: String) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.setGroupUserPointer(chatGroup.toDto(), userPointer)
}
}
@@ -743,7 +743,7 @@ class GnunetChatBoundService(
override fun sendText(chatContext: ChatContext, text: String) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.sendText(chatContext.toDto(), text)
}
}
@@ -751,7 +751,7 @@ class GnunetChatBoundService(
override fun getContactKey(chatContact: ChatContact): String {
return runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.getContactKey(chatContact.toDto())
}
}
@@ -759,7 +759,7 @@ class GnunetChatBoundService(
override fun getContextContact(context: ChatContext): ChatContact {
return runBlocking {
- val contactDto = withReadyRemote(ChatHandle(0)) { remote, _ ->
+ val contactDto = withReadyRemote(lastHandle) { remote, _ ->
remote.getContextContact(context.toDto())
}
contactDto.toLocal()
@@ -768,7 +768,7 @@ class GnunetChatBoundService(
override fun deleteContact(chatContact: ChatContact) {
runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.deleteContact(chatContact.toDto())
}
}
@@ -776,7 +776,7 @@ class GnunetChatBoundService(
override fun isGroup(context: ChatContext): Boolean {
return runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.isGroup(context.toDto())
}
}
@@ -784,7 +784,7 @@ class GnunetChatBoundService(
override fun isPlatform(context: ChatContext): Boolean {
return runBlocking {
- withReadyRemote(ChatHandle(0)) { remote, _ ->
+ withReadyRemote(lastHandle) { remote, _ ->
remote.isPlatform(context.toDto())
}
}
diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/LobbyJoinFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/LobbyJoinFragment.kt
@@ -55,7 +55,8 @@ class LobbyJoinFragment : Fragment() {
private val cameraExecutor = Executors.newSingleThreadExecutor()
override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?,
+ inflater: LayoutInflater,
+ container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val view = inflater.inflate(R.layout.fragment_join_lobby, container, false)
@@ -81,11 +82,7 @@ class LobbyJoinFragment : Fragment() {
if (allPermissionsGranted()) {
startCamera()
} else {
- ActivityCompat.requestPermissions(
- requireActivity(),
- arrayOf(Manifest.permission.CAMERA),
- 10
- )
+ requestPermissions(arrayOf(Manifest.permission.CAMERA), 10)
}
return view
diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_join_lobby.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_join_lobby.xml
@@ -26,7 +26,7 @@
android:id="@+id/lobby_join_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".ui.lobby.LobbyJoinFragment">
+ tools:context=".ui.contact.LobbyJoinFragment">
<androidx.camera.view.PreviewView
android:id="@+id/camera_preview"
diff --git a/GNUnetMessenger/app/src/main/res/navigation/nav_graph.xml b/GNUnetMessenger/app/src/main/res/navigation/nav_graph.xml
@@ -130,7 +130,7 @@
<fragment
android:id="@+id/lobbyJoinFragment"
- android:name="org.gnunet.gnunetmessenger.ui.lobby.LobbyJoinFragment"
+ android:name="org.gnunet.gnunetmessenger.ui.contact.LobbyJoinFragment"
android:label="Join Lobby"
tools:layout="@layout/fragment_join_lobby" />