mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
Conversation List jumps to position of clicked conversation item when back pressed
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
d0ff4320a8
commit
4792f171fc
@ -193,6 +193,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_BREAKOUT_ROOM
|
|||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_MODERATOR
|
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_RECORDING_STATE
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||||
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_OFFSET
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH
|
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_SWITCH_TO_ROOM
|
||||||
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
||||||
@ -367,6 +368,7 @@ class ChatActivity :
|
|||||||
|
|
||||||
var myFirstMessage: CharSequence? = null
|
var myFirstMessage: CharSequence? = null
|
||||||
var checkingLobbyStatus: Boolean = false
|
var checkingLobbyStatus: Boolean = false
|
||||||
|
private var listScrollOffset: Int = 0
|
||||||
|
|
||||||
private var conversationVoiceCallMenuItem: MenuItem? = null
|
private var conversationVoiceCallMenuItem: MenuItem? = null
|
||||||
private var conversationVideoMenuItem: MenuItem? = null
|
private var conversationVideoMenuItem: MenuItem? = null
|
||||||
@ -390,7 +392,10 @@ class ChatActivity :
|
|||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java)
|
val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java)
|
||||||
intent.putExtras(Bundle())
|
val bundle = bundleOf()
|
||||||
|
bundle.putInt(KEY_SCROLL_OFFSET, listScrollOffset)
|
||||||
|
bundle.putString(KEY_ROOM_TOKEN, roomToken)
|
||||||
|
intent.putExtras(bundle)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -526,6 +531,7 @@ class ChatActivity :
|
|||||||
val extras: Bundle? = intent.extras
|
val extras: Bundle? = intent.extras
|
||||||
|
|
||||||
roomToken = extras?.getString(KEY_ROOM_TOKEN).orEmpty()
|
roomToken = extras?.getString(KEY_ROOM_TOKEN).orEmpty()
|
||||||
|
listScrollOffset = extras?.getInt(KEY_SCROLL_OFFSET, 0) ?: 0
|
||||||
|
|
||||||
sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty()
|
sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty()
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ import androidx.core.view.isVisible
|
|||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.work.Data
|
import androidx.work.Data
|
||||||
import androidx.work.OneTimeWorkRequest
|
import androidx.work.OneTimeWorkRequest
|
||||||
@ -140,6 +141,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FORWARD_MSG_FLAG
|
|||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FORWARD_MSG_TEXT
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_FORWARD_MSG_TEXT
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||||
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_OFFSET
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_TO_NOTIFICATION_CATEGORY
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SCROLL_TO_NOTIFICATION_CATEGORY
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SHARED_TEXT
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SHARED_TEXT
|
||||||
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
||||||
@ -235,6 +237,8 @@ class ConversationsListActivity :
|
|||||||
private var conversationsListBottomDialog: ConversationsListBottomDialog? = null
|
private var conversationsListBottomDialog: ConversationsListBottomDialog? = null
|
||||||
private var searchHelper: MessageSearchHelper? = null
|
private var searchHelper: MessageSearchHelper? = null
|
||||||
private var searchViewDisposable: Disposable? = null
|
private var searchViewDisposable: Disposable? = null
|
||||||
|
private var roomTokenFromIntent: String? = null
|
||||||
|
private var scrollOffset: Int = 0
|
||||||
private var filterState =
|
private var filterState =
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
MENTION to false,
|
MENTION to false,
|
||||||
@ -306,6 +310,8 @@ class ConversationsListActivity :
|
|||||||
showNotificationWarning()
|
showNotificationWarning()
|
||||||
|
|
||||||
showShareToScreen = hasActivityActionSendIntent()
|
showShareToScreen = hasActivityActionSendIntent()
|
||||||
|
roomTokenFromIntent = intent.extras?.getString(KEY_ROOM_TOKEN)
|
||||||
|
scrollOffset = intent.extras?.getInt(KEY_SCROLL_OFFSET, 0) ?: 0
|
||||||
|
|
||||||
if (!eventBus.isRegistered(this)) {
|
if (!eventBus.isRegistered(this)) {
|
||||||
eventBus.register(this)
|
eventBus.register(this)
|
||||||
@ -415,6 +421,17 @@ class ConversationsListActivity :
|
|||||||
.firstOrNull { ConversationUtils.isNoteToSelfConversation(it) }
|
.firstOrNull { ConversationUtils.isNoteToSelfConversation(it) }
|
||||||
val isNoteToSelfAvailable = noteToSelf != null
|
val isNoteToSelfAvailable = noteToSelf != null
|
||||||
handleNoteToSelfShortcut(isNoteToSelfAvailable, noteToSelf?.token ?: "")
|
handleNoteToSelfShortcut(isNoteToSelfAvailable, noteToSelf?.token ?: "")
|
||||||
|
if (roomTokenFromIntent != null) {
|
||||||
|
val item = adapter?.currentItems?.first {
|
||||||
|
it is ConversationItem && it.model.token == roomTokenFromIntent
|
||||||
|
}
|
||||||
|
val pos = adapter?.currentItems?.indexOf(item)
|
||||||
|
pos?.let {
|
||||||
|
val layoutManager = binding.recyclerView.layoutManager as LinearLayoutManager
|
||||||
|
layoutManager.scrollToPosition(scrollOffset)
|
||||||
|
}
|
||||||
|
roomTokenFromIntent = null
|
||||||
|
}
|
||||||
}.collect()
|
}.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1871,7 +1888,8 @@ class ConversationsListActivity :
|
|||||||
bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId)
|
bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId)
|
||||||
selectedMessageId = null
|
selectedMessageId = null
|
||||||
}
|
}
|
||||||
|
val firstVisible = layoutManager?.findFirstVisibleItemPosition() ?: 0
|
||||||
|
bundle.putInt(KEY_SCROLL_OFFSET, firstVisible)
|
||||||
val intent = Intent(context, ChatActivity::class.java)
|
val intent = Intent(context, ChatActivity::class.java)
|
||||||
intent.putExtras(bundle)
|
intent.putExtras(bundle)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
|
@ -81,5 +81,6 @@ object BundleKeys {
|
|||||||
const val KEY_FIELD_MAP: String = "KEY_FIELD_MAP"
|
const val KEY_FIELD_MAP: String = "KEY_FIELD_MAP"
|
||||||
const val KEY_CHAT_URL: String = "KEY_CHAT_URL"
|
const val KEY_CHAT_URL: String = "KEY_CHAT_URL"
|
||||||
const val KEY_SCROLL_TO_NOTIFICATION_CATEGORY: String = "KEY_SCROLL_TO_NOTIFICATION_CATEGORY"
|
const val KEY_SCROLL_TO_NOTIFICATION_CATEGORY: String = "KEY_SCROLL_TO_NOTIFICATION_CATEGORY"
|
||||||
|
const val KEY_SCROLL_OFFSET: String = "KEY_SCROLL_OFFSET"
|
||||||
const val KEY_FOCUS_INPUT: String = "KEY_FOCUS_INPUT"
|
const val KEY_FOCUS_INPUT: String = "KEY_FOCUS_INPUT"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user