mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
Share menu item added to image media viewer.
This commit is contained in:
parent
febadcc4f6
commit
2b2e6dd6f8
5 changed files with 51 additions and 1 deletions
|
@ -5,7 +5,7 @@ Features ✨:
|
|||
- Cross-Signing | Support SSSS secret sharing (#944)
|
||||
- Cross-Signing | Verify new session from existing session (#1134)
|
||||
- Cross-Signing | Bootstraping cross signing with 4S from mobile (#985)
|
||||
|
||||
- Save media files to Gallery (#973)
|
||||
|
||||
Improvements 🙌:
|
||||
- Verification DM / Handle concurrent .start after .ready (#794)
|
||||
|
|
|
@ -279,6 +279,7 @@ class MessageItemFactory @Inject constructor(
|
|||
attributes: AbsMessageItem.Attributes): MessageImageVideoItem? {
|
||||
val (maxWidth, maxHeight) = timelineMediaSizeProvider.getMaxSize()
|
||||
val data = ImageContentRenderer.Data(
|
||||
eventId = informationData.eventId,
|
||||
filename = messageContent.body,
|
||||
url = messageContent.getFileUrl(),
|
||||
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||
|
@ -314,6 +315,7 @@ class MessageItemFactory @Inject constructor(
|
|||
attributes: AbsMessageItem.Attributes): MessageImageVideoItem? {
|
||||
val (maxWidth, maxHeight) = timelineMediaSizeProvider.getMaxSize()
|
||||
val thumbnailData = ImageContentRenderer.Data(
|
||||
eventId = informationData.eventId,
|
||||
filename = messageContent.body,
|
||||
url = messageContent.videoInfo?.thumbnailFile?.url
|
||||
?: messageContent.videoInfo?.thumbnailUrl,
|
||||
|
|
|
@ -46,6 +46,7 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
|
|||
|
||||
@Parcelize
|
||||
data class Data(
|
||||
val eventId: String,
|
||||
val filename: String,
|
||||
val url: String?,
|
||||
val elementToDecrypt: ElementToDecrypt?,
|
||||
|
|
|
@ -21,10 +21,12 @@ import android.content.Intent
|
|||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.transition.addListener
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.isInvisible
|
||||
|
@ -36,15 +38,23 @@ import com.bumptech.glide.request.RequestListener
|
|||
import com.bumptech.glide.request.target.Target
|
||||
import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator
|
||||
import com.github.piasy.biv.view.GlideImageViewFactory
|
||||
import im.vector.matrix.android.api.MatrixCallback
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.file.FileService
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.di.ScreenComponent
|
||||
import im.vector.riotx.core.glide.GlideApp
|
||||
import im.vector.riotx.core.intent.getMimeTypeFromUri
|
||||
import im.vector.riotx.core.platform.VectorBaseActivity
|
||||
import im.vector.riotx.core.utils.shareMedia
|
||||
import kotlinx.android.synthetic.main.activity_image_media_viewer.*
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
class ImageMediaViewerActivity : VectorBaseActivity() {
|
||||
|
||||
@Inject lateinit var session: Session
|
||||
@Inject lateinit var imageContentRenderer: ImageContentRenderer
|
||||
|
||||
private lateinit var mediaData: ImageContentRenderer.Data
|
||||
|
@ -110,6 +120,33 @@ class ImageMediaViewerActivity : VectorBaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun getMenuRes() = R.menu.vector_media_viewer
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.mediaViewerShareAction -> {
|
||||
onShareActionClicked()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun onShareActionClicked() {
|
||||
session.downloadFile(
|
||||
FileService.DownloadMode.FOR_EXTERNAL_SHARE,
|
||||
mediaData.eventId,
|
||||
mediaData.filename,
|
||||
mediaData.url,
|
||||
mediaData.elementToDecrypt,
|
||||
object : MatrixCallback<File> {
|
||||
override fun onSuccess(data: File) {
|
||||
shareMedia(this@ImageMediaViewerActivity, data, getMimeTypeFromUri(this@ImageMediaViewerActivity, data.toUri()))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun configureToolbar(toolbar: Toolbar, mediaData: ImageContentRenderer.Data) {
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.apply {
|
||||
|
|
10
vector/src/main/res/menu/vector_media_viewer.xml
Normal file
10
vector/src/main/res/menu/vector_media_viewer.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/mediaViewerShareAction"
|
||||
android:icon="@drawable/ic_material_share"
|
||||
android:title="@string/share"
|
||||
app:iconTint="?attr/colorAccent"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
Loading…
Reference in a new issue