mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
Media preview: do not propose to edit Gif
This commit is contained in:
parent
b6f5e27155
commit
31d5578063
2 changed files with 40 additions and 0 deletions
|
@ -23,6 +23,7 @@ import android.content.Intent
|
|||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -107,6 +108,16 @@ class AttachmentsPreviewFragment @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
withState(viewModel) { state ->
|
||||
val editMenuItem = menu.findItem(R.id.attachmentsPreviewEditAction)
|
||||
val showEditMenuItem = state.attachments[state.currentAttachmentIndex].isEditable()
|
||||
editMenuItem.setVisible(showEditMenuItem)
|
||||
}
|
||||
|
||||
super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun getMenuRes() = R.menu.vector_attachments_preview
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -116,6 +127,7 @@ class AttachmentsPreviewFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun invalidate() = withState(viewModel) { state ->
|
||||
requireActivity().invalidateOptionsMenu()
|
||||
if (state.attachments.isEmpty()) {
|
||||
requireActivity().setResult(RESULT_CANCELED)
|
||||
requireActivity().finish()
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2020 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.riotx.features.attachments.preview
|
||||
|
||||
import im.vector.matrix.android.api.session.content.ContentAttachmentData
|
||||
|
||||
/**
|
||||
* All images are editable, expect Gif
|
||||
*/
|
||||
fun ContentAttachmentData.isEditable(): Boolean {
|
||||
return type == ContentAttachmentData.Type.IMAGE
|
||||
&& mimeType?.startsWith("image/") == true
|
||||
&& mimeType != "image/gif"
|
||||
}
|
Loading…
Reference in a new issue