From 16f913a026902a71ffb37f7a68ea3317def62115 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Dec 2017 12:08:36 +0100 Subject: [PATCH] handle storage permission at EditActivity --- app/build.gradle | 2 +- .../gallery/activities/EditActivity.kt | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b7355763d..ad5cc1c3f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,7 +42,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.3.12' + implementation 'com.simplemobiletools:commons:3.4.0' implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.9.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0' implementation 'com.android.support:multidex:1.0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index 16d60200e..d41ba13c4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -11,6 +11,7 @@ import android.provider.MediaStore import android.view.Menu import android.view.MenuItem import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.dialogs.ResizeDialog import com.simplemobiletools.gallery.dialogs.SaveAsDialog @@ -24,17 +25,28 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private val ASPECT_Y = "aspectY" private val CROP = "crop" - lateinit var uri: Uri - lateinit var saveUri: Uri - var resizeWidth = 0 - var resizeHeight = 0 - var isCropIntent = false - var isEditingWithThirdParty = false + private lateinit var uri: Uri + private lateinit var saveUri: Uri + private var resizeWidth = 0 + private var resizeHeight = 0 + private var isCropIntent = false + private var isEditingWithThirdParty = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.view_crop_image) + handlePermission(PERMISSION_WRITE_STORAGE) { + if (it) { + initEditActivity() + } else { + toast(R.string.no_storage_permissions) + finish() + } + } + } + + private fun initEditActivity() { if (intent.data == null) { toast(R.string.invalid_image_path) finish()