mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 09:25:49 +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 | Support SSSS secret sharing (#944)
|
||||||
- Cross-Signing | Verify new session from existing session (#1134)
|
- Cross-Signing | Verify new session from existing session (#1134)
|
||||||
- Cross-Signing | Bootstraping cross signing with 4S from mobile (#985)
|
- Cross-Signing | Bootstraping cross signing with 4S from mobile (#985)
|
||||||
|
- Save media files to Gallery (#973)
|
||||||
|
|
||||||
Improvements 🙌:
|
Improvements 🙌:
|
||||||
- Verification DM / Handle concurrent .start after .ready (#794)
|
- Verification DM / Handle concurrent .start after .ready (#794)
|
||||||
|
|
|
@ -279,6 +279,7 @@ class MessageItemFactory @Inject constructor(
|
||||||
attributes: AbsMessageItem.Attributes): MessageImageVideoItem? {
|
attributes: AbsMessageItem.Attributes): MessageImageVideoItem? {
|
||||||
val (maxWidth, maxHeight) = timelineMediaSizeProvider.getMaxSize()
|
val (maxWidth, maxHeight) = timelineMediaSizeProvider.getMaxSize()
|
||||||
val data = ImageContentRenderer.Data(
|
val data = ImageContentRenderer.Data(
|
||||||
|
eventId = informationData.eventId,
|
||||||
filename = messageContent.body,
|
filename = messageContent.body,
|
||||||
url = messageContent.getFileUrl(),
|
url = messageContent.getFileUrl(),
|
||||||
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt(),
|
elementToDecrypt = messageContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||||
|
@ -314,6 +315,7 @@ class MessageItemFactory @Inject constructor(
|
||||||
attributes: AbsMessageItem.Attributes): MessageImageVideoItem? {
|
attributes: AbsMessageItem.Attributes): MessageImageVideoItem? {
|
||||||
val (maxWidth, maxHeight) = timelineMediaSizeProvider.getMaxSize()
|
val (maxWidth, maxHeight) = timelineMediaSizeProvider.getMaxSize()
|
||||||
val thumbnailData = ImageContentRenderer.Data(
|
val thumbnailData = ImageContentRenderer.Data(
|
||||||
|
eventId = informationData.eventId,
|
||||||
filename = messageContent.body,
|
filename = messageContent.body,
|
||||||
url = messageContent.videoInfo?.thumbnailFile?.url
|
url = messageContent.videoInfo?.thumbnailFile?.url
|
||||||
?: messageContent.videoInfo?.thumbnailUrl,
|
?: messageContent.videoInfo?.thumbnailUrl,
|
||||||
|
|
|
@ -46,6 +46,7 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data class Data(
|
data class Data(
|
||||||
|
val eventId: String,
|
||||||
val filename: String,
|
val filename: String,
|
||||||
val url: String?,
|
val url: String?,
|
||||||
val elementToDecrypt: ElementToDecrypt?,
|
val elementToDecrypt: ElementToDecrypt?,
|
||||||
|
|
|
@ -21,10 +21,12 @@ import android.content.Intent
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.core.net.toUri
|
||||||
import androidx.core.transition.addListener
|
import androidx.core.transition.addListener
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
|
@ -36,15 +38,23 @@ import com.bumptech.glide.request.RequestListener
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator
|
import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator
|
||||||
import com.github.piasy.biv.view.GlideImageViewFactory
|
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.di.ScreenComponent
|
||||||
import im.vector.riotx.core.glide.GlideApp
|
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.platform.VectorBaseActivity
|
||||||
|
import im.vector.riotx.core.utils.shareMedia
|
||||||
import kotlinx.android.synthetic.main.activity_image_media_viewer.*
|
import kotlinx.android.synthetic.main.activity_image_media_viewer.*
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ImageMediaViewerActivity : VectorBaseActivity() {
|
class ImageMediaViewerActivity : VectorBaseActivity() {
|
||||||
|
|
||||||
|
@Inject lateinit var session: Session
|
||||||
@Inject lateinit var imageContentRenderer: ImageContentRenderer
|
@Inject lateinit var imageContentRenderer: ImageContentRenderer
|
||||||
|
|
||||||
private lateinit var mediaData: ImageContentRenderer.Data
|
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) {
|
private fun configureToolbar(toolbar: Toolbar, mediaData: ImageContentRenderer.Data) {
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
supportActionBar?.apply {
|
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