leave room before joining another room

refactor retrieving of extras

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-04-02 20:50:41 +02:00
parent cd2ef40dc8
commit d42783273d
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 45 additions and 67 deletions

View File

@ -105,9 +105,9 @@ class MainActivity : BaseActivity(), ActionBarProvider {
// true // true
// ) // )
val intent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
intent.putExtras(intent.extras!!) chatIntent.putExtras(intent.extras!!)
startActivity(intent) startActivity(chatIntent)
logRouterBackStack(router!!) logRouterBackStack(router!!)
} }
@ -312,17 +312,10 @@ class MainActivity : BaseActivity(), ActionBarProvider {
KEY_ACTIVE_CONVERSATION, KEY_ACTIVE_CONVERSATION,
Parcels.wrap(roomOverall.ocs!!.data) Parcels.wrap(roomOverall.ocs!!.data)
) )
// remapChatController(
// router!!,
// currentUser!!.id!!,
// roomOverall.ocs!!.data!!.token!!,
// bundle,
// true
// )
val intent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
intent.putExtras(bundle) chatIntent.putExtras(bundle)
startActivity(intent) startActivity(chatIntent)
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
@ -386,9 +379,9 @@ class MainActivity : BaseActivity(), ActionBarProvider {
// true // true
// ) // )
val intent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
intent.putExtras(intent.extras!!) chatIntent.putExtras(intent.extras!!)
startActivity(intent) startActivity(chatIntent)
logRouterBackStack(router!!) logRouterBackStack(router!!)
} }
@ -412,9 +405,9 @@ class MainActivity : BaseActivity(), ActionBarProvider {
// true // true
// ) // )
val intent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
intent.putExtras(intent.extras!!) chatIntent.putExtras(intent.extras!!)
startActivity(intent) startActivity(chatIntent)
logRouterBackStack(router!!) logRouterBackStack(router!!)
} }

View File

@ -180,7 +180,6 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
import com.nextcloud.talk.utils.remapchat.RemapChatModel
import com.nextcloud.talk.utils.rx.DisposableSet import com.nextcloud.talk.utils.rx.DisposableSet
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
import com.nextcloud.talk.utils.text.Spans import com.nextcloud.talk.utils.text.Spans
@ -255,7 +254,7 @@ class ChatActivity :
var layoutManager: LinearLayoutManager? = null var layoutManager: LinearLayoutManager? = null
var pullChatMessagesPending = false var pullChatMessagesPending = false
var newMessagesCount = 0 var newMessagesCount = 0
var startCallFromNotification: Boolean? = null var startCallFromNotification: Boolean = false
var startCallFromRoomSwitch: Boolean = false var startCallFromRoomSwitch: Boolean = false
lateinit var roomId: String lateinit var roomId: String
var voiceOnly: Boolean = true var voiceOnly: Boolean = true
@ -308,24 +307,25 @@ class ChatActivity :
setupSystemColors() setupSystemColors()
setContentView(binding.root) setContentView(binding.root)
conversationUser = intent.getParcelableExtra(KEY_USER_ENTITY) val extras: Bundle? = intent.extras
roomId = intent.getStringExtra(KEY_ROOM_ID)!!
roomToken = intent.getStringExtra(KEY_ROOM_TOKEN)!! conversationUser = extras?.getParcelable(KEY_USER_ENTITY)
sharedText = intent.getStringExtra(BundleKeys.KEY_SHARED_TEXT)!! roomId = extras?.getString(KEY_ROOM_ID).orEmpty()
roomToken = extras?.getString(KEY_ROOM_TOKEN).orEmpty()
sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty()
Log.d(TAG, " roomToken = $roomToken") Log.d(TAG, " roomToken = $roomToken")
if (roomToken.isNullOrEmpty()) { if (roomToken.isEmpty()) {
Log.d(TAG, " roomToken was null or empty!") Log.d(TAG, " roomToken was null or empty!")
} }
if (intent.hasExtra(KEY_ACTIVE_CONVERSATION)) { if (intent.hasExtra(KEY_ACTIVE_CONVERSATION)) {
currentConversation = Parcels.unwrap<Conversation>(intent.getParcelableExtra(KEY_ACTIVE_CONVERSATION)) currentConversation = Parcels.unwrap<Conversation>(extras?.getParcelable(KEY_ACTIVE_CONVERSATION))
participantPermissions = ParticipantPermissions(conversationUser!!, currentConversation!!) participantPermissions = ParticipantPermissions(conversationUser!!, currentConversation!!)
} }
if (intent.hasExtra(BundleKeys.KEY_CONVERSATION_PASSWORD)) { roomPassword = extras?.getString(BundleKeys.KEY_CONVERSATION_PASSWORD).orEmpty()
roomPassword = intent.getStringExtra(BundleKeys.KEY_CONVERSATION_PASSWORD)!!
}
credentials = if (conversationUser?.userId == "?") { credentials = if (conversationUser?.userId == "?") {
null null
@ -333,15 +333,10 @@ class ChatActivity :
ApiUtils.getCredentials(conversationUser!!.username, conversationUser!!.token) ApiUtils.getCredentials(conversationUser!!.username, conversationUser!!.token)
} }
if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) { startCallFromNotification = extras?.getBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false) == true
startCallFromNotification = intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false) startCallFromRoomSwitch = extras?.getBoolean(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL, false) == true
}
if (intent.hasExtra(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL)) { voiceOnly = extras?.getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false) == true
startCallFromRoomSwitch = intent.getBooleanExtra(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL, false)
}
voiceOnly = intent.getBooleanExtra(BundleKeys.KEY_CALL_VOICE_ONLY, false)
} }
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@ -1020,14 +1015,11 @@ class ChatActivity :
bundle.putParcelable(KEY_USER_ENTITY, conversationUser) bundle.putParcelable(KEY_USER_ENTITY, conversationUser)
bundle.putString(KEY_ROOM_TOKEN, token) bundle.putString(KEY_ROOM_TOKEN, token)
// TODO leaveRoom {
// ConductorRemapping.remapChatController( val chatIntent = Intent(context, ChatActivity::class.java)
// router, chatIntent.putExtras(bundle)
// conversationUser.id!!, startActivity(chatIntent)
// token, }
// bundle,
// true
// )
} }
} }
@ -1929,7 +1921,7 @@ class ChatActivity :
if (conversationUser != null && isActivityNotChangingConfigurations() && isNotInCall()) { if (conversationUser != null && isActivityNotChangingConfigurations() && isNotInCall()) {
ApplicationWideCurrentRoomHolder.getInstance().clear() ApplicationWideCurrentRoomHolder.getInstance().clear()
if (validSessionId()) { if (validSessionId()) {
leaveRoom(null, null) leaveRoom(null)
} else { } else {
Log.d(TAG, "not leaving room (validSessionId is false)") Log.d(TAG, "not leaving room (validSessionId is false)")
} }
@ -2097,8 +2089,7 @@ class ChatActivity :
} }
fun leaveRoom( fun leaveRoom(
remapChatModel: RemapChatModel?, funToCallWhenLeaveSuccessful: (() -> Unit)?
funToCallWhenLeaveSuccessful: ((RemapChatModel) -> Unit)?
) { ) {
logConversationInfos("leaveRoom") logConversationInfos("leaveRoom")
@ -2144,9 +2135,9 @@ class ChatActivity :
sessionIdAfterRoomJoined = "0" sessionIdAfterRoomJoined = "0"
if (remapChatModel != null && funToCallWhenLeaveSuccessful != null) { if (funToCallWhenLeaveSuccessful != null) {
Log.d(TAG, "a callback action was set and is now executed because room was left successfully") Log.d(TAG, "a callback action was set and is now executed because room was left successfully")
funToCallWhenLeaveSuccessful(remapChatModel) funToCallWhenLeaveSuccessful()
} else { } else {
Log.d(TAG, "remapChatController was not set") Log.d(TAG, "remapChatController was not set")
} }
@ -3092,14 +3083,11 @@ class ChatActivity :
Parcels.wrap(roomOverall.ocs!!.data!!) Parcels.wrap(roomOverall.ocs!!.data!!)
) )
// TODO leaveRoom {
// ConductorRemapping.remapChatController( val chatIntent = Intent(context, ChatActivity::class.java)
// router, chatIntent.putExtras(bundle)
// conversationUser!!.id!!, startActivity(chatIntent)
// roomOverall.ocs!!.data!!.token!!, }
// bundle,
// true
// )
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
@ -3413,14 +3401,11 @@ class ChatActivity :
) )
conversationIntent.putExtras(bundle) conversationIntent.putExtras(bundle)
// TODO leaveRoom {
// ConductorRemapping.remapChatController( val chatIntent = Intent(context, ChatActivity::class.java)
// router, chatIntent.putExtras(bundle)
// conversationUser.id!!, startActivity(chatIntent)
// roomOverall.ocs!!.data!!.token!!, }
// bundle,
// true
// )
} else { } else {
conversationIntent.putExtras(bundle) conversationIntent.putExtras(bundle)
startActivity(conversationIntent) startActivity(conversationIntent)