Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@
android:name=".chat.ChatActivity"
android:theme="@style/AppTheme" />

<activity
android:name=".chat.BubbleActivity"
android:theme="@style/AppTheme"
android:allowEmbedded="true"
android:resizeableActivity="true"
android:documentLaunchMode="always" />

<activity
android:name=".activities.CallActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
Expand Down
70 changes: 70 additions & 0 deletions app/src/main/java/com/nextcloud/talk/chat/BubbleActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2025 Alexandre Wery <[email protected]>
* SPDX-License-Identifier: GPL-3.0-or-later
*/

package com.nextcloud.talk.chat

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.nextcloud.talk.R
import com.nextcloud.talk.utils.bundle.BundleKeys

class BubbleActivity : ChatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportActionBar?.setDisplayHomeAsUpEnabled(false)
supportActionBar?.setDisplayShowHomeEnabled(false)
}

override fun onPrepareOptionsMenu(menu: android.view.Menu): Boolean {
super.onPrepareOptionsMenu(menu)

menu.findItem(R.id.create_conversation_bubble)?.isVisible = false
menu.findItem(R.id.open_conversation_in_app)?.isVisible = true

return true
}

override fun onOptionsItemSelected(item: android.view.MenuItem): Boolean =
when (item.itemId) {
R.id.open_conversation_in_app -> {
openInMainApp()
true
}
else -> super.onOptionsItemSelected(item)
}

private fun openInMainApp() {
val intent = Intent(this, ChatActivity::class.java).apply {
putExtras([email protected])
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
Copy link
Collaborator

Choose a reason for hiding this comment

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

multiple instances of the app are opened when "open is app" is used.
https://developer.android.com/develop/ui/views/notifications/bubbles#launching-activities

}
startActivity(intent)
moveTaskToBack(false)
}

override fun onBackPressed() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

as onBackPressed is deprecated we want to avoid it and use onBackPressedDispatcher

moveTaskToBack(false)
}

@Deprecated("Deprecated in Java")
override fun onSupportNavigateUp(): Boolean {
moveTaskToBack(false)
return true
}

companion object {
fun newIntent(context: Context, roomToken: String, conversationName: String?): Intent =
Intent(context, BubbleActivity::class.java).apply {
putExtra(BundleKeys.KEY_ROOM_TOKEN, roomToken)
conversationName?.let { putExtra(BundleKeys.KEY_CONVERSATION_NAME, it) }
action = Intent.ACTION_VIEW
flags = Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
}
}
}
Loading
Loading