mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-22 21:15:30 +03:00
Merge pull request #2620 from nextcloud/bugfix/2181/fixConversationTitle
Bugfix/2181/fix conversation title
This commit is contained in:
commit
82b4907118
7 changed files with 142 additions and 64 deletions
|
@ -50,13 +50,13 @@ import com.nextcloud.talk.databinding.ActivityMainBinding
|
|||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
import com.nextcloud.talk.users.UserManager
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.ConductorRemapping.remapChatController
|
||||
import com.nextcloud.talk.utils.SecurityUtils
|
||||
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_ROOM_ID
|
||||
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.remapchat.ConductorRemapping.remapChatController
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.SingleObserver
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
|
@ -354,7 +354,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||
intent.getParcelableExtra<User>(KEY_USER_ENTITY)!!.id!!,
|
||||
intent.getStringExtra(KEY_ROOM_TOKEN)!!,
|
||||
intent.extras!!,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
)
|
||||
logRouterBackStack(router!!)
|
||||
|
@ -366,7 +366,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||
if (router!!.getControllerWithTag(LockedController.TAG) != null) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!router!!.handleBack()) {
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
|
|
@ -161,8 +161,6 @@ import com.nextcloud.talk.ui.dialog.ShowReactionsDialog
|
|||
import com.nextcloud.talk.ui.recyclerview.MessageSwipeActions
|
||||
import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.ConductorRemapping
|
||||
import com.nextcloud.talk.utils.ConductorRemapping.remapChatController
|
||||
import com.nextcloud.talk.utils.ContactUtils
|
||||
import com.nextcloud.talk.utils.DateConstants
|
||||
import com.nextcloud.talk.utils.DateUtils
|
||||
|
@ -181,6 +179,8 @@ 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.database.user.CapabilitiesUtilNew
|
||||
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
||||
import com.nextcloud.talk.utils.remapchat.ConductorRemapping
|
||||
import com.nextcloud.talk.utils.remapchat.RemapChatModel
|
||||
import com.nextcloud.talk.utils.rx.DisposableSet
|
||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
||||
import com.nextcloud.talk.utils.text.Spans
|
||||
|
@ -336,6 +336,8 @@ class ChatController(args: Bundle) :
|
|||
}
|
||||
|
||||
private fun getRoomInfo() {
|
||||
logConversationInfos("getRoomInfo")
|
||||
|
||||
val shouldRepeat = CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "webinary-lobby")
|
||||
if (shouldRepeat) {
|
||||
checkingLobbyStatus = true
|
||||
|
@ -358,11 +360,9 @@ class ChatController(args: Bundle) :
|
|||
override fun onNext(roomOverall: RoomOverall) {
|
||||
Log.d(TAG, "getRoomInfo - getRoom - got response: $startNanoTime")
|
||||
currentConversation = roomOverall.ocs!!.data
|
||||
Log.d(
|
||||
TAG,
|
||||
"getRoomInfo. token: " + currentConversation?.token +
|
||||
" sessionId: " + currentConversation?.sessionId
|
||||
)
|
||||
|
||||
logConversationInfos("getRoomInfo#onNext")
|
||||
|
||||
loadAvatarForStatusBar()
|
||||
setTitle()
|
||||
participantPermissions = ParticipantPermissions(conversationUser, currentConversation!!)
|
||||
|
@ -376,6 +376,8 @@ class ChatController(args: Bundle) :
|
|||
|
||||
if (!inConversation) {
|
||||
joinRoomWithPassword()
|
||||
} else {
|
||||
Log.d(TAG, "already inConversation. joinRoomWithPassword is skipped")
|
||||
}
|
||||
} catch (npe: NullPointerException) {
|
||||
// view binding can be null
|
||||
|
@ -910,7 +912,7 @@ class ChatController(args: Bundle) :
|
|||
}
|
||||
|
||||
if (adapterWasNull) {
|
||||
// we're starting
|
||||
Log.d(TAG, "starting for the first time (because adapter was null)")
|
||||
if (TextUtils.isEmpty(roomToken)) {
|
||||
handleFromNotification()
|
||||
} else {
|
||||
|
@ -1739,11 +1741,8 @@ class ChatController(args: Bundle) :
|
|||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
Log.d(
|
||||
TAG,
|
||||
"onAttach: Controller: " + System.identityHashCode(this).toString() +
|
||||
" Activity: " + System.identityHashCode(activity).toString()
|
||||
)
|
||||
logConversationInfos("onAttach")
|
||||
|
||||
eventBus.register(this)
|
||||
|
||||
if (conversationUser?.userId != "?" &&
|
||||
|
@ -1831,11 +1830,8 @@ class ChatController(args: Bundle) :
|
|||
|
||||
override fun onDetach(view: View) {
|
||||
super.onDetach(view)
|
||||
Log.d(
|
||||
TAG,
|
||||
"onDetach: Controller: " + System.identityHashCode(this).toString() +
|
||||
" Activity: " + System.identityHashCode(activity).toString()
|
||||
)
|
||||
|
||||
logConversationInfos("onDetach")
|
||||
|
||||
eventBus.unregister(this)
|
||||
|
||||
|
@ -1852,8 +1848,13 @@ class ChatController(args: Bundle) :
|
|||
if (conversationUser != null && isActivityNotChangingConfigurations() && isNotInCall()) {
|
||||
ApplicationWideCurrentRoomHolder.getInstance().clear()
|
||||
if (inConversation && validSessionId()) {
|
||||
leaveRoom()
|
||||
leaveRoom(null, null)
|
||||
} else {
|
||||
Log.d(TAG, "not leaving room (inConversation is false and/or validSessionId is false)")
|
||||
// room might have already been left...
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "not leaving room...")
|
||||
}
|
||||
|
||||
if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) {
|
||||
|
@ -1884,6 +1885,7 @@ class ChatController(args: Bundle) :
|
|||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
logConversationInfos("onDestroy")
|
||||
|
||||
if (activity != null) {
|
||||
activity?.findViewById<View>(R.id.toolbar)?.setOnClickListener(null)
|
||||
|
@ -1897,16 +1899,12 @@ class ChatController(args: Bundle) :
|
|||
|
||||
adapter = null
|
||||
inConversation = false
|
||||
Log.d(TAG, "inConversation was set to false!")
|
||||
}
|
||||
|
||||
private fun joinRoomWithPassword() {
|
||||
Log.d(
|
||||
TAG,
|
||||
"joinRoomWithPassword start: " + (currentConversation == null).toString() +
|
||||
" sessionId: " + currentConversation?.sessionId
|
||||
)
|
||||
|
||||
if (!validSessionId()) {
|
||||
Log.d(TAG, "sessionID was not valid -> joinRoom")
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
if (conversationUser != null) {
|
||||
|
@ -1933,7 +1931,8 @@ class ChatController(args: Bundle) :
|
|||
Log.d(TAG, "joinRoomWithPassword - joinRoom - got response: $startNanoTime")
|
||||
inConversation = true
|
||||
currentConversation?.sessionId = roomOverall.ocs!!.data!!.sessionId
|
||||
Log.d(TAG, "joinRoomWithPassword - sessionId: " + currentConversation?.sessionId)
|
||||
|
||||
logConversationInfos("joinRoomWithPassword#onNext")
|
||||
|
||||
ApplicationWideCurrentRoomHolder.getInstance().session =
|
||||
currentConversation?.sessionId
|
||||
|
@ -1975,6 +1974,8 @@ class ChatController(args: Bundle) :
|
|||
}
|
||||
})
|
||||
} else {
|
||||
Log.d(TAG, "sessionID was valid -> skip joinRoom")
|
||||
|
||||
inConversation = true
|
||||
ApplicationWideCurrentRoomHolder.getInstance().session = currentConversation?.sessionId
|
||||
if (magicWebSocketInstance != null) {
|
||||
|
@ -1992,8 +1993,12 @@ class ChatController(args: Bundle) :
|
|||
}
|
||||
}
|
||||
|
||||
private fun leaveRoom() {
|
||||
Log.d(TAG, "leaveRoom")
|
||||
fun leaveRoom(
|
||||
remapChatModel: RemapChatModel?,
|
||||
funToCallWhenLeaveSuccessful: ((RemapChatModel) -> Unit)?
|
||||
) {
|
||||
logConversationInfos("leaveRoom")
|
||||
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
if (conversationUser != null) {
|
||||
|
@ -2019,6 +2024,8 @@ class ChatController(args: Bundle) :
|
|||
|
||||
override fun onNext(genericOverall: GenericOverall) {
|
||||
Log.d(TAG, "leaveRoom - leaveRoom - got response: $startNanoTime")
|
||||
logConversationInfos("leaveRoom#onNext")
|
||||
|
||||
checkingLobbyStatus = false
|
||||
|
||||
if (lobbyTimerHandler != null) {
|
||||
|
@ -2032,9 +2039,23 @@ class ChatController(args: Bundle) :
|
|||
)
|
||||
} else {
|
||||
Log.e(TAG, "magicWebSocketInstance or currentConversation were null! Failed to leave the room!")
|
||||
if (BuildConfig.DEBUG) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
"magicWebSocketInstance or currentConversation were null! Failed to leave the room!",
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
currentConversation?.sessionId = "0"
|
||||
|
||||
if (remapChatModel != null && funToCallWhenLeaveSuccessful != null) {
|
||||
Log.d(TAG, "a callback action was set and is now executed because room was left successfully")
|
||||
funToCallWhenLeaveSuccessful(remapChatModel)
|
||||
} else {
|
||||
Log.d(TAG, "remapChatController was not set")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
|
@ -3006,7 +3027,8 @@ class ChatController(args: Bundle) :
|
|||
KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.ocs!!.data!!)
|
||||
)
|
||||
remapChatController(
|
||||
|
||||
ConductorRemapping.remapChatController(
|
||||
router,
|
||||
conversationUser!!.id!!,
|
||||
roomOverall.ocs!!.data!!.token!!,
|
||||
|
@ -3336,7 +3358,7 @@ class ChatController(args: Bundle) :
|
|||
conversationUser.id!!,
|
||||
roomOverall.ocs!!.data!!.token!!,
|
||||
bundle,
|
||||
false
|
||||
true
|
||||
)
|
||||
} else {
|
||||
conversationIntent.putExtras(bundle)
|
||||
|
@ -3412,6 +3434,17 @@ class ChatController(args: Bundle) :
|
|||
)
|
||||
}
|
||||
|
||||
private fun logConversationInfos(methodName: String) {
|
||||
Log.d(TAG, " |-----------------------------------------------")
|
||||
Log.d(TAG, " | method: $methodName")
|
||||
Log.d(TAG, " | ChatController: " + System.identityHashCode(this).toString())
|
||||
Log.d(TAG, " | roomToken: $roomToken")
|
||||
Log.d(TAG, " | currentConversation?.displayName: ${currentConversation?.displayName}")
|
||||
Log.d(TAG, " | currentConversation?.sessionId: ${currentConversation?.sessionId}")
|
||||
Log.d(TAG, " | inConversation: $inConversation")
|
||||
Log.d(TAG, " |-----------------------------------------------")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ChatController"
|
||||
private const val CONTENT_TYPE_SYSTEM_MESSAGE: Byte = 1
|
||||
|
|
|
@ -66,9 +66,9 @@ import com.nextcloud.talk.models.json.participants.Participant
|
|||
import com.nextcloud.talk.ui.dialog.ContactsBottomDialog
|
||||
import com.nextcloud.talk.users.UserManager
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.ConductorRemapping
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
|
||||
import com.nextcloud.talk.utils.remapchat.ConductorRemapping
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.SelectableAdapter
|
||||
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
|
||||
|
@ -285,8 +285,11 @@ class ContactsController(args: Bundle) :
|
|||
Parcels.wrap(roomOverall.ocs!!.data!!)
|
||||
)
|
||||
ConductorRemapping.remapChatController(
|
||||
router, currentUser!!.id!!,
|
||||
roomOverall.ocs!!.data!!.token!!, bundle, true
|
||||
router,
|
||||
currentUser!!.id!!,
|
||||
roomOverall.ocs!!.data!!.token!!,
|
||||
bundle,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -738,9 +741,11 @@ class ContactsController(args: Bundle) :
|
|||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onMessageEvent(openConversationEvent: OpenConversationEvent) {
|
||||
ConductorRemapping.remapChatController(
|
||||
router, currentUser!!.id!!,
|
||||
router,
|
||||
currentUser!!.id!!,
|
||||
openConversationEvent.conversation!!.token!!,
|
||||
openConversationEvent.bundle!!, true
|
||||
openConversationEvent.bundle!!,
|
||||
true
|
||||
)
|
||||
contactsBottomDialog?.dismiss()
|
||||
}
|
||||
|
|
|
@ -99,7 +99,6 @@ import com.nextcloud.talk.ui.dialog.ConversationsListBottomDialog
|
|||
import com.nextcloud.talk.users.UserManager
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.ClosedInterfaceImpl
|
||||
import com.nextcloud.talk.utils.ConductorRemapping.remapChatController
|
||||
import com.nextcloud.talk.utils.FileUtils
|
||||
import com.nextcloud.talk.utils.Mimetype
|
||||
import com.nextcloud.talk.utils.ParticipantPermissions
|
||||
|
@ -119,6 +118,7 @@ import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.hasSpreedFeatu
|
|||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isServerEOL
|
||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isUnifiedSearchAvailable
|
||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isUserStatusAvailable
|
||||
import com.nextcloud.talk.utils.remapchat.ConductorRemapping.remapChatController
|
||||
import com.nextcloud.talk.utils.rx.SearchViewObservable.Companion.observeSearchView
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
|
||||
|
|
|
@ -41,8 +41,8 @@ import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.EMAIL
|
|||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.PROFILE
|
||||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.SPREED
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.ConductorRemapping
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import com.nextcloud.talk.utils.remapchat.ConductorRemapping
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.utils
|
||||
package com.nextcloud.talk.utils.remapchat
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
|
@ -62,34 +62,43 @@ object ConductorRemapping {
|
|||
} else {
|
||||
HorizontalChangeHandler()
|
||||
}
|
||||
if (!replaceTop) {
|
||||
if (!router.hasRootController()) {
|
||||
Log.d(TAG, "router has no RootController. creating backstack with ConversationsListController")
|
||||
val newBackstack = listOf(
|
||||
RouterTransaction.with(ConversationsListController(Bundle()))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler()),
|
||||
RouterTransaction.with(ChatController(bundle))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler()).tag(chatControllerTag)
|
||||
)
|
||||
router.setBackstack(newBackstack, SimpleSwapChangeHandler())
|
||||
|
||||
if (router.hasRootController()) {
|
||||
val backstack = router.backstack
|
||||
val topController = backstack[router.backstackSize - 1].controller
|
||||
|
||||
val remapChatModel = RemapChatModel(
|
||||
router,
|
||||
pushChangeHandler,
|
||||
chatControllerTag,
|
||||
bundle
|
||||
)
|
||||
|
||||
if (topController is ChatController) {
|
||||
if (replaceTop) {
|
||||
topController.leaveRoom(remapChatModel, this::replaceTopController)
|
||||
} else {
|
||||
topController.leaveRoom(remapChatModel, this::pushController)
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "router has RootController. pushing ChatController")
|
||||
router.pushController(
|
||||
RouterTransaction.with(ChatController(bundle))
|
||||
.pushChangeHandler(pushChangeHandler)
|
||||
.popChangeHandler(HorizontalChangeHandler()).tag(chatControllerTag)
|
||||
)
|
||||
if (replaceTop) {
|
||||
replaceTopController(remapChatModel)
|
||||
} else {
|
||||
pushController(remapChatModel)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "ChatController replace topController")
|
||||
|
||||
router.replaceTopController(
|
||||
Log.d(TAG, "router has no RootController. creating backstack with ConversationsListController")
|
||||
val newBackstack = listOf(
|
||||
RouterTransaction.with(ConversationsListController(Bundle()))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler()),
|
||||
RouterTransaction.with(ChatController(bundle))
|
||||
.pushChangeHandler(pushChangeHandler)
|
||||
.popChangeHandler(HorizontalChangeHandler()).tag(chatControllerTag)
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
.tag(chatControllerTag)
|
||||
)
|
||||
router.setBackstack(newBackstack, SimpleSwapChangeHandler())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,6 +107,26 @@ object ConductorRemapping {
|
|||
}
|
||||
}
|
||||
|
||||
fun pushController(remapChatModel: RemapChatModel) {
|
||||
Log.d(TAG, "pushController")
|
||||
remapChatModel.router.pushController(
|
||||
RouterTransaction.with(ChatController(remapChatModel.bundle))
|
||||
.pushChangeHandler(remapChatModel.controllerChangeHandler)
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
.tag(remapChatModel.chatControllerTag)
|
||||
)
|
||||
}
|
||||
|
||||
private fun replaceTopController(remapChatModel: RemapChatModel) {
|
||||
Log.d(TAG, "replaceTopController")
|
||||
remapChatModel.router.replaceTopController(
|
||||
RouterTransaction.with(ChatController(remapChatModel.bundle))
|
||||
.pushChangeHandler(remapChatModel.controllerChangeHandler)
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
.tag(remapChatModel.chatControllerTag)
|
||||
)
|
||||
}
|
||||
|
||||
private fun moveControllerToTop(router: Router, controllerTag: String) {
|
||||
Log.d(TAG, "moving $controllerTag to top...")
|
||||
val backstack = router.backstack
|
|
@ -0,0 +1,12 @@
|
|||
package com.nextcloud.talk.utils.remapchat
|
||||
|
||||
import android.os.Bundle
|
||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||
import com.bluelinelabs.conductor.Router
|
||||
|
||||
data class RemapChatModel(
|
||||
val router: Router,
|
||||
val controllerChangeHandler: ControllerChangeHandler,
|
||||
val chatControllerTag: String,
|
||||
val bundle: Bundle
|
||||
)
|
Loading…
Reference in a new issue