Skip to content

Add support for Direct Share targets. #6024

Merged
mahibi merged 3 commits intonextcloud:masterfrom
anakin78z:share-suggestions
Apr 17, 2026
Merged

Add support for Direct Share targets. #6024
mahibi merged 3 commits intonextcloud:masterfrom
anakin78z:share-suggestions

Conversation

@anakin78z
Copy link
Copy Markdown
Contributor

@anakin78z anakin78z commented Apr 4, 2026

When an app shares something using the share sheet, it can now suggest Nextcloud Talk contacts.

🖼️ Screenshots

share sheet with nextcloud talk contact shortcuts

This also adds shortcuts to the app on the launcher, accessible by long pressing the app icon.
Note that it may end up pushing the Open Notes shortcut off the list, depending on how many active conversations you have going.

🏚️ Before 🏡 After
no contact shortcuts multiple contact shortcuts

TESTING

Whether or not shortcuts show up in the share sheet is at the whim of Android's prioritization, so you may not see them right away. To guarantee that you can see them, start a new emulator and sign into Nextcloud Talk there. Direct Share contacts should show on the share sheet right away.

🚧 TODO

  • Handle account switching, sign out, and conversation deleting
  • Add testing instructions
  • Codacy
  • Merge latest master with chat changes

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

@anakin78z anakin78z force-pushed the share-suggestions branch 4 times, most recently from 406e340 to 8a74480 Compare April 4, 2026 16:44
@anakin78z
Copy link
Copy Markdown
Contributor Author

@mahibi Hey, I saw that your recent commit changed incoming message handling quite a bit. I wanted to double check what the best place is to react to a new incoming message?

Right now I'm using OfflineFirstChatRepository.kt but I'm not sure that's the right place.

Thanks!

…ing the share sheet, it can now suggest Nextcloud Talk contacts.

Signed-off-by: Jens Zalzala <jens@shakingearthdigital.com>
@anakin78z anakin78z marked this pull request as ready for review April 10, 2026 14:29
@mahibi
Copy link
Copy Markdown
Collaborator

mahibi commented Apr 13, 2026

Thanks @anakin78z
i will come back to you soon

Copy link
Copy Markdown
Collaborator

@mahibi mahibi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution, it works pretty good! 👍

You are right to question if OfflineFirstChatRepo is the correct place to call the DirectShareHelper.
It should not directly call it. I suggest to add another flow and then obesrve this in the ChatViewModel.

Lets add this flow in the OfflineFirstChatRepo:

    override val incomingMessageFlow: Flow<Unit>
        get() = _incomingMessageFlow

    private val _incomingMessageFlow: MutableSharedFlow<Unit> = MutableSharedFlow()

Move the emitOnIncoming block into persistChatMessagesAndHandleSystemMessages:

    suspend fun persistChatMessagesAndHandleSystemMessages(
        chatMessages: List<ChatMessageJson>,
        emitOnIncoming: Boolean = false
    ): List<ChatMessageEntity> {
        handleSystemMessagesThatAffectDatabase(chatMessages)

        val chatMessageEntities = chatMessages.map {
            it.asEntity(currentUser.id!!)
        }

        chatDao.upsertChatMessagesAndDeleteTemp(internalConversationId, chatMessageEntities)

        if (emitOnIncoming) {
            val hasIncomingFromOther = chatMessages.any { msg ->
                msg.systemMessageType == ChatMessage.SystemMessageType.DUMMY &&
                    msg.actorId != currentUser.userId
            }
            if (hasIncomingFromOther) {
                _incomingMessageFlow.emit(Unit)
            }
        }

        return chatMessageEntities
    }

In
OfflineFirstChatRepository.updateMessagesData , just pass lookIntoFuture
and in
onSignalingChatMessageReceived , just pass true
for emitOnIncoming

In ChatViewModel, observe the flow like this:

    private fun observeIncomingMessages() {
        chatRepository.incomingMessageFlow
            .onEach {
                val (conversation, user) = conversationAndUserFlow.first()
                val context = NextcloudTalkApplication.sharedApplication!!
                val isOneToOne = conversation.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL
                DirectShareHelper.reportIncomingMessage(
                    context,
                    user,
                    conversation.token,
                    conversation.displayName ?: conversation.token,
                    isOneToOne
                )
            }
            .launchIn(viewModelScope)
    }

What do you think?

@github-project-automation github-project-automation bot moved this to 🏗️ In progress in 💬 Talk team Apr 17, 2026
@mahibi mahibi added the 3. to review Waiting for reviews label Apr 17, 2026
@mahibi mahibi self-assigned this Apr 17, 2026
@anakin78z
Copy link
Copy Markdown
Contributor Author

Great, I can give that a try, but if you think it would be quicker for you to just do it (looks like you pretty much have 😆), feel free.

…to ChatViewModel.kt

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
Copy link
Copy Markdown
Collaborator

mahibi commented Apr 17, 2026

Great, I can give that a try, but if you think it would be quicker for you to just do it (looks like you pretty much have 😆), feel free.

i pushed this.

  • in general, is it fine for you if i push changes directly to your branches or should i inform you beforehand?

  • are you interested to be invited to the nextcloud.com instance as a guest so we could also chat and you can further connect to the community? Should i invite you via anakin78z@gmail.com ?

  • Also, do you like to have advanced access to the talk repo? Then you could create PR's inside it instead in your fork, which will simplify the review process

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@anakin78z
Copy link
Copy Markdown
Contributor Author

  • in general, is it fine for you if i push changes directly to your branches or should i inform you beforehand?

Yep, totally fine.

  • are you interested to be invited to the nextcloud.com instance as a guest so we could also chat and you can further connect to the community? Should i invite you via anakin78z@gmail.com ?

Sounds great. that email is good.

  • Also, do you like to have advanced access to the talk repo? Then you could create PR's inside it instead in your fork, which will simplify the review process

If that's easier for you, sure. If you can set it up so that I can't accidentally push to master, that would be best (probably already set up that way).

@mahibi
Copy link
Copy Markdown
Collaborator

mahibi commented Apr 17, 2026

  • are you interested to be invited to the nextcloud.com instance as a guest so we could also chat and you can further connect to the community? Should i invite you via anakin78z@gmail.com ?

Sounds great. that email is good.

invited

  • Also, do you like to have advanced access to the talk repo? Then you could create PR's inside it instead in your fork, which will simplify the review process

If that's easier for you, sure. If you can set it up so that I can't accidentally push to master, that would be best (probably already set up that way).

sure, that's set up. You should get an invite next week

@mahibi mahibi merged commit bb1aaf9 into nextcloud:master Apr 17, 2026
14 of 17 checks passed
@github-project-automation github-project-automation bot moved this from 🏗️ In progress to ☑️ Done in 💬 Talk team Apr 17, 2026
@mahibi
Copy link
Copy Markdown
Collaborator

mahibi commented Apr 17, 2026

Thanks again, great PR 👍

@AndyScherzinger AndyScherzinger added this to the 24.0.0 milestone Apr 17, 2026
@anakin78z anakin78z deleted the share-suggestions branch April 17, 2026 18:13
@github-actions
Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

3 participants