From ff8b664470a827e75357d99375f26cc15d7e1734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Kr=C3=BCger?= Date: Thu, 17 Nov 2022 18:37:36 +0100 Subject: [PATCH] Update dependency ImagePicker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In further versions of the ImagePicker library the class 'File' is used to reference an image. Using 'File' caused the permission problems mentioned in #2511. Resolves: #2511 See: https://github.com/Dhaval2404/ImagePicker/commit/d7e643b560f54f2a9999816e719af71cafa3a846 Signed-off-by: Tim Krüger --- app/build.gradle | 3 +-- .../talk/controllers/ProfileController.kt | 22 +++++++++---------- settings.gradle | 6 +++++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6bd4bf501..f3b8d023e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -280,8 +280,7 @@ dependencies { implementation "io.noties.markwon:core:$markwonVersion" - //implementation 'com.github.dhaval2404:imagepicker:1.8' - implementation 'com.github.nextcloud-deps:ImagePicker:1.8.0.2' + implementation 'com.github.nextcloud-deps:ImagePicker:2.1.0.2' implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0' implementation 'org.osmdroid:osmdroid-android:6.1.14' diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt index c3f988ccb..a2c5254b3 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt @@ -40,13 +40,14 @@ import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.annotation.DrawableRes +import androidx.core.net.toFile import androidx.core.view.ViewCompat import androidx.recyclerview.widget.RecyclerView import autodagger.AutoInjector import com.github.dhaval2404.imagepicker.ImagePicker import com.github.dhaval2404.imagepicker.ImagePicker.Companion.getError -import com.github.dhaval2404.imagepicker.ImagePicker.Companion.getFile import com.github.dhaval2404.imagepicker.ImagePicker.Companion.with +import com.github.dhaval2404.imagepicker.constant.ImageProvider import com.nextcloud.talk.R import com.nextcloud.talk.activities.TakePhotoActivity import com.nextcloud.talk.api.NcApi @@ -486,14 +487,13 @@ class ProfileController : BaseController(R.layout.controller_profile) { } private fun sendSelectLocalFileIntent() { - val intent = with(activity!!) - .galleryOnly() + with(activity!!) + .provider(ImageProvider.GALLERY) .crop() .cropSquare() .compress(MAX_SIZE) .maxResultSize(MAX_SIZE, MAX_SIZE) - .prepareIntent() - startActivityForResult(intent, 1) + .createIntent { intent -> startActivityForResult(intent, REQUEST_CODE_IMAGE_PICKER) } } private fun showBrowserScreen() { @@ -584,21 +584,21 @@ class ProfileController : BaseController(R.layout.controller_profile) { } private fun openImageWithPicker(file: File) { - val intent = with(activity!!) - .fileOnly() + with(activity!!) + .provider(ImageProvider.URI) .crop() .cropSquare() .compress(MAX_SIZE) .maxResultSize(MAX_SIZE, MAX_SIZE) - .prepareIntent() - intent.putExtra("extra.file", file) - startActivityForResult(intent, REQUEST_CODE_IMAGE_PICKER) + .setUri(Uri.fromFile(file)) + .createIntent { intent -> startActivityForResult(intent, REQUEST_CODE_IMAGE_PICKER) } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (resultCode == Activity.RESULT_OK) { if (requestCode == REQUEST_CODE_IMAGE_PICKER) { - uploadAvatar(getFile(data)) + val uri: Uri = data?.data!! + uploadAvatar(uri.toFile()) } else if (requestCode == REQUEST_CODE_SELECT_REMOTE_FILES) { val pathList = data?.getStringArrayListExtra(RemoteFileBrowserActivity.EXTRA_SELECTED_PATHS) if (pathList?.size!! >= 1) { diff --git a/settings.gradle b/settings.gradle index bb0692b16..7cf8a9b08 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,3 +26,9 @@ include ':app' // substitute module('com.github.nextcloud.android-common:ui') using project(':ui') // } //} + +//includeBuild('../../../deps/ImagePicker') { +// dependencySubstitution { +// substitute module('com.github.nextcloud-deps:ImagePicker') using project(':imagepicker') +// } +//}