kopia lustrzana https://github.com/ryukoposting/Signal-Android
Do not close gallery picker once 0 items selected.
This change only takes effect if the user navigates directly to the gallery picker.main
rodzic
084e806c25
commit
371267a1d3
|
@ -24,7 +24,8 @@ data class MediaSelectionState(
|
||||||
val editorStateMap: Map<Uri, Any> = mapOf(),
|
val editorStateMap: Map<Uri, Any> = mapOf(),
|
||||||
val cameraFirstCapture: Media? = null,
|
val cameraFirstCapture: Media? = null,
|
||||||
val isStory: Boolean,
|
val isStory: Boolean,
|
||||||
val storySendRequirements: Stories.MediaTransform.SendRequirements = Stories.MediaTransform.SendRequirements.CAN_NOT_SEND
|
val storySendRequirements: Stories.MediaTransform.SendRequirements = Stories.MediaTransform.SendRequirements.CAN_NOT_SEND,
|
||||||
|
val suppressEmptyError: Boolean = true
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val maxSelection = if (sendType.usesSmsTransport) {
|
val maxSelection = if (sendType.usesSmsTransport) {
|
||||||
|
|
|
@ -140,6 +140,10 @@ class MediaSelectionViewModel(
|
||||||
store.update { it.copy(isTouchEnabled = isEnabled) }
|
store.update { it.copy(isTouchEnabled = isEnabled) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setSuppressEmptyError(isSuppressed: Boolean) {
|
||||||
|
store.update { it.copy(suppressEmptyError = isSuppressed) }
|
||||||
|
}
|
||||||
|
|
||||||
fun addMedia(media: Media) {
|
fun addMedia(media: Media) {
|
||||||
addMedia(listOf(media))
|
addMedia(listOf(media))
|
||||||
}
|
}
|
||||||
|
@ -230,10 +234,6 @@ class MediaSelectionViewModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeMedia(media: Media) {
|
fun removeMedia(media: Media) {
|
||||||
removeMedia(media, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun removeMedia(media: Media, suppressEmptyError: Boolean) {
|
|
||||||
val snapshot = store.state
|
val snapshot = store.state
|
||||||
val newMediaList = snapshot.selectedMedia - media
|
val newMediaList = snapshot.selectedMedia - media
|
||||||
val oldFocusIndex = snapshot.selectedMedia.indexOf(media)
|
val oldFocusIndex = snapshot.selectedMedia.indexOf(media)
|
||||||
|
@ -252,7 +252,7 @@ class MediaSelectionViewModel(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newMediaList.isEmpty() && !suppressEmptyError) {
|
if (newMediaList.isEmpty() && !store.state.suppressEmptyError) {
|
||||||
mediaErrors.onNext(MediaValidator.FilterError.NoItems())
|
mediaErrors.onNext(MediaValidator.FilterError.NoItems())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,8 @@ class MediaSelectionViewModel(
|
||||||
fun removeCameraFirstCapture() {
|
fun removeCameraFirstCapture() {
|
||||||
val cameraFirstCapture: Media? = store.state.cameraFirstCapture
|
val cameraFirstCapture: Media? = store.state.cameraFirstCapture
|
||||||
if (cameraFirstCapture != null) {
|
if (cameraFirstCapture != null) {
|
||||||
removeMedia(cameraFirstCapture, true)
|
setSuppressEmptyError(true)
|
||||||
|
removeMedia(cameraFirstCapture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ class MediaSelectionGalleryFragment : Fragment(R.layout.fragment_container), Med
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
val isFirst = arguments?.getBoolean("first") ?: false
|
||||||
|
sharedViewModel.setSuppressEmptyError(isFirst)
|
||||||
mediaGalleryFragment = ensureMediaGalleryFragment()
|
mediaGalleryFragment = ensureMediaGalleryFragment()
|
||||||
|
|
||||||
mediaGalleryFragment.bindSelectedMediaItemDragHelper(ItemTouchHelper(MediaSelectionItemTouchHelper(sharedViewModel)))
|
mediaGalleryFragment.bindSelectedMediaItemDragHelper(ItemTouchHelper(MediaSelectionItemTouchHelper(sharedViewModel)))
|
||||||
|
|
Ładowanie…
Reference in New Issue