From d8d4c6f9e7317462570ab4edd0910f84fc9c1e3a Mon Sep 17 00:00:00 2001 From: Julian Raufelder Date: Wed, 24 Feb 2021 15:09:16 +0100 Subject: [PATCH] #275 when deleting the last image using preview jump to vault content As well as fixing a logged IndexOutOfBoundsException when deleting the image with the last indices from the list. --- .../presentation/ui/activity/ImagePreviewActivity.kt | 12 +++++++++++- presentation/src/main/res/values/strings.xml | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/org/cryptomator/presentation/ui/activity/ImagePreviewActivity.kt b/presentation/src/main/java/org/cryptomator/presentation/ui/activity/ImagePreviewActivity.kt index 7834f891..f44a24f8 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/ui/activity/ImagePreviewActivity.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/ui/activity/ImagePreviewActivity.kt @@ -203,7 +203,17 @@ class ImagePreviewActivity : BaseActivity(), ImagePreviewView, ConfirmDeleteClou override fun onImageDeleted(index: Int) { imagePreviewSliderAdapter.deletePage(index) - updateTitle(index) + + presenter.pageIndexes.size.let { + when { + it == 0 -> { + showMessage(getString(R.string.dialog_no_more_images_to_display )) + finish() + } + it > index -> updateTitle(index) + it <= index -> updateTitle(index - 1) + } + } } private fun setControlViewVisibility(visibility: Int) { diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 9059d03e..f7532163 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -433,6 +433,8 @@ Beta release This is a beta release which introduces the support of vault format 7. Please make sure that you don\'t use your production vault for testing or have a good backup strategy. + No more images to display… + Cryptomator needs storage access to use local vaults Cryptomator needs storage access to use auto photo upload