diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt
index f864e725ff..84adddd58b 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt
@@ -24,8 +24,11 @@ import im.vector.matrix.android.api.session.content.ContentAttachmentData
import im.vector.matrix.android.api.session.events.model.Event
import im.vector.matrix.android.api.session.events.model.toContent
import im.vector.matrix.android.api.session.events.model.toModel
+import im.vector.matrix.android.api.session.room.model.message.MessageAudioContent
import im.vector.matrix.android.api.session.room.model.message.MessageContent
+import im.vector.matrix.android.api.session.room.model.message.MessageFileContent
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
+import im.vector.matrix.android.api.session.room.model.message.MessageVideoContent
import im.vector.matrix.android.internal.di.MatrixKoinComponent
import im.vector.matrix.android.internal.session.room.send.SendEventWorker
import im.vector.matrix.android.internal.util.WorkerParamsFactory
@@ -69,6 +72,9 @@ internal class UploadContentWorker(context: Context, params: WorkerParameters)
val messageContent: MessageContent = event.content.toModel() ?: return event
val updatedContent = when (messageContent) {
is MessageImageContent -> messageContent.update(url)
+ is MessageVideoContent -> messageContent.update(url)
+ is MessageFileContent -> messageContent.update(url)
+ is MessageAudioContent -> messageContent.update(url)
else -> messageContent
}
return event.copy(content = updatedContent.toContent())
@@ -78,6 +84,18 @@ internal class UploadContentWorker(context: Context, params: WorkerParameters)
return copy(url = url)
}
+ private fun MessageVideoContent.update(url: String): MessageVideoContent {
+ return copy(url = url)
+ }
+
+ private fun MessageFileContent.update(url: String): MessageFileContent {
+ return copy(url = url)
+ }
+
+ private fun MessageAudioContent.update(url: String): MessageAudioContent {
+ return copy(url = url)
+ }
+
}
diff --git a/vector/build.gradle b/vector/build.gradle
index 691090f07f..bdf958030b 100644
--- a/vector/build.gradle
+++ b/vector/build.gradle
@@ -187,6 +187,7 @@ dependencies {
implementation "com.github.piasy:GlideImageViewFactory:$big_image_viewer_version"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
+ implementation 'com.danikula:videocache:2.7.1'
// Badge for compatibility
implementation 'me.leolin:ShortcutBadger:1.1.2@aar'
diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml
index bea4280eef..7aac94fa4f 100644
--- a/vector/src/main/AndroidManifest.xml
+++ b/vector/src/main/AndroidManifest.xml
@@ -29,7 +29,7 @@
-
+
@@ -37,6 +37,7 @@
android:name=".features.settings.VectorSettingsActivity"
android:label="@string/title_activity_settings"
android:windowSoftInputMode="adjustResize" />
+
callback?.onVideoMessageClicked(messageContent, data, view) }
+ .mediaData(thumbnailData)
+ .clickListener { view -> callback?.onVideoMessageClicked(messageContent, videoData, view) }
}
private fun buildTextMessageItem(messageContent: MessageTextContent,
diff --git a/vector/src/main/java/im/vector/riotredesign/features/media/MediaViewerActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/media/ImageMediaViewerActivity.kt
similarity index 78%
rename from vector/src/main/java/im/vector/riotredesign/features/media/MediaViewerActivity.kt
rename to vector/src/main/java/im/vector/riotredesign/features/media/ImageMediaViewerActivity.kt
index 9859b94bb6..902c2f9bc1 100644
--- a/vector/src/main/java/im/vector/riotredesign/features/media/MediaViewerActivity.kt
+++ b/vector/src/main/java/im/vector/riotredesign/features/media/ImageMediaViewerActivity.kt
@@ -25,22 +25,22 @@ import androidx.appcompat.widget.Toolbar
import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator
import com.github.piasy.biv.view.GlideImageViewFactory
import im.vector.riotredesign.core.platform.VectorBaseActivity
-import kotlinx.android.synthetic.main.activity_media_viewer.*
+import kotlinx.android.synthetic.main.activity_image_media_viewer.*
-class MediaViewerActivity : VectorBaseActivity() {
+class ImageMediaViewerActivity : VectorBaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setContentView(im.vector.riotredesign.R.layout.activity_media_viewer)
+ setContentView(im.vector.riotredesign.R.layout.activity_image_media_viewer)
val mediaData = intent.getParcelableExtra(EXTRA_MEDIA_DATA)
if (mediaData.url.isNullOrEmpty()) {
finish()
} else {
- configureToolbar(mediaViewerToolbar, mediaData)
- mediaViewerImageView.setImageViewFactory(GlideImageViewFactory())
- mediaViewerImageView.setProgressIndicator(ProgressPieIndicator())
- ImageContentRenderer.render(mediaData, mediaViewerImageView)
+ configureToolbar(imageMediaViewerToolbar, mediaData)
+ imageMediaViewerImageView.setImageViewFactory(GlideImageViewFactory())
+ imageMediaViewerImageView.setProgressIndicator(ProgressPieIndicator())
+ ImageContentRenderer.render(mediaData, imageMediaViewerImageView)
}
}
@@ -58,7 +58,7 @@ class MediaViewerActivity : VectorBaseActivity() {
private const val EXTRA_MEDIA_DATA = "EXTRA_MEDIA_DATA"
fun newIntent(context: Context, mediaData: ImageContentRenderer.Data): Intent {
- return Intent(context, MediaViewerActivity::class.java).apply {
+ return Intent(context, ImageMediaViewerActivity::class.java).apply {
putExtra(EXTRA_MEDIA_DATA, mediaData)
}
}
diff --git a/vector/src/main/java/im/vector/riotredesign/features/media/VideoContentRenderer.kt b/vector/src/main/java/im/vector/riotredesign/features/media/VideoContentRenderer.kt
new file mode 100644
index 0000000000..577b65703d
--- /dev/null
+++ b/vector/src/main/java/im/vector/riotredesign/features/media/VideoContentRenderer.kt
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2019 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.riotredesign.features.media
+
+import android.os.Parcelable
+import android.widget.ImageView
+import android.widget.VideoView
+import im.vector.matrix.android.api.Matrix
+import kotlinx.android.parcel.Parcelize
+
+object VideoContentRenderer {
+
+ @Parcelize
+ data class Data(
+ val filename: String,
+ val videoUrl: String?,
+ val thumbnailMediaData: ImageContentRenderer.Data
+ ) : Parcelable
+
+ fun render(data: Data, thumbnailView: ImageView, videoView: VideoView) {
+ val contentUrlResolver = Matrix.getInstance().currentSession!!.contentUrlResolver()
+ val resolvedUrl = contentUrlResolver.resolveFullSize(data.videoUrl)
+ videoView.setVideoPath(resolvedUrl)
+ videoView.start()
+ }
+
+}
\ No newline at end of file
diff --git a/vector/src/main/java/im/vector/riotredesign/features/media/VideoMediaViewerActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/media/VideoMediaViewerActivity.kt
new file mode 100644
index 0000000000..0630a2cb01
--- /dev/null
+++ b/vector/src/main/java/im/vector/riotredesign/features/media/VideoMediaViewerActivity.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2019 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.riotredesign.features.media
+
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import androidx.appcompat.widget.Toolbar
+import im.vector.riotredesign.core.platform.VectorBaseActivity
+import kotlinx.android.synthetic.main.activity_video_media_viewer.*
+
+
+class VideoMediaViewerActivity : VectorBaseActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(im.vector.riotredesign.R.layout.activity_video_media_viewer)
+ val mediaData = intent.getParcelableExtra(EXTRA_MEDIA_DATA)
+ if (mediaData.videoUrl.isNullOrEmpty()) {
+ finish()
+ } else {
+ configureToolbar(videoMediaViewerToolbar, mediaData)
+ VideoContentRenderer.render(mediaData, videoMediaViewerThumbnailView, videoMediaViewerVideoView)
+ }
+ }
+
+ private fun configureToolbar(toolbar: Toolbar, mediaData: VideoContentRenderer.Data) {
+ setSupportActionBar(toolbar)
+ supportActionBar?.apply {
+ title = mediaData.filename
+ setHomeButtonEnabled(true)
+ setDisplayHomeAsUpEnabled(true)
+ }
+ }
+
+ companion object {
+
+ private const val EXTRA_MEDIA_DATA = "EXTRA_MEDIA_DATA"
+
+ fun newIntent(context: Context, mediaData: VideoContentRenderer.Data): Intent {
+ return Intent(context, VideoMediaViewerActivity::class.java).apply {
+ putExtra(EXTRA_MEDIA_DATA, mediaData)
+ }
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/vector/src/main/res/layout/activity_media_viewer.xml b/vector/src/main/res/layout/activity_image_media_viewer.xml
similarity index 88%
rename from vector/src/main/res/layout/activity_media_viewer.xml
rename to vector/src/main/res/layout/activity_image_media_viewer.xml
index 9927331ed4..3644714bd1 100644
--- a/vector/src/main/res/layout/activity_media_viewer.xml
+++ b/vector/src/main/res/layout/activity_image_media_viewer.xml
@@ -6,7 +6,7 @@
android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file