mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-18 13:00:18 +03:00
Enhance search functionality to support threads
This commit is contained in:
parent
e7b8b90b0a
commit
0241d66f8e
5 changed files with 32 additions and 15 deletions
|
@ -1024,7 +1024,12 @@ class TimelineFragment @Inject constructor(
|
||||||
|
|
||||||
private fun handleSearchAction() {
|
private fun handleSearchAction() {
|
||||||
if (session.getRoom(timelineArgs.roomId)?.isEncrypted() == false) {
|
if (session.getRoom(timelineArgs.roomId)?.isEncrypted() == false) {
|
||||||
navigator.openSearch(requireContext(), timelineArgs.roomId)
|
navigator.openSearch(
|
||||||
|
context = requireContext(),
|
||||||
|
roomId = timelineArgs.roomId,
|
||||||
|
roomDisplayName = roomDetailViewModel.getRoomSummary()?.displayName,
|
||||||
|
roomAvatarUrl = roomDetailViewModel.getRoomSummary()?.avatarUrl
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
showDialogWithMessage(getString(R.string.search_is_not_supported_in_e2e_room))
|
showDialogWithMessage(getString(R.string.search_is_not_supported_in_e2e_room))
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,17 @@ import im.vector.app.core.extensions.trackItemsVisibilityChange
|
||||||
import im.vector.app.core.platform.StateView
|
import im.vector.app.core.platform.StateView
|
||||||
import im.vector.app.core.platform.VectorBaseFragment
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
import im.vector.app.databinding.FragmentSearchBinding
|
import im.vector.app.databinding.FragmentSearchBinding
|
||||||
|
import im.vector.app.features.home.room.threads.arguments.ThreadTimelineArgs
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.getRootThreadEventId
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class SearchArgs(
|
data class SearchArgs(
|
||||||
val roomId: String
|
val roomId: String,
|
||||||
|
val roomDisplayName: String?,
|
||||||
|
val roomAvatarUrl: String?
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
|
||||||
class SearchFragment @Inject constructor(
|
class SearchFragment @Inject constructor(
|
||||||
|
@ -112,10 +116,20 @@ class SearchFragment @Inject constructor(
|
||||||
searchViewModel.handle(SearchAction.Retry)
|
searchViewModel.handle(SearchAction.Retry)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClicked(event: Event) {
|
override fun onItemClicked(event: Event) =
|
||||||
event.roomId?.let {
|
navigateToEvent(event)
|
||||||
navigator.openRoom(requireContext(), it, event.eventId)
|
|
||||||
}
|
/**
|
||||||
|
* Navigate and highlight the event. If this is a thread event,
|
||||||
|
* user will be redirected to the appropriate thread room
|
||||||
|
* @param event the event to navigate and highlight
|
||||||
|
*/
|
||||||
|
private fun navigateToEvent(event: Event) {
|
||||||
|
val roomId = event.roomId ?: return
|
||||||
|
event.getRootThreadEventId()?.let {
|
||||||
|
val threadTimelineArgs = ThreadTimelineArgs(roomId, displayName = fragmentArgs.roomDisplayName, fragmentArgs.roomAvatarUrl, it)
|
||||||
|
navigator.openThread(requireContext(), threadTimelineArgs, event.eventId)
|
||||||
|
} ?: navigator.openRoom(requireContext(), roomId, event.eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadMore() {
|
override fun loadMore() {
|
||||||
|
|
|
@ -54,10 +54,6 @@ class SearchResultController @Inject constructor(
|
||||||
fun loadMore()
|
fun loadMore()
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
|
||||||
setData(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun buildModels(data: SearchViewState?) {
|
override fun buildModels(data: SearchViewState?) {
|
||||||
data ?: return
|
data ?: return
|
||||||
|
|
||||||
|
|
|
@ -492,8 +492,11 @@ class DefaultNavigator @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openSearch(context: Context, roomId: String) {
|
override fun openSearch(context: Context,
|
||||||
val intent = SearchActivity.newIntent(context, SearchArgs(roomId))
|
roomId: String,
|
||||||
|
roomDisplayName: String?,
|
||||||
|
roomAvatarUrl: String?) {
|
||||||
|
val intent = SearchActivity.newIntent(context, SearchArgs(roomId, roomDisplayName, roomAvatarUrl))
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,7 +525,7 @@ class DefaultNavigator @Inject constructor(
|
||||||
threadTimelineArgs = threadTimelineArgs,
|
threadTimelineArgs = threadTimelineArgs,
|
||||||
threadListArgs = null,
|
threadListArgs = null,
|
||||||
eventIdToNavigate = eventIdToNavigate
|
eventIdToNavigate = eventIdToNavigate
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openThreadList(context: Context, threadTimelineArgs: ThreadTimelineArgs) {
|
override fun openThreadList(context: Context, threadTimelineArgs: ThreadTimelineArgs) {
|
||||||
|
|
|
@ -136,7 +136,7 @@ interface Navigator {
|
||||||
inMemory: List<AttachmentData> = emptyList(),
|
inMemory: List<AttachmentData> = emptyList(),
|
||||||
options: ((MutableList<Pair<View, String>>) -> Unit)?)
|
options: ((MutableList<Pair<View, String>>) -> Unit)?)
|
||||||
|
|
||||||
fun openSearch(context: Context, roomId: String)
|
fun openSearch(context: Context, roomId: String, roomDisplayName: String?, roomAvatarUrl: String?)
|
||||||
|
|
||||||
fun openDevTools(context: Context, roomId: String)
|
fun openDevTools(context: Context, roomId: String)
|
||||||
|
|
||||||
|
@ -145,5 +145,4 @@ interface Navigator {
|
||||||
fun openThread(context: Context, threadTimelineArgs: ThreadTimelineArgs, eventIdToNavigate: String? = null)
|
fun openThread(context: Context, threadTimelineArgs: ThreadTimelineArgs, eventIdToNavigate: String? = null)
|
||||||
|
|
||||||
fun openThreadList(context: Context, threadTimelineArgs: ThreadTimelineArgs)
|
fun openThreadList(context: Context, threadTimelineArgs: ThreadTimelineArgs)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue