Code review fixes.

This commit is contained in:
onurays 2020-02-26 15:26:53 +03:00
parent 1a273407de
commit 56fc91a8c3
5 changed files with 32 additions and 27 deletions

View File

@ -19,7 +19,10 @@ package im.vector.riotx.features.navigation
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.view.View
import androidx.core.app.ActivityOptionsCompat
import androidx.core.app.TaskStackBuilder import androidx.core.app.TaskStackBuilder
import androidx.core.view.ViewCompat
import im.vector.matrix.android.api.session.crypto.sas.IncomingSasVerificationTransaction import im.vector.matrix.android.api.session.crypto.sas.IncomingSasVerificationTransaction
import im.vector.matrix.android.api.session.crypto.sas.VerificationMethod import im.vector.matrix.android.api.session.crypto.sas.VerificationMethod
import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom
@ -36,6 +39,7 @@ import im.vector.riotx.features.debug.DebugMenuActivity
import im.vector.riotx.features.home.room.detail.RoomDetailActivity import im.vector.riotx.features.home.room.detail.RoomDetailActivity
import im.vector.riotx.features.home.room.detail.RoomDetailArgs import im.vector.riotx.features.home.room.detail.RoomDetailArgs
import im.vector.riotx.features.home.room.filtered.FilteredRoomsActivity import im.vector.riotx.features.home.room.filtered.FilteredRoomsActivity
import im.vector.riotx.features.media.BigImageViewerActivity
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewActivity import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewActivity
@ -179,6 +183,14 @@ class DefaultNavigator @Inject constructor(
context.startActivity(RoomProfileActivity.newIntent(context, roomId)) context.startActivity(RoomProfileActivity.newIntent(context, roomId))
} }
override fun openBigImageViewer(activity: Activity, sharedElement: View?, title: String, avatarUrl: String) {
val intent = BigImageViewerActivity.newIntent(activity, title, avatarUrl)
val options = sharedElement?.let {
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, it, ViewCompat.getTransitionName(it) ?: "")
}
activity.startActivity(intent, options?.toBundle())
}
private fun startActivity(context: Context, intent: Intent, buildTask: Boolean) { private fun startActivity(context: Context, intent: Intent, buildTask: Boolean) {
if (buildTask) { if (buildTask) {
val stackBuilder = TaskStackBuilder.create(context) val stackBuilder = TaskStackBuilder.create(context)

View File

@ -18,6 +18,7 @@ package im.vector.riotx.features.navigation
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.view.View
import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom
import im.vector.riotx.features.settings.VectorSettingsActivity import im.vector.riotx.features.settings.VectorSettingsActivity
import im.vector.riotx.features.share.SharedData import im.vector.riotx.features.share.SharedData
@ -59,4 +60,6 @@ interface Navigator {
fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean = false) fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean = false)
fun openRoomProfile(context: Context, roomId: String) fun openRoomProfile(context: Context, roomId: String)
fun openBigImageViewer(activity: Activity, sharedElement: View?, title: String, avatarUrl: String)
} }

View File

@ -22,8 +22,6 @@ import android.os.Parcelable
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.app.ActivityOptionsCompat
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.Incomplete import com.airbnb.mvrx.Incomplete
@ -44,7 +42,6 @@ import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.core.utils.startSharePlainTextIntent import im.vector.riotx.core.utils.startSharePlainTextIntent
import im.vector.riotx.features.crypto.verification.VerificationBottomSheet import im.vector.riotx.features.crypto.verification.VerificationBottomSheet
import im.vector.riotx.features.home.AvatarRenderer import im.vector.riotx.features.home.AvatarRenderer
import im.vector.riotx.features.media.BigImageViewerActivity
import im.vector.riotx.features.roommemberprofile.devices.DeviceListBottomSheet import im.vector.riotx.features.roommemberprofile.devices.DeviceListBottomSheet
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.fragment_matrix_profile.* import kotlinx.android.synthetic.main.fragment_matrix_profile.*
@ -197,12 +194,7 @@ class RoomMemberProfileFragment @Inject constructor(
} }
memberProfileAvatarView.setOnClickListener { view -> memberProfileAvatarView.setOnClickListener { view ->
userMatrixItem.avatarUrl onAvatarClicked(view, userMatrixItem)
?.takeIf { it.isNotBlank() }
?.let { avatarUrl ->
val title = userMatrixItem.displayName ?: ""
onAvatarClicked(view, title, avatarUrl)
}
} }
} }
} }
@ -240,9 +232,12 @@ class RoomMemberProfileFragment @Inject constructor(
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink) startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
} }
private fun onAvatarClicked(view: View, title: String, avatarUrl: String) { private fun onAvatarClicked(view: View, userMatrixItem: MatrixItem) {
val intent = BigImageViewerActivity.newIntent(context!!, title, avatarUrl) userMatrixItem.avatarUrl
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(requireActivity(), view, ViewCompat.getTransitionName(view) ?: "") ?.takeIf { it.isNotBlank() }
startActivity(intent, options.toBundle()) ?.let { avatarUrl ->
val title = userMatrixItem.getBestName()
navigator.openBigImageViewer(requireActivity(), view, title, avatarUrl)
}
} }
} }

View File

@ -22,13 +22,12 @@ import android.os.Parcelable
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.app.ActivityOptionsCompat
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.airbnb.mvrx.args import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState import com.airbnb.mvrx.withState
import im.vector.matrix.android.api.session.room.notification.RoomNotificationState import im.vector.matrix.android.api.session.room.notification.RoomNotificationState
import im.vector.matrix.android.api.util.MatrixItem
import im.vector.matrix.android.api.util.toMatrixItem import im.vector.matrix.android.api.util.toMatrixItem
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.animations.AppBarStateChangeListener import im.vector.riotx.core.animations.AppBarStateChangeListener
@ -46,7 +45,6 @@ import im.vector.riotx.features.home.room.list.actions.RoomListActionsArgs
import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsBottomSheet import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsBottomSheet
import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsSharedAction import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsSharedAction
import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel
import im.vector.riotx.features.media.BigImageViewerActivity
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.fragment_matrix_profile.* import kotlinx.android.synthetic.main.fragment_matrix_profile.*
import kotlinx.android.synthetic.main.view_stub_room_profile_header.* import kotlinx.android.synthetic.main.view_stub_room_profile_header.*
@ -169,12 +167,7 @@ class RoomProfileFragment @Inject constructor(
matrixProfileDecorationToolbarAvatarImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes()) matrixProfileDecorationToolbarAvatarImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
roomProfileAvatarView.setOnClickListener { view -> roomProfileAvatarView.setOnClickListener { view ->
matrixItem.avatarUrl onAvatarClicked(view, matrixItem)
?.takeIf { it.isNotBlank() }
?.let { avatarUrl ->
val title = state.roomSummary()?.displayName ?: ""
onAvatarClicked(view, title, avatarUrl)
}
} }
} }
} }
@ -224,9 +217,12 @@ class RoomProfileFragment @Inject constructor(
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink) startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
} }
private fun onAvatarClicked(view: View, title: String, avatarUrl: String) { private fun onAvatarClicked(view: View, matrixItem: MatrixItem.RoomItem) {
val intent = BigImageViewerActivity.newIntent(context!!, title, avatarUrl) matrixItem.avatarUrl
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(requireActivity(), view, ViewCompat.getTransitionName(view) ?: "") ?.takeIf { it.isNotBlank() }
startActivity(intent, options.toBundle()) ?.let { avatarUrl ->
val title = matrixItem.getBestName()
navigator.openBigImageViewer(requireActivity(), view, title, avatarUrl)
}
} }
} }

View File

@ -9,7 +9,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:elevation="4dp" android:elevation="4dp"
android:transitionName="toolbar"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />