mirror of
https://github.com/element-hq/element-android
synced 2024-12-11 20:52:35 +03:00
Add room avatar to threads activities
This commit is contained in:
parent
ab87937e5b
commit
cb6376670b
5 changed files with 66 additions and 18 deletions
|
@ -161,7 +161,7 @@ import im.vector.app.features.home.room.detail.timeline.url.PreviewUrlRetriever
|
|||
import im.vector.app.features.home.room.detail.upgrade.MigrateRoomBottomSheet
|
||||
import im.vector.app.features.home.room.detail.views.RoomDetailLazyLoadedViews
|
||||
import im.vector.app.features.home.room.detail.widget.RoomWidgetsBottomSheet
|
||||
import im.vector.app.features.home.room.threads.detail.RoomThreadDetailArgs
|
||||
import im.vector.app.features.home.room.threads.detail.arguments.RoomThreadDetailArgs
|
||||
import im.vector.app.features.home.room.threads.detail.RoomThreadDetailActivity
|
||||
import im.vector.app.features.html.EventHtmlRenderer
|
||||
import im.vector.app.features.html.PillImageSpan
|
||||
|
@ -1962,7 +1962,11 @@ class RoomDetailFragment @Inject constructor(
|
|||
is EventSharedAction.ReplyInThread -> {
|
||||
if (!views.voiceMessageRecorderView.isActive()) {
|
||||
context?.let {
|
||||
val roomThreadDetailArgs = RoomThreadDetailArgs(roomDetailArgs.roomId,action.eventId)
|
||||
val roomThreadDetailArgs = RoomThreadDetailArgs(
|
||||
roomId = roomDetailArgs.roomId,
|
||||
displayName = roomDetailViewModel.getRoomSummary()?.displayName,
|
||||
avatarUrl = roomDetailViewModel.getRoomSummary()?.avatarUrl,
|
||||
eventId = action.eventId)
|
||||
startActivity(RoomThreadDetailActivity.newIntent(it, roomThreadDetailArgs))
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -282,6 +282,8 @@ class RoomDetailViewModel @AssistedInject constructor(
|
|||
|
||||
fun getOtherUserIds() = room.roomSummary()?.otherMemberIds
|
||||
|
||||
fun getRoomSummary() = room.roomSummary()
|
||||
|
||||
override fun handle(action: RoomDetailAction) {
|
||||
when (action) {
|
||||
is RoomDetailAction.ComposerFocusChange -> handleComposerFocusChange(action)
|
||||
|
|
|
@ -24,9 +24,16 @@ import im.vector.app.core.di.ScreenComponent
|
|||
import im.vector.app.core.extensions.replaceFragment
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.databinding.ActivityRoomThreadDetailBinding
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.threads.detail.arguments.RoomThreadDetailArgs
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
import javax.inject.Inject
|
||||
|
||||
class RoomThreadDetailActivity : VectorBaseActivity<ActivityRoomThreadDetailBinding>() {
|
||||
|
||||
@Inject
|
||||
lateinit var avatarRenderer: AvatarRenderer
|
||||
|
||||
// private val roomThreadDetailFragment: RoomThreadDetailFragment?
|
||||
// get() {
|
||||
// return supportFragmentManager.findFragmentByTag(FRAGMENT_TAG) as? RoomThreadDetailFragment
|
||||
|
@ -44,20 +51,34 @@ class RoomThreadDetailActivity : VectorBaseActivity<ActivityRoomThreadDetailBind
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
initToolbar()
|
||||
initFragment()
|
||||
}
|
||||
|
||||
private fun initToolbar() {
|
||||
configureToolbar(views.roomThreadDetailToolbar)
|
||||
if (isFirstCreation()) {
|
||||
val roomThreadDetailArgs: RoomThreadDetailArgs? = intent?.extras?.getParcelable(EXTRA_ROOM_THREAD_DETAIL_ARGS)
|
||||
replaceFragment(R.id.roomThreadDetailFragmentContainer, RoomThreadDetailFragment::class.java, roomThreadDetailArgs, FRAGMENT_TAG)
|
||||
getRoomThreadDetailArgs()?.let {
|
||||
val matrixItem = MatrixItem.RoomItem(it.roomId, it.displayName, it.avatarUrl)
|
||||
avatarRenderer.render(matrixItem, views.roomThreadDetailToolbarImageView)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initFragment() {
|
||||
if (isFirstCreation()) {
|
||||
replaceFragment(R.id.roomThreadDetailFragmentContainer, RoomThreadDetailFragment::class.java, getRoomThreadDetailArgs(), FRAGMENT_TAG)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRoomThreadDetailArgs(): RoomThreadDetailArgs? = intent?.extras?.getParcelable(ROOM_THREAD_DETAIL_ARGS)
|
||||
|
||||
companion object {
|
||||
private const val FRAGMENT_TAG = "RoomThreadDetailFragment"
|
||||
const val EXTRA_ROOM_THREAD_DETAIL_ARGS = "EXTRA_ROOM_THREAD_DETAIL_ARGS"
|
||||
private val FRAGMENT_TAG = RoomThreadDetailFragment::class.simpleName
|
||||
const val ROOM_THREAD_DETAIL_ARGS = "ROOM_THREAD_DETAIL_ARGS"
|
||||
|
||||
fun newIntent(context: Context, roomThreadDetailArgs: RoomThreadDetailArgs): Intent {
|
||||
return Intent(context, RoomThreadDetailActivity::class.java).apply {
|
||||
putExtra(EXTRA_ROOM_THREAD_DETAIL_ARGS, roomThreadDetailArgs)
|
||||
putExtra(ROOM_THREAD_DETAIL_ARGS, roomThreadDetailArgs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,27 +18,20 @@ package im.vector.app.features.home.room.threads.detail
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.airbnb.mvrx.args
|
||||
import im.vector.app.core.platform.VectorBaseFragment
|
||||
import im.vector.app.databinding.FragmentRoomThreadDetailBinding
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import im.vector.app.features.home.room.threads.detail.arguments.RoomThreadDetailArgs
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import javax.inject.Inject
|
||||
|
||||
@Parcelize
|
||||
data class RoomThreadDetailArgs(
|
||||
val roomId: String,
|
||||
val eventId: String? = null,
|
||||
) : Parcelable
|
||||
|
||||
class RoomThreadDetailFragment @Inject constructor(
|
||||
private val session: Session
|
||||
) :
|
||||
VectorBaseFragment<FragmentRoomThreadDetailBinding>() {
|
||||
) : VectorBaseFragment<FragmentRoomThreadDetailBinding>() {
|
||||
|
||||
private val roomThreadDetailArgs: RoomThreadDetailArgs by args()
|
||||
|
||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomThreadDetailBinding {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.home.room.threads.detail.arguments
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class RoomThreadDetailArgs(
|
||||
val roomId: String,
|
||||
val displayName: String?,
|
||||
val avatarUrl: String?,
|
||||
val eventId: String? = null,
|
||||
) : Parcelable
|
Loading…
Reference in a new issue