From 00df20cafc9e11b3c271b6ae7b907d5f31a11a1d Mon Sep 17 00:00:00 2001 From: Muhammad Shams Date: Sat, 16 Apr 2022 06:17:23 +0500 Subject: [PATCH 01/18] camera only back press crash issues (#398) --- .../com/esafirm/imagepicker/features/ImagePickerActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt index 37b45b01..6400039a 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt @@ -117,7 +117,11 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener } override fun onBackPressed() { - if (!imagePickerFragment.handleBack()) { + if (this::imagePickerFragment.isInitialized) { + if (!imagePickerFragment.handleBack()) { + super.onBackPressed() + } + }else { super.onBackPressed() } } From 59c1d6664839d9a32937b5856c038ed19b1b231b Mon Sep 17 00:00:00 2001 From: Andreas Date: Sat, 16 Apr 2022 03:19:31 +0200 Subject: [PATCH 02/18] Add Swedish translation (#386) Co-authored-by: Nightfright <10356028+Nightfright@users.noreply.github.com> Co-authored-by: Nightfright <10356028+Nightfright@users.noreply.github.com> --- .../src/main/res/values-sv-rSE/strings.xml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 imagepicker/src/main/res/values-sv-rSE/strings.xml diff --git a/imagepicker/src/main/res/values-sv-rSE/strings.xml b/imagepicker/src/main/res/values-sv-rSE/strings.xml new file mode 100644 index 00000000..3ff8482b --- /dev/null +++ b/imagepicker/src/main/res/values-sv-rSE/strings.xml @@ -0,0 +1,23 @@ + + + Tillåt åtkomst extern lagring för att välja bilder + + OK + KLAR + KAMERA + + Mapp + Tryck för att välja bilder + Åtkomst nekad + + %d valda + %1$d/%2$d valda + + Misslyckades att skapa bildfil + Ingen kamera hittades + Hopsan! Något gick fel! + + Inga bilder hittades + Vänligen bevilja lagringsbehörighet för att välja bilder + Bildvalsgräns + \ No newline at end of file From fee5a74b976c1204396a7d4250a337214c047043 Mon Sep 17 00:00:00 2001 From: Esa Firman Date: Sun, 24 Apr 2022 12:01:03 +0700 Subject: [PATCH 03/18] remove jetifier from all projects repo --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index 182d6b79..82b7a730 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,6 @@ allprojects { mavenCentral() google() maven { url "https://jitpack.io" } - jcenter() } } From ea079125ce69e0bcaab25260f2943ad6b0484d1b Mon Sep 17 00:00:00 2001 From: Pau Ballart Date: Mon, 9 May 2022 02:40:04 +0200 Subject: [PATCH 04/18] Add spanish and catalan translations (#376) --- .../src/main/res/values-ca/strings.xml | 29 +++++++++++++++++++ .../src/main/res/values-es-rES/strings.xml | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 imagepicker/src/main/res/values-ca/strings.xml create mode 100644 imagepicker/src/main/res/values-es-rES/strings.xml diff --git a/imagepicker/src/main/res/values-ca/strings.xml b/imagepicker/src/main/res/values-ca/strings.xml new file mode 100644 index 00000000..5dbc994f --- /dev/null +++ b/imagepicker/src/main/res/values-ca/strings.xml @@ -0,0 +1,29 @@ + + + Permet l\'accès a l\'emmagatzematge extern per seleccionar imatges + + OK + FET + CÀMERA + + Carpeta + Toqueu per seleccionar imatges + Permís denegat + + %d seleccionades + %1$d/%2$d seleccionades + + Error al crear el fitxer d\'imatge + No s\'ha trobat cap càmera + Oops, alguna cosa no ha anat bé! + + No s\'han trobat imatges + Si us plau, dona permisos d\'emmagatzematge per seleccionar imatges + Límit de selecció d\'imatges + + + GIF + Folder + Image + + diff --git a/imagepicker/src/main/res/values-es-rES/strings.xml b/imagepicker/src/main/res/values-es-rES/strings.xml new file mode 100644 index 00000000..81f33617 --- /dev/null +++ b/imagepicker/src/main/res/values-es-rES/strings.xml @@ -0,0 +1,29 @@ + + + Permite el acceso al almacenamiento externo para seleccionar imágenes + + OK + HECHO + CÁMARA + + Carpeta + Toque para seleccionar imágenes + Permiso denegado + + %d seleccionadas + %1$d/%2$d seleccionadas + + Error al crear el fichero de imágen + No se encontró la cámara + Oops, algo ha ido mal! + + No se han encontrado imágenes + Por favor permite permisos de almacenamiento para seleccionar imágenes + Límite de selección de imágenes + + + GIF + Folder + Image + + From 283b4cac57838fc99c4674e56759de33c75030d2 Mon Sep 17 00:00:00 2001 From: Alessandro Tedesco Date: Sun, 23 Oct 2022 16:19:08 +0200 Subject: [PATCH 05/18] Add camera permission english string (#405) (#406) Co-authored-by: Alessandro Tedesco --- imagepicker/src/main/res/values/strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/imagepicker/src/main/res/values/strings.xml b/imagepicker/src/main/res/values/strings.xml index 74c80b92..07472e17 100644 --- a/imagepicker/src/main/res/values/strings.xml +++ b/imagepicker/src/main/res/values/strings.xml @@ -25,5 +25,6 @@ GIF Folder Image + You have to give the app permission to use the camera to be able to take pictures From 19e306f2e0edb6ce6165083d8c9a46931e978e06 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 23 Oct 2022 21:22:30 +0700 Subject: [PATCH 06/18] add vi language (#407) Co-authored-by: Hung <> Co-authored-by: Esa Firman --- .../src/main/res/values-vi/strings.xml | 25 +++++++++++++++++++ imagepicker/src/main/res/values/strings.xml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 imagepicker/src/main/res/values-vi/strings.xml diff --git a/imagepicker/src/main/res/values-vi/strings.xml b/imagepicker/src/main/res/values-vi/strings.xml new file mode 100644 index 00000000..acdad396 --- /dev/null +++ b/imagepicker/src/main/res/values-vi/strings.xml @@ -0,0 +1,25 @@ + + + Cho phép truy cập bộ nhớ ngoài để chọn hình ảnh + + Đồng Ý + XONG + CAMERA + + Thư mục + Nhấn để chọn hình ảnh + Quyền bị từ chối + + %d đã chọn + %1$d/%2$d đã chọn + + Không tạo được tệp hình ảnh + Không tìm thấy máy ảnh + Rất tiếc, đã xảy ra lỗi! + + Không tìm thấy hình ảnh + Vui lòng cấp quyền lưu trữ để chọn hình ảnh + Giới hạn chọn hình ảnh + + Vui lòng cấp quyền cho máy ảnh để chụp ảnh + diff --git a/imagepicker/src/main/res/values/strings.xml b/imagepicker/src/main/res/values/strings.xml index 07472e17..4f33fbad 100644 --- a/imagepicker/src/main/res/values/strings.xml +++ b/imagepicker/src/main/res/values/strings.xml @@ -20,11 +20,11 @@ No images found Please grant storage permission to select images Image selection limit + You have to give the app permission to use the camera to be able to take pictures GIF Folder Image - You have to give the app permission to use the camera to be able to take pictures From e669823b53bc360900ea162db9553da5f519fe7e Mon Sep 17 00:00:00 2001 From: Esa Firman Date: Sun, 23 Oct 2022 22:25:49 +0700 Subject: [PATCH 07/18] Fix - Change barista dependency (#415) * change barista dependency * change the imports --- .gitignore | 3 +++ sample/build.gradle | 2 +- sample/src/androidTest/AndroidManifest.xml | 2 +- .../java/com/esafirm/sample/CameraOnPickerTest.kt | 6 +++--- .../androidTest/java/com/esafirm/sample/CameraOnlyTest.kt | 6 +++--- .../androidTest/java/com/esafirm/sample/CustomUiTest.kt | 2 +- .../java/com/esafirm/sample/PickImageFolderMode.kt | 2 +- .../java/com/esafirm/sample/PickImageFragmentTest.kt | 8 ++++---- .../java/com/esafirm/sample/PickImageSingleTest.kt | 2 +- 9 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index a58f683e..6d6970cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Github +.fork/ + # Idea **/*.iml .idea/ diff --git a/sample/build.gradle b/sample/build.gradle index 16d27fb6..bacf07fb 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -58,7 +58,7 @@ dependencies { androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion" androidTestImplementation "androidx.test:runner:$runnerVersion" androidTestImplementation "androidx.test:rules:$runnerVersion" - androidTestImplementation('com.schibsted.spain:barista:3.7.0') { + androidTestImplementation('com.adevinta.android:barista:3.10.0') { exclude group: 'org.jetbrains.kotlin' } } diff --git a/sample/src/androidTest/AndroidManifest.xml b/sample/src/androidTest/AndroidManifest.xml index b81f1910..15b85903 100644 --- a/sample/src/androidTest/AndroidManifest.xml +++ b/sample/src/androidTest/AndroidManifest.xml @@ -2,6 +2,6 @@ - + diff --git a/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt index bc2722e9..89ea64e3 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt @@ -11,9 +11,9 @@ import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views -import com.schibsted.spain.barista.intents.BaristaIntents.mockAndroidCamera -import com.schibsted.spain.barista.interaction.BaristaClickInteractions.clickOn -import com.schibsted.spain.barista.interaction.BaristaMenuClickInteractions +import com.adevinta.android.barista.intents.BaristaIntents.mockAndroidCamera +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn +import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith diff --git a/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt index 158225f9..58bd5ff1 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt @@ -18,9 +18,9 @@ import androidx.test.runner.AndroidJUnit4 import com.esafirm.sample.matchers.hasDrawable import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views -import com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed -import com.schibsted.spain.barista.intents.BaristaIntents.mockAndroidCamera -import com.schibsted.spain.barista.interaction.BaristaClickInteractions.clickOn +import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed +import com.adevinta.android.barista.intents.BaristaIntents.mockAndroidCamera +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith diff --git a/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt index 7133c6ab..0a63d3d1 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt @@ -11,7 +11,7 @@ import androidx.test.rule.GrantPermissionRule import androidx.test.runner.AndroidJUnit4 import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views -import com.schibsted.spain.barista.interaction.BaristaClickInteractions.clickOn +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt index 15c8f11f..e3d7a20d 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt @@ -10,7 +10,7 @@ import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views -import com.schibsted.spain.barista.interaction.BaristaClickInteractions.clickOn +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt index 1ddac9c4..aa37571e 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt @@ -8,9 +8,9 @@ import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule import com.esafirm.sample.utils.Views -import com.schibsted.spain.barista.assertion.BaristaImageViewAssertions.assertHasAnyDrawable -import com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed -import com.schibsted.spain.barista.interaction.BaristaClickInteractions.clickOn +import com.adevinta.android.barista.assertion.BaristaImageViewAssertions.assertHasAnyDrawable +import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -43,4 +43,4 @@ class PickImageFragmentTest { assertHasAnyDrawable(R.id.img_fragment) } -} \ No newline at end of file +} diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt index 5168308c..4e199f6f 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt @@ -10,7 +10,7 @@ import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views -import com.schibsted.spain.barista.interaction.BaristaClickInteractions.clickOn +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith From fa67fbbb9f69a02942ca40b7f23d63e66ce70bca Mon Sep 17 00:00:00 2001 From: Masato Ishikawa <66544606+masato1230@users.noreply.github.com> Date: Mon, 24 Oct 2022 00:34:30 +0900 Subject: [PATCH 08/18] Add permission check for android13 (#404) --- build.gradle | 4 +-- imagepicker/src/main/AndroidManifest.xml | 1 + .../features/ImagePickerFragment.kt | 26 +++++++++++-------- sample/build.gradle | 2 +- sample/src/main/AndroidManifest.xml | 4 ++- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index 82b7a730..653c18d0 100644 --- a/build.gradle +++ b/build.gradle @@ -14,8 +14,8 @@ buildscript { ext { sdk = [ - compileSdk: 30, - targetSdk : 30, + compileSdk: 33, + targetSdk : 33, minSdk : 21 ] } diff --git a/imagepicker/src/main/AndroidManifest.xml b/imagepicker/src/main/AndroidManifest.xml index 09492d3f..d47672f4 100644 --- a/imagepicker/src/main/AndroidManifest.xml +++ b/imagepicker/src/main/AndroidManifest.xml @@ -4,6 +4,7 @@ + = Build.VERSION_CODES.TIRAMISU) { + Manifest.permission.READ_MEDIA_IMAGES + } else Manifest.permission.WRITE_EXTERNAL_STORAGE + } + private val requestPermissionLauncher = registerForActivityResult(RequestPermission()) { isGranted -> if (isGranted) { @@ -80,9 +88,9 @@ class ImagePickerFragment : Fragment() { if (::interactionListener.isInitialized.not()) { throw RuntimeException( "ImagePickerFragment needs an " + - "ImagePickerInteractionListener. This will be set automatically if the " + - "activity implements ImagePickerInteractionListener, and can be set manually " + - "with fragment.setInteractionListener(listener)." + "ImagePickerInteractionListener. This will be set automatically if the " + + "activity implements ImagePickerInteractionListener, and can be set manually " + + "with fragment.setInteractionListener(listener)." ) } @@ -244,14 +252,11 @@ class ImagePickerFragment : Fragment() { * Check permission */ private fun loadDataWithPermission() { - val rc = ActivityCompat.checkSelfPermission( - requireContext(), - Manifest.permission.WRITE_EXTERNAL_STORAGE - ) + val rc = ActivityCompat.checkSelfPermission(requireContext(), permission) if (rc == PackageManager.PERMISSION_GRANTED) { loadData() } else { - requestWriteExternalPermission() + requestWriteExternalOrReadImagesPermission() } } @@ -262,9 +267,8 @@ class ImagePickerFragment : Fragment() { * If permission denied or app is first launched, request for permission * If permission denied and user choose 'Never Ask Again', show snackbar with an action that navigate to app settings */ - private fun requestWriteExternalPermission() { - IpLogger.w("Write External permission is not granted. Requesting permission") - val permission = Manifest.permission.WRITE_EXTERNAL_STORAGE + private fun requestWriteExternalOrReadImagesPermission() { + IpLogger.w("Write External permission or Read Media Images is not granted. Requesting permission") when { shouldShowRequestPermissionRationale(permission) -> { requestPermissionLauncher.launch(permission) diff --git a/sample/build.gradle b/sample/build.gradle index bacf07fb..6ead8d61 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -48,7 +48,7 @@ dependencies { /* Development */ implementation project(':imagepicker') - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' implementation "androidx.core:core-ktx:$core_ktx_version" /* UI Test */ diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index f3acd351..acec947c 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -8,7 +8,9 @@ android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> - + From f4feee3cf28617a74eeb4162de064ddc1d9cc0d9 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 23 Oct 2022 22:38:45 +0700 Subject: [PATCH 09/18] fix deprecated pickCamera (#408) * fix deprecated pickCamera * formatting Co-authored-by: Hung <> Co-authored-by: Esa Firman --- .../features/ImagePickerActivity.kt | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt index 6400039a..f142759e 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt @@ -7,6 +7,8 @@ import android.graphics.PorterDuff import android.os.Bundle import android.view.Menu import android.view.MenuItem +import androidx.activity.result.ActivityResult +import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.ActionBar import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar @@ -21,10 +23,6 @@ import com.esafirm.imagepicker.model.Image class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener { - companion object { - private const val RC_CAMERA = 1011 - } - private val cameraModule = ImagePickerComponentsHolder.cameraModule private var actionBar: ActionBar? = null @@ -40,6 +38,28 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener private val isCameraOnly by lazy { cameraOnlyConfig != null } + private val startForCameraResult = registerForActivityResult( + ActivityResultContracts.StartActivityForResult() + ) { result: ActivityResult -> + if (result.resultCode == Activity.RESULT_OK) { + val intent = result.data + // Handle the Intent + if (intent?.extras?.isEmpty == true) { + cameraModule.removeImage(this) + setResult(RESULT_CANCELED) + finish() + } else { + cameraModule.getImage(this, intent) { images -> + finishPickImages(ImagePickerUtils.createResultIntent(images)) + } + } + } else { + cameraModule.removeImage(this) + setResult(RESULT_CANCELED) + finish() + } + } + override fun attachBaseContext(newBase: Context) { super.attachBaseContext(LocaleManager.updateResources(newBase)) } @@ -56,7 +76,7 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener if (isCameraOnly) { val cameraIntent = cameraModule.getCameraIntent(this, cameraOnlyConfig!!) - startActivityForResult(cameraIntent, RC_CAMERA) + startForCameraResult.launch(cameraIntent) return } @@ -121,7 +141,7 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener if (!imagePickerFragment.handleBack()) { super.onBackPressed() } - }else { + } else { super.onBackPressed() } } @@ -142,22 +162,6 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener } } - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) - if (resultCode == Activity.RESULT_CANCELED) { - cameraModule.removeImage(this) - setResult(RESULT_CANCELED) - finish() - return - } - if (requestCode == RC_CAMERA && resultCode == Activity.RESULT_OK) { - cameraModule.getImage(this, data) { images -> - val result = ImagePickerUtils.createResultIntent(images) - finishPickImages(result) - } - } - } - /* --------------------------------------------------- */ /* > ImagePickerInteractionListener Methods */ /* --------------------------------------------------- */ @@ -179,4 +183,4 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener setResult(RESULT_OK, result) finish() } -} \ No newline at end of file +} From 5979023893e20067ab918c73480bfdeedf135ef6 Mon Sep 17 00:00:00 2001 From: Kavita Patil Date: Sun, 23 Oct 2022 18:55:51 +0200 Subject: [PATCH 10/18] BugFix: Image count visible in the folder mode when moved from one folder to another (#410) * Fix image count issue in the app bar when the folder mode is selected * clean up * decrest the target SDK for now because android test issue https://issuetracker.google.com/issues/182098106 Co-authored-by: Esa Firman --- build.gradle | 2 +- .../imagepicker/features/ImagePickerFragment.kt | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 653c18d0..5a8449c5 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { ext { sdk = [ compileSdk: 33, - targetSdk : 33, + targetSdk : 30, minSdk : 21 ] } diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt index 7f72c402..866dda7e 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt @@ -32,7 +32,6 @@ import com.esafirm.imagepicker.helper.IpLogger import com.esafirm.imagepicker.helper.state.fetch import com.esafirm.imagepicker.model.Folder import com.esafirm.imagepicker.model.Image -import java.util.ArrayList class ImagePickerFragment : Fragment() { @@ -88,9 +87,9 @@ class ImagePickerFragment : Fragment() { if (::interactionListener.isInitialized.not()) { throw RuntimeException( "ImagePickerFragment needs an " + - "ImagePickerInteractionListener. This will be set automatically if the " + - "activity implements ImagePickerInteractionListener, and can be set manually " + - "with fragment.setInteractionListener(listener)." + "ImagePickerInteractionListener. This will be set automatically if the " + + "activity implements ImagePickerInteractionListener, and can be set manually " + + "with fragment.setInteractionListener(listener)." ) } @@ -184,7 +183,10 @@ class ImagePickerFragment : Fragment() { resources.configuration.orientation ).apply { val selectListener = { isSelected: Boolean -> selectImage(isSelected) } - val folderClick = { bucket: Folder -> setImageAdapter(bucket.images) } + val folderClick = { bucket: Folder -> + setImageAdapter(bucket.images) + updateTitle() + } setupAdapters(passedSelectedImages, selectListener, folderClick) setImageSelectedListener { selectedImages -> @@ -273,6 +275,7 @@ class ImagePickerFragment : Fragment() { shouldShowRequestPermissionRationale(permission) -> { requestPermissionLauncher.launch(permission) } + else -> { if (!preferences.isPermissionRequested()) { preferences.setPermissionIsRequested() @@ -384,7 +387,6 @@ class ImagePickerFragment : Fragment() { private const val STATE_KEY_SELECTED_IMAGES = "Key.SelectedImages" private const val RC_CAPTURE = 2000 - private const val RC_PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 23 fun newInstance(config: ImagePickerConfig): ImagePickerFragment { val args = Bundle().apply { @@ -395,4 +397,4 @@ class ImagePickerFragment : Fragment() { } } } -} \ No newline at end of file +} From ffeac4a4ea8ea1301ef550b7943d67c592aaf06a Mon Sep 17 00:00:00 2001 From: Esa Firman Date: Wed, 26 Oct 2022 07:38:16 +0700 Subject: [PATCH 11/18] upgrade AGP and Kotlin version (#416) * upgrade AGP and Kotlin version * update java version for github action to java 11 * fix instrumentation test setup * fix pick result to pass the test * remove unused code * skip lint on build * set max metaspace to 1g * fix wrong config --- .github/workflows/android.yml | 9 ++++---- build.gradle | 11 +++++----- gradle.properties | 3 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- imagepicker/build.gradle | 9 +++----- .../features/ImagePickerActivity.kt | 22 ++++++++----------- sample/build.gradle | 5 ++++- sample/src/androidTest/AndroidManifest.xml | 1 - .../com/esafirm/sample/CameraOnPickerTest.kt | 12 +++++----- .../java/com/esafirm/sample/CameraOnlyTest.kt | 15 ++++++------- .../java/com/esafirm/sample/CustomUiTest.kt | 11 +++++----- .../com/esafirm/sample/PickImageFolderMode.kt | 10 ++++----- .../esafirm/sample/PickImageFragmentTest.kt | 10 ++++----- .../com/esafirm/sample/PickImageSingleTest.kt | 10 ++++----- .../java/com/esafirm/sample/PickImageTest.kt | 10 ++++----- .../sample/helper/ImageGeneratorScenario.kt | 6 ++--- sample/src/main/AndroidManifest.xml | 2 ++ 17 files changed, 72 insertions(+), 76 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 42d1477e..4c015b9e 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -11,10 +11,11 @@ jobs: steps: - uses: actions/checkout@v2 - - name: set up JDK 1.8 - uses: actions/setup-java@v1 + - name: set up JDK 11 + uses: actions/setup-java@v2.4.0 with: - java-version: 1.8 + distribution: adopt-openj9 + java-version: '11' - name: Cache Gradle uses: actions/cache@v2 @@ -28,7 +29,7 @@ jobs: gradle- - name: Build with Gradle - run: ./gradlew build + run: ./gradlew build -x lint - name: Build test run: ./gradlew sample:assembleAndroidTest diff --git a/build.gradle b/build.gradle index 5a8449c5..d6b8dfb3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,21 @@ buildscript { - ext.kotlin_version = '1.4.32' + ext.kotlin_version = '1.6.21' ext.core_ktx_version = '1.3.2' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.2.1' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.android.tools.build:gradle:7.0.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } ext { sdk = [ - compileSdk: 33, - targetSdk : 30, - minSdk : 21 + compileSdk: 33, + targetSdk : 33, + minSdk : 21 ] } diff --git a/gradle.properties b/gradle.properties index ccd5dda1..c16f3ebc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,5 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -android.useAndroidX=true \ No newline at end of file +android.useAndroidX=true +org.gradle.jvmargs=-XX:MaxMetaSpaceSize=1g diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 856eac00..14e92a46 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip diff --git a/imagepicker/build.gradle b/imagepicker/build.gradle index 8b6713da..3facb44a 100644 --- a/imagepicker/build.gradle +++ b/imagepicker/build.gradle @@ -1,7 +1,6 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' -apply plugin: 'com.github.dcendents.android-maven' android { final sdk = rootProject.ext.sdk @@ -11,8 +10,6 @@ android { defaultConfig { minSdkVersion sdk.minSdk targetSdkVersion sdk.targetSdk - versionCode 1 - versionName "1.0" } buildFeatures { @@ -31,16 +28,16 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - lintOptions { + lint { abortOnError false } resourcePrefix "ef_" } -task sourcesJar(type: Jar) { +tasks.register("sourcesJar", Jar) { from android.sourceSets.main.java.srcDirs - classifier = 'sources' + archiveClassifier.set('sources') } artifacts { diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt index f142759e..8ece339f 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt @@ -41,22 +41,18 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener private val startForCameraResult = registerForActivityResult( ActivityResultContracts.StartActivityForResult() ) { result: ActivityResult -> - if (result.resultCode == Activity.RESULT_OK) { - val intent = result.data - // Handle the Intent - if (intent?.extras?.isEmpty == true) { - cameraModule.removeImage(this) - setResult(RESULT_CANCELED) - finish() - } else { - cameraModule.getImage(this, intent) { images -> - finishPickImages(ImagePickerUtils.createResultIntent(images)) - } - } - } else { + val resultCode = result.resultCode + if (resultCode == Activity.RESULT_CANCELED) { cameraModule.removeImage(this) setResult(RESULT_CANCELED) finish() + return@registerForActivityResult + } + if (resultCode == Activity.RESULT_OK) { + cameraModule.getImage(this, result.data) { images -> + val resultIntent = ImagePickerUtils.createResultIntent(images) + finishPickImages(resultIntent) + } } } diff --git a/sample/build.gradle b/sample/build.gradle index 6ead8d61..b2d397f0 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -7,7 +7,7 @@ android { compileSdkVersion sdk.compileSdk buildFeatures { - viewBinding true + viewBinding = true } defaultConfig { @@ -58,7 +58,10 @@ dependencies { androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion" androidTestImplementation "androidx.test:runner:$runnerVersion" androidTestImplementation "androidx.test:rules:$runnerVersion" + androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3' + androidTestImplementation "androidx.test:core:1.5.0-beta01" androidTestImplementation('com.adevinta.android:barista:3.10.0') { exclude group: 'org.jetbrains.kotlin' + exclude group: 'org.hamcrest' } } diff --git a/sample/src/androidTest/AndroidManifest.xml b/sample/src/androidTest/AndroidManifest.xml index 15b85903..ed239ee2 100644 --- a/sample/src/androidTest/AndroidManifest.xml +++ b/sample/src/androidTest/AndroidManifest.xml @@ -3,5 +3,4 @@ package="com.esafirm.sample"> - diff --git a/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt index 89ea64e3..55237056 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt @@ -5,26 +5,26 @@ import androidx.recyclerview.widget.RecyclerView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition import androidx.test.espresso.intent.Intents +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule -import com.esafirm.sample.utils.ViewAsserts -import com.esafirm.sample.utils.Views import com.adevinta.android.barista.intents.BaristaIntents.mockAndroidCamera import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions +import com.esafirm.sample.utils.ViewAsserts +import com.esafirm.sample.utils.Views import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @LargeTest -@RunWith(AndroidJUnit4ClassRunner::class) +@RunWith(AndroidJUnit4::class) class CameraOnPickerTest { @Rule @JvmField - val testRule = ActivityTestRule(MainActivity::class.java) + val testRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt index 58bd5ff1..50dc3ca7 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt @@ -10,28 +10,27 @@ import androidx.test.espresso.intent.Intents import androidx.test.espresso.intent.Intents.intending import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule -import androidx.test.runner.AndroidJUnit4 -import com.esafirm.sample.matchers.hasDrawable -import com.esafirm.sample.utils.ViewAsserts -import com.esafirm.sample.utils.Views import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed import com.adevinta.android.barista.intents.BaristaIntents.mockAndroidCamera import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn +import com.esafirm.sample.matchers.hasDrawable +import com.esafirm.sample.utils.ViewAsserts +import com.esafirm.sample.utils.Views import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @LargeTest -@RunWith(AndroidJUnit4ClassRunner::class) +@RunWith(AndroidJUnit4::class) class CameraOnlyTest { @Rule @JvmField - var testRule = ActivityTestRule(MainActivity::class.java) + var testRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt index 0a63d3d1..d21c4b98 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt @@ -4,25 +4,24 @@ package com.esafirm.sample import androidx.recyclerview.widget.RecyclerView import androidx.test.espresso.action.ViewActions import androidx.test.espresso.contrib.RecyclerViewActions +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule -import androidx.test.runner.AndroidJUnit4 +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views -import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @LargeTest -@RunWith(AndroidJUnit4ClassRunner::class) +@RunWith(AndroidJUnit4::class) class CustomUiTest { @Rule @JvmField - var testRule = ActivityTestRule(MainActivity::class.java) + var testRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt index e3d7a20d..398b7004 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt @@ -4,24 +4,24 @@ package com.esafirm.sample import androidx.recyclerview.widget.RecyclerView.ViewHolder import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views -import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @LargeTest -@RunWith(AndroidJUnit4ClassRunner::class) +@RunWith(AndroidJUnit4::class) class PickImageFolderMode { @Rule @JvmField - var mActivityTestRule = ActivityTestRule(MainActivity::class.java) + var mActivityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt index aa37571e..51846ff3 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt @@ -3,25 +3,25 @@ package com.esafirm.sample import androidx.recyclerview.widget.RecyclerView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule -import com.esafirm.sample.utils.Views import com.adevinta.android.barista.assertion.BaristaImageViewAssertions.assertHasAnyDrawable import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn +import com.esafirm.sample.utils.Views import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @LargeTest -@RunWith(AndroidJUnit4ClassRunner::class) +@RunWith(AndroidJUnit4::class) class PickImageFragmentTest { @Rule @JvmField - val mActivityTestRule = ActivityTestRule(MainActivity::class.java) + val mActivityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt index 4e199f6f..61cb0c63 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt @@ -4,24 +4,24 @@ package com.esafirm.sample import androidx.recyclerview.widget.RecyclerView.ViewHolder import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views -import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @LargeTest -@RunWith(AndroidJUnit4ClassRunner::class) +@RunWith(AndroidJUnit4::class) class PickImageSingleTest { @Rule @JvmField - var mActivityTestRule = ActivityTestRule(MainActivity::class.java) + var mActivityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt index ea6ea220..c239f1c1 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt @@ -10,24 +10,24 @@ import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition import androidx.test.espresso.matcher.ViewMatchers.isClickable import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner -import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule import com.esafirm.sample.matchers.hasDrawable import com.esafirm.sample.utils.Views -import org.hamcrest.Matchers.allOf +import org.hamcrest.CoreMatchers.allOf import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @LargeTest -@RunWith(AndroidJUnit4ClassRunner::class) +@RunWith(AndroidJUnit4::class) class PickImageTest { @Rule @JvmField - var mActivityTestRule = ActivityTestRule(MainActivity::class.java) + var mActivityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/helper/ImageGeneratorScenario.kt b/sample/src/androidTest/java/com/esafirm/sample/helper/ImageGeneratorScenario.kt index 3add0791..0ffca115 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/helper/ImageGeneratorScenario.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/helper/ImageGeneratorScenario.kt @@ -1,10 +1,10 @@ package com.esafirm.sample.helper +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.rule.ActivityTestRule import androidx.test.rule.GrantPermissionRule -import androidx.test.runner.AndroidJUnit4 import com.esafirm.sample.MainActivity import com.esafirm.sample.utils.ImageGenerator import org.junit.Ignore @@ -22,7 +22,7 @@ class ImageGeneratorScenario { @Rule @JvmField - var testRule = ActivityTestRule(MainActivity::class.java) + var testRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index acec947c..06b83b8a 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -22,6 +22,8 @@ + + From 32bd85d62b3c9f267c1d8e4998aad6c9add1001b Mon Sep 17 00:00:00 2001 From: Esa Firman Date: Thu, 27 Oct 2022 22:48:22 +0700 Subject: [PATCH 12/18] code cleanup (#421) --- build.gradle | 2 +- .../com/esafirm/imagepicker/helper/LocaleManager.kt | 13 +++++-------- .../com/esafirm/imagepicker/helper/ViewUtils.kt | 4 ++-- sample/build.gradle | 3 +-- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index d6b8dfb3..73c13fea 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,6 @@ allprojects { } } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/helper/LocaleManager.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/helper/LocaleManager.kt index 29e2f1f7..ec44d349 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/helper/LocaleManager.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/helper/LocaleManager.kt @@ -18,13 +18,8 @@ object LocaleManager { val res = resultContext.resources val config = Configuration(res.configuration) - if (Build.VERSION.SDK_INT >= 17) { - config.setLocale(locale) - resultContext = resultContext.createConfigurationContext(config) - } else { - config.locale = locale - res.updateConfiguration(config, res.displayMetrics) - } + config.setLocale(locale) + resultContext = resultContext.createConfigurationContext(config) return resultContext } @@ -43,6 +38,7 @@ object LocaleManager { ) locale } + newLocaleLanguage == ZH -> { locale = if (Locale.getDefault().country == TW) { Locale(ZH, TW) @@ -51,9 +47,10 @@ object LocaleManager { } locale } + else -> { localeLanguage } } } -} \ No newline at end of file +} diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/helper/ViewUtils.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/helper/ViewUtils.kt index cd2a6bb5..fde43e33 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/helper/ViewUtils.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/helper/ViewUtils.kt @@ -9,7 +9,7 @@ import com.esafirm.imagepicker.R object ViewUtils { fun getArrowIcon(context: Context): Drawable? { - val backResourceId: Int = if (Build.VERSION.SDK_INT >= 17 && context.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL) { + val backResourceId: Int = if (context.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL) { // For right-to-left layouts, pick the drawable that points to the right (forward). R.drawable.ef_ic_arrow_forward } else { @@ -18,4 +18,4 @@ object ViewUtils { } return ContextCompat.getDrawable(context.applicationContext, backResourceId) } -} \ No newline at end of file +} diff --git a/sample/build.gradle b/sample/build.gradle index b2d397f0..2bd30214 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -4,13 +4,12 @@ apply plugin: 'kotlin-android' android { final sdk = rootProject.ext.sdk - compileSdkVersion sdk.compileSdk - buildFeatures { viewBinding = true } defaultConfig { + compileSdk sdk.compileSdk minSdkVersion sdk.minSdk targetSdkVersion sdk.targetSdk From ee8abcb88384c9931fdf485c289f1ad3eecfd971 Mon Sep 17 00:00:00 2001 From: Esa Firman Date: Sat, 12 Nov 2022 07:27:28 +0700 Subject: [PATCH 13/18] Feature/add non sdk api strict mode (#423) * fix gradle properties metaspace * add strict mode to detect issue close #394 * add the app class to manifest * add xmx to 2g --- README.md | 68 ++++++++++--------- gradle.properties | 3 +- sample/src/main/AndroidManifest.xml | 3 +- .../main/java/com/esafirm/sample/SampleApp.kt | 22 ++++++ settings.gradle | 2 +- 5 files changed, 63 insertions(+), 35 deletions(-) create mode 100644 sample/src/main/java/com/esafirm/sample/SampleApp.kt diff --git a/README.md b/README.md index b6ea02a1..f46a07d6 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ And add this to your module's `build.gradle` ```groovy dependencies { - implementation 'com.github.esafirm:android-image-picker:x.y.z' + implementation 'com.github.esafirm:android-image-picker:x.y.z' } ``` @@ -49,7 +49,8 @@ change `x.y.z` to version in the [release page](https://github.com/esafirm/andro For full example, please refer to the `sample` app. -Also you can browse the issue labeled as question [here](https://github.com/esafirm/android-image-picker/issues?utf8=%E2%9C%93&q=label%3Aquestion+) +Also you can browse the issue labeled as +question [here](https://github.com/esafirm/android-image-picker/issues?utf8=%E2%9C%93&q=label%3Aquestion+) ## Start image picker activity @@ -57,7 +58,7 @@ The simplest way to start ```kotlin val launcher = registerImagePicker { - // handle result here + // handle result here } launcher.launch() @@ -67,33 +68,35 @@ Complete features of what you can do with ImagePicker ```kotlin val config = ImagePickerConfig { - mode = ImagePickerMode.SINGLE // default is multi image mode - language = "in" // Set image picker language - theme = R.style.ImagePickerTheme - - // set whether pick action or camera action should return immediate result or not. Only works in single mode for image picker - returnMode = if (returnAfterCapture) ReturnMode.ALL else ReturnMode.NONE - - isFolderMode = folderMode // set folder mode (false by default) - isIncludeVideo = includeVideo // include video (false by default) - isOnlyVideo = onlyVideo // include video (false by default) - arrowColor = Color.RED // set toolbar arrow up color - folderTitle = "Folder" // folder selection title - imageTitle = "Tap to select" // image selection title - doneButtonText = "DONE" // done button text - limit = 10 // max images can be selected (99 by default) - isShowCamera = true // show camera or not (true by default) - savePath = ImagePickerSavePath("Camera") // captured image directory name ("Camera" folder by default) - savePath = ImagePickerSavePath(Environment.getExternalStorageDirectory().path, isRelative = false) // can be a full path - - excludedImages = images.toFiles() // don't show anything on this selected images - selectedImages = images // original selected images, used in multi mode + mode = ImagePickerMode.SINGLE // default is multi image mode + language = "in" // Set image picker language + theme = R.style.ImagePickerTheme + + // set whether pick action or camera action should return immediate result or not. Only works in single mode for image picker + returnMode = if (returnAfterCapture) ReturnMode.ALL else ReturnMode.NONE + + isFolderMode = folderMode // set folder mode (false by default) + isIncludeVideo = includeVideo // include video (false by default) + isOnlyVideo = onlyVideo // include video (false by default) + arrowColor = Color.RED // set toolbar arrow up color + folderTitle = "Folder" // folder selection title + imageTitle = "Tap to select" // image selection title + doneButtonText = "DONE" // done button text + limit = 10 // max images can be selected (99 by default) + isShowCamera = true // show camera or not (true by default) + savePath = ImagePickerSavePath("Camera") // captured image directory name ("Camera" folder by default) + savePath = + ImagePickerSavePath(Environment.getExternalStorageDirectory().path, isRelative = false) // can be a full path + + excludedImages = images.toFiles() // don't show anything on this selected images + selectedImages = images // original selected images, used in multi mode } ``` If you want to call it outside `Activity` or `Fragment`, you can get the `Intent` with `createImagePickerIntent` -> Please note: handling in `onActivityResult` is not recommended since it's already deprecated in favor of the new result API +> Please note: handling in `onActivityResult` is not recommended since it's already deprecated in favor of the new +> result API ```kotlin val intent = createImagePickerIntent(context, ImagePickerConfig()) @@ -102,13 +105,14 @@ startActivityForResult(intent, RC_IMAGE_PICKER) ## Receive result -when you're done picking images, result will be returned on launcher callback with type `List`. This list cannot be null but can be empty +when you're done picking images, result will be returned on launcher callback with type `List`. This list cannot +be null but can be empty ```kotlin val launcher = registerImagePicker { result: List -> - result.forEach { image -> - println(image) - } + result.forEach { image -> + println(image) + } } ``` @@ -130,10 +134,10 @@ You also still can use the `DefaultCameraModule` but discouraged to do it. - [Return mode](https://github.com/esafirm/android-image-picker/blob/master/docs/return_mode.md) - [Save location](https://github.com/esafirm/android-image-picker/blob/master/docs/save_location.md) - # Version 2.x.x -If you still use the previous version, you can check `2.x` branch in [here](https://github.com/esafirm/android-image-picker/tree/2.x) +If you still use the previous version, you can check `2.x` branch +in [here](https://github.com/esafirm/android-image-picker/tree/2.x) # Support Me! @@ -149,4 +153,4 @@ Would you help me achieving this goals? # License -MIT @ Esa Firman \ No newline at end of file +MIT @ Esa Firman diff --git a/gradle.properties b/gradle.properties index c16f3ebc..e77c8538 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,5 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true android.useAndroidX=true -org.gradle.jvmargs=-XX:MaxMetaSpaceSize=1g +org.gradle.jvmargs=-XX:MaxMetaspaceSize=1g +org.gradle.jvmargs=-Xmx2g diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 06b83b8a..c0b640b6 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -7,7 +7,8 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + android:name=".SampleApp"> diff --git a/sample/src/main/java/com/esafirm/sample/SampleApp.kt b/sample/src/main/java/com/esafirm/sample/SampleApp.kt new file mode 100644 index 00000000..99a6c4de --- /dev/null +++ b/sample/src/main/java/com/esafirm/sample/SampleApp.kt @@ -0,0 +1,22 @@ +package com.esafirm.sample + +import android.app.Application +import android.os.Build +import android.os.StrictMode + +class SampleApp : Application() { + override fun onCreate() { + super.onCreate() + + // Check if we ever get this issue + // https://github.com/esafirm/android-image-picker/issues/394 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + StrictMode.setVmPolicy( + StrictMode.VmPolicy.Builder() + .detectNonSdkApiUsage() + .penaltyLog() + .build() + ) + } + } +} diff --git a/settings.gradle b/settings.gradle index cbe2dbd9..dccb8625 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':imagepicker', ':rximagepicker', ':sample' +include ':imagepicker', ':sample' From 514f7eda429db80459bdbb9962ac7fb077be919b Mon Sep 17 00:00:00 2001 From: Abrar Wiryawan Date: Sun, 20 Nov 2022 05:43:01 +0700 Subject: [PATCH 14/18] update `save_location.md` to reflect current API (#425) --- docs/save_location.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/save_location.md b/docs/save_location.md index a2bcaa9f..94cf01f1 100644 --- a/docs/save_location.md +++ b/docs/save_location.md @@ -2,14 +2,21 @@ By default, ImagePicker will try to save the image generated from camera to `Environment.DIRECTORY_PICTURES` with directory name `"Camera"`. -You can change the directory name only by using: +You can change the directory name by using: -```java -ImagePicker.create(activity).imageDirectory(String dirName) -``` +```kotlin +val config = ImagePickerConfig { + savePath = ImagePickerSavePath(dirName) +} +``` Or you can change the full path of the save location by using: -```java -ImagePicker.create(activity).imageFullDirectory(String fullPath) +```kotlin +val config = ImagePickerConfig { + savePath = ImagePickerSavePath( + path = fullPath, + isRelative = false, + ) +} ``` From 5ff7914d79ab828d3c9f1dfc94b3cc10f68ef189 Mon Sep 17 00:00:00 2001 From: Abrar Wiryawan Date: Sun, 20 Nov 2022 05:44:29 +0700 Subject: [PATCH 15/18] update `custom_components.md` to use Kotlin and reflect current API (#424) * update `custom_components.md` to reflect current API * add explanation about creating custom ImagePickerComponents --- docs/custom_components.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/custom_components.md b/docs/custom_components.md index 77aeefcd..2cab7209 100644 --- a/docs/custom_components.md +++ b/docs/custom_components.md @@ -1,12 +1,23 @@ # Custom Components You also can change how to process the image and how to get the image files through `ImageLoader` and `ImageFileLoader` -To change this, simply set it on `ImagePickerComponentHolder` +To change this, first, create custom `ImagePickerComponents`. +You could inherit from `DefaultImagePickerComponents` or directly implements from `ImagePickerComponents` interface. -```java -ImagePickerComponentHolder.getInstance() - .setImageLoader(new GrayScaleImageLoader()) - .setImageFileLoader(new WebpImageFileLoader()) -``` +```kotlin +class CustomImagePickerComponents( + context: Context +) : DefaultImagePickerComponents(context.applicationContext) { + override val imageLoader: ImageLoader + get() = GrayscaleImageLoader() +} +``` -Happy coding! \ No newline at end of file +Then, use it by calling `setInternalComponent` on `ImagePickerComponentsHolder`. +```kotlin +ImagePickerComponentsHolder.setInternalComponent( + CustomImagePickerComponents(context) +) +``` + +Happy coding! From 6369bf29f0cd642779b69d5adc931a1dcd34c646 Mon Sep 17 00:00:00 2001 From: Esa Firman Date: Sun, 20 Nov 2022 11:46:19 +0700 Subject: [PATCH 16/18] Fix/handle scoped storage again (#431) * request right permission * adjust connected test --- imagepicker/src/main/AndroidManifest.xml | 7 ++- .../features/ImagePickerFragment.kt | 52 +++++++++++-------- .../com/esafirm/sample/CameraOnPickerTest.kt | 5 +- .../java/com/esafirm/sample/CameraOnlyTest.kt | 6 +-- .../java/com/esafirm/sample/CustomUiTest.kt | 6 +-- .../com/esafirm/sample/PickImageFolderMode.kt | 4 +- .../esafirm/sample/PickImageFragmentTest.kt | 5 +- .../com/esafirm/sample/PickImageSingleTest.kt | 4 +- .../java/com/esafirm/sample/PickImageTest.kt | 4 +- .../java/com/esafirm/sample/utils/Rules.kt | 20 +++++++ 10 files changed, 70 insertions(+), 43 deletions(-) create mode 100644 sample/src/androidTest/java/com/esafirm/sample/utils/Rules.kt diff --git a/imagepicker/src/main/AndroidManifest.xml b/imagepicker/src/main/AndroidManifest.xml index d47672f4..951393b0 100644 --- a/imagepicker/src/main/AndroidManifest.xml +++ b/imagepicker/src/main/AndroidManifest.xml @@ -3,8 +3,13 @@ package="com.esafirm.imagepicker"> - + + + + = Build.VERSION_CODES.TIRAMISU) { - Manifest.permission.READ_MEDIA_IMAGES - } else Manifest.permission.WRITE_EXTERNAL_STORAGE + private val permissions: Array by lazy { + when { + Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> + arrayOf(Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VIDEO) + + Build.VERSION.SDK_INT < Build.VERSION_CODES.Q + || Environment.isExternalStorageLegacy() -> arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE) + + else -> arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE) } + } private val requestPermissionLauncher = - registerForActivityResult(RequestPermission()) { isGranted -> + registerForActivityResult(RequestMultiplePermissions()) { resultMap -> + val isGranted = resultMap.values.all { it } if (isGranted) { IpLogger.d("Write External permission granted") loadData() @@ -254,8 +261,10 @@ class ImagePickerFragment : Fragment() { * Check permission */ private fun loadDataWithPermission() { - val rc = ActivityCompat.checkSelfPermission(requireContext(), permission) - if (rc == PackageManager.PERMISSION_GRANTED) { + val allGranted = permissions.all { + ActivityCompat.checkSelfPermission(requireContext(), it) == PackageManager.PERMISSION_GRANTED + } + if (allGranted) { loadData() } else { requestWriteExternalOrReadImagesPermission() @@ -271,20 +280,19 @@ class ImagePickerFragment : Fragment() { */ private fun requestWriteExternalOrReadImagesPermission() { IpLogger.w("Write External permission or Read Media Images is not granted. Requesting permission") - when { - shouldShowRequestPermissionRationale(permission) -> { - requestPermissionLauncher.launch(permission) - } - else -> { - if (!preferences.isPermissionRequested()) { - preferences.setPermissionIsRequested() - requestPermissionLauncher.launch(permission) - } else { - binding?.efSnackbar?.show(R.string.ef_msg_no_write_external_permission) { - openAppSettings() - } - } + val shouldProvideRationale = permissions.any { permission -> shouldShowRequestPermissionRationale(permission) } + if (shouldProvideRationale) { + requestPermissionLauncher.launch(permissions) + return + } + + if (!preferences.isPermissionRequested()) { + preferences.setPermissionIsRequested() + requestPermissionLauncher.launch(permissions) + } else { + binding?.efSnackbar?.show(R.string.ef_msg_no_write_external_permission) { + openAppSettings() } } } diff --git a/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt index 55237056..2b0ad38e 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt @@ -12,6 +12,7 @@ import androidx.test.rule.GrantPermissionRule import com.adevinta.android.barista.intents.BaristaIntents.mockAndroidCamera import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions +import com.esafirm.sample.utils.Rules import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views import org.junit.Rule @@ -28,9 +29,7 @@ class CameraOnPickerTest { @Rule @JvmField - val grantPermissionRule = GrantPermissionRule.grant( - "android.permission.WRITE_EXTERNAL_STORAGE" - ) + val grantPermissionRule = Rules.AIP_PERMISSIONS private fun callCamera() { Intents.init() diff --git a/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt index 50dc3ca7..e6e29ccf 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt @@ -13,11 +13,11 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.rule.GrantPermissionRule import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed import com.adevinta.android.barista.intents.BaristaIntents.mockAndroidCamera import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.esafirm.sample.matchers.hasDrawable +import com.esafirm.sample.utils.Rules import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views import org.junit.Rule @@ -34,9 +34,7 @@ class CameraOnlyTest { @Rule @JvmField - var grantPermissionRule = GrantPermissionRule.grant( - "android.permission.WRITE_EXTERNAL_STORAGE" - ) + val grantPermissionRule = Rules.AIP_PERMISSIONS private fun runCameraOnly() { Intents.init() diff --git a/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt index d21c4b98..ba6f8985 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt @@ -7,8 +7,8 @@ import androidx.test.espresso.contrib.RecyclerViewActions import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.rule.GrantPermissionRule import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn +import com.esafirm.sample.utils.Rules import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views import org.junit.Rule @@ -25,9 +25,7 @@ class CustomUiTest { @Rule @JvmField - var grantPermissionRule = GrantPermissionRule.grant( - "android.permission.WRITE_EXTERNAL_STORAGE" - ) + val grantPermissionRule = Rules.AIP_PERMISSIONS @Test fun cameraOnlyTestTwo() { diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt index 398b7004..e406638b 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt @@ -7,8 +7,8 @@ import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.rule.GrantPermissionRule import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn +import com.esafirm.sample.utils.Rules import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views import org.junit.Rule @@ -25,7 +25,7 @@ class PickImageFolderMode { @Rule @JvmField - var mGrantPermissionRule = GrantPermissionRule.grant("android.permission.WRITE_EXTERNAL_STORAGE") + val grantPermissionRule = Rules.AIP_PERMISSIONS @Test fun pickImage() { diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt index 51846ff3..18e8b9c9 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt @@ -6,10 +6,10 @@ import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.rule.GrantPermissionRule import com.adevinta.android.barista.assertion.BaristaImageViewAssertions.assertHasAnyDrawable import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn +import com.esafirm.sample.utils.Rules import com.esafirm.sample.utils.Views import org.junit.Rule import org.junit.Test @@ -25,8 +25,7 @@ class PickImageFragmentTest { @Rule @JvmField - val mGrantPermissionRule = - GrantPermissionRule.grant("android.permission.WRITE_EXTERNAL_STORAGE") + val grantPermissionRule = Rules.AIP_PERMISSIONS @Test fun pickImage() { diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt index 61cb0c63..b0f8cb3c 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt @@ -7,8 +7,8 @@ import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.rule.GrantPermissionRule import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn +import com.esafirm.sample.utils.Rules import com.esafirm.sample.utils.ViewAsserts import com.esafirm.sample.utils.Views import org.junit.Rule @@ -25,7 +25,7 @@ class PickImageSingleTest { @Rule @JvmField - var mGrantPermissionRule = GrantPermissionRule.grant("android.permission.WRITE_EXTERNAL_STORAGE") + val grantPermissionRule = Rules.AIP_PERMISSIONS @Test fun pickImage() { diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt index c239f1c1..d392c728 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt @@ -13,8 +13,8 @@ import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest -import androidx.test.rule.GrantPermissionRule import com.esafirm.sample.matchers.hasDrawable +import com.esafirm.sample.utils.Rules import com.esafirm.sample.utils.Views import org.hamcrest.CoreMatchers.allOf import org.junit.Rule @@ -31,7 +31,7 @@ class PickImageTest { @Rule @JvmField - var mGrantPermissionRule = GrantPermissionRule.grant("android.permission.WRITE_EXTERNAL_STORAGE") + val grantPermissionRule = Rules.AIP_PERMISSIONS @Test fun pickImage() { diff --git a/sample/src/androidTest/java/com/esafirm/sample/utils/Rules.kt b/sample/src/androidTest/java/com/esafirm/sample/utils/Rules.kt new file mode 100644 index 00000000..13aad476 --- /dev/null +++ b/sample/src/androidTest/java/com/esafirm/sample/utils/Rules.kt @@ -0,0 +1,20 @@ +package com.esafirm.sample.utils + +import android.os.Build +import androidx.test.rule.GrantPermissionRule + +object Rules { + val AIP_PERMISSIONS: GrantPermissionRule by lazy { + // Tiramisu + if (Build.VERSION.SDK_INT >= 31) { + GrantPermissionRule.grant( + "android.permission.READ_MEDIA_IMAGES", + "android.permission.READ_MEDIA_VIDEO" + ) + } else { + GrantPermissionRule.grant( + "android.permission.READ_EXTERNAL_STORAGE" + ) + } + } +} From 9045e4a307ecbcbcde536147537950de2e5e0abf Mon Sep 17 00:00:00 2001 From: Abrar Wiryawan Date: Sun, 20 Nov 2022 15:08:06 +0700 Subject: [PATCH 17/18] fix Wiki links pointing to `master` instead of `main` (#430) --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f46a07d6..bc4d9b75 100644 --- a/README.md +++ b/README.md @@ -129,10 +129,10 @@ You also still can use the `DefaultCameraModule` but discouraged to do it. # Wiki -- [Custom components](https://github.com/esafirm/android-image-picker/blob/master/docs/custom_components.md) -- [Using another image library](https://github.com/esafirm/android-image-picker/blob/master/docs/another_image_library.md) -- [Return mode](https://github.com/esafirm/android-image-picker/blob/master/docs/return_mode.md) -- [Save location](https://github.com/esafirm/android-image-picker/blob/master/docs/save_location.md) +- [Custom components](https://github.com/esafirm/android-image-picker/blob/main/docs/custom_components.md) +- [Using another image library](https://github.com/esafirm/android-image-picker/blob/main/docs/another_image_library.md) +- [Return mode](https://github.com/esafirm/android-image-picker/blob/main/docs/return_mode.md) +- [Save location](https://github.com/esafirm/android-image-picker/blob/main/docs/save_location.md) # Version 2.x.x From 13e3bea95828150901cf7cc43d9f045dbe23bda5 Mon Sep 17 00:00:00 2001 From: Abrar Wiryawan Date: Mon, 21 Nov 2022 08:10:21 +0700 Subject: [PATCH 18/18] replace KAE with `kotlin-parcelize` and update dependencies (#429) * replace KAE plugin with `kotlin-parcelize` and update dependencies * fix unit test "test even not received" * upgrade AGP version and rename test rule for consistency --- build.gradle | 6 ++--- imagepicker/build.gradle | 23 +++++++++++------ imagepicker/src/main/AndroidManifest.xml | 3 +-- .../adapter/FolderPickerAdapter.kt | 21 +++++++--------- .../imagepicker/adapter/ImagePickerAdapter.kt | 24 ++++++++---------- .../imagepicker/features/ImagePickerConfig.kt | 4 ++- .../features/ImagePickerSavePath.kt | 2 +- .../features/cameraonly/CameraOnlyConfig.kt | 2 +- .../com/esafirm/imagepicker/model/Image.kt | 4 +-- .../esafirm/imagepicker/view/SnackBarView.kt | 9 +++---- ...ackbar.xml => ef_imagepicker_snackbar.xml} | 0 sample/build.gradle | 25 ++++++++++--------- sample/src/androidTest/AndroidManifest.xml | 3 +-- .../com/esafirm/sample/CameraOnPickerTest.kt | 2 +- .../java/com/esafirm/sample/CameraOnlyTest.kt | 2 +- .../java/com/esafirm/sample/CustomUiTest.kt | 2 +- .../com/esafirm/sample/PickImageFolderMode.kt | 2 +- .../esafirm/sample/PickImageFragmentTest.kt | 2 +- .../com/esafirm/sample/PickImageSingleTest.kt | 2 +- .../java/com/esafirm/sample/PickImageTest.kt | 2 +- sample/src/main/AndroidManifest.xml | 3 +-- 21 files changed, 72 insertions(+), 71 deletions(-) rename imagepicker/src/main/res/layout/{ef_imagepikcer_snackbar.xml => ef_imagepicker_snackbar.xml} (100%) diff --git a/build.gradle b/build.gradle index 73c13fea..6038229b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.21' - ext.core_ktx_version = '1.3.2' + ext.kotlin_version = '1.7.20' + ext.core_ktx_version = '1.9.0' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' + classpath 'com.android.tools.build:gradle:7.3.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/imagepicker/build.gradle b/imagepicker/build.gradle index 3facb44a..1921b3c9 100644 --- a/imagepicker/build.gradle +++ b/imagepicker/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' +plugins { + id "com.android.library" + id "kotlin-android" + id "kotlin-parcelize" +} android { final sdk = rootProject.ext.sdk @@ -32,7 +34,14 @@ android { abortOnError false } + testOptions { + unitTests.all { + useJUnitPlatform() + } + } + resourcePrefix "ef_" + namespace 'com.esafirm.imagepicker' } tasks.register("sourcesJar", Jar) { @@ -45,16 +54,14 @@ artifacts { } dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation "com.github.bumptech.glide:glide:4.11.0" + implementation "com.github.bumptech.glide:glide:4.14.2" implementation 'androidx.recyclerview:recyclerview:1.2.1' - implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'androidx.appcompat:appcompat:1.5.1' implementation "androidx.core:core-ktx:$core_ktx_version" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation platform("org.junit:junit-bom:5.7.1") + testImplementation platform("org.junit:junit-bom:5.9.1") testImplementation "org.junit.jupiter:junit-jupiter" testImplementation 'com.natpryce:hamkrest:1.8.0.1' } diff --git a/imagepicker/src/main/AndroidManifest.xml b/imagepicker/src/main/AndroidManifest.xml index 951393b0..ef32f53a 100644 --- a/imagepicker/src/main/AndroidManifest.xml +++ b/imagepicker/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + = mutableListOf() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FolderViewHolder { - val layout = inflater.inflate( - R.layout.ef_imagepicker_item_folder, + val binding = EfImagepickerItemFolderBinding.inflate( + LayoutInflater.from(parent.context), parent, false ) - return FolderViewHolder(layout) + return FolderViewHolder(binding) } override fun onBindViewHolder(holder: FolderViewHolder, position: Int) { @@ -54,9 +51,9 @@ class FolderPickerAdapter( override fun getItemCount() = folders.size - class FolderViewHolder(itemView: View) : ViewHolder(itemView) { - val image: ImageView = itemView.image - val name: TextView = itemView.tv_name - val number: TextView = itemView.tv_number + class FolderViewHolder(binding: EfImagepickerItemFolderBinding) : ViewHolder(binding.root) { + val image = binding.image + val name = binding.tvName + val number = binding.tvNumber } } \ No newline at end of file diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/adapter/ImagePickerAdapter.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/adapter/ImagePickerAdapter.kt index 99f625ac..60585429 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/adapter/ImagePickerAdapter.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/adapter/ImagePickerAdapter.kt @@ -3,16 +3,16 @@ package com.esafirm.imagepicker.adapter import android.content.Context import android.net.Uri import android.provider.MediaStore +import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.FrameLayout -import android.widget.ImageView -import android.widget.TextView import androidx.core.content.ContextCompat import androidx.recyclerview.widget.AsyncListDiffer import androidx.recyclerview.widget.RecyclerView.ViewHolder import com.esafirm.imagepicker.R import com.esafirm.imagepicker.adapter.ImagePickerAdapter.ImageViewHolder +import com.esafirm.imagepicker.databinding.EfImagepickerItemImageBinding import com.esafirm.imagepicker.features.imageloader.ImageLoader import com.esafirm.imagepicker.features.imageloader.ImageType import com.esafirm.imagepicker.helper.ImagePickerUtils @@ -20,8 +20,6 @@ import com.esafirm.imagepicker.helper.diff.SimpleDiffUtilCallBack import com.esafirm.imagepicker.listeners.OnImageClickListener import com.esafirm.imagepicker.listeners.OnImageSelectedListener import com.esafirm.imagepicker.model.Image -import kotlinx.android.synthetic.main.ef_imagepicker_item_image.view.* -import java.util.HashMap class ImagePickerAdapter( context: Context, @@ -46,12 +44,12 @@ class ImagePickerAdapter( } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ImageViewHolder { - val layout = inflater.inflate( - R.layout.ef_imagepicker_item_image, + val binding = EfImagepickerItemImageBinding.inflate( + LayoutInflater.from(parent.context), parent, false ) - return ImageViewHolder(layout) + return ImageViewHolder(binding) } override fun onBindViewHolder(viewHolder: ImageViewHolder, position: Int) { @@ -94,7 +92,7 @@ class ImagePickerAdapter( addSelected(image, position) } } - container?.foreground = if (isSelected) ContextCompat.getDrawable( + container.foreground = if (isSelected) ContextCompat.getDrawable( context, R.drawable.ef_ic_done_white ) else null @@ -143,10 +141,10 @@ class ImagePickerAdapter( private fun getItem(position: Int) = listDiffer.currentList.getOrNull(position) - class ImageViewHolder(itemView: View) : ViewHolder(itemView) { - val imageView: ImageView = itemView.image_view - val alphaView: View = itemView.view_alpha - val fileTypeIndicator: TextView = itemView.ef_item_file_type_indicator - val container: FrameLayout? = itemView as? FrameLayout + class ImageViewHolder(binding: EfImagepickerItemImageBinding) : ViewHolder(binding.root) { + val imageView = binding.imageView + val alphaView = binding.viewAlpha + val fileTypeIndicator = binding.efItemFileTypeIndicator + val container = binding.root as FrameLayout } } \ No newline at end of file diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt index d8f41764..2e266a41 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt @@ -5,7 +5,8 @@ import androidx.annotation.StyleRes import com.esafirm.imagepicker.features.common.BaseConfig import com.esafirm.imagepicker.helper.IpLogger import com.esafirm.imagepicker.model.Image -import kotlinx.android.parcel.Parcelize +import kotlinx.parcelize.IgnoredOnParcel +import kotlinx.parcelize.Parcelize import java.io.File @Parcelize @@ -30,6 +31,7 @@ class ImagePickerConfig( var showDoneButtonAlways: Boolean = false ) : BaseConfig(), Parcelable { + @IgnoredOnParcel @Transient var language: String? = null diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerSavePath.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerSavePath.kt index 075bbb5a..0ee1922d 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerSavePath.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerSavePath.kt @@ -1,7 +1,7 @@ package com.esafirm.imagepicker.features import android.os.Parcelable -import kotlinx.android.parcel.Parcelize +import kotlinx.parcelize.Parcelize @Parcelize class ImagePickerSavePath( diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/cameraonly/CameraOnlyConfig.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/cameraonly/CameraOnlyConfig.kt index 90bb19a3..e7489567 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/cameraonly/CameraOnlyConfig.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/cameraonly/CameraOnlyConfig.kt @@ -4,7 +4,7 @@ import android.os.Parcelable import com.esafirm.imagepicker.features.ImagePickerSavePath import com.esafirm.imagepicker.features.ReturnMode import com.esafirm.imagepicker.features.common.BaseConfig -import kotlinx.android.parcel.Parcelize +import kotlinx.parcelize.Parcelize @Parcelize class CameraOnlyConfig( diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/model/Image.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/model/Image.kt index 23d401c7..44631615 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/model/Image.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/model/Image.kt @@ -5,8 +5,8 @@ import android.net.Uri import android.os.Parcelable import android.provider.MediaStore import com.esafirm.imagepicker.helper.ImagePickerUtils -import kotlinx.android.parcel.IgnoredOnParcel -import kotlinx.android.parcel.Parcelize +import kotlinx.parcelize.IgnoredOnParcel +import kotlinx.parcelize.Parcelize @Parcelize class Image( diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/view/SnackBarView.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/view/SnackBarView.kt index 553b0a58..d56c4208 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/view/SnackBarView.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/view/SnackBarView.kt @@ -4,22 +4,21 @@ import android.content.Context import android.util.AttributeSet import android.view.animation.Interpolator import android.widget.RelativeLayout +import android.widget.TextView import androidx.annotation.StringRes import androidx.interpolator.view.animation.FastOutLinearInInterpolator import com.esafirm.imagepicker.R -import kotlinx.android.synthetic.main.ef_imagepikcer_snackbar.view.* class SnackBarView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyle: Int = 0 ) : RelativeLayout(context, attrs, defStyle) { - - private val txtCaption get() = ef_snackbar_txt_bottom_caption - private val btnAction get() = ef_snackbar_btn_action + private val txtCaption get() = findViewById(R.id.ef_snackbar_txt_bottom_caption) + private val btnAction get() = findViewById(R.id.ef_snackbar_btn_action) init { - inflate(context, R.layout.ef_imagepikcer_snackbar, this) + inflate(context, R.layout.ef_imagepicker_snackbar, this) if (!isInEditMode) { val height = context.resources.getDimensionPixelSize(R.dimen.ef_height_snackbar) translationY = height.toFloat() diff --git a/imagepicker/src/main/res/layout/ef_imagepikcer_snackbar.xml b/imagepicker/src/main/res/layout/ef_imagepicker_snackbar.xml similarity index 100% rename from imagepicker/src/main/res/layout/ef_imagepikcer_snackbar.xml rename to imagepicker/src/main/res/layout/ef_imagepicker_snackbar.xml diff --git a/sample/build.gradle b/sample/build.gradle index 2bd30214..c281a616 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,5 +1,7 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' +plugins { + id "com.android.application" + id "kotlin-android" +} android { final sdk = rootProject.ext.sdk @@ -36,13 +38,12 @@ android { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() } + namespace 'com.esafirm.sample' } dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - - implementation "com.github.bumptech.glide:glide:4.10.0" - implementation "androidx.appcompat:appcompat:1.2.0" + implementation "com.github.bumptech.glide:glide:4.14.2" + implementation "androidx.appcompat:appcompat:1.5.1" /* Development */ implementation project(':imagepicker') @@ -51,15 +52,15 @@ dependencies { implementation "androidx.core:core-ktx:$core_ktx_version" /* UI Test */ - final espressoVersion = '3.3.0' - final runnerVersion = '1.3.0' + final espressoVersion = '3.5.0' + final runnerVersion = '1.5.1' androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion" androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion" androidTestImplementation "androidx.test:runner:$runnerVersion" - androidTestImplementation "androidx.test:rules:$runnerVersion" - androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3' - androidTestImplementation "androidx.test:core:1.5.0-beta01" - androidTestImplementation('com.adevinta.android:barista:3.10.0') { + androidTestImplementation "androidx.test:rules:1.5.0" + androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.4' + androidTestImplementation "androidx.test:core:1.5.0" + androidTestImplementation('com.adevinta.android:barista:4.2.0') { exclude group: 'org.jetbrains.kotlin' exclude group: 'org.hamcrest' } diff --git a/sample/src/androidTest/AndroidManifest.xml b/sample/src/androidTest/AndroidManifest.xml index ed239ee2..236318ef 100644 --- a/sample/src/androidTest/AndroidManifest.xml +++ b/sample/src/androidTest/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt index 2b0ad38e..d3a605bd 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CameraOnPickerTest.kt @@ -25,7 +25,7 @@ class CameraOnPickerTest { @Rule @JvmField - val testRule = ActivityScenarioRule(MainActivity::class.java) + val activityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt index e6e29ccf..ccd42a6b 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CameraOnlyTest.kt @@ -30,7 +30,7 @@ class CameraOnlyTest { @Rule @JvmField - var testRule = ActivityScenarioRule(MainActivity::class.java) + val activityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt b/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt index ba6f8985..30431d66 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/CustomUiTest.kt @@ -21,7 +21,7 @@ class CustomUiTest { @Rule @JvmField - var testRule = ActivityScenarioRule(MainActivity::class.java) + val activityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt index e406638b..1018a561 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageFolderMode.kt @@ -21,7 +21,7 @@ class PickImageFolderMode { @Rule @JvmField - var mActivityTestRule = ActivityScenarioRule(MainActivity::class.java) + val activityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt index 18e8b9c9..890acfdf 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageFragmentTest.kt @@ -21,7 +21,7 @@ class PickImageFragmentTest { @Rule @JvmField - val mActivityTestRule = ActivityScenarioRule(MainActivity::class.java) + val activityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt index b0f8cb3c..611f6b2d 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageSingleTest.kt @@ -21,7 +21,7 @@ class PickImageSingleTest { @Rule @JvmField - var mActivityTestRule = ActivityScenarioRule(MainActivity::class.java) + val activityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt b/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt index d392c728..41834830 100644 --- a/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt +++ b/sample/src/androidTest/java/com/esafirm/sample/PickImageTest.kt @@ -27,7 +27,7 @@ class PickImageTest { @Rule @JvmField - var mActivityTestRule = ActivityScenarioRule(MainActivity::class.java) + val activityTestRule = ActivityScenarioRule(MainActivity::class.java) @Rule @JvmField diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index c0b640b6..9f0f1622 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - +