Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
18a7a2f
Adding bubbles support
arlexTech Nov 14, 2025
57c2d7f
fix ktlintCheck detekt testGplayDebugUnitTest
arlexTech Nov 14, 2025
0053b5b
remove deprecated onBackPressed and extracted code in function
arlexTech Nov 27, 2025
734a700
prevent second app instance and adding talk icon button in bubble mode
arlexTech Dec 5, 2025
3cc598e
fix potential issue with room token
arlexTech Dec 6, 2025
eaf4731
fix getLargeIcon preventing bubble notification
arlexTech Dec 6, 2025
63f0818
bubbles off by default and lead to android bubble settings if needed …
arlexTech Dec 6, 2025
7c463cb
codacy warnings
arlexTech Dec 28, 2025
4e23c56
systemNotificationId fix
arlexTech Dec 28, 2025
d11c761
Fix 2 bubbles
arlexTech Dec 28, 2025
0578f62
Merge branch 'master' into feature/bubble-conversations
arlexTech Jan 1, 2026
605af97
fix user provider usage
mahibi Jan 8, 2026
6a5a728
change logic to not delete bubbles
mahibi Jan 8, 2026
0341869
fix to enable system bubble when they are disabled but "create bubble…
mahibi Jan 8, 2026
39bb469
Merge branch 'nextcloud:master' into feature/bubble-conversations
arlexTech Jan 8, 2026
43f442f
Merge branch 'nextcloud:master' into feature/bubble-conversations
arlexTech Jan 9, 2026
304da57
Remove outdated comment
arlexTech Jan 10, 2026
a255e19
Merge branch 'nextcloud:master' into feature/bubble-conversations
arlexTech Jan 12, 2026
374c378
Fix build
arlexTech Jan 12, 2026
8ab2945
Extracted bubble logic
arlexTech Jan 12, 2026
658d629
Fix codacy
arlexTech Jan 12, 2026
93f31f2
Fix codacy fix
arlexTech Jan 12, 2026
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
93 changes: 93 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,93 @@
/*
* 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 androidx.activity.OnBackPressedCallback
import com.nextcloud.talk.R
import com.nextcloud.talk.activities.MainActivity
import com.nextcloud.talk.utils.bundle.BundleKeys

class BubbleActivity : ChatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_talk)
supportActionBar?.setDisplayShowHomeEnabled(true)
findViewById<androidx.appcompat.widget.Toolbar>(R.id.chat_toolbar)?.setNavigationOnClickListener {
openConversationList()
}

onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
moveTaskToBack(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
}
android.R.id.home -> {
openConversationList()
true
}
else -> super.onOptionsItemSelected(item)
}

private fun openInMainApp() {
val intent = Intent(this, MainActivity::class.java).apply {
action = Intent.ACTION_MAIN
addCategory(Intent.CATEGORY_LAUNCHER)
putExtras([email protected])
conversationUser?.id?.let { putExtra(BundleKeys.KEY_INTERNAL_USER_ID, it) }
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
}
startActivity(intent)
}

private fun openConversationList() {
val intent = Intent(this, MainActivity::class.java).apply {
action = Intent.ACTION_MAIN
addCategory(Intent.CATEGORY_LAUNCHER)
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
}
startActivity(intent)
}

@Deprecated("Deprecated in Java")
override fun onSupportNavigateUp(): Boolean {
openInMainApp()
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
}
}
}
110 changes: 101 additions & 9 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2025 Alexandre Wery <[email protected]>
* SPDX-FileCopyrightText: 2024 Christian Reiner <[email protected]>
* SPDX-FileCopyrightText: 2024 Parneet Singh <[email protected]>
* SPDX-FileCopyrightText: 2024 Giacomo Pacini <[email protected]>
Expand Down Expand Up @@ -163,6 +164,7 @@ import com.nextcloud.talk.models.json.threads.ThreadInfo
import com.nextcloud.talk.polls.ui.PollCreateDialogFragment
import com.nextcloud.talk.remotefilebrowser.activities.RemoteFileBrowserActivity
import com.nextcloud.talk.shareditems.activities.SharedItemsActivity
import com.nextcloud.talk.settings.SettingsActivity
import com.nextcloud.talk.signaling.SignalingMessageReceiver
import com.nextcloud.talk.signaling.SignalingMessageSender
import com.nextcloud.talk.threadsoverview.ThreadsOverviewActivity
Expand Down Expand Up @@ -214,6 +216,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_THREAD_ID
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
import com.nextcloud.talk.utils.rx.DisposableSet
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
import com.nextcloud.talk.utils.preferences.preferencestorage.DatabaseStorageModule
import com.nextcloud.talk.webrtc.WebSocketConnectionHelper
import com.nextcloud.talk.webrtc.WebSocketInstance
import com.otaliastudios.autocomplete.Autocomplete
Expand Down Expand Up @@ -252,7 +255,7 @@ import kotlin.math.roundToInt

@Suppress("TooManyFunctions")
@AutoInjector(NextcloudTalkApplication::class)
class ChatActivity :
open class ChatActivity :
BaseActivity(),
MessagesListAdapter.OnLoadMoreListener,
MessagesListAdapter.Formatter<Date>,
Expand Down Expand Up @@ -2678,26 +2681,36 @@ class ChatActivity :
)
}

private fun showConversationInfoScreen() {
private fun showConversationInfoScreen(focusBubbleSwitch: Boolean = false) {
val bundle = Bundle()

bundle.putString(KEY_ROOM_TOKEN, roomToken)
bundle.putBoolean(BundleKeys.KEY_ROOM_ONE_TO_ONE, isOneToOneConversation())
if (focusBubbleSwitch) {
bundle.putBoolean(BundleKeys.KEY_FOCUS_CONVERSATION_BUBBLE, true)
}

val intent = Intent(this, ConversationInfoActivity::class.java)
intent.putExtras(bundle)
startActivity(intent)
}

private fun openBubbleSettings() {
val intent = Intent(this, SettingsActivity::class.java)
intent.putExtra(BundleKeys.KEY_FOCUS_BUBBLE_SETTINGS, true)
startActivity(intent)
}

private fun validSessionId(): Boolean =
currentConversation != null &&
sessionIdAfterRoomJoined?.isNotEmpty() == true &&
sessionIdAfterRoomJoined != "0"

@Suppress("Detekt.TooGenericExceptionCaught")
private fun cancelNotificationsForCurrentConversation() {
protected open fun cancelNotificationsForCurrentConversation() {
val isBubbleMode = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && isLaunchedFromBubble
if (conversationUser != null) {
if (!TextUtils.isEmpty(roomToken)) {
if (!TextUtils.isEmpty(roomToken) && !isBubbleMode) {
try {
NotificationUtils.cancelExistingNotificationsForRoom(
applicationContext,
Expand Down Expand Up @@ -3284,6 +3297,10 @@ class ChatActivity :
showThreadsItem.isVisible = !isChatThread() &&
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.THREADS)

val createBubbleItem = menu.findItem(R.id.create_conversation_bubble)
createBubbleItem.isVisible = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R &&
!isChatThread()

if (CapabilitiesUtil.isAbleToCall(spreedCapabilities) && !isChatThread()) {
conversationVoiceCallMenuItem = menu.findItem(R.id.conversation_voice_call)
conversationVideoMenuItem = menu.findItem(R.id.conversation_video_call)
Expand Down Expand Up @@ -3316,6 +3333,8 @@ class ChatActivity :
menu.removeItem(R.id.conversation_voice_call)
}

menu.findItem(R.id.create_conversation_bubble)?.isVisible = NotificationUtils.deviceSupportsBubbles

handleThreadNotificationIcon(menu.findItem(R.id.thread_notifications))
}
return true
Expand All @@ -3326,8 +3345,8 @@ class ChatActivity :
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.THREADS)

val threadNotificationIcon = when (conversationThreadInfo?.attendee?.notificationLevel) {
1 -> R.drawable.outline_notifications_active_24
3 -> R.drawable.ic_baseline_notifications_off_24
NOTIFICATION_LEVEL_DEFAULT -> R.drawable.outline_notifications_active_24
NOTIFICATION_LEVEL_NEVER -> R.drawable.ic_baseline_notifications_off_24
else -> R.drawable.baseline_notifications_24
}
threadNotificationItem.icon = ContextCompat.getDrawable(context, threadNotificationIcon)
Expand Down Expand Up @@ -3376,9 +3395,79 @@ class ChatActivity :
true
}

R.id.create_conversation_bubble -> {
createConversationBubble()
true
}

else -> super.onOptionsItemSelected(item)
}

private fun createConversationBubble() {
if (!NotificationUtils.deviceSupportsBubbles) {
Log.e(TAG, "createConversationBubble was called but device doesnt support it. It should not be possible " +
"to get here via UI!")
return
}

lifecycleScope.launch {
if (!appPreferences.areBubblesEnabled() || !NotificationUtils.areSystemBubblesEnabled(context)) {
// Do not replace with snackbar as it needs to survive screen change
Toast.makeText(
this@ChatActivity,
getString(R.string.nc_conversation_notification_bubble_disabled),
Toast.LENGTH_SHORT
).show()
openBubbleSettings()
return@launch
}

if (!appPreferences.areBubblesForced()) {
val conversationAllowsBubbles = isConversationBubbleEnabled()
if (!conversationAllowsBubbles) {
// Do not replace with snackbar as it needs to survive screen change
Toast.makeText(
this@ChatActivity,
getString(R.string.nc_conversation_notification_bubble_enable_conversation),
Toast.LENGTH_SHORT
).show()
showConversationInfoScreen(focusBubbleSwitch = true)
return@launch
}
}

val conversationName = currentConversation?.displayName ?: getString(R.string.nc_app_name)

NotificationUtils.createConversationBubble(
context = this@ChatActivity,
bubbleInfo = NotificationUtils.BubbleInfo(
roomToken = roomToken,
conversationRemoteId = currentConversation!!.name,
conversationName = conversationName,
conversationUser = conversationUser!!,
isOneToOneConversation = isOneToOneConversation(),
credentials = credentials
),
appPreferences = appPreferences!!
)
}
}

private suspend fun isConversationBubbleEnabled(): Boolean {
val user = conversationUser ?: return false
return withContext(Dispatchers.IO) {
try {
DatabaseStorageModule(user, roomToken).getBoolean(BUBBLE_SWITCH_KEY, false)
} catch (e: IOException) {
Log.e(TAG, "Failed to read conversation bubble preference: IO error", e)
false
} catch (e: IllegalStateException) {
Log.e(TAG, "Failed to read conversation bubble preference: Invalid state", e)
false
}
}
}

@Suppress("Detekt.LongMethod")
private fun showThreadNotificationMenu() {
fun setThreadNotificationLevel(level: Int) {
Expand Down Expand Up @@ -3433,7 +3522,7 @@ class ChatActivity :
subtitle = null,
icon = R.drawable.ic_baseline_notifications_off_24,
onClick = {
setThreadNotificationLevel(3)
setThreadNotificationLevel(NOTIFICATION_LEVEL_NEVER)
}
)
)
Expand Down Expand Up @@ -4106,8 +4195,8 @@ class ChatActivity :
displayName = currentConversation?.displayName ?: ""
)
showSnackBar(roomToken)
} catch (e: Exception) {
Log.w(TAG, "File corresponding to the uri does not exist $shareUri", e)
} catch (e: IOException) {
Log.w(TAG, "File corresponding to the uri does not exist: IO error $shareUri", e)
downloadFileToCache(message, false) {
uploadFile(
fileUri = shareUri.toString(),
Expand Down Expand Up @@ -4593,6 +4682,8 @@ class ChatActivity :
private const val HTTP_FORBIDDEN = 403
private const val HTTP_NOT_FOUND = 404
private const val MESSAGE_PULL_LIMIT = 100
private const val NOTIFICATION_LEVEL_DEFAULT = 1
private const val NOTIFICATION_LEVEL_NEVER = 3
private const val INVITE_LENGTH = 6
private const val ACTOR_LENGTH = 6
private const val CHUNK_SIZE: Int = 10
Expand All @@ -4608,6 +4699,7 @@ class ChatActivity :
private const val CURRENT_AUDIO_POSITION_KEY = "CURRENT_AUDIO_POSITION"
private const val CURRENT_AUDIO_WAS_PLAYING_KEY = "CURRENT_AUDIO_PLAYING"
private const val RESUME_AUDIO_TAG = "RESUME_AUDIO_TAG"
private const val BUBBLE_SWITCH_KEY = "bubble_switch"
private const val FIVE_MINUTES_IN_SECONDS: Long = 300
private const val ROOM_TYPE_ONE_TO_ONE = "1"
private const val ACTOR_TYPE = "users"
Expand Down
Loading