messenger-android

Android graphical user interfaces for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit 4f2d2e3ef38714343c08488892576ace19696712
parent 202ef3417d09054423af2dd4ab38fd31a927f7bb
Author: t3sserakt <t3sserakt@posteo.de>
Date:   Mon,  2 Jun 2025 10:01:31 +0200

Added group functionality, contact information and settings.

Diffstat:
MGNUnetMessenger/.idea/deploymentTargetSelector.xml | 8++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/MainActivity.kt | 64+++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/logic/ChatRegistry.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatAccount.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContact.kt | 27++++++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContext.kt | 29++++++++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContextType.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatGroup.kt | 26+++++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatHandle.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatMessage.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatMessageType.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatSummary.kt | 28+++++++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatUri.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/EventType.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/GnunetReturnValue.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/MessageKind.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/MessengerApp.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/GnunetChat.kt | 32+++++++++++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/ServiceFactory.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/boundimpl/GnunetChatBoundService.kt | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++--
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/mock/GnunetChatMock.kt | 145++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/BaseProfileFragment.kt | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/SettingsFragment.kt | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountAdapter.kt | 59-----------------------------------------------------------
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountDetailsFragment.kt | 94+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountListFragment.kt | 31++++++++++++++++++++++++++-----
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountOverviewFragment.kt | 25++++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AttributeListFragment.kt | 70+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/CreateAccountFragment.kt | 28++++++++++++++++++++++++----
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/LobbyCreateFragment.kt | 25++++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/LobbyDisplayFragment.kt | 24++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/AccountAdapter.kt | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/AttributeAdapter.kt | 27++++++++++++++++++++++++---
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/BlockedContactAdapter.kt | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ChatListAdapter.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ChatMessageAdapter.kt | 27+++++++++++++++++++++++++--
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ContactListAdapter.kt | 73++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ShareAttributesAdapter.kt | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/chat/ChatFragment.kt | 103++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/chat/MemberListFragment.kt | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ContactFragment.kt | 127+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ContactListFragment.kt | 29++++++++++++++++++++++++++---
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/LobbyJoinFragment.kt | 28++++++++++++++++++++++++++--
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ShareAttributesFragment.kt | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/group/CreateGroupOrPlatformFragment.kt | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/group/SelectGroupMembersFragment.kt | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/util/AvatarStorageUtil.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/util/LobbyDisplayHelper.kt | 24++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatMenuViewModel.kt | 34++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatOverviewViewModel.kt | 25++++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatViewModel.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatViewModelFactory.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ContactListViewModel.kt | 24++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/account_drawer_header.xml | 21+++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/activity_main.xml | 21+++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/attribute_item.xml | 23+++++++++++++++++++++--
MGNUnetMessenger/app/src/main/res/layout/fragment_account_details.xml | 21+++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/fragment_account_list.xml | 21+++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/fragment_account_overview.xml | 24++++++++++++++++++++++--
MGNUnetMessenger/app/src/main/res/layout/fragment_attribute_list.xml | 23+++++++++++++++++++++--
MGNUnetMessenger/app/src/main/res/layout/fragment_chat.xml | 28+++++++++++++++++++++++-----
AGNUnetMessenger/app/src/main/res/layout/fragment_contact.xml | 37+++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/fragment_contact_list.xml | 21+++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/fragment_create_account.xml | 21+++++++++++++++++++++
AGNUnetMessenger/app/src/main/res/layout/fragment_create_group_or_platform.xml | 43+++++++++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/fragment_join_lobby.xml | 23++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/res/layout/fragment_lobby_create.xml | 30+++++++++++++++++++++++-------
MGNUnetMessenger/app/src/main/res/layout/fragment_lobby_display.xml | 21+++++++++++++++++++++
AGNUnetMessenger/app/src/main/res/layout/fragment_member_list.xml | 45+++++++++++++++++++++++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/res/layout/fragment_profile_base.xml | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/res/layout/fragment_select_group_members.xml | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/res/layout/fragment_settings.xml | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AGNUnetMessenger/app/src/main/res/layout/fragment_share_attribute.xml | 40++++++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/item_account.xml | 21+++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/item_chat.xml | 23++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/res/layout/item_contact.xml | 21+++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/item_message_other.xml | 23++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/res/layout/item_message_own.xml | 23++++++++++++++++++++++-
MGNUnetMessenger/app/src/main/res/layout/item_message_system.xml | 23++++++++++++++++++++++-
AGNUnetMessenger/app/src/main/res/layout/item_share_attribute.xml | 41+++++++++++++++++++++++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/layout/view_lobby_info.xml | 21+++++++++++++++++++++
MGNUnetMessenger/app/src/main/res/menu/chat_menu.xml | 4++++
MGNUnetMessenger/app/src/main/res/menu/main_menu.xml | 19++++++++++++++++++-
MGNUnetMessenger/app/src/main/res/navigation/nav_graph.xml | 109++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
MGNUnetMessenger/app/src/main/res/values/strings.xml | 8++++++++
Mapp-debug.apk | 0
86 files changed, 3139 insertions(+), 235 deletions(-)

diff --git a/GNUnetMessenger/.idea/deploymentTargetSelector.xml b/GNUnetMessenger/.idea/deploymentTargetSelector.xml @@ -4,6 +4,14 @@ <selectionStates> <SelectionState runConfigName="app"> <option name="selectionMode" value="DROPDOWN" /> + <DropdownSelection timestamp="2025-06-02T07:08:31.015580Z"> + <Target type="DEFAULT_BOOT"> + <handle> + <DeviceId pluginId="LocalEmulator" identifier="path=/Users/ffelgenh/.android/avd/Pixel_4.avd" /> + </handle> + </Target> + </DropdownSelection> + <DialogSelection /> </SelectionState> </selectionStates> </component> diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/MainActivity.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/MainActivity.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/MainActivity.kt + */ + package org.gnunet.gnunetmessenger import android.os.Bundle @@ -14,6 +38,7 @@ import org.gnunet.gnunetmessenger.model.ChatAccount import org.gnunet.gnunetmessenger.model.ChatContact import org.gnunet.gnunetmessenger.model.ChatContext import org.gnunet.gnunetmessenger.model.ChatHandle +import org.gnunet.gnunetmessenger.viewmodel.ChatMenuViewModel import org.gnunet.gnunetmessenger.model.ChatMessage import org.gnunet.gnunetmessenger.model.ChatMessageType import org.gnunet.gnunetmessenger.model.ChatSummary @@ -33,6 +58,7 @@ class MainActivity : AppCompatActivity() { private lateinit var handle: ChatHandle private val chatOverviewViewModel: ChatOverviewViewModel by viewModels() val contactListViewModel: ContactListViewModel by viewModels() + private val chatMenuViewModels = mutableMapOf<String, ChatMenuViewModel>() private val chatViewModels = mutableMapOf<String, ChatViewModel>() private val chats = mutableMapOf<String, ChatContext>() var currentAccount: ChatAccount? = null @@ -176,7 +202,7 @@ class MainActivity : AppCompatActivity() { //app.callMessageEvent(EventType.DISCOURSE_DATA, chatContext, chatMessage) } else -> { - // Unbekannter Typ – nichts tun + assert(false) } } } @@ -191,6 +217,16 @@ class MainActivity : AppCompatActivity() { return chatViewModel } + fun getChatMenuViewModel(chatContext: ChatContext): ChatMenuViewModel? { + val key = gnunetChat.getUserPointerForContext(chatContext) + var chatMenuViewModel: ChatMenuViewModel? = null + if (null != key) + chatMenuViewModel = chatMenuViewModels.getOrPut(key) { + ChatMenuViewModel(chatContext) + } + return chatMenuViewModel + } + private fun loadChats() { val summaries = mutableListOf<ChatSummary>() @@ -203,13 +239,15 @@ class MainActivity : AppCompatActivity() { gnunetChat.setUserPointerForContext(chatContext, uuid) chats.put(uuid, chatContext) + contact.blocked = gnunetChat.isContactBlocked(contact) summaries.add( ChatSummary( chatContext = chatContext, - displayName = contact.name + displayName = contact.name, + contact = contact ) ) - 0 // Rückgabewert (OK) + 0 } contactListViewModel.setContacts(contacts) @@ -222,7 +260,8 @@ class MainActivity : AppCompatActivity() { summaries.add( ChatSummary( chatContext = group.chatContext, - displayName = group.name + displayName = group.name, + group = group ) ) 0 @@ -263,19 +302,27 @@ class MainActivity : AppCompatActivity() { navController.navigate(action) true } + R.id.menu_new_group -> { + val action = NavGraphDirections.actionGlobalCreateGroupOrPlatformFragment(isGroup = true) + navController.navigate(action) + true + } + R.id.menu_new_platform -> { + val action = NavGraphDirections.actionGlobalCreateGroupOrPlatformFragment(isGroup = false) + navController.navigate(action) + true + } R.id.menu_contact_list -> { val action = NavGraphDirections.actionGlobalContactListFragment() navController.navigate(action) true } R.id.menu_settings -> { - // Beispiel: Navigation zu Einstellungen - // startActivity(Intent(this, SettingsActivity::class.java)) + val action = NavGraphDirections.actionGlobalSettingsFragment() + navController.navigate(action) true } R.id.menu_about -> { - // Beispiel: Über-Dialog anzeigen - // showAboutDialog() true } else -> super.onOptionsItemSelected(item) @@ -287,7 +334,6 @@ class MainActivity : AppCompatActivity() { || super.onSupportNavigateUp() } - // Add the method to access the GnunetChat instance fun getGnunetChatInstance(): GnunetChat { return gnunetChat } diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/logic/ChatRegistry.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/logic/ChatRegistry.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/logic/ChatRegistry.kt + */ + package org.gnunet.gnunetmessenger.logic import org.gnunet.gnunetmessenger.viewmodel.ChatViewModel diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatAccount.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatAccount.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatAccount.kt + */ + package org.gnunet.gnunetmessenger.model import android.os.Parcelable diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContact.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContact.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContact.kt + */ + package org.gnunet.gnunetmessenger.model import android.os.Parcelable @@ -6,5 +30,6 @@ import kotlinx.parcelize.Parcelize @Parcelize data class ChatContact( val chatContext: ChatContext, - val name: String + val name: String, + var blocked: Boolean = false ) : Parcelable diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContext.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContext.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContext.kt + */ + package org.gnunet.gnunetmessenger.model import android.os.Parcelable @@ -6,4 +30,7 @@ import kotlinx.parcelize.Parcelize @Parcelize data class ChatContext ( val chatContextType: ChatContextType, - var userPointer: String?): Parcelable + var userPointer: String?, + val isGroup: Boolean, + val isPlatform: Boolean): Parcelable + diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContextType.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContextType.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatContextType.kt + */ + package org.gnunet.gnunetmessenger.model enum class ChatContextType { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatGroup.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatGroup.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatGroup.kt + */ + package org.gnunet.gnunetmessenger.model import android.os.Parcelable @@ -6,5 +30,5 @@ import kotlinx.parcelize.Parcelize @Parcelize data class ChatGroup ( val chatContext: ChatContext, - val name: String + var name: String ): Parcelable \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatHandle.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatHandle.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatHandle.kt + */ + package org.gnunet.gnunetmessenger.model class ChatHandle(pointer: Long) { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatMessage.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatMessage.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatMessage.kt + */ + package org.gnunet.gnunetmessenger.model import android.os.Parcelable diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatMessageType.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatMessageType.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatMessageType.kt + */ + package org.gnunet.gnunetmessenger.model enum class ChatMessageType { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatSummary.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatSummary.kt @@ -1,7 +1,33 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatSummary.kt + */ + package org.gnunet.gnunetmessenger.model data class ChatSummary( val chatContext: ChatContext, val displayName: String, - val lastMessagePreview: String? = null + val lastMessagePreview: String? = null, + val group: ChatGroup? = null, + val contact: ChatContact? = null ) \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatUri.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatUri.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/ChatUri.kt + */ + package org.gnunet.gnunetmessenger.model import android.os.Parcelable diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/EventType.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/EventType.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/EventType.kt + */ + package org.gnunet.gnunetmessenger.model enum class EventType { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/GnunetReturnValue.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/GnunetReturnValue.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/GnunetReturnValue.kt + */ + package org.gnunet.gnunetmessenger.model enum class GnunetReturnValue(val value: Int) { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/MessageKind.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/MessageKind.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/MessageKind.kt + */ + package org.gnunet.gnunetmessenger.model enum class MessageKind { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/MessengerApp.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/MessengerApp.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/model/MessengerApp.kt + */ + package org.gnunet.gnunetmessenger.model class MessengerApp { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/GnunetChat.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/GnunetChat.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/GnunetChat.kt + */ + package org.gnunet.gnunetmessenger.service @@ -28,7 +52,7 @@ interface GnunetChat { fun lobbyOpen(handle: ChatHandle, callback: (String) -> Unit) fun lobbyJoin(handle: ChatHandle, uri: String) fun setGroupName(group: ChatGroup, name: String) - fun createGroup(handle: ChatHandle, topic: String) + fun createGroup(handle: ChatHandle, topic: String): ChatGroup fun parseUri(uri: String): ChatUri fun destroyUri(uri: ChatUri) fun inviteContactToGroup(group: ChatGroup, contact: ChatContact) @@ -53,5 +77,11 @@ interface GnunetChat { fun getContactKey(chatContact: ChatContact): String fun getContextContact(context: ChatContext): ChatContact fun deleteContact(chatContact: ChatContact) + fun isGroup(context: ChatContext): Boolean + fun isPlatform(context: ChatContext): Boolean + fun iterateGroupContacts(chatGroup: ChatGroup, callback: (ChatGroup, ChatContact) -> Int) fun randomUUID(): String + fun getContactAttributes(contact: ChatContact, callback: (String, String) -> Unit) + fun shareAttributes (handle: ChatHandle, contact: ChatContact, key: String) + fun unshareAttributes (handle: ChatHandle, contact: ChatContact, key: String) } \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/ServiceFactory.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/ServiceFactory.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/ServiceFactory.kt + */ + package org.gnunet.gnunetmessenger.service import android.content.Context 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 @@ -1,10 +1,33 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/boundimpl/GnunetChatBoundService.kt + */ + package org.gnunet.gnunetmessenger.service.boundimpl import org.gnunet.gnunetmessenger.model.ChatAccount import org.gnunet.gnunetmessenger.model.ChatContact import org.gnunet.gnunetmessenger.model.ChatContext -import org.gnunet.gnunetmessenger.model.ChatContextType import org.gnunet.gnunetmessenger.model.ChatGroup import org.gnunet.gnunetmessenger.model.ChatHandle import org.gnunet.gnunetmessenger.model.ChatMessage @@ -82,7 +105,7 @@ class GnunetChatBoundService : GnunetChat { TODO("Not yet implemented") } - override fun createGroup(handle: ChatHandle, topic: String) { + override fun createGroup(handle: ChatHandle, topic: String): ChatGroup { TODO("Not yet implemented") } @@ -186,7 +209,37 @@ class GnunetChatBoundService : GnunetChat { TODO("Not yet implemented") } + override fun isGroup(context: ChatContext): Boolean { + TODO("Not yet implemented") + } + + override fun isPlatform(context: ChatContext): Boolean { + TODO("Not yet implemented") + } + + override fun iterateGroupContacts( + chatGroup: ChatGroup, + callback: (ChatGroup, ChatContact) -> Int + ) { + TODO("Not yet implemented") + } + override fun randomUUID(): String { return UUID.randomUUID().toString() } + + override fun getContactAttributes( + contact: ChatContact, + callback: (String, String) -> Unit + ) { + TODO("Not yet implemented") + } + + override fun shareAttributes(handle: ChatHandle, contact: ChatContact, key: String) { + TODO("Not yet implemented") + } + + override fun unshareAttributes(handle: ChatHandle, contact: ChatContact, key: String) { + TODO("Not yet implemented") + } } \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/mock/GnunetChatMock.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/mock/GnunetChatMock.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/service/mock/GnunetChatMock.kt + */ + package org.gnunet.gnunetmessenger.service.mock @@ -8,7 +32,6 @@ import org.gnunet.gnunetmessenger.model.ChatContextType import org.gnunet.gnunetmessenger.model.ChatGroup import org.gnunet.gnunetmessenger.model.ChatHandle import org.gnunet.gnunetmessenger.model.ChatMessage -import org.gnunet.gnunetmessenger.model.ChatMessageType import org.gnunet.gnunetmessenger.model.ChatUri import org.gnunet.gnunetmessenger.model.GnunetReturnValue import org.gnunet.gnunetmessenger.model.MessageKind @@ -49,16 +72,16 @@ class GnunetChatMock : GnunetChat { override fun connect(handle: ChatHandle, account: ChatAccount) { println("connect") - messageCallback(ChatContext(ChatContextType.UNKNOWN,UUID.randomUUID().toString()), - ChatMessage(ChatContext(ChatContextType.UNKNOWN,null),"",0,null,MessageKind.LOGIN,null) + messageCallback(ChatContext(ChatContextType.UNKNOWN,UUID.randomUUID().toString(), false, false), + ChatMessage(ChatContext(ChatContextType.UNKNOWN,null, true, false),"",0,null,MessageKind.LOGIN,null) ) } override fun disconnect(handle: ChatHandle) { println("disconnect") uuidCounter = 0 - messageCallback(ChatContext(ChatContextType.UNKNOWN,UUID.randomUUID().toString()), - ChatMessage(ChatContext(ChatContextType.UNKNOWN,null),"",0,null,MessageKind.LOGOUT,null) + messageCallback(ChatContext(ChatContextType.UNKNOWN,UUID.randomUUID().toString(), false, false), + ChatMessage(ChatContext(ChatContextType.UNKNOWN,null, false, false),"",0,null,MessageKind.LOGOUT,null) ) } @@ -75,8 +98,7 @@ class GnunetChatMock : GnunetChat { } override fun isContactBlocked(contact: ChatContact): Boolean { - println("is contact blocked") - return false + return true } override fun setContactBlocked(contact: ChatContact, isBlocked: Boolean) { @@ -107,15 +129,16 @@ class GnunetChatMock : GnunetChat { handle: ChatHandle, uri: String ) { - TODO("Not yet implemented") + println("join lobby") } override fun setGroupName(group: ChatGroup, name: String) { - TODO("Not yet implemented") + group.name = name } - override fun createGroup(handle: ChatHandle, topic: String) { - TODO("Not yet implemented") + override fun createGroup(handle: ChatHandle, topic: String): ChatGroup { + return ChatGroup(ChatContext(ChatContextType.GROUP, null, + true, false), topic) } override fun parseUri(uri: String): ChatUri { @@ -127,7 +150,7 @@ class GnunetChatMock : GnunetChat { } override fun inviteContactToGroup(group: ChatGroup, contact: ChatContact) { - TODO("Not yet implemented") + println("contact ${contact.name} invited") } override fun getUserPointerForContext(context: ChatContext): String? { @@ -139,15 +162,16 @@ class GnunetChatMock : GnunetChat { } override fun getSenderFromMessage(message: ChatMessage): ChatContact { - return ChatContact(ChatContext(ChatContextType.CONTACT, null), message.sender?.name ?: "") + return ChatContact(ChatContext(ChatContextType.CONTACT, null, true, false), message.sender?.name ?: "") } override fun getGroupFromContext(context: ChatContext): ChatGroup? { if ("3" == context.userPointer){ - val contextDev = ChatContext(ChatContextType.GROUP, null) + val contextDev = ChatContext(ChatContextType.GROUP, null, true, false) return ChatGroup(contextDev, name = "Dev Team") } - return null + val contextDev = ChatContext(ChatContextType.GROUP, null, true, false) + return ChatGroup(contextDev, name = "GNUnet Team") } override fun getMessageForGroupContact(group: ChatGroup, contact: ChatContact): ChatMessage { @@ -175,8 +199,8 @@ class GnunetChatMock : GnunetChat { } override fun iterateContacts(handle: ChatHandle, callback: (ChatContact) -> Int) { - val contextAlice = ChatContext(ChatContextType.CONTACT, null) - val contextBob = ChatContext(ChatContextType.CONTACT, null) + val contextAlice = ChatContext(ChatContextType.CONTACT, null, false, false) + val contextBob = ChatContext(ChatContextType.CONTACT, null, false, false) val contacts = listOf( ChatContact(contextAlice, name = "Alice"), @@ -189,8 +213,8 @@ class GnunetChatMock : GnunetChat { override fun iterateGroups(handle: ChatHandle, callback: (ChatGroup) -> Int) { println("iterate groups") - val contextDev = ChatContext(ChatContextType.GROUP, null) - val contextFriends = ChatContext(ChatContextType.GROUP, null) + val contextDev = ChatContext(ChatContextType.GROUP, null, true, false) + val contextFriends = ChatContext(ChatContextType.GROUP, null, true, false) val groups = listOf( ChatGroup(contextDev, name = "Dev Team"), ChatGroup(contextFriends, name = "Friends") @@ -199,34 +223,34 @@ class GnunetChatMock : GnunetChat { callback(group) } - messageCallback(ChatContext(ChatContextType.CONTACT, null), - ChatMessage(ChatContext(ChatContextType.CONTACT,null),"",0, - ChatContact(ChatContext(ChatContextType.CONTACT, null), "Mallory"),MessageKind.JOIN, null) + messageCallback(ChatContext(ChatContextType.CONTACT, null, true, false), + ChatMessage(ChatContext(ChatContextType.CONTACT,null, true, false),"",0, + ChatContact(ChatContext(ChatContextType.CONTACT, null, true, false), "Mallory"),MessageKind.JOIN, null) ) - messageCallback(ChatContext(ChatContextType.CONTACT,"5"), - ChatMessage(ChatContext(ChatContextType.CONTACT,null),"Hi, I am Mallory!",0, - ChatContact(ChatContext(ChatContextType.CONTACT, "6"), "Mallory"),MessageKind.TEXT, null) + messageCallback(ChatContext(ChatContextType.CONTACT,"5", true, false), + ChatMessage(ChatContext(ChatContextType.CONTACT,null, true, false),"Hi, I am Mallory!",0, + ChatContact(ChatContext(ChatContextType.CONTACT, "6", true, false), "Mallory"),MessageKind.TEXT, null) ) - messageCallback(ChatContext(ChatContextType.GROUP,"3"), - ChatMessage(ChatContext(ChatContextType.GROUP,null),"",0, - ChatContact(ChatContext(ChatContextType.CONTACT, null), "Flo"),MessageKind.JOIN, null) + messageCallback(ChatContext(ChatContextType.GROUP,"3", true, false), + ChatMessage(ChatContext(ChatContextType.GROUP,null, true, false),"",0, + ChatContact(ChatContext(ChatContextType.CONTACT, null, true, false), "Flo"),MessageKind.JOIN, null) ) - messageCallback(ChatContext(ChatContextType.GROUP,"3"), - ChatMessage(ChatContext(ChatContextType.GROUP,null),"Hi, I am Flo!",0, - ChatContact(ChatContext(ChatContextType.CONTACT, "7"), "Flo"),MessageKind.TEXT, null) + messageCallback(ChatContext(ChatContextType.GROUP,"3", true, false), + ChatMessage(ChatContext(ChatContextType.GROUP,null, true, false),"Hi, I am Flo!",0, + ChatContact(ChatContext(ChatContextType.CONTACT, "7", true, false), "Flo"),MessageKind.TEXT, null) ) - messageCallback(ChatContext(ChatContextType.GROUP,"3"), - ChatMessage(ChatContext(ChatContextType.GROUP,null),"",0, - ChatContact(ChatContext(ChatContextType.CONTACT, "1"), "Alice"),MessageKind.JOIN, null) + messageCallback(ChatContext(ChatContextType.GROUP,"3", true, false), + ChatMessage(ChatContext(ChatContextType.GROUP,null, true, false),"",0, + ChatContact(ChatContext(ChatContextType.CONTACT, "1", true, false), "Alice"),MessageKind.JOIN, null) ) - messageCallback(ChatContext(ChatContextType.GROUP,"3"), - ChatMessage(ChatContext(ChatContextType.GROUP,null),"Hi, I am Alice!",0, - ChatContact(ChatContext(ChatContextType.CONTACT, "1"), "Alice"),MessageKind.TEXT, null) + messageCallback(ChatContext(ChatContextType.GROUP,"3", true, false), + ChatMessage(ChatContext(ChatContextType.GROUP,null, true, false),"Hi, I am Alice!",0, + ChatContact(ChatContext(ChatContextType.CONTACT, "1", true, false), "Alice"),MessageKind.TEXT, null) ) } @@ -252,7 +276,7 @@ class GnunetChatMock : GnunetChat { } override fun setGroupUserPointer(chatGroup: ChatGroup, userPointer: String) { - TODO("Not yet implemented") + println("set group name") } override fun sendText(chatContext: ChatContext, text: String) { @@ -272,7 +296,52 @@ class GnunetChatMock : GnunetChat { println("delete contact") } + override fun isGroup(context: ChatContext): Boolean { + return context.isGroup + } + + override fun isPlatform(context: ChatContext): Boolean { + return context.isPlatform + } + + override fun iterateGroupContacts( + chatGroup: ChatGroup, + callback: (ChatGroup, ChatContact) -> Int + ) { + val contextCharlie = ChatContext(ChatContextType.CONTACT, null, true, false) + val contacts = listOf( + + ChatContact(contextCharlie, name = "Charlie") + ) + for (contact in contacts) { + callback(chatGroup, contact) + } + } + override fun randomUUID(): String { return uuidCounter++.toString() } + + override fun getContactAttributes( + contact: ChatContact, + callback: (String, String) -> Unit + ) { + val mockAttributes = listOf( + "nickname" to "Alice", + "location" to "Berlin", + "status" to "Online" + ) + + for ((key, value) in mockAttributes) { + callback(key, value) + } + } + + override fun shareAttributes(handle: ChatHandle, contact: ChatContact, key: String) { + println("share ${key} for contact ${contact.name}") + } + + override fun unshareAttributes(handle: ChatHandle, contact: ChatContact, key: String) { + println("unshare ${key} for contact ${contact.name}") + } } \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/BaseProfileFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/BaseProfileFragment.kt @@ -0,0 +1,65 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/BaseProfileFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui + +import android.os.Bundle +import android.view.View +import android.widget.Button +import android.widget.EditText +import android.widget.ImageView +import android.widget.TextView +import androidx.fragment.app.Fragment +import org.gnunet.gnunetmessenger.R + +abstract class BaseProfileFragment : Fragment() { + + protected lateinit var avatarImage: ImageView + protected lateinit var nameText: TextView + protected lateinit var nameEdit: EditText + protected lateinit var saveNameButton: Button + protected lateinit var publicKeyText: TextView + protected lateinit var qrCodeImage: ImageView + protected lateinit var listAttributesButton: Button + protected lateinit var shareAttributesButton: Button + protected lateinit var shareIdentityButton: Button + protected lateinit var blockContactButton: Button + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + avatarImage = view.findViewById(R.id.avatarImage) + nameText = view.findViewById(R.id.nameText) + nameEdit = view.findViewById(R.id.nameEdit) + saveNameButton = view.findViewById(R.id.btn_save_name) + publicKeyText = view.findViewById(R.id.publicKeyText) + qrCodeImage = view.findViewById(R.id.qrCodeImage) + listAttributesButton = view.findViewById(R.id.btn_list_attributes) + shareAttributesButton = view.findViewById(R.id.btn_share_attributes) + shareIdentityButton = view.findViewById(R.id.btn_share_identity) + blockContactButton = view.findViewById(R.id.btn_block_contact) + + setupUI() + } + + abstract fun setupUI() +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/SettingsFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/SettingsFragment.kt @@ -0,0 +1,98 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/SettingsFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.CompoundButton +import androidx.fragment.app.Fragment +import androidx.fragment.app.activityViewModels +import androidx.recyclerview.widget.LinearLayoutManager +import org.gnunet.gnunetmessenger.MainActivity +import org.gnunet.gnunetmessenger.databinding.FragmentSettingsBinding +import org.gnunet.gnunetmessenger.model.ChatContact +import org.gnunet.gnunetmessenger.model.ChatSummary +import org.gnunet.gnunetmessenger.service.GnunetChat +import org.gnunet.gnunetmessenger.ui.adapters.BlockedContactAdapter +import org.gnunet.gnunetmessenger.viewmodel.ChatOverviewViewModel + +class SettingsFragment : Fragment() { + + private var _binding: FragmentSettingsBinding? = null + private val binding get() = _binding!! + + private lateinit var gnunetChat: GnunetChat + private lateinit var adapter: BlockedContactAdapter + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + _binding = FragmentSettingsBinding.inflate(inflater, container, false) + gnunetChat = (requireActivity() as MainActivity).getGnunetChatInstance() + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + val prefs = requireContext().getSharedPreferences("settings", 0) + val viewModel: ChatOverviewViewModel by activityViewModels() + + binding.switchNotifications.isChecked = prefs.getBoolean("notifications", true) + binding.switchReceipts.isChecked = prefs.getBoolean("receipts", true) + + binding.switchNotifications.setOnCheckedChangeListener { _: CompoundButton, isChecked: Boolean -> + prefs.edit().putBoolean("notifications", isChecked).apply() + } + + binding.switchReceipts.setOnCheckedChangeListener { _: CompoundButton, isChecked: Boolean -> + prefs.edit().putBoolean("receipts", isChecked).apply() + } + + val blockedContacts = getBlockedContacts(viewModel) // returns List<ChatContact> + adapter = BlockedContactAdapter(blockedContacts) + + binding.blockedContactsList.layoutManager = LinearLayoutManager(requireContext()) + binding.blockedContactsList.adapter = adapter + } + + private fun getBlockedContacts(viewModel: ChatOverviewViewModel): List<ChatContact> { + val blockedContacts = mutableListOf<ChatContact>() + viewModel.chats.value?.forEach { chatSummary: ChatSummary -> + if (!chatSummary.chatContext.isGroup && + !chatSummary.chatContext.isPlatform && + chatSummary.contact!!.blocked) + blockedContacts.add(chatSummary.contact) + } + + return blockedContacts + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountAdapter.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountAdapter.kt @@ -1,59 +0,0 @@ -package org.gnunet.gnunetmessenger.ui.account - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter -import androidx.recyclerview.widget.RecyclerView -import org.gnunet.gnunetmessenger.MainActivity -import org.gnunet.gnunetmessenger.R -import org.gnunet.gnunetmessenger.model.ChatAccount -import org.gnunet.gnunetmessenger.util.AvatarStorageUtil - -class AccountAdapter( - private val onClick: (ChatAccount) -> Unit -) : ListAdapter<ChatAccount, AccountAdapter.AccountViewHolder>(DIFF) { - - companion object { - val DIFF = object : DiffUtil.ItemCallback<ChatAccount>() { - override fun areItemsTheSame(oldItem: ChatAccount, newItem: ChatAccount) = - oldItem.name == newItem.name - - override fun areContentsTheSame(oldItem: ChatAccount, newItem: ChatAccount) = - oldItem == newItem - } - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountViewHolder { - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.item_account, parent, false) - return AccountViewHolder(view) - } - - override fun onBindViewHolder(holder: AccountViewHolder, position: Int) { - holder.bind(getItem(position)) - } - - inner class AccountViewHolder(view: View) : RecyclerView.ViewHolder(view) { - private val nameView: TextView = view.findViewById(R.id.account_name) - private val avatarView: ImageView = view.findViewById(R.id.account_avatar) - - - fun bind(account: ChatAccount) { - nameView.text = account.name - val context = itemView.context - val avatarBitmap = AvatarStorageUtil.loadAvatar(context, account.key) - - if (avatarBitmap != null) { - avatarView.setImageBitmap(avatarBitmap) - } else { - avatarView.setImageResource(R.drawable.ic_account_circle) - } - - itemView.setOnClickListener { onClick(account) } - } - } -} diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountDetailsFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountDetailsFragment.kt @@ -1,67 +1,80 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountDetailsFragment.kt + */ + package org.gnunet.gnunetmessenger.ui.account import android.os.Bundle +import android.graphics.BitmapFactory import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.Button -import android.widget.ProgressBar -import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController import org.gnunet.gnunetmessenger.MainActivity import org.gnunet.gnunetmessenger.R -import org.gnunet.gnunetmessenger.databinding.FragmentAccountDetailsBinding +import org.gnunet.gnunetmessenger.ui.BaseProfileFragment import org.gnunet.gnunetmessenger.util.AvatarStorageUtil -class AccountDetailsFragment : Fragment() { - - private var _binding: FragmentAccountDetailsBinding? = null - private val binding get() = _binding!! +class AccountDetailsFragment : BaseProfileFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? { - val activity = activity as MainActivity + ): View { + return inflater.inflate(R.layout.fragment_profile_base, container, false) + } + + override fun setupUI() { + val activity = requireActivity() as MainActivity val gnunetChat = activity.getGnunetChatInstance() val handle = activity.getChatHandle() - _binding = FragmentAccountDetailsBinding.inflate(inflater, container, false) + val profileName = gnunetChat.getProfileName(handle) + nameText.visibility = View.GONE + nameEdit.visibility = View.VISIBLE + saveNameButton.visibility = View.VISIBLE + nameEdit.setText(profileName) - // Setze aktuellen Namen - binding.accountName.setText(gnunetChat.getProfileName(handle)) - binding.btnSaveName.setOnClickListener { - val newName = binding.accountName.text.toString() + saveNameButton.setOnClickListener { + val newName = nameEdit.text.toString() gnunetChat.setProfileName(handle, newName) } - val avatar = AvatarStorageUtil.loadAvatar(requireContext(), gnunetChat.getProfileKey(handle)) - if (avatar != null) { - binding.accountAvatar.setImageBitmap(avatar) - } else { - binding.accountAvatar.setImageResource(R.drawable.ic_account_circle) - } - binding.btnListAttributes.setOnClickListener { - val navController = activity.supportFragmentManager.findFragmentById(R.id.nav_host_fragment)?.findNavController() - navController?.navigate(R.id.action_accountDetailsFragment_to_attributeListFragment) - } + val avatar = AvatarStorageUtil.loadAvatar(requireContext(), gnunetChat.getProfileKey(handle)) + avatarImage.setImageBitmap(avatar ?: BitmapFactory.decodeResource(resources, R.drawable.ic_account_circle)) - binding.btnShareIdentity.setOnClickListener { - println("share identity") + shareIdentityButton.setOnClickListener { val action = AccountDetailsFragmentDirections.actionAccountDetailsFragmentToLobbyDisplayFragment( - lobbyId = gnunetChat.getProfileKey(handle), - // lifetime not used here - lifetime = "0" - ) - findNavController().navigate(action) - + lobbyId = gnunetChat.getProfileKey(handle), + lifetime = "0" + ) + findNavController().navigate(action) } - return binding.root - } - - override fun onDestroyView() { - super.onDestroyView() - _binding = null + listAttributesButton.setOnClickListener { + val action = AccountDetailsFragmentDirections + .actionAccountDetailsFragmentToAttributeListFragment(null, editable = true) + findNavController().navigate(action) + } } -} +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountListFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountListFragment.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountListFragment.kt + */ + package org.gnunet.gnunetmessenger.ui.account import android.os.Bundle @@ -12,6 +36,7 @@ import androidx.recyclerview.widget.RecyclerView import org.gnunet.gnunetmessenger.MainActivity import org.gnunet.gnunetmessenger.R import org.gnunet.gnunetmessenger.model.ChatAccount +import org.gnunet.gnunetmessenger.ui.adapters.AccountAdapter class AccountListFragment : Fragment() { @@ -23,11 +48,7 @@ class AccountListFragment : Fragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { - // Demo-Daten - val list = mutableListOf<ChatAccount>()/*listOf( - ChatAccount(1, "Alice"), - ChatAccount(2, "Bob") - )*/ + val list = mutableListOf<ChatAccount>() val view = inflater.inflate(R.layout.fragment_account_list, container, false) val activity = activity as MainActivity val gnunetChat = activity.getGnunetChatInstance() diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountOverviewFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountOverviewFragment.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountOverviewFragment.kt + */ + package org.gnunet.gnunetmessenger.ui.account import android.os.Bundle @@ -20,7 +44,6 @@ class AccountOverviewFragment : Fragment() { private lateinit var drawerLayout: DrawerLayout private lateinit var adapter: ChatListAdapter - // Hol dir das ViewModel direkt aus der MainActivity (shared scope) private val viewModel: ChatOverviewViewModel by activityViewModels() override fun onCreateView( diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AttributeListFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AttributeListFragment.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AttributeListFragment.kt + */ + package org.gnunet.gnunetmessenger.ui.account import android.os.Bundle @@ -6,6 +30,7 @@ import org.gnunet.gnunetmessenger.ui.adapters.AttributeAdapter import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.LinearLayoutManager import org.gnunet.gnunetmessenger.MainActivity import org.gnunet.gnunetmessenger.databinding.FragmentAttributeListBinding @@ -13,6 +38,7 @@ import org.gnunet.gnunetmessenger.databinding.FragmentAttributeListBinding class AttributeListFragment : Fragment() { + private val args: AttributeListFragmentArgs by navArgs() private lateinit var binding: FragmentAttributeListBinding private val attributes = mutableListOf<Pair<String, String>>() private lateinit var adapter: AttributeAdapter @@ -21,28 +47,46 @@ class AttributeListFragment : Fragment() { val activity = activity as MainActivity val gnunetChat = activity.getGnunetChatInstance() val handle = activity.getChatHandle() + val contact = args.contact + val editable = args.editable binding = FragmentAttributeListBinding.inflate(inflater, container, false) adapter = AttributeAdapter(attributes) - gnunetChat.getAttributes(handle) { key, value -> - attributes.add(key to value) - adapter.notifyItemInserted(attributes.size - 1) - } + if (editable) + gnunetChat.getAttributes(handle) { key, value -> + attributes.add(key to value) + adapter.notifyItemInserted(attributes.size - 1) + } + else + gnunetChat.getContactAttributes(contact!!) { key, value -> + attributes.add(key to value) + adapter.notifyItemInserted(attributes.size - 1) + } binding.attributeList.layoutManager = LinearLayoutManager(requireContext()) binding.attributeList.adapter = adapter - binding.btnAddAttribute.setOnClickListener { - val key = binding.editKey.text.toString() - val value = binding.editValue.text.toString() - if (key.isNotBlank()) { - attributes.add(Pair(key, value)) - adapter.notifyItemInserted(attributes.size - 1) - gnunetChat.setAttribute(handle,key, value) - binding.editKey.text.clear() - binding.editValue.text.clear() + if (editable) { + binding.editKey.visibility = View.VISIBLE + binding.editValue.visibility = View.VISIBLE + binding.btnAddAttribute.visibility = View.VISIBLE + + binding.btnAddAttribute.setOnClickListener { + val key = binding.editKey.text.toString() + val value = binding.editValue.text.toString() + if (key.isNotBlank()) { + attributes.add(Pair(key, value)) + adapter.notifyItemInserted(attributes.size - 1) + gnunetChat.setAttribute(handle, key, value) + binding.editKey.text.clear() + binding.editValue.text.clear() + } } + } else { + binding.editKey.visibility = View.GONE + binding.editValue.visibility = View.GONE + binding.btnAddAttribute.visibility = View.GONE } return binding.root diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/CreateAccountFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/CreateAccountFragment.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/CreateAccountFragment.kt + */ + package org.gnunet.gnunetmessenger.ui.account import android.net.Uri @@ -10,7 +34,6 @@ import androidx.activity.result.contract.ActivityResultContracts import androidx.navigation.fragment.findNavController import org.gnunet.gnunetmessenger.MainActivity import org.gnunet.gnunetmessenger.databinding.FragmentCreateAccountBinding -import org.gnunet.gnunetmessenger.model.ChatAccount import org.gnunet.gnunetmessenger.model.ChatHandle import org.gnunet.gnunetmessenger.service.GnunetChat import org.gnunet.gnunetmessenger.model.GnunetReturnValue @@ -24,7 +47,6 @@ class CreateAccountFragment : Fragment() { private lateinit var handle: ChatHandle private var selectedAvatarUri: Uri? = null - // Request code for selecting avatar image private val avatarImageRequest = registerForActivityResult(ActivityResultContracts.GetContent()) { uri -> uri?.let { selectedAvatarUri = it @@ -44,7 +66,6 @@ class CreateAccountFragment : Fragment() { binding = FragmentCreateAccountBinding.inflate(inflater, container, false) - // Set up listeners binding.selectAvatarButton.setOnClickListener { avatarImageRequest.launch("image/*") // Start the image picker } @@ -71,7 +92,6 @@ class CreateAccountFragment : Fragment() { } private fun createAccount(accountName: String) { - // Call the service to create the account val result = gnunetChat.createAccount(handle = ChatHandle(1), name = accountName) when (result) { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/LobbyCreateFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/LobbyCreateFragment.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/AccountAdapter.kt + */ + package org.gnunet.gnunetmessenger.ui.account import android.os.Bundle @@ -12,7 +36,6 @@ import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController import org.gnunet.gnunetmessenger.MainActivity import org.gnunet.gnunetmessenger.R -import java.util.UUID class LobbyCreateFragment : Fragment() { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/LobbyDisplayFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/LobbyDisplayFragment.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/account/LobbyDisplayFragment.kt + */ + package org.gnunet.gnunetmessenger.ui.account import android.content.ClipboardManager diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/AccountAdapter.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/AccountAdapter.kt @@ -0,0 +1,82 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/AccountAdapter.kt + */ + +package org.gnunet.gnunetmessenger.ui.adapters + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import org.gnunet.gnunetmessenger.R +import org.gnunet.gnunetmessenger.model.ChatAccount +import org.gnunet.gnunetmessenger.util.AvatarStorageUtil + +class AccountAdapter( + private val onClick: (ChatAccount) -> Unit +) : ListAdapter<ChatAccount, AccountAdapter.AccountViewHolder>(DIFF) { + + companion object { + val DIFF = object : DiffUtil.ItemCallback<ChatAccount>() { + override fun areItemsTheSame(oldItem: ChatAccount, newItem: ChatAccount) = + oldItem.name == newItem.name + + override fun areContentsTheSame(oldItem: ChatAccount, newItem: ChatAccount) = + oldItem == newItem + } + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AccountViewHolder { + val view = LayoutInflater.from(parent.context) + .inflate(R.layout.item_account, parent, false) + return AccountViewHolder(view) + } + + override fun onBindViewHolder(holder: AccountViewHolder, position: Int) { + holder.bind(getItem(position)) + } + + inner class AccountViewHolder(view: View) : RecyclerView.ViewHolder(view) { + private val nameView: TextView = view.findViewById(R.id.account_name) + private val avatarView: ImageView = view.findViewById(R.id.account_avatar) + + + fun bind(account: ChatAccount) { + nameView.text = account.name + val context = itemView.context + val avatarBitmap = AvatarStorageUtil.loadAvatar(context, account.key) + + if (avatarBitmap != null) { + avatarView.setImageBitmap(avatarBitmap) + } else { + avatarView.setImageResource(R.drawable.ic_account_circle) + } + + itemView.setOnClickListener { onClick(account) } + } + } +} diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/AttributeAdapter.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/AttributeAdapter.kt @@ -1,11 +1,32 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/AttributeAdapter.kt + */ + package org.gnunet.gnunetmessenger.ui.adapters import android.view.LayoutInflater -import android.view.View import android.view.ViewGroup -import android.widget.TextView import androidx.recyclerview.widget.RecyclerView -import org.gnunet.gnunetmessenger.R import org.gnunet.gnunetmessenger.databinding.AttributeItemBinding class AttributeAdapter(private val attributes: MutableList<Pair<String, String>>) : RecyclerView.Adapter<AttributeAdapter.AttributeViewHolder>() { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/BlockedContactAdapter.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/BlockedContactAdapter.kt @@ -0,0 +1,50 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/BlockedContactAdapter.kt + */ + +package org.gnunet.gnunetmessenger.ui.adapters + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import org.gnunet.gnunetmessenger.databinding.ItemContactBinding +import org.gnunet.gnunetmessenger.model.ChatContact + +class BlockedContactAdapter(private val contacts: List<ChatContact>) : + RecyclerView.Adapter<BlockedContactAdapter.ContactViewHolder>() { + + inner class ContactViewHolder(val binding: ItemContactBinding) : + RecyclerView.ViewHolder(binding.root) + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ContactViewHolder { + val binding = ItemContactBinding.inflate(LayoutInflater.from(parent.context), parent, false) + return ContactViewHolder(binding) + } + + override fun onBindViewHolder(holder: ContactViewHolder, position: Int) { + val contact = contacts[position] + holder.binding.contactName.text = contact.name + } + + override fun getItemCount(): Int = contacts.size +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ChatListAdapter.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ChatListAdapter.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ChatListAdapter.kt + */ + package org.gnunet.gnunetmessenger.ui.adapters import android.view.LayoutInflater diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ChatMessageAdapter.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ChatMessageAdapter.kt @@ -1,3 +1,28 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ChatMessageAdapter.kt + */ + + package org.gnunet.gnunetmessenger.ui.adapters @@ -85,14 +110,12 @@ class ChatMessageAdapter : ListAdapter<ChatMessage, RecyclerView.ViewHolder>(Dif class DiffCallback : DiffUtil.ItemCallback<ChatMessage>() { override fun areItemsTheSame(oldItem: ChatMessage, newItem: ChatMessage): Boolean { - // Zwei Nachrichten sind gleich, wenn Text, Absender und Zeit identisch sind return oldItem.text == newItem.text && oldItem.sender == newItem.sender && oldItem.timestamp == newItem.timestamp } override fun areContentsTheSame(oldItem: ChatMessage, newItem: ChatMessage): Boolean { - // Wenn alle Felder identisch sind, dann Inhalte gleich return oldItem == newItem } } diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ContactListAdapter.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ContactListAdapter.kt @@ -1,5 +1,31 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ContactListAdapter.kt + */ + + package org.gnunet.gnunetmessenger.ui.adapters +import android.graphics.Color import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -8,18 +34,41 @@ import androidx.recyclerview.widget.RecyclerView import org.gnunet.gnunetmessenger.R import org.gnunet.gnunetmessenger.model.ChatContact -class ContactListAdapter : RecyclerView.Adapter<ContactListAdapter.ViewHolder>() { +class ContactListAdapter( + private val onClick: ((ChatContact) -> Unit)? = null, + private val multiSelect: Boolean = true +) : RecyclerView.Adapter<ContactListAdapter.ViewHolder>() { private val contacts = mutableListOf<ChatContact>() + private val selectedContacts = mutableSetOf<ChatContact>() fun submitList(list: List<ChatContact>) { contacts.clear() contacts.addAll(list) + selectedContacts.clear() notifyDataSetChanged() } - class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + fun getSelectedContacts(): List<ChatContact> = selectedContacts.toList() + + inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { val nameText: TextView = view.findViewById(R.id.contactName) + + init { + view.setOnClickListener { + val contact = contacts[adapterPosition] + toggleSelection(contact) + notifyDataSetChanged() + onClick?.invoke(contact) + } + } + + fun bind(contact: ChatContact, isSelected: Boolean) { + nameText.text = contact.name + itemView.setBackgroundColor( + if (isSelected) Color.LTGRAY else Color.TRANSPARENT + ) + } } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { @@ -31,6 +80,24 @@ class ContactListAdapter : RecyclerView.Adapter<ContactListAdapter.ViewHolder>() override fun getItemCount(): Int = contacts.size override fun onBindViewHolder(holder: ViewHolder, position: Int) { - holder.nameText.text = contacts[position].name + val contact = contacts[position] + holder.bind(contact, selectedContacts.contains(contact)) + } + + private fun toggleSelection(contact: ChatContact) { + if (multiSelect) { + if (selectedContacts.contains(contact)) { + selectedContacts.remove(contact) + } else { + selectedContacts.add(contact) + } + } else { + if (!selectedContacts.contains(contact)) { + selectedContacts.clear() + selectedContacts.add(contact) + } else { + selectedContacts.clear() + } + } } } \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ShareAttributesAdapter.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ShareAttributesAdapter.kt @@ -0,0 +1,61 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/adapters/ShareAttributesAdapter.kt + */ + +package org.gnunet.gnunetmessenger.ui.adapters + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.CheckBox +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import org.gnunet.gnunetmessenger.R + +class ShareAttributesAdapter( + private val items: List<Pair<String, String>>, + private val selected: MutableSet<Pair<String, String>> +) : RecyclerView.Adapter<ShareAttributesAdapter.ViewHolder>() { + + inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + val checkbox: CheckBox = view.findViewById(R.id.checkbox) + val keyValue: TextView = view.findViewById(R.id.keyValue) + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + val view = LayoutInflater.from(parent.context) + .inflate(R.layout.item_share_attribute, parent, false) + return ViewHolder(view) + } + + override fun getItemCount() = items.size + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val (key, value) = items[position] + holder.keyValue.text = "$key: $value" + holder.checkbox.isChecked = selected.contains(items[position]) + holder.checkbox.setOnCheckedChangeListener { _, isChecked -> + if (isChecked) selected.add(items[position]) else selected.remove(items[position]) + } + } +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/chat/ChatFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/chat/ChatFragment.kt @@ -1,9 +1,39 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/chat/ChatFragment.kt + */ + package org.gnunet.gnunetmessenger.ui.chat import android.os.Bundle -import android.view.* +import android.view.LayoutInflater +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup import android.widget.Button import android.widget.EditText +import androidx.appcompat.app.AppCompatActivity import androidx.core.view.MenuHost import androidx.core.view.MenuProvider import androidx.fragment.app.Fragment @@ -16,9 +46,11 @@ import org.gnunet.gnunetmessenger.MainActivity import org.gnunet.gnunetmessenger.R import org.gnunet.gnunetmessenger.model.ChatContact import org.gnunet.gnunetmessenger.model.ChatContext +import org.gnunet.gnunetmessenger.viewmodel.ChatMenuViewModel import org.gnunet.gnunetmessenger.model.ChatMessage import org.gnunet.gnunetmessenger.model.ChatMessageType import org.gnunet.gnunetmessenger.model.MessageKind +import org.gnunet.gnunetmessenger.service.GnunetChat import org.gnunet.gnunetmessenger.ui.adapters.ChatMessageAdapter import org.gnunet.gnunetmessenger.viewmodel.ChatViewModel @@ -29,24 +61,46 @@ class ChatFragment : Fragment(R.layout.fragment_chat) { private val args: ChatFragmentArgs by navArgs() private lateinit var chatViewModel: ChatViewModel private lateinit var chatContext: ChatContext + private lateinit var chatMenuViewModel: ChatMenuViewModel + private lateinit var mainActivity: MainActivity + private lateinit var gnunetChat: GnunetChat override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val menuHost = requireActivity() as MenuHost + + menuHost.addMenuProvider(object : MenuProvider { override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { + + menuInflater.inflate(R.menu.chat_menu, menu) + + val chatGroup = gnunetChat.getGroupFromContext(chatContext) + + if (null != chatGroup) { + + gnunetChat.iterateGroupContacts(chatGroup) { _, contact -> + val itemId = View.generateViewId() + chatMenuViewModel.contactMenuIds[itemId] = contact + menu.add(Menu.NONE, itemId, 0, "👤 ${contact.name}") + 0 + } + } } override fun onPrepareMenu(menu: Menu) { - val mainActivity = requireActivity() as MainActivity - val gnunetChat = mainActivity.getGnunetChatInstance() val contact = gnunetChat.getContextContact(chatContext) val isBlocked = gnunetChat.isContactBlocked(contact) - + val isGroup = gnunetChat.isGroup(chatContext) + val isPlatform = gnunetChat.isPlatform(chatContext) val blockItem = menu.findItem(R.id.menu_block_contact) + + blockItem.isVisible = !isGroup || !isPlatform blockItem.title = if (isBlocked) "Unblock Contact" else "Block Contact" + + menu.findItem(R.id.menu_invite_members)?.isVisible = isGroup || isPlatform } override fun onMenuItemSelected(menuItem: MenuItem): Boolean { @@ -54,6 +108,13 @@ class ChatFragment : Fragment(R.layout.fragment_chat) { val gnunetChat = mainActivity.getGnunetChatInstance() val handle = mainActivity.getChatHandle() + val contact = chatMenuViewModel.contactMenuIds[menuItem.itemId] + if (contact != null) { + val action = ChatFragmentDirections.actionChatFragmentToContactFragment(contact) + findNavController().navigate(action) + return true + } + return when (menuItem.itemId) { R.id.menu_share_identity -> { val action = ChatFragmentDirections.actionChatFragmentToLobbyDisplayFragment(lobbyId = gnunetChat.getProfileKey(handle), @@ -66,6 +127,7 @@ class ChatFragment : Fragment(R.layout.fragment_chat) { val contact = gnunetChat.getContextContact(chatContext) val isBlocked = gnunetChat.isContactBlocked(contact) gnunetChat.setContactBlocked(contact, !isBlocked) + contact.blocked = !isBlocked requireActivity().invalidateOptionsMenu() true } @@ -74,10 +136,27 @@ class ChatFragment : Fragment(R.layout.fragment_chat) { gnunetChat.deleteContact(contact) true } + R.id.menu_invite_members -> { + val chatGroup = gnunetChat.getGroupFromContext(chatContext) + if (null != chatGroup) { + val action = ChatFragmentDirections.actionChatFragmentToMemberListFragment(chatGroup) + findNavController().navigate(action) + } + true + } else -> false } } }, viewLifecycleOwner) + val title = when { + gnunetChat.isGroup(chatContext) || gnunetChat.isPlatform(chatContext) -> { + gnunetChat.getGroupFromContext(chatContext)?.name ?: getString(R.string.placeholder_label_chat) + } + else -> { + gnunetChat.getContextContact(chatContext).name + } + } + (requireActivity() as AppCompatActivity).supportActionBar?.title = title } override fun onCreateView( @@ -85,15 +164,15 @@ class ChatFragment : Fragment(R.layout.fragment_chat) { savedInstanceState: Bundle? ): View? { val view = inflater.inflate(R.layout.fragment_chat, container, false) - val activity = activity as MainActivity - val gnunetChat = activity.getGnunetChatInstance() + mainActivity = activity as MainActivity + gnunetChat = mainActivity.getGnunetChatInstance() chatContext = args.chatContext - chatViewModel = (requireActivity() as MainActivity).getChatViewModel(chatContext)!! + chatViewModel = mainActivity.getChatViewModel(chatContext)!! + chatMenuViewModel = mainActivity.getChatMenuViewModel(chatContext)!! recyclerView = view.findViewById(R.id.chatRecyclerView) recyclerView.layoutManager = LinearLayoutManager(requireContext()) - // Adapter initialisieren adapter = ChatMessageAdapter() recyclerView.adapter = adapter @@ -103,30 +182,26 @@ class ChatFragment : Fragment(R.layout.fragment_chat) { } }) - // Beobachte das LiveData aus dem ViewModel chatViewModel.messages.observe(viewLifecycleOwner, Observer { messages -> - // Wenn sich die Nachrichten im ViewModel ändern, aktualisiere den Adapter adapter.submitList(messages) recyclerView.scrollToPosition(messages.size - 1) }) - // Sende-Nachricht Logik view.findViewById<Button>(R.id.sendButton).setOnClickListener { val input = view.findViewById<EditText>(R.id.inputMessage) val text = input.text.toString() if (text.isNotBlank()) { - // Erstelle eine neue Nachricht und sende sie an das ViewModel val newMessage = ChatMessage( chatContext = chatContext, text = text, timestamp = System.currentTimeMillis(), - sender = ChatContact(chatContext, activity.currentAccount?.name ?: ""), + sender = ChatContact(chatContext, mainActivity.currentAccount?.name ?: ""), kind = MessageKind.TEXT, type = ChatMessageType.OWN ) chatViewModel.addMessage(newMessage) gnunetChat.sendText(chatContext, text) - input.text.clear() // Eingabefeld leeren + input.text.clear() } } diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/chat/MemberListFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/chat/MemberListFragment.kt @@ -0,0 +1,71 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/chat/MemberListFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui.chat + +import android.os.Bundle +import android.view.View +import android.widget.Button +import androidx.fragment.app.Fragment +import androidx.fragment.app.activityViewModels +import androidx.lifecycle.Observer +import androidx.navigation.fragment.findNavController +import androidx.navigation.fragment.navArgs +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import org.gnunet.gnunetmessenger.MainActivity +import org.gnunet.gnunetmessenger.R +import org.gnunet.gnunetmessenger.ui.adapters.ContactListAdapter +import org.gnunet.gnunetmessenger.viewmodel.ContactListViewModel + +class MemberListFragment : Fragment(R.layout.fragment_member_list) { + + private val args: MemberListFragmentArgs by navArgs() + private lateinit var adapter: ContactListAdapter + private val viewModel: ContactListViewModel by activityViewModels() + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + val chatGroup = args.chatGroup + val gnunetChat = (requireActivity() as MainActivity).getGnunetChatInstance() + + val recyclerView = view.findViewById<RecyclerView>(R.id.memberRecyclerView) + val inviteButton = view.findViewById<Button>(R.id.confirmButton) + + recyclerView.layoutManager = LinearLayoutManager(requireContext()) + adapter = ContactListAdapter() + recyclerView.adapter = adapter + + viewModel.contacts.observe(viewLifecycleOwner, Observer { contactList -> + adapter.submitList(contactList) + }) + + inviteButton.setOnClickListener { + val selectedContacts = adapter.getSelectedContacts() + for (contact in selectedContacts) { + gnunetChat.inviteContactToGroup(chatGroup, contact) + } + findNavController().popBackStack() + } + } +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ContactFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ContactFragment.kt @@ -0,0 +1,126 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ContactFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui.contact + +import android.graphics.BitmapFactory +import android.net.Uri +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Toast +import androidx.activity.result.contract.ActivityResultContracts +import androidx.navigation.fragment.findNavController +import androidx.navigation.fragment.navArgs +import org.gnunet.gnunetmessenger.MainActivity +import org.gnunet.gnunetmessenger.R +import org.gnunet.gnunetmessenger.model.ChatContact +import org.gnunet.gnunetmessenger.service.GnunetChat +import org.gnunet.gnunetmessenger.ui.BaseProfileFragment +import org.gnunet.gnunetmessenger.util.AvatarStorageUtil + +class ContactFragment : BaseProfileFragment() { + + private val args: ContactFragmentArgs by navArgs() + private lateinit var contact: ChatContact + private lateinit var gnunetChat: GnunetChat + private var selectedAvatarUri: Uri? = null + + private val avatarImageRequest = + registerForActivityResult(ActivityResultContracts.GetContent()) { uri -> + uri?.let { + selectedAvatarUri = it + val key = gnunetChat.getContactKey(contact) + AvatarStorageUtil.saveAvatarFromUri(requireContext(), uri, key) + avatarImage.setImageURI(uri) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val activity = requireActivity() as MainActivity + gnunetChat = activity.getGnunetChatInstance() + contact = args.contact + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + return inflater.inflate(R.layout.fragment_profile_base, container, false) + } + + override fun setupUI() { + nameEdit.visibility = View.GONE + saveNameButton.visibility = View.GONE + nameText.text = contact.name + + val publicKey = gnunetChat.getContactKey(contact) + + val avatar = AvatarStorageUtil.loadAvatar(requireContext(), publicKey) + avatarImage.setImageBitmap( + avatar ?: BitmapFactory.decodeResource(resources, R.drawable.ic_account_circle) + ) + + avatarImage.setOnClickListener { + avatarImageRequest.launch("image/*") + } + + publicKeyText.visibility = View.VISIBLE + qrCodeImage.visibility = View.GONE + publicKeyText.text = publicKey + + shareAttributesButton.visibility = View.VISIBLE + blockContactButton.visibility = View.VISIBLE + + listAttributesButton.setOnClickListener { + val action = ContactFragmentDirections + .actionContactFragmentToAttributeListFragment(contact, editable = false) + findNavController().navigate(action) + } + + shareAttributesButton.setOnClickListener { + val action = ContactFragmentDirections + .actionContactFragmentToShareAttributesFragment(contact) + findNavController().navigate(action) + } + + blockContactButton.setOnClickListener { + val blocked = gnunetChat.isContactBlocked(contact) + gnunetChat.setContactBlocked(contact, !blocked) + contact.blocked = !blocked + val msg = if (blocked) "Unblocked" else "Blocked" + Toast.makeText(requireContext(), msg, Toast.LENGTH_SHORT).show() + } + + shareIdentityButton.setOnClickListener { + val action = ContactFragmentDirections.actionContactFragmentToLobbyDisplayFragment( + lobbyId = publicKey, + lifetime = "0" + ) + findNavController().navigate(action) + } + } +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ContactListFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ContactListFragment.kt @@ -1,4 +1,28 @@ -package org.gnunet.gnunetmessenger.ui.contacts +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ContactListFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui.contact import android.os.Bundle import android.view.View @@ -7,7 +31,6 @@ import androidx.fragment.app.activityViewModels import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import org.gnunet.gnunetmessenger.MainActivity import org.gnunet.gnunetmessenger.R import org.gnunet.gnunetmessenger.ui.adapters.ContactListAdapter import org.gnunet.gnunetmessenger.viewmodel.ContactListViewModel @@ -16,7 +39,7 @@ class ContactListFragment : Fragment(R.layout.fragment_contact_list) { private lateinit var recyclerView: RecyclerView private lateinit var adapter: ContactListAdapter - private val viewModel: ContactListViewModel by activityViewModels() // ViewModel teilen mit Activity + private val viewModel: ContactListViewModel by activityViewModels() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) 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 @@ -1,4 +1,28 @@ -package org.gnunet.gnunetmessenger.ui.lobby +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/LobbyJoinFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui.contact import android.Manifest import android.content.pm.PackageManager @@ -112,7 +136,7 @@ class LobbyJoinFragment : Fragment() { requireActivity().runOnUiThread { qrText.setText(rawValue) } - break // nur ersten Treffer nehmen + break } } } diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ShareAttributesFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ShareAttributesFragment.kt @@ -0,0 +1,76 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/contact/ShareAttributesFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui.contact + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Button +import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.LinearLayoutManager +import android.widget.Toast +import androidx.navigation.fragment.navArgs +import androidx.recyclerview.widget.RecyclerView +import org.gnunet.gnunetmessenger.MainActivity +import org.gnunet.gnunetmessenger.R +import org.gnunet.gnunetmessenger.ui.adapters.ShareAttributesAdapter + +class ShareAttributesFragment : Fragment() { + + private val args: ShareAttributesFragmentArgs by navArgs() + private lateinit var adapter: ShareAttributesAdapter + private val selectedAttributes = mutableSetOf<Pair<String, String>>() + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + val view = inflater.inflate(R.layout.fragment_share_attribute, container, false) + val recycler = view.findViewById<RecyclerView>(R.id.shareAttributeList) + val button = view.findViewById<Button>(R.id.btn_confirm_share) + + val activity = activity as MainActivity + val gnunetChat = activity.getGnunetChatInstance() + val handle = activity.getChatHandle() + val attributes = mutableListOf<Pair<String, String>>() + + adapter = ShareAttributesAdapter(attributes, selectedAttributes) + recycler.layoutManager = LinearLayoutManager(requireContext()) + recycler.adapter = adapter + + gnunetChat.getAttributes(handle) { key, value -> + attributes.add(key to value) + adapter.notifyItemInserted(attributes.size - 1) + } + + button.setOnClickListener { + Toast.makeText(requireContext(), + "Share ${selectedAttributes.size} Attribute", Toast.LENGTH_SHORT).show() + + } + + return view + } +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/group/CreateGroupOrPlatformFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/group/CreateGroupOrPlatformFragment.kt @@ -0,0 +1,87 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/group/CreateGroupOrPlatformFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui.group + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Button +import android.widget.EditText +import android.widget.Toast +import androidx.fragment.app.Fragment +import androidx.navigation.fragment.findNavController +import androidx.navigation.fragment.navArgs +import org.gnunet.gnunetmessenger.MainActivity +import org.gnunet.gnunetmessenger.R +import org.gnunet.gnunetmessenger.service.GnunetChat + +class CreateGroupOrPlatformFragment : Fragment() { + + private val args: CreateGroupOrPlatformFragmentArgs by navArgs() + private lateinit var gnunetChat: GnunetChat + private lateinit var mainActivity: MainActivity + private lateinit var nameEdit: EditText + + + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { + return inflater.inflate(R.layout.fragment_create_group_or_platform, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + mainActivity = activity as MainActivity + gnunetChat = mainActivity.getGnunetChatInstance() + + + + nameEdit = view.findViewById(R.id.editName) + val continueBtn = view.findViewById<Button>(R.id.btn_continue) + + continueBtn.setOnClickListener { + val name = nameEdit.text.toString() + if (name.isBlank()) { + Toast.makeText(requireContext(), "Name must not be empty", Toast.LENGTH_SHORT).show() + return@setOnClickListener + } + + if (args.isGroup) { + val action = CreateGroupOrPlatformFragmentDirections + .actionCreateGroupOrPlatformFragmentToSelectGroupMembersFragment(groupName = name) + findNavController().navigate(action) + } else { + processPlatform(name) + } + } + } + + private fun processPlatform(name: String) { + val handle = mainActivity.getChatHandle() + gnunetChat.createGroup(handle, name) + + Toast.makeText(requireContext(), "Platform created", Toast.LENGTH_SHORT).show() + findNavController().popBackStack() + } +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/group/SelectGroupMembersFragment.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/group/SelectGroupMembersFragment.kt @@ -0,0 +1,82 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/group/SelectGroupMembersFragment.kt + */ + +package org.gnunet.gnunetmessenger.ui.group + +import android.os.Bundle +import android.view.View +import android.widget.Button +import androidx.fragment.app.Fragment +import androidx.fragment.app.activityViewModels +import androidx.lifecycle.Observer +import androidx.navigation.fragment.findNavController +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import org.gnunet.gnunetmessenger.MainActivity +import org.gnunet.gnunetmessenger.R +import org.gnunet.gnunetmessenger.model.ChatContact +import org.gnunet.gnunetmessenger.model.ChatHandle +import org.gnunet.gnunetmessenger.service.GnunetChat +import org.gnunet.gnunetmessenger.ui.adapters.ContactListAdapter +import org.gnunet.gnunetmessenger.viewmodel.ContactListViewModel + +class SelectGroupMembersFragment : Fragment(R.layout.fragment_select_group_members) { + + private lateinit var recyclerView: RecyclerView + private lateinit var adapter: ContactListAdapter + private lateinit var gnunetChat: GnunetChat + private lateinit var handle: ChatHandle + private val viewModel: ContactListViewModel by activityViewModels() + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + val activity = requireActivity() as MainActivity + gnunetChat = activity.getGnunetChatInstance() + handle = activity.getChatHandle() + + recyclerView = view.findViewById(R.id.contactRecyclerView) + recyclerView.layoutManager = LinearLayoutManager(requireContext()) + + adapter = ContactListAdapter() + recyclerView.adapter = adapter + + viewModel.contacts.observe(viewLifecycleOwner, Observer { contactList -> + adapter.submitList(contactList) + }) + + view.findViewById<Button>(R.id.btn_confirm_selection).setOnClickListener { + val selected = adapter.getSelectedContacts() + val groupName = arguments?.getString("groupName") ?: "New Group" + + val group = gnunetChat.createGroup(handle, groupName) + gnunetChat.setGroupName(group,groupName) + selected.forEach { chatContact: ChatContact -> + gnunetChat.inviteContactToGroup(group, chatContact) + } + findNavController().popBackStack() + findNavController().popBackStack() + } + } +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/util/AvatarStorageUtil.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/util/AvatarStorageUtil.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/util/AvatarStorageUtil.kt + */ + package org.gnunet.gnunetmessenger.util import android.content.Context diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/util/LobbyDisplayHelper.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/util/LobbyDisplayHelper.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/util/LobbyDisplayHelper.kt + */ + package org.gnunet.gnunetmessenger.util import android.graphics.Bitmap diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatMenuViewModel.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatMenuViewModel.kt @@ -0,0 +1,33 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/viewmodel/ChatMenuViewModel.kt + */ + +package org.gnunet.gnunetmessenger.viewmodel + +import androidx.lifecycle.ViewModel +import org.gnunet.gnunetmessenger.model.ChatContact +import org.gnunet.gnunetmessenger.model.ChatContext + +class ChatMenuViewModel(chatContext: ChatContext) : ViewModel() { + val contactMenuIds: MutableMap<Int, ChatContact> = mutableMapOf() +} +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatOverviewViewModel.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatOverviewViewModel.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/viewmodel/ChatOverviewViewModel.kt + */ + package org.gnunet.gnunetmessenger.viewmodel import androidx.lifecycle.MutableLiveData @@ -5,7 +29,6 @@ import androidx.lifecycle.ViewModel import org.gnunet.gnunetmessenger.model.ChatContext import org.gnunet.gnunetmessenger.model.ChatMessage import org.gnunet.gnunetmessenger.model.ChatSummary -import org.gnunet.gnunetmessenger.model.MessageKind class ChatOverviewViewModel : ViewModel() { diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatViewModel.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatViewModel.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/viewmodel/ChatViewModel.kt + */ + package org.gnunet.gnunetmessenger.viewmodel import androidx.lifecycle.LiveData diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatViewModelFactory.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ChatViewModelFactory.kt @@ -1,5 +1,29 @@ // Datei: ChatViewModelFactory.kt +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/viewmodel/ChatViewModelFactory.kt + */ + package org.gnunet.gnunetmessenger.viewmodel import androidx.lifecycle.ViewModel diff --git a/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ContactListViewModel.kt b/GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/viewmodel/ContactListViewModel.kt @@ -1,3 +1,27 @@ +/* + This file is part of GNUnet. + Copyright (C) 2021--2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/* + * @author t3sserakt + * @file GNUnetMessenger/app/src/main/java/org/gnunet/gnunetmessenger/ui/viewmodel/ContactListViewModel.kt + */ + package org.gnunet.gnunetmessenger.viewmodel import androidx.lifecycle.LiveData diff --git a/GNUnetMessenger/app/src/main/res/layout/account_drawer_header.xml b/GNUnetMessenger/app/src/main/res/layout/account_drawer_header.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="16dp" diff --git a/GNUnetMessenger/app/src/main/res/layout/activity_main.xml b/GNUnetMessenger/app/src/main/res/layout/activity_main.xml @@ -1,4 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" diff --git a/GNUnetMessenger/app/src/main/res/layout/attribute_item.xml b/GNUnetMessenger/app/src/main/res/layout/attribute_item.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" @@ -6,7 +27,6 @@ android:padding="8dp" android:gravity="center_vertical"> - <!-- Name Spalte - linksbündig --> <TextView android:id="@+id/key_name" android:layout_width="0dp" @@ -15,7 +35,6 @@ android:gravity="start" android:text="Name"/> - <!-- Value Spalte - zentriert --> <TextView android:id="@+id/value_name" android:layout_width="0dp" diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_account_details.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_account_details.xml @@ -1,4 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:padding="16dp" diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_account_list.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_account_list.xml @@ -1,4 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/account_list_root" diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_account_overview.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_account_overview.xml @@ -1,4 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" @@ -7,13 +28,12 @@ android:layout_height="match_parent" tools:context=".AccountOverviewFragment"> - <!-- Main content --> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <!-- RecyclerView für die Chatliste --> + <androidx.recyclerview.widget.RecyclerView android:id="@+id/chatListRecyclerView" android:layout_width="match_parent" diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_attribute_list.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_attribute_list.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:padding="16dp" @@ -11,7 +32,6 @@ android:layout_height="wrap_content" android:gravity="center"> - <!-- Name Überschrift - linksbündig --> <TextView android:text="Name" android:layout_width="0dp" @@ -19,7 +39,6 @@ android:layout_weight="1" android:gravity="start"/> - <!-- Value Überschrift - zentriert --> <TextView android:text="Value" android:layout_width="0dp" diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_chat.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_chat.xml @@ -1,9 +1,29 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> - <!-- Chatverlauf --> <androidx.recyclerview.widget.RecyclerView android:id="@+id/chatRecyclerView" android:layout_width="match_parent" @@ -14,21 +34,19 @@ android:padding="8dp" android:descendantFocusability="afterDescendants" /> - <!-- Eingabe --> <EditText android:id="@+id/inputMessage" android:layout_width="match_parent" android:layout_height="wrap_content" - android:hint="Nachricht eingeben..." + android:hint="Enter your message..." android:inputType="text" android:padding="10dp" android:background="@drawable/edittext_bg" /> - <!-- Button --> <Button android:id="@+id/sendButton" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="Senden" + android:text="Send" android:layout_marginTop="8dp" /> </LinearLayout> \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_contact.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_contact.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="16dp"> + + <TextView + android:id="@+id/contactNameView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Contactname" + android:textSize="20sp" + android:textStyle="bold" /> +</LinearLayout> +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_contact_list.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_contact_list.xml @@ -1,4 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_create_account.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_create_account.xml @@ -1,4 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_create_group_or_platform.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_create_group_or_platform.xml @@ -0,0 +1,42 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:padding="16dp" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <EditText + android:id="@+id/editName" + android:hint="Name" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="16dp"/> + + <Button + android:id="@+id/btn_continue" + android:text="Next" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="end" + android:layout_marginTop="16dp"/> +</LinearLayout> +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_join_lobby.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_join_lobby.xml @@ -1,4 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" @@ -18,7 +39,7 @@ <EditText android:id="@+id/qr_text" - android:hint="Lobby ID oder QR Code" + android:hint="Lobby ID or QR Code" android:layout_width="0dp" android:layout_height="wrap_content" android:inputType="text" diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_lobby_create.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_lobby_create.xml @@ -1,10 +1,30 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:padding="16dp" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> - <!-- TextView mit größerer Schrift und zusätzlichem Abstand --> <TextView android:id="@+id/lobby_notice" android:text="@string/lobby_warning" @@ -14,14 +34,13 @@ android:textSize="16sp" android:layout_marginBottom="16dp" /> <!-- Fügt Abstand hinzu --> - <!-- Spinner mit größerer Höhe und Padding --> <Spinner android:id="@+id/lifetime_spinner" android:layout_width="match_parent" android:layout_height="48dp" android:entries="@array/lobby_lifetimes" android:layout_marginTop="24dp" - android:padding="8dp" /> <!-- Padding hinzugefügt für besseren Touch-Bereich --> + android:padding="8dp" /> <ProgressBar android:id="@+id/progress_bar" @@ -32,7 +51,6 @@ android:visibility="gone" /> - <!-- LinearLayout für Buttons --> <LinearLayout android:orientation="horizontal" android:gravity="end" @@ -40,7 +58,6 @@ android:layout_height="wrap_content" android:layout_marginTop="32dp"> - <!-- Cancel Button mit größerer Höhe und Padding --> <Button android:id="@+id/btn_cancel" android:text="Cancel" @@ -49,13 +66,12 @@ android:layout_marginEnd="16dp" android:padding="12dp" /> <!-- Padding hinzugefügt --> - <!-- Generate Button mit größerer Höhe und Padding --> <Button android:id="@+id/btn_generate" android:text="Generate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" - android:padding="12dp" /> <!-- Padding hinzugefügt --> + android:padding="12dp" /> </LinearLayout> </LinearLayout> diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_lobby_display.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_lobby_display.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:padding="16dp" android:orientation="vertical" diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_member_list.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_member_list.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/memberListRoot" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="16dp"> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/memberRecyclerView" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:scrollbars="vertical" + android:clipToPadding="false" + android:padding="8dp" /> + + <Button + android:id="@+id/confirmButton" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/confirm" /> +</LinearLayout> +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_profile_base.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_profile_base.xml @@ -0,0 +1,106 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/profileContainer" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="16dp"> + + <ImageView + android:id="@+id/avatarImage" + android:layout_width="100dp" + android:layout_height="100dp" + android:layout_gravity="center_horizontal" + android:src="@drawable/ic_account_circle" /> + + <TextView + android:id="@+id/nameText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Name" + android:textSize="18sp" + android:gravity="center" + android:paddingTop="8dp" /> + + + <EditText + android:id="@+id/nameEdit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="Account Name" + android:visibility="gone" + android:paddingTop="8dp" /> + + <Button + android:id="@+id/btn_save_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Save Name" + android:visibility="gone" /> + + <TextView + android:id="@+id/publicKeyText" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Public Key" + android:gravity="center" + android:paddingTop="16dp" + android:visibility="gone" /> + + <ImageView + android:id="@+id/qrCodeImage" + android:layout_width="200dp" + android:layout_height="200dp" + android:layout_gravity="center_horizontal" + android:visibility="gone" /> + + <Button + android:id="@+id/btn_list_attributes" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="List Attributes" + android:layout_marginTop="16dp" /> + + <Button + android:id="@+id/btn_share_attributes" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Share Attributes" + android:layout_marginTop="8dp" + android:visibility="gone" /> + + <Button + android:id="@+id/btn_share_identity" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Share Identity" + android:layout_marginTop="8dp" /> + + <Button + android:id="@+id/btn_block_contact" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Block Contact" + android:layout_marginTop="8dp" + android:visibility="gone" /> +</LinearLayout> +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_select_group_members.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_select_group_members.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/layout_select_group_members" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="16dp"> + + <TextView + android:id="@+id/selectionHint" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Select members for the group" + android:textAppearance="?android:attr/textAppearanceMedium" + android:paddingBottom="8dp" /> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/contactRecyclerView" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:scrollbars="vertical" /> + + <Button + android:id="@+id/btn_confirm_selection" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="create group" + android:layout_marginTop="12dp" /> +</LinearLayout> +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_settings.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_settings.xml @@ -0,0 +1,58 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:padding="16dp"> + + <LinearLayout + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <Switch + android:id="@+id/switch_notifications" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="activate notifications" /> + + <Switch + android:id="@+id/switch_receipts" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Send confirmation of receipt" /> + + <TextView + android:id="@+id/blocked_contacts_label" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Blocked contacts" + android:textSize="18sp" + android:layout_marginTop="24dp" /> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/blocked_contacts_list" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" /> + </LinearLayout> +</ScrollView> +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/fragment_share_attribute.xml b/GNUnetMessenger/app/src/main/res/layout/fragment_share_attribute.xml @@ -0,0 +1,39 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:padding="16dp" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/shareAttributeList" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" /> + + <Button + android:id="@+id/btn_confirm_share" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Share" /> +</LinearLayout> +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/item_account.xml b/GNUnetMessenger/app/src/main/res/layout/item_account.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/GNUnetMessenger/app/src/main/res/layout/item_chat.xml b/GNUnetMessenger/app/src/main/res/layout/item_chat.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -26,6 +47,6 @@ android:textColor="@android:color/darker_gray" android:maxLines="1" android:ellipsize="end" - android:text="Letzte Nachricht..." /> + android:text="Last message..." /> </LinearLayout> </androidx.cardview.widget.CardView> \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/item_contact.xml b/GNUnetMessenger/app/src/main/res/layout/item_contact.xml @@ -1,4 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" diff --git a/GNUnetMessenger/app/src/main/res/layout/item_message_other.xml b/GNUnetMessenger/app/src/main/res/layout/item_message_other.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -20,7 +41,7 @@ android:background="@drawable/bubble_other" android:textColor="#000000" android:padding="8dp" - android:text="Nachricht" /> + android:text="Message" /> <TextView android:id="@+id/timestamp" diff --git a/GNUnetMessenger/app/src/main/res/layout/item_message_own.xml b/GNUnetMessenger/app/src/main/res/layout/item_message_own.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -12,7 +33,7 @@ android:background="@drawable/bubble_own" android:textColor="#FFFFFF" android:padding="8dp" - android:text="Nachricht" /> + android:text="Message" /> <TextView android:id="@+id/timestamp" diff --git a/GNUnetMessenger/app/src/main/res/layout/item_message_system.xml b/GNUnetMessenger/app/src/main/res/layout/item_message_system.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -11,7 +32,7 @@ android:layout_height="wrap_content" android:textColor="#888888" android:textStyle="italic" - android:text="Systemnachricht" /> + android:text="system message" /> <TextView android:id="@+id/timestamp" diff --git a/GNUnetMessenger/app/src/main/res/layout/item_share_attribute.xml b/GNUnetMessenger/app/src/main/res/layout/item_share_attribute.xml @@ -0,0 +1,40 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:padding="8dp" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <CheckBox + android:id="@+id/checkbox" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + <TextView + android:id="@+id/keyValue" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:paddingStart="8dp" + android:text="key: value" /> +</LinearLayout> +\ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/layout/view_lobby_info.xml b/GNUnetMessenger/app/src/main/res/layout/view_lobby_info.xml @@ -1,3 +1,24 @@ +<!-- + This file is part of GNUnet. + Copyright (C) 2021–2025 GNUnet e.V. + + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + SPDX-License-Identifier: AGPL3.0-or-later + + @author t3sserakt +--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:gravity="center" diff --git a/GNUnetMessenger/app/src/main/res/menu/chat_menu.xml b/GNUnetMessenger/app/src/main/res/menu/chat_menu.xml @@ -19,4 +19,8 @@ android:title="@string/leave_chat" android:orderInCategory="3" app:showAsAction="never" /> + <item + android:id="@+id/menu_invite_members" + android:title="@string/invite_members" + app:showAsAction="never" /> </menu> \ No newline at end of file diff --git a/GNUnetMessenger/app/src/main/res/menu/main_menu.xml b/GNUnetMessenger/app/src/main/res/menu/main_menu.xml @@ -4,6 +4,13 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> <!-- Aktueller Account-Name --> <item + android:id="@+id/menu_divider" + android:title="@string/global_options" + android:enabled="false" + android:visible="true" + android:orderInCategory="100" + app:showAsAction="never" /> + <item android:id="@+id/menu_current_account" android:title="Account: Name" android:orderInCategory="101" @@ -22,8 +29,18 @@ android:orderInCategory="103" app:showAsAction="never" /> <item + android:id="@+id/menu_new_group" + android:title="@string/new_group" + android:orderInCategory="103" + app:showAsAction="never" /> + <item + android:id="@+id/menu_new_platform" + android:title="@string/new_platform" + android:orderInCategory="103" + app:showAsAction="never" /> + <item android:id="@+id/menu_contact_list" - android:title="Contacts" + android:title="@string/contacts" android:orderInCategory="104" app:showAsAction="never" /> <item diff --git a/GNUnetMessenger/app/src/main/res/navigation/nav_graph.xml b/GNUnetMessenger/app/src/main/res/navigation/nav_graph.xml @@ -41,7 +41,7 @@ <fragment android:id="@+id/accountOverviewFragment" android:name="org.gnunet.gnunetmessenger.ui.account.AccountOverviewFragment" - android:label="Account Overview"> + android:label="@string/account_overview"> <argument android:name="account" app:argType="org.gnunet.gnunetmessenger.model.ChatAccount" /> @@ -56,22 +56,52 @@ <!-- Chat Fragment --> <fragment android:id="@+id/chatFragment" - android:name="org.gnunet.gnunetmessenger.ui.chat.ChatFragment" - android:label="Chat" > + android:name="org.gnunet.gnunetmessenger.ui.chat.ChatFragment"> <argument android:name="chatContext" app:argType="org.gnunet.gnunetmessenger.model.ChatContext" app:nullable="false" /> <action + android:id="@+id/action_chatFragment_to_ContactFragment" + app:destination="@id/contactFragment" /> + <action android:id="@+id/action_chatFragment_to_lobbyDisplayFragment" app:destination="@id/lobbyDisplayFragment" /> + <action + android:id="@+id/action_chatFragment_to_memberListFragment" + app:destination="@id/memberListFragment"> + <argument + android:name="chatGroup" + app:argType="org.gnunet.gnunetmessenger.model.ChatGroup" /> + </action> + </fragment> + + <fragment + android:id="@+id/memberListFragment" + android:name="org.gnunet.gnunetmessenger.ui.chat.MemberListFragment" + android:label="Mitgliederliste" + tools:layout="@layout/fragment_member_list"> + <argument + android:name="chatGroup" + app:argType="org.gnunet.gnunetmessenger.model.ChatGroup" /> </fragment> <fragment android:id="@+id/attributeListFragment" android:name="org.gnunet.gnunetmessenger.ui.account.AttributeListFragment" android:label="Attributes" - tools:layout="@layout/fragment_attribute_list" /> + tools:layout="@layout/fragment_attribute_list"> + <argument + android:name="contact" + app:argType="org.gnunet.gnunetmessenger.model.ChatContact" + app:nullable="true" + android:defaultValue="@null"/> + + <argument + android:name="editable" + app:argType="boolean" + android:defaultValue="false"/> + </fragment> <!-- Account Details --> <fragment @@ -120,8 +150,69 @@ <fragment android:id="@+id/contactListFragment" - android:name="org.gnunet.gnunetmessenger.ui.contacts.ContactListFragment" - android:label="Contacts" /> + android:name="org.gnunet.gnunetmessenger.ui.contact.ContactListFragment" + android:label="Contacts"> + <action + android:id="@+id/action_contactListFragment_to_ContactFragment" + app:destination="@id/contactFragment" /> + </fragment> + + <fragment + android:id="@+id/contactFragment" + android:name="org.gnunet.gnunetmessenger.ui.contact.ContactFragment" + android:label="Contact"> + <argument + android:name="contact" + app:argType="org.gnunet.gnunetmessenger.model.ChatContact" /> + <action + android:id="@+id/action_contactFragment_to_attributeListFragment" + app:destination="@id/attributeListFragment" /> + <action + android:id="@+id/action_contactFragment_to_shareAttributesFragment" + app:destination="@id/shareAttributesFragment" /> + <action + android:id="@+id/action_contactFragment_to_lobbyDisplayFragment" + app:destination="@id/lobbyDisplayFragment" /> + </fragment> + + <fragment + android:id="@+id/shareAttributesFragment" + android:name="org.gnunet.gnunetmessenger.ui.contact.ShareAttributesFragment" + tools:layout="@layout/fragment_share_attribute"> + <argument + android:name="contact" + app:argType="org.gnunet.gnunetmessenger.model.ChatContact" /> + </fragment> + + <fragment + android:id="@+id/selectGroupMembersFragment" + android:name="org.gnunet.gnunetmessenger.ui.group.SelectGroupMembersFragment" + android:label="Mitglieder auswählen" + tools:layout="@layout/fragment_select_group_members"> + <argument + android:name="groupName" + app:argType="string" /> + </fragment> + + <fragment + android:id="@+id/settingsFragment" + android:name="org.gnunet.gnunetmessenger.ui.SettingsFragment" + tools:layout="@layout/fragment_settings"> + </fragment> + + <fragment + android:id="@+id/createGroupOrPlatformFragment" + android:name="org.gnunet.gnunetmessenger.ui.group.CreateGroupOrPlatformFragment" + android:label="Create" + tools:layout="@layout/fragment_create_group_or_platform"> + <argument + android:name="isGroup" + app:argType="boolean" + android:defaultValue="false" /> + <action + android:id="@+id/action_createGroupOrPlatformFragment_to_selectGroupMembersFragment" + app:destination="@id/selectGroupMembersFragment" /> + </fragment> <!-- Global Navigation for Menu Actions --> <action @@ -135,6 +226,12 @@ android:id="@+id/action_global_lobbyJoinFragment" app:destination="@id/lobbyJoinFragment" /> <action + android:id="@+id/action_global_createGroupOrPlatformFragment" + app:destination="@id/createGroupOrPlatformFragment" /> + <action android:id="@+id/action_global_contactListFragment" app:destination="@id/contactListFragment" /> + <action + android:id="@+id/action_global_settingsFragment" + app:destination="@id/settingsFragment" /> </navigation> diff --git a/GNUnetMessenger/app/src/main/res/values/strings.xml b/GNUnetMessenger/app/src/main/res/values/strings.xml @@ -19,6 +19,14 @@ <string name="block_contact">Block Contact</string> <string name="leave_chat">Leave Chat</string> <string name="reveal_identity">Reveal Identity</string> + <string name="new_group">New Group</string> + <string name="contacts">Contacts</string> + <string name="new_platform">New Platform</string> + <string name="invite_members">Invite Members</string> + <string name="invite_contact">Invite Contact</string> + <string name="global_options">--- Global Options ---</string> + <string name="account_overview">Chat Overview</string> + <string name="placeholder_label_chat">Chat</string> <string-array name="lobby_lifetimes"> <item>Off</item> <item>4 weeks</item> diff --git a/app-debug.apk b/app-debug.apk Binary files differ.