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 @@ - +