Cleanup Navigator
This commit is contained in:
parent
e979bee920
commit
5a65eddf59
|
@ -1171,14 +1171,24 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onImageMessageClicked(messageImageContent: MessageImageInfoContent, mediaData: ImageContentRenderer.Data, view: View) {
|
||||
navigator.openImageViewer(requireActivity(), roomDetailArgs.roomId, mediaData, view) { pairs ->
|
||||
navigator.openMediaViewer(
|
||||
activity = requireActivity(),
|
||||
roomId = roomDetailArgs.roomId,
|
||||
mediaData = mediaData,
|
||||
view = view
|
||||
) { pairs ->
|
||||
pairs.add(Pair(roomToolbar, ViewCompat.getTransitionName(roomToolbar) ?: ""))
|
||||
pairs.add(Pair(composerLayout, ViewCompat.getTransitionName(composerLayout) ?: ""))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVideoMessageClicked(messageVideoContent: MessageVideoContent, mediaData: VideoContentRenderer.Data, view: View) {
|
||||
navigator.openVideoViewer(requireActivity(), roomDetailArgs.roomId, mediaData, view) { pairs ->
|
||||
navigator.openMediaViewer(
|
||||
activity = requireActivity(),
|
||||
roomId = roomDetailArgs.roomId,
|
||||
mediaData = mediaData,
|
||||
view = view
|
||||
) { pairs ->
|
||||
pairs.add(Pair(roomToolbar, ViewCompat.getTransitionName(roomToolbar) ?: ""))
|
||||
pairs.add(Pair(composerLayout, ViewCompat.getTransitionName(composerLayout) ?: ""))
|
||||
}
|
||||
|
|
|
@ -237,7 +237,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen
|
|||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val EXTRA_ARGS = "EXTRA_ARGS"
|
||||
const val EXTRA_IMAGE_DATA = "EXTRA_IMAGE_DATA"
|
||||
const val EXTRA_IN_MEMORY_DATA = "EXTRA_IN_MEMORY_DATA"
|
||||
|
@ -246,11 +245,11 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen
|
|||
mediaData: AttachmentData,
|
||||
roomId: String?,
|
||||
eventId: String,
|
||||
inMemoryData: List<AttachmentData>?,
|
||||
inMemoryData: List<AttachmentData>,
|
||||
sharedTransitionName: String?) = Intent(context, VectorAttachmentViewerActivity::class.java).also {
|
||||
it.putExtra(EXTRA_ARGS, Args(roomId, eventId, sharedTransitionName))
|
||||
it.putExtra(EXTRA_IMAGE_DATA, mediaData)
|
||||
if (inMemoryData != null) {
|
||||
if (inMemoryData.isNotEmpty()) {
|
||||
it.putParcelableArrayListExtra(EXTRA_IN_MEMORY_DATA, ArrayList(inMemoryData))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package im.vector.riotx.features.navigation
|
|||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
|
@ -52,7 +51,6 @@ import im.vector.riotx.features.invite.InviteUsersToRoomActivity
|
|||
import im.vector.riotx.features.media.AttachmentData
|
||||
import im.vector.riotx.features.media.BigImageViewerActivity
|
||||
import im.vector.riotx.features.media.VectorAttachmentViewerActivity
|
||||
import im.vector.riotx.features.media.VideoContentRenderer
|
||||
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
|
||||
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActivity
|
||||
import im.vector.riotx.features.roomdirectory.roompreview.RoomPreviewActivity
|
||||
|
@ -245,11 +243,11 @@ class DefaultNavigator @Inject constructor(
|
|||
context.startActivity(WidgetActivity.newIntent(context, widgetArgs))
|
||||
}
|
||||
|
||||
override fun openImageViewer(activity: Activity,
|
||||
override fun openMediaViewer(activity: Activity,
|
||||
roomId: String,
|
||||
mediaData: AttachmentData,
|
||||
view: View,
|
||||
inMemory: List<AttachmentData>?,
|
||||
inMemory: List<AttachmentData>,
|
||||
options: ((MutableList<Pair<View, String>>) -> Unit)?) {
|
||||
VectorAttachmentViewerActivity.newIntent(activity,
|
||||
mediaData,
|
||||
|
@ -268,52 +266,6 @@ class DefaultNavigator @Inject constructor(
|
|||
pairs.add(Pair(view, ViewCompat.getTransitionName(view) ?: ""))
|
||||
options?.invoke(pairs)
|
||||
|
||||
val bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, *pairs.toTypedArray()).toBundle()
|
||||
activity.startActivity(intent, bundle)
|
||||
}
|
||||
// val intent = ImageMediaViewerActivity.newIntent(activity, mediaData, ViewCompat.getTransitionName(view))
|
||||
// val pairs = ArrayList<Pair<View, String>>()
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
// activity.window.decorView.findViewById<View>(android.R.id.statusBarBackground)?.let {
|
||||
// pairs.add(Pair(it, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME))
|
||||
// }
|
||||
// activity.window.decorView.findViewById<View>(android.R.id.navigationBarBackground)?.let {
|
||||
// pairs.add(Pair(it, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME))
|
||||
// }
|
||||
// }
|
||||
// pairs.add(Pair(view, ViewCompat.getTransitionName(view) ?: ""))
|
||||
// options?.invoke(pairs)
|
||||
//
|
||||
// val bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, *pairs.toTypedArray()).toBundle()
|
||||
// activity.startActivity(intent, bundle)
|
||||
}
|
||||
|
||||
override fun openVideoViewer(activity: Activity,
|
||||
roomId: String,
|
||||
mediaData: AttachmentData,
|
||||
view: View,
|
||||
inMemory: List<AttachmentData>?,
|
||||
options: ((MutableList<Pair<View, String>>) -> Unit)?) {
|
||||
// val intent = VideoMediaViewerActivity.newIntent(activity, mediaData)
|
||||
// activity.startActivity(intent)
|
||||
VectorAttachmentViewerActivity.newIntent(activity,
|
||||
mediaData,
|
||||
roomId,
|
||||
mediaData.eventId,
|
||||
inMemory,
|
||||
ViewCompat.getTransitionName(view)).let { intent ->
|
||||
val pairs = ArrayList<Pair<View, String>>()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
activity.window.decorView.findViewById<View>(android.R.id.statusBarBackground)?.let {
|
||||
pairs.add(Pair(it, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME))
|
||||
}
|
||||
activity.window.decorView.findViewById<View>(android.R.id.navigationBarBackground)?.let {
|
||||
pairs.add(Pair(it, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME))
|
||||
}
|
||||
}
|
||||
pairs.add(Pair(view, ViewCompat.getTransitionName(view) ?: ""))
|
||||
options?.invoke(pairs)
|
||||
|
||||
val bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, *pairs.toTypedArray()).toBundle()
|
||||
activity.startActivity(intent, bundle)
|
||||
}
|
||||
|
|
|
@ -91,17 +91,10 @@ interface Navigator {
|
|||
|
||||
fun openRoomWidget(context: Context, roomId: String, widget: Widget)
|
||||
|
||||
fun openImageViewer(activity: Activity,
|
||||
fun openMediaViewer(activity: Activity,
|
||||
roomId: String,
|
||||
mediaData: AttachmentData,
|
||||
view: View,
|
||||
inMemory: List<AttachmentData>? = null,
|
||||
options: ((MutableList<Pair<View, String>>) -> Unit)?)
|
||||
|
||||
fun openVideoViewer(activity: Activity,
|
||||
roomId: String,
|
||||
mediaData: VideoContentRenderer.Data,
|
||||
view: View,
|
||||
inMemory: List<AttachmentData>? = null,
|
||||
inMemory: List<AttachmentData> = emptyList(),
|
||||
options: ((MutableList<Pair<View, String>>) -> Unit)?)
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class RoomUploadsMediaFragment @Inject constructor(
|
|||
|
||||
// It's very strange i can't just access
|
||||
// the app bar using find by id...
|
||||
private fun trickFindAppBar() : AppBarLayout? {
|
||||
private fun trickFindAppBar(): AppBarLayout? {
|
||||
return activity?.supportFragmentManager?.fragments
|
||||
?.filterIsInstance<RoomUploadsFragment>()
|
||||
?.firstOrNull()
|
||||
|
@ -97,9 +97,14 @@ class RoomUploadsMediaFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onOpenImageClicked(view: View, mediaData: ImageContentRenderer.Data) = withState(uploadsViewModel) { state ->
|
||||
|
||||
val inMemory = getItemsArgs(state)
|
||||
navigator.openImageViewer(requireActivity(), state.roomId, mediaData, view, inMemory) { pairs ->
|
||||
navigator.openMediaViewer(
|
||||
activity = requireActivity(),
|
||||
roomId = state.roomId,
|
||||
mediaData = mediaData,
|
||||
view = view,
|
||||
inMemory = inMemory
|
||||
) { pairs ->
|
||||
trickFindAppBar()?.let {
|
||||
pairs.add(Pair(it, ViewCompat.getTransitionName(it) ?: ""))
|
||||
}
|
||||
|
@ -151,7 +156,13 @@ class RoomUploadsMediaFragment @Inject constructor(
|
|||
|
||||
override fun onOpenVideoClicked(view: View, mediaData: VideoContentRenderer.Data) = withState(uploadsViewModel) { state ->
|
||||
val inMemory = getItemsArgs(state)
|
||||
navigator.openVideoViewer(requireActivity(), state.roomId, mediaData, view, inMemory) { pairs ->
|
||||
navigator.openMediaViewer(
|
||||
activity = requireActivity(),
|
||||
roomId = state.roomId,
|
||||
mediaData = mediaData,
|
||||
view = view,
|
||||
inMemory = inMemory
|
||||
) { pairs ->
|
||||
trickFindAppBar()?.let {
|
||||
pairs.add(Pair(it, ViewCompat.getTransitionName(it) ?: ""))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue