diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 27a5f6d87..c15528198 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -221,6 +221,7 @@
(KEY_USER_ENTITY)!!.id!!,
- // intent.getStringExtra(KEY_ROOM_TOKEN)!!,
- // intent.extras!!,
- // true,
- // true
- // )
-
- val chatIntent = Intent(context, ChatActivity::class.java)
- chatIntent.putExtras(intent.extras!!)
- startActivity(chatIntent)
-
- logRouterBackStack(router!!)
- }
-
if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
if (intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
if (!router!!.hasRootController()) {
@@ -377,14 +359,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
startActivity(callNotificationIntent)
} else {
logRouterBackStack(router!!)
- // remapChatController(
- // router!!,
- // intent.getParcelableExtra(KEY_USER_ENTITY)!!.id!!,
- // intent.getStringExtra(KEY_ROOM_TOKEN)!!,
- // intent.extras!!,
- // true,
- // true
- // )
val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(intent.extras!!)
diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
index b2272934e..60a0d1089 100644
--- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
+++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
@@ -169,6 +169,7 @@ import com.nextcloud.talk.utils.ParticipantPermissions
import com.nextcloud.talk.utils.VibrationUtils
import com.nextcloud.talk.utils.bundle.BundleKeys
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ACTIVE_CONVERSATION
+import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_CALL_VOICE_ONLY
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_CONVERSATION_NAME
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FILE_PATHS
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
@@ -177,6 +178,8 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_MODERATOR
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_RECORDING_STATE
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
+import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH
+import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SWITCH_TO_ROOM
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
@@ -295,7 +298,11 @@ class ChatActivity :
private val localParticipantMessageListener = object : SignalingMessageReceiver.LocalParticipantMessageListener {
override fun onSwitchTo(token: String?) {
if (token != null) {
- switchToRoom(token)
+ if (CallActivity.active) {
+ Log.d(TAG, "CallActivity is running. Ignore to switch chat in ChatActivity...")
+ } else {
+ switchToRoom(token, false, false)
+ }
}
}
}
@@ -309,6 +316,34 @@ class ChatActivity :
setupSystemColors()
setContentView(binding.root)
+ handleIntent(intent)
+
+ binding.progressBar.visibility = View.VISIBLE
+
+ initAdapter()
+ binding.messagesListView.setAdapter(adapter)
+ }
+
+ override fun onNewIntent(intent: Intent) {
+ super.onNewIntent(intent)
+ val extras: Bundle? = intent.extras
+
+ val requestedRoomSwitch = extras?.getBoolean(KEY_SWITCH_TO_ROOM, false) == true
+
+ if (requestedRoomSwitch) {
+ val newRoomToken = extras?.getString(KEY_ROOM_TOKEN).orEmpty()
+ val startCallAfterRoomSwitch = extras?.getBoolean(KEY_START_CALL_AFTER_ROOM_SWITCH, false) == true
+ val isVoiceOnlyCall = extras?.getBoolean(KEY_CALL_VOICE_ONLY, false) == true
+
+ if (newRoomToken != roomToken) {
+ switchToRoom(newRoomToken, startCallAfterRoomSwitch, isVoiceOnlyCall)
+ }
+ } else {
+ handleIntent(intent)
+ }
+ }
+
+ private fun handleIntent(intent: Intent) {
val extras: Bundle? = intent.extras
conversationUser = extras?.getParcelable(KEY_USER_ENTITY)
@@ -336,14 +371,9 @@ class ChatActivity :
}
startCallFromNotification = extras?.getBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false) == true
- startCallFromRoomSwitch = extras?.getBoolean(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL, false) == true
+ startCallFromRoomSwitch = extras?.getBoolean(KEY_START_CALL_AFTER_ROOM_SWITCH, false) == true
- voiceOnly = extras?.getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false) == true
-
- binding.progressBar.visibility = View.VISIBLE
-
- initAdapter()
- binding.messagesListView.setAdapter(adapter)
+ voiceOnly = extras?.getBoolean(KEY_CALL_VOICE_ONLY, false) == true
}
override fun onStart() {
@@ -1010,12 +1040,7 @@ class ChatActivity :
currentConversation?.type == Conversation.ConversationType
.ROOM_TYPE_ONE_TO_ONE_CALL
- private fun switchToRoom(token: String) {
- if (CallActivity.active) {
- Log.d(TAG, "CallActivity is running. Ignore to switch chat in ChatController...")
- return
- }
-
+ private fun switchToRoom(token: String, startCallAfterRoomSwitch: Boolean, isVoiceOnlyCall: Boolean) {
if (conversationUser != null) {
runOnUiThread {
if (currentConversation?.objectType == Conversation.ObjectType.ROOM) {
@@ -1037,6 +1062,11 @@ class ChatActivity :
bundle.putParcelable(KEY_USER_ENTITY, conversationUser)
bundle.putString(KEY_ROOM_TOKEN, token)
+ if (startCallAfterRoomSwitch) {
+ bundle.putBoolean(KEY_START_CALL_AFTER_ROOM_SWITCH, true)
+ bundle.putBoolean(KEY_CALL_VOICE_ONLY, isVoiceOnlyCall)
+ }
+
leaveRoom {
val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle)
@@ -1926,7 +1956,7 @@ class ChatActivity :
override fun onPause() {
super.onPause()
- logConversationInfos("onDetach")
+ logConversationInfos("onPause")
eventBus.unregister(this)
@@ -1995,24 +2025,6 @@ class ChatActivity :
}
private fun joinRoomWithPassword() {
- if (CallActivity.active &&
- roomToken != ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken
- ) {
- Toast.makeText(
- context,
- context.getString(R.string.restrict_join_other_room_while_call),
- Toast.LENGTH_LONG
- ).show()
-
- Log.e(
- TAG,
- "Restricted to open chat controller because a call in another room is active. This is an " +
- "edge case which is not properly handled yet."
- )
- finish()
- return
- }
-
// if ApplicationWideCurrentRoomHolder contains a session (because a call is active), then keep the sessionId
if (ApplicationWideCurrentRoomHolder.getInstance().currentRoomId ==
currentConversation!!.roomId
@@ -2080,6 +2092,7 @@ class ChatActivity :
}
if (startCallFromRoomSwitch) {
+ startCallFromRoomSwitch = false
startACall(voiceOnly, true)
}
}
@@ -2160,8 +2173,6 @@ class ChatActivity :
if (funToCallWhenLeaveSuccessful != null) {
Log.d(TAG, "a callback action was set and is now executed because room was left successfully")
funToCallWhenLeaveSuccessful()
- } else {
- Log.d(TAG, "remapChatController was not set")
}
}
@@ -2872,7 +2883,7 @@ class ChatActivity :
)
if (isVoiceOnlyCall) {
- bundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true)
+ bundle.putBoolean(KEY_CALL_VOICE_ONLY, true)
}
if (callWithoutNotification) {
bundle.putBoolean(BundleKeys.KEY_CALL_WITHOUT_NOTIFICATION, true)
@@ -3509,7 +3520,7 @@ class ChatActivity :
private fun logConversationInfos(methodName: String) {
Log.d(TAG, " |-----------------------------------------------")
Log.d(TAG, " | method: $methodName")
- Log.d(TAG, " | ChatController: " + System.identityHashCode(this).toString())
+ Log.d(TAG, " | ChatActivity: " + System.identityHashCode(this).toString())
Log.d(TAG, " | roomToken: $roomToken")
Log.d(TAG, " | currentConversation?.displayName: ${currentConversation?.displayName}")
Log.d(TAG, " | sessionIdAfterRoomJoined: $sessionIdAfterRoomJoined")
@@ -3517,7 +3528,7 @@ class ChatActivity :
}
companion object {
- private const val TAG = "ChatController"
+ private val TAG = ChatActivity::class.simpleName
private const val CONTENT_TYPE_SYSTEM_MESSAGE: Byte = 1
private const val CONTENT_TYPE_UNREAD_NOTICE_MESSAGE: Byte = 2
private const val CONTENT_TYPE_LOCATION: Byte = 3
diff --git a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt
index 4b643b1ed..2dd613648 100644
--- a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt
+++ b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt
@@ -80,7 +80,8 @@ object BundleKeys {
const val KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_AUDIO = "KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_AUDIO"
const val KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_VIDEO = "KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_VIDEO"
const val KEY_IS_MODERATOR = "KEY_IS_MODERATOR"
- const val KEY_SWITCH_TO_ROOM_AND_START_CALL = "KEY_SWITCH_TO_ROOM_AND_START_CALL"
+ const val KEY_SWITCH_TO_ROOM = "KEY_SWITCH_TO_ROOM"
+ const val KEY_START_CALL_AFTER_ROOM_SWITCH = "KEY_START_CALL_AFTER_ROOM_SWITCH"
const val KEY_IS_BREAKOUT_ROOM = "KEY_IS_BREAKOUT_ROOM"
const val KEY_NOTIFICATION_RESTRICT_DELETION = "KEY_NOTIFICATION_RESTRICT_DELETION"
const val KEY_DISMISS_RECORDING_URL = "KEY_DISMISS_RECORDING_URL"
diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt
index 3694e6bcc..dd9daf562 100644
--- a/scripts/analysis/lint-results.txt
+++ b/scripts/analysis/lint-results.txt
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
- Lint Report: 108 warnings
+ Lint Report: 109 warnings