From b8226f255cea8c54dedf4e7130f8c13b8ca255f9 Mon Sep 17 00:00:00 2001 From: Kavita Patil Date: Tue, 18 Oct 2022 01:16:08 +0200 Subject: [PATCH 1/3] Add video recording functionality when `OnlyVideo` option is selected and user clicks on camera icon --- .../features/ImagePickerComponentsHolder.kt | 5 +++ .../imagepicker/features/ImagePickerConfig.kt | 1 + .../features/ImagePickerFragment.kt | 6 +++- .../features/ImagePickerPresenter.kt | 16 ++++++++- .../features/camera/CameraModule.kt | 1 + .../features/camera/DefaultCameraModule.kt | 31 +++++++++++++++++ .../features/cameraonly/CameraOnlyConfig.kt | 3 +- .../imagepicker/features/common/BaseConfig.kt | 1 + .../imagepicker/helper/ImagePickerUtils.kt | 33 +++++++++++++++++++ 9 files changed, 94 insertions(+), 3 deletions(-) diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerComponentsHolder.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerComponentsHolder.kt index 55875fb1..f83407fb 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerComponentsHolder.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerComponentsHolder.kt @@ -13,6 +13,7 @@ interface ImagePickerComponents { val imageLoader: ImageLoader val imageFileLoader: ImageFileLoader val cameraModule: CameraModule + val videoModule: CameraModule } open class DefaultImagePickerComponents(context: Context) : ImagePickerComponents { @@ -20,6 +21,7 @@ open class DefaultImagePickerComponents(context: Context) : ImagePickerComponent override val imageLoader: ImageLoader by lazy { DefaultImageLoader() } override val imageFileLoader: ImageFileLoader by lazy { DefaultImageFileLoader(context.applicationContext) } override val cameraModule: CameraModule by lazy { DefaultCameraModule() } + override val videoModule: CameraModule by lazy { DefaultCameraModule() } } object ImagePickerComponentsHolder : ImagePickerComponents { @@ -38,6 +40,9 @@ object ImagePickerComponentsHolder : ImagePickerComponents { override val cameraModule: CameraModule get() = internalComponents.cameraModule + override val videoModule: CameraModule + get() = internalComponents.videoModule + fun setInternalComponent(components: ImagePickerComponents) { internalComponents = components } 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..044d28be 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt @@ -27,6 +27,7 @@ class ImagePickerConfig( override var savePath: ImagePickerSavePath = ImagePickerSavePath.DEFAULT, override var returnMode: ReturnMode = ReturnMode.NONE, override var isSaveImage: Boolean = true, + override var isSaveVideo: Boolean = true, var showDoneButtonAlways: Boolean = false ) : BaseConfig(), Parcelable { 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 23563fba..1eb02207 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt @@ -317,7 +317,11 @@ class ImagePickerFragment : Fragment() { if (!checkCameraAvailability(requireActivity())) { return } - presenter.captureImage(this, config, RC_CAPTURE) + if (config.isOnlyVideo) { + presenter.captureVideo(this, config, RC_CAPTURE) + } else{ + presenter.captureImage(this, config, RC_CAPTURE) + } } override fun onDestroy() { diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerPresenter.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerPresenter.kt index f62e005e..fb53bafd 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerPresenter.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerPresenter.kt @@ -22,7 +22,7 @@ internal class ImagePickerPresenter( ) : ImagePickerAction { private val cameraModule: CameraModule = ImagePickerComponentsHolder.cameraModule - + private val videoModule: CameraModule = ImagePickerComponentsHolder.videoModule private val stateObs = LiveDataObservableState( ImagePickerState(isLoading = true), usePostValue = true @@ -95,6 +95,20 @@ internal class ImagePickerPresenter( fragment.startActivityForResult(intent, requestCode) } + fun captureVideo(fragment: Fragment, config: BaseConfig, requestCode: Int) { + val context = fragment.requireContext().applicationContext + val intent = videoModule.getVideoIntent(fragment.requireContext(), config) + if (intent == null) { + Toast.makeText( + context, + context.getString(R.string.ef_error_create_image_file), + Toast.LENGTH_LONG + ).show() + return + } + fragment.startActivityForResult(intent, requestCode) + } + fun finishCaptureImage(context: Context, data: Intent?, config: BaseConfig?) { cameraModule.getImage(context, data) { images -> if (ConfigUtils.shouldReturn(config!!, true)) { diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/CameraModule.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/CameraModule.kt index ab5ed66c..592e32bf 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/CameraModule.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/CameraModule.kt @@ -9,6 +9,7 @@ typealias OnImageReadyListener = (List?) -> Unit interface CameraModule { fun getCameraIntent(context: Context, config: BaseConfig): Intent? + fun getVideoIntent(context: Context, config: BaseConfig): Intent? fun getImage(context: Context, intent: Intent?, imageReadyListener: OnImageReadyListener) fun removeImage(context: Context) } \ No newline at end of file diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/DefaultCameraModule.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/DefaultCameraModule.kt index 89b6a0c7..c810edce 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/DefaultCameraModule.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/DefaultCameraModule.kt @@ -35,6 +35,22 @@ class DefaultCameraModule : CameraModule { return intent } + override fun getVideoIntent(context: Context, config: BaseConfig): Intent? { + prepareForNewIntent() + + val intent = Intent(MediaStore.ACTION_VIDEO_CAPTURE) + val imageFile = ImagePickerUtils.createVideoFile(config.savePath, context) + + if (config.isSaveVideo && imageFile != null) { + val appContext = context.applicationContext + val uri = createVideoUri(appContext, imageFile) + intent.putExtra(MediaStore.EXTRA_OUTPUT, uri) + ImagePickerUtils.grantAppPermission(context, intent, uri) + currentUri = uri.toString() + } + return intent + } + private fun prepareForNewIntent() { currentImagePath = null currentUri = null @@ -55,6 +71,21 @@ class DefaultCameraModule : CameraModule { return UriUtils.uriForFile(appContext, imageFile) } + private fun createVideoUri(appContext: Context, videoFile: File): Uri? { + currentImagePath = "file:" + videoFile.absolutePath + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + + val values = ContentValues().apply { + put(MediaStore.Video.Media.DISPLAY_NAME, videoFile.name) + put(MediaStore.Video.Media.MIME_TYPE, "video/mp4") + } + val collection = + MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY) + return appContext.contentResolver.insert(collection, values) + } + return UriUtils.uriForFile(appContext, videoFile) + } + override fun getImage( context: Context, intent: Intent?, 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..132e4bb2 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 @@ -10,5 +10,6 @@ import kotlinx.android.parcel.Parcelize class CameraOnlyConfig( override var savePath: ImagePickerSavePath = ImagePickerSavePath.DEFAULT, override var returnMode: ReturnMode = ReturnMode.ALL, - override var isSaveImage: Boolean = true + override var isSaveImage: Boolean = true, + override var isSaveVideo: Boolean = true ) : BaseConfig(), Parcelable \ No newline at end of file diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/common/BaseConfig.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/common/BaseConfig.kt index 225ba8a3..e236513a 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/common/BaseConfig.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/common/BaseConfig.kt @@ -7,4 +7,5 @@ abstract class BaseConfig { abstract var savePath: ImagePickerSavePath abstract var returnMode: ReturnMode abstract var isSaveImage: Boolean + abstract var isSaveVideo: Boolean } \ No newline at end of file diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/helper/ImagePickerUtils.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/helper/ImagePickerUtils.kt index 807585a2..061c87d8 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/helper/ImagePickerUtils.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/helper/ImagePickerUtils.kt @@ -48,6 +48,27 @@ object ImagePickerUtils { return mediaStorageDir } + private fun createFileInDirectoryVideo(savePath: ImagePickerSavePath, context: Context): File? { + val path = savePath.path + val mediaStorageDir: File = if (savePath.isRelative) { + val parent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + context.getExternalFilesDir(Environment.DIRECTORY_MOVIES) + } else { + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + } + File(parent, path) + } else { + File(path) + } + if (!mediaStorageDir.exists()) { + if (!mediaStorageDir.mkdirs()) { + d("Oops! Failed create $path") + return null + } + } + return mediaStorageDir + } + fun createImageFile(savePath: ImagePickerSavePath, context: Context): File? { val mediaStorageDir = createFileInDirectory(savePath, context) ?: return null @@ -62,6 +83,18 @@ object ImagePickerUtils { return result } + fun createVideoFile(savePath: ImagePickerSavePath, context: Context): File? { + val mediaStorageDir = createFileInDirectoryVideo(savePath, context) ?: return null + val timeStamp = SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.getDefault()).format(Date()) + var result = File(mediaStorageDir, "VID_$timeStamp.mp4") + var counter = 0 + while (result.exists()) { + counter++ + result = File(mediaStorageDir, "VID_$timeStamp($counter).mp4") + } + return result + } + fun getNameFromFilePath(path: String): String { return if (path.contains(File.separator)) { path.substring(path.lastIndexOf(File.separator) + 1) From 7c7f704612e37e2cc499937860ae9a074cadee43 Mon Sep 17 00:00:00 2001 From: Kavita Patil Date: Wed, 26 Oct 2022 00:59:33 +0200 Subject: [PATCH 2/3] - Add video icon --- .../imagepicker/features/ImagePickerActivity.kt | 8 +++++++- .../imagepicker/features/ImagePickerConfig.kt | 1 + .../imagepicker/features/ImagePickerFragment.kt | 7 +++++++ .../src/main/res/drawable/ef_video_placeholder.xml | 12 ++++++++++++ .../src/main/res/menu/ef_image_picker_menu_main.xml | 6 ++++++ imagepicker/src/main/res/values-ar/strings.xml | 1 + imagepicker/src/main/res/values-ca/strings.xml | 1 + imagepicker/src/main/res/values-da/strings.xml | 1 + imagepicker/src/main/res/values-de/strings.xml | 1 + imagepicker/src/main/res/values-es-rES/strings.xml | 1 + imagepicker/src/main/res/values-fr/strings.xml | 1 + imagepicker/src/main/res/values-in/strings.xml | 1 + imagepicker/src/main/res/values-it/strings.xml | 1 + imagepicker/src/main/res/values-ja/strings.xml | 1 + imagepicker/src/main/res/values-ko/strings.xml | 1 + imagepicker/src/main/res/values-pt-rBR/strings.xml | 1 + imagepicker/src/main/res/values-ro/strings.xml | 1 + imagepicker/src/main/res/values-ru/strings.xml | 2 ++ imagepicker/src/main/res/values-sv-rSE/strings.xml | 1 + imagepicker/src/main/res/values-tr/strings.xml | 2 ++ imagepicker/src/main/res/values-uk/strings.xml | 2 ++ imagepicker/src/main/res/values-zh-rCN/strings.xml | 1 + imagepicker/src/main/res/values-zh-rTW/strings.xml | 1 + imagepicker/src/main/res/values/strings.xml | 1 + .../java/com/esafirm/sample/CustomUIActivity.kt | 13 ++++++++++--- .../main/java/com/esafirm/sample/MainActivity.kt | 1 + 26 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 imagepicker/src/main/res/drawable/ef_video_placeholder.xml 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..0c1c0518 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt @@ -87,7 +87,9 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener override fun onPrepareOptionsMenu(menu: Menu): Boolean { if (!isCameraOnly) { - menu.findItem(R.id.menu_camera).isVisible = config?.isShowCamera ?: true + menu.findItem(R.id.menu_camera).isVisible = + config?.isShowCamera == true && config?.isOnlyVideo == false + menu.findItem(R.id.menu_video).isVisible = config?.isShowVideo ?: true menu.findItem(R.id.menu_done).apply { title = ConfigUtils.getDoneButtonText(this@ImagePickerActivity, config!!) isVisible = imagePickerFragment.isShowDoneButton @@ -113,6 +115,10 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener imagePickerFragment.captureImage() return true } + if (id == R.id.menu_video) { + imagePickerFragment.captureVideo() + return true + } return super.onOptionsItemSelected(item) } 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 044d28be..e8810d9f 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt @@ -22,6 +22,7 @@ class ImagePickerConfig( var isOnlyVideo: Boolean = false, var isIncludeAnimation: Boolean = false, var isShowCamera: Boolean = true, + var isShowVideo: Boolean = true, var selectedImages: List = emptyList(), var excludedImages: List = emptyList(), override var savePath: ImagePickerSavePath = ImagePickerSavePath.DEFAULT, 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 1eb02207..15330a6e 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt @@ -324,6 +324,13 @@ class ImagePickerFragment : Fragment() { } } + fun captureVideo() { + if (!checkCameraAvailability(requireActivity())) { + return + } + presenter.captureVideo(this, config, RC_CAPTURE) + } + override fun onDestroy() { super.onDestroy() presenter.abortLoad() diff --git a/imagepicker/src/main/res/drawable/ef_video_placeholder.xml b/imagepicker/src/main/res/drawable/ef_video_placeholder.xml new file mode 100644 index 00000000..f70e0d01 --- /dev/null +++ b/imagepicker/src/main/res/drawable/ef_video_placeholder.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/imagepicker/src/main/res/menu/ef_image_picker_menu_main.xml b/imagepicker/src/main/res/menu/ef_image_picker_menu_main.xml index a0535829..1638dc14 100644 --- a/imagepicker/src/main/res/menu/ef_image_picker_menu_main.xml +++ b/imagepicker/src/main/res/menu/ef_image_picker_menu_main.xml @@ -9,6 +9,12 @@ app:showAsAction="always" tools:ignore="AlwaysShowAction" /> + + وافق انهي كاميرا + فيديو دليل أنقر لإختيار الصور diff --git a/imagepicker/src/main/res/values-ca/strings.xml b/imagepicker/src/main/res/values-ca/strings.xml index 5dbc994f..7fe78740 100644 --- a/imagepicker/src/main/res/values-ca/strings.xml +++ b/imagepicker/src/main/res/values-ca/strings.xml @@ -5,6 +5,7 @@ OK FET CÀMERA + VÍDEO Carpeta Toqueu per seleccionar imatges diff --git a/imagepicker/src/main/res/values-da/strings.xml b/imagepicker/src/main/res/values-da/strings.xml index 1955e0fd..a543520f 100644 --- a/imagepicker/src/main/res/values-da/strings.xml +++ b/imagepicker/src/main/res/values-da/strings.xml @@ -5,6 +5,7 @@ Ok Færdig Kamera + VIDEO Mappe Tryk for at vælge billeder diff --git a/imagepicker/src/main/res/values-de/strings.xml b/imagepicker/src/main/res/values-de/strings.xml index f3d51ffc..eb86553a 100644 --- a/imagepicker/src/main/res/values-de/strings.xml +++ b/imagepicker/src/main/res/values-de/strings.xml @@ -5,6 +5,7 @@ OK FERTIG KAMERA + VIDEO Verzeichnis Tippen um Bilder auszuwählen diff --git a/imagepicker/src/main/res/values-es-rES/strings.xml b/imagepicker/src/main/res/values-es-rES/strings.xml index 81f33617..0f5b6c99 100644 --- a/imagepicker/src/main/res/values-es-rES/strings.xml +++ b/imagepicker/src/main/res/values-es-rES/strings.xml @@ -5,6 +5,7 @@ OK HECHO CÁMARA + VIDEO Carpeta Toque para seleccionar imágenes diff --git a/imagepicker/src/main/res/values-fr/strings.xml b/imagepicker/src/main/res/values-fr/strings.xml index 90a7407a..66140301 100644 --- a/imagepicker/src/main/res/values-fr/strings.xml +++ b/imagepicker/src/main/res/values-fr/strings.xml @@ -5,6 +5,7 @@ OK TERMINER CAMERA + VIDÉO Dossier Toucher pour sélectionner des images diff --git a/imagepicker/src/main/res/values-in/strings.xml b/imagepicker/src/main/res/values-in/strings.xml index 5a4806fe..9c5b2384 100644 --- a/imagepicker/src/main/res/values-in/strings.xml +++ b/imagepicker/src/main/res/values-in/strings.xml @@ -5,6 +5,7 @@ OK SELESAI KAMERA + VIDEO Folder Ketuk untuk memilih gambar diff --git a/imagepicker/src/main/res/values-it/strings.xml b/imagepicker/src/main/res/values-it/strings.xml index 6db39f2a..9b642425 100644 --- a/imagepicker/src/main/res/values-it/strings.xml +++ b/imagepicker/src/main/res/values-it/strings.xml @@ -5,6 +5,7 @@ OK FATTO CAMERA + VIDEO Cartella Premi per selezionare l\'immagine diff --git a/imagepicker/src/main/res/values-ja/strings.xml b/imagepicker/src/main/res/values-ja/strings.xml index c4a31679..c6faa5c3 100644 --- a/imagepicker/src/main/res/values-ja/strings.xml +++ b/imagepicker/src/main/res/values-ja/strings.xml @@ -4,6 +4,7 @@ OK 完了 カメラ + ビデオ フォルダ 画像を選択 diff --git a/imagepicker/src/main/res/values-ko/strings.xml b/imagepicker/src/main/res/values-ko/strings.xml index db37f48b..684d5e71 100644 --- a/imagepicker/src/main/res/values-ko/strings.xml +++ b/imagepicker/src/main/res/values-ko/strings.xml @@ -5,6 +5,7 @@ 확인 완료 카메라 + 동영상 사진첩 이미지를 선택하세요 diff --git a/imagepicker/src/main/res/values-pt-rBR/strings.xml b/imagepicker/src/main/res/values-pt-rBR/strings.xml index 02860b5c..7e7544ef 100644 --- a/imagepicker/src/main/res/values-pt-rBR/strings.xml +++ b/imagepicker/src/main/res/values-pt-rBR/strings.xml @@ -5,6 +5,7 @@ OK FEITO CAMERA + VÍDEO Pasta Toque para selecionar as imagens diff --git a/imagepicker/src/main/res/values-ro/strings.xml b/imagepicker/src/main/res/values-ro/strings.xml index 65a4e439..978c8873 100644 --- a/imagepicker/src/main/res/values-ro/strings.xml +++ b/imagepicker/src/main/res/values-ro/strings.xml @@ -5,6 +5,7 @@ OK TERMINAT CAMERA + VIDEO Fișier Atingeți pentru a selecta imagini diff --git a/imagepicker/src/main/res/values-ru/strings.xml b/imagepicker/src/main/res/values-ru/strings.xml index c8039f46..99b74d81 100644 --- a/imagepicker/src/main/res/values-ru/strings.xml +++ b/imagepicker/src/main/res/values-ru/strings.xml @@ -4,6 +4,8 @@ ОК ГОТОВО КАМЕРА + ВИДЕО + Папка Коснитесь, чтобы выбрать Доступ запрещён diff --git a/imagepicker/src/main/res/values-sv-rSE/strings.xml b/imagepicker/src/main/res/values-sv-rSE/strings.xml index 3ff8482b..2374ac63 100644 --- a/imagepicker/src/main/res/values-sv-rSE/strings.xml +++ b/imagepicker/src/main/res/values-sv-rSE/strings.xml @@ -5,6 +5,7 @@ OK KLAR KAMERA + VIDEO Mapp Tryck för att välja bilder diff --git a/imagepicker/src/main/res/values-tr/strings.xml b/imagepicker/src/main/res/values-tr/strings.xml index ae9aa89c..df6c591d 100644 --- a/imagepicker/src/main/res/values-tr/strings.xml +++ b/imagepicker/src/main/res/values-tr/strings.xml @@ -3,6 +3,8 @@ TAMAM BİTTİ KAMERA + VİDEO + Görüntüleri seçmek için harici depolama alanına erişime izin ver Klasör diff --git a/imagepicker/src/main/res/values-uk/strings.xml b/imagepicker/src/main/res/values-uk/strings.xml index a2a84e6c..dea55d89 100644 --- a/imagepicker/src/main/res/values-uk/strings.xml +++ b/imagepicker/src/main/res/values-uk/strings.xml @@ -4,6 +4,8 @@ ОК ГОТОВО КАМЕРА + ВІДЕО + Папка Торкніться, щоб обрати Доступ заборонено diff --git a/imagepicker/src/main/res/values-zh-rCN/strings.xml b/imagepicker/src/main/res/values-zh-rCN/strings.xml index 950a7999..7fbe09cb 100644 --- a/imagepicker/src/main/res/values-zh-rCN/strings.xml +++ b/imagepicker/src/main/res/values-zh-rCN/strings.xml @@ -4,6 +4,7 @@ 完成 相机 + 视频 文件夹 选择照片 diff --git a/imagepicker/src/main/res/values-zh-rTW/strings.xml b/imagepicker/src/main/res/values-zh-rTW/strings.xml index 2392a5ef..6b353533 100644 --- a/imagepicker/src/main/res/values-zh-rTW/strings.xml +++ b/imagepicker/src/main/res/values-zh-rTW/strings.xml @@ -4,6 +4,7 @@ 完成 相機 + 視頻 檔案夹 選擇相片 diff --git a/imagepicker/src/main/res/values/strings.xml b/imagepicker/src/main/res/values/strings.xml index 74c80b92..92069d5c 100644 --- a/imagepicker/src/main/res/values/strings.xml +++ b/imagepicker/src/main/res/values/strings.xml @@ -5,6 +5,7 @@ OK DONE CAMERA + VIDEO Folder Tap to select images diff --git a/sample/src/main/java/com/esafirm/sample/CustomUIActivity.kt b/sample/src/main/java/com/esafirm/sample/CustomUIActivity.kt index 3440e9bd..388e8f82 100644 --- a/sample/src/main/java/com/esafirm/sample/CustomUIActivity.kt +++ b/sample/src/main/java/com/esafirm/sample/CustomUIActivity.kt @@ -87,11 +87,14 @@ class CustomUIActivity : AppCompatActivity() { } override fun onPrepareOptionsMenu(menu: Menu): Boolean { + if (config == null) super.onPrepareOptionsMenu(menu) val menuCamera = menu.findItem(com.esafirm.imagepicker.R.id.menu_camera) if (menuCamera != null) { - if (config != null) { - menuCamera.isVisible = config!!.isShowCamera - } + menuCamera.isVisible = config?.isShowCamera == true && config?.isOnlyVideo == false + } + val menuVideo = menu.findItem(com.esafirm.imagepicker.R.id.menu_video) + if (menuVideo != null) { + menuVideo.isVisible = config!!.isShowVideo } val menuDone = menu.findItem(com.esafirm.imagepicker.R.id.menu_done) if (menuDone != null) { @@ -118,6 +121,10 @@ class CustomUIActivity : AppCompatActivity() { imagePickerFragment.captureImage() return true } + if (id == com.esafirm.imagepicker.R.id.menu_video) { + imagePickerFragment.captureVideo() + return true + } return super.onOptionsItemSelected(item) } diff --git a/sample/src/main/java/com/esafirm/sample/MainActivity.kt b/sample/src/main/java/com/esafirm/sample/MainActivity.kt index 300f04fe..42b85f47 100644 --- a/sample/src/main/java/com/esafirm/sample/MainActivity.kt +++ b/sample/src/main/java/com/esafirm/sample/MainActivity.kt @@ -85,6 +85,7 @@ class MainActivity : AppCompatActivity() { showDoneButtonAlways = true // Show done button always or not limit = 10 // max images can be selected (99 by default) isShowCamera = true // show camera or not (true by default) + isShowVideo = true // show video 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 From 34ececf7852e2e5ba71ded84ffbedf53be7c35d4 Mon Sep 17 00:00:00 2001 From: Kavita Patil Date: Mon, 31 Oct 2022 17:18:58 +0100 Subject: [PATCH 3/3] - Fixed MR comments --- .../esafirm/imagepicker/features/ImagePickerActivity.kt | 4 ++-- .../imagepicker/features/ImagePickerComponentsHolder.kt | 7 +------ .../com/esafirm/imagepicker/features/ImagePickerConfig.kt | 4 ++-- .../esafirm/imagepicker/features/ImagePickerFragment.kt | 4 ++-- .../esafirm/imagepicker/features/ImagePickerPresenter.kt | 5 ++--- .../esafirm/imagepicker/features/camera/CameraModule.kt | 4 ++-- .../imagepicker/features/camera/DefaultCameraModule.kt | 4 ++-- imagepicker/src/main/res/values-ar/strings.xml | 1 + imagepicker/src/main/res/values-ca/strings.xml | 2 ++ imagepicker/src/main/res/values-da/strings.xml | 4 +++- imagepicker/src/main/res/values-de/strings.xml | 1 + imagepicker/src/main/res/values-es-rES/strings.xml | 1 + imagepicker/src/main/res/values-fr/strings.xml | 1 + imagepicker/src/main/res/values-in/strings.xml | 1 + imagepicker/src/main/res/values-it/strings.xml | 1 + imagepicker/src/main/res/values-ja/strings.xml | 1 + imagepicker/src/main/res/values-ko/strings.xml | 1 + imagepicker/src/main/res/values-pt-rBR/strings.xml | 1 + imagepicker/src/main/res/values-ro/strings.xml | 1 + imagepicker/src/main/res/values-ru/strings.xml | 1 + imagepicker/src/main/res/values-sv-rSE/strings.xml | 4 +++- imagepicker/src/main/res/values-tr/strings.xml | 1 + imagepicker/src/main/res/values-uk/strings.xml | 1 + imagepicker/src/main/res/values-zh-rCN/strings.xml | 2 ++ imagepicker/src/main/res/values-zh-rTW/strings.xml | 2 ++ imagepicker/src/main/res/values/strings.xml | 1 + .../src/main/java/com/esafirm/sample/CustomUIActivity.kt | 5 ++--- sample/src/main/java/com/esafirm/sample/MainActivity.kt | 4 ++-- 28 files changed, 43 insertions(+), 26 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 0c1c0518..df6bcb64 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerActivity.kt @@ -89,7 +89,7 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener if (!isCameraOnly) { menu.findItem(R.id.menu_camera).isVisible = config?.isShowCamera == true && config?.isOnlyVideo == false - menu.findItem(R.id.menu_video).isVisible = config?.isShowVideo ?: true + menu.findItem(R.id.menu_video).isVisible = config?.isShowVideoCamera ?: true menu.findItem(R.id.menu_done).apply { title = ConfigUtils.getDoneButtonText(this@ImagePickerActivity, config!!) isVisible = imagePickerFragment.isShowDoneButton @@ -185,4 +185,4 @@ class ImagePickerActivity : AppCompatActivity(), ImagePickerInteractionListener setResult(RESULT_OK, result) finish() } -} \ No newline at end of file +} diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerComponentsHolder.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerComponentsHolder.kt index f83407fb..a104ae82 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerComponentsHolder.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerComponentsHolder.kt @@ -13,7 +13,6 @@ interface ImagePickerComponents { val imageLoader: ImageLoader val imageFileLoader: ImageFileLoader val cameraModule: CameraModule - val videoModule: CameraModule } open class DefaultImagePickerComponents(context: Context) : ImagePickerComponents { @@ -21,7 +20,6 @@ open class DefaultImagePickerComponents(context: Context) : ImagePickerComponent override val imageLoader: ImageLoader by lazy { DefaultImageLoader() } override val imageFileLoader: ImageFileLoader by lazy { DefaultImageFileLoader(context.applicationContext) } override val cameraModule: CameraModule by lazy { DefaultCameraModule() } - override val videoModule: CameraModule by lazy { DefaultCameraModule() } } object ImagePickerComponentsHolder : ImagePickerComponents { @@ -40,10 +38,7 @@ object ImagePickerComponentsHolder : ImagePickerComponents { override val cameraModule: CameraModule get() = internalComponents.cameraModule - override val videoModule: CameraModule - get() = internalComponents.videoModule - fun setInternalComponent(components: ImagePickerComponents) { internalComponents = components } -} \ 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 e8810d9f..0d43d619 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerConfig.kt @@ -22,7 +22,7 @@ class ImagePickerConfig( var isOnlyVideo: Boolean = false, var isIncludeAnimation: Boolean = false, var isShowCamera: Boolean = true, - var isShowVideo: Boolean = true, + var isShowVideoCamera: Boolean = false, var selectedImages: List = emptyList(), var excludedImages: List = emptyList(), override var savePath: ImagePickerSavePath = ImagePickerSavePath.DEFAULT, @@ -52,4 +52,4 @@ fun ImagePickerConfig.enableLog(isEnable: Boolean) { IpLogger.setEnable(isEnable) } -fun List.toFiles() = this.map { File(it.path) } \ No newline at end of file +fun List.toFiles() = this.map { File(it.path) } 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 15330a6e..84d9bf24 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerFragment.kt @@ -319,7 +319,7 @@ class ImagePickerFragment : Fragment() { } if (config.isOnlyVideo) { presenter.captureVideo(this, config, RC_CAPTURE) - } else{ + } else { presenter.captureImage(this, config, RC_CAPTURE) } } @@ -402,4 +402,4 @@ class ImagePickerFragment : Fragment() { } } } -} \ No newline at end of file +} diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerPresenter.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerPresenter.kt index fb53bafd..b5f2e928 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerPresenter.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/ImagePickerPresenter.kt @@ -22,7 +22,6 @@ internal class ImagePickerPresenter( ) : ImagePickerAction { private val cameraModule: CameraModule = ImagePickerComponentsHolder.cameraModule - private val videoModule: CameraModule = ImagePickerComponentsHolder.videoModule private val stateObs = LiveDataObservableState( ImagePickerState(isLoading = true), usePostValue = true @@ -97,7 +96,7 @@ internal class ImagePickerPresenter( fun captureVideo(fragment: Fragment, config: BaseConfig, requestCode: Int) { val context = fragment.requireContext().applicationContext - val intent = videoModule.getVideoIntent(fragment.requireContext(), config) + val intent = cameraModule.getVideoCameraIntent(fragment.requireContext(), config) if (intent == null) { Toast.makeText( context, @@ -126,4 +125,4 @@ internal class ImagePickerPresenter( fun abortCaptureImage(context: Context) { cameraModule.removeImage(context) } -} \ No newline at end of file +} diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/CameraModule.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/CameraModule.kt index 592e32bf..7c7b6ec6 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/CameraModule.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/CameraModule.kt @@ -9,7 +9,7 @@ typealias OnImageReadyListener = (List?) -> Unit interface CameraModule { fun getCameraIntent(context: Context, config: BaseConfig): Intent? - fun getVideoIntent(context: Context, config: BaseConfig): Intent? + fun getVideoCameraIntent(context: Context, config: BaseConfig): Intent? fun getImage(context: Context, intent: Intent?, imageReadyListener: OnImageReadyListener) fun removeImage(context: Context) -} \ No newline at end of file +} diff --git a/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/DefaultCameraModule.kt b/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/DefaultCameraModule.kt index c810edce..db6a1238 100644 --- a/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/DefaultCameraModule.kt +++ b/imagepicker/src/main/java/com/esafirm/imagepicker/features/camera/DefaultCameraModule.kt @@ -35,7 +35,7 @@ class DefaultCameraModule : CameraModule { return intent } - override fun getVideoIntent(context: Context, config: BaseConfig): Intent? { + override fun getVideoCameraIntent(context: Context, config: BaseConfig): Intent? { prepareForNewIntent() val intent = Intent(MediaStore.ACTION_VIDEO_CAPTURE) @@ -140,4 +140,4 @@ class DefaultCameraModule : CameraModule { e.printStackTrace() } } -} \ No newline at end of file +} diff --git a/imagepicker/src/main/res/values-ar/strings.xml b/imagepicker/src/main/res/values-ar/strings.xml index ed817de0..ac8ab046 100644 --- a/imagepicker/src/main/res/values-ar/strings.xml +++ b/imagepicker/src/main/res/values-ar/strings.xml @@ -15,6 +15,7 @@ إخترت %1$d/%2$d حدث خطأ في تسجيل الصوره + فشل إنشاء ملف الفيديو لا يوجد كاميرا عذراً، هناك خطأ ما! diff --git a/imagepicker/src/main/res/values-ca/strings.xml b/imagepicker/src/main/res/values-ca/strings.xml index 7fe78740..d64f3de8 100644 --- a/imagepicker/src/main/res/values-ca/strings.xml +++ b/imagepicker/src/main/res/values-ca/strings.xml @@ -15,6 +15,8 @@ %1$d/%2$d seleccionades Error al crear el fitxer d\'imatge + No s\'ha pogut crear el fitxer de vídeo + No s\'ha trobat cap càmera Oops, alguna cosa no ha anat bé! diff --git a/imagepicker/src/main/res/values-da/strings.xml b/imagepicker/src/main/res/values-da/strings.xml index a543520f..266c1489 100644 --- a/imagepicker/src/main/res/values-da/strings.xml +++ b/imagepicker/src/main/res/values-da/strings.xml @@ -15,6 +15,8 @@ %1$d/%2$d valgt Fejl, kunne ikke oprette billedfilen + Kunne ikke oprette videofil + Kamera blev ikke fundet Beklager, der er sket en fejl! @@ -28,4 +30,4 @@ Folder Image - \ No newline at end of file + diff --git a/imagepicker/src/main/res/values-de/strings.xml b/imagepicker/src/main/res/values-de/strings.xml index eb86553a..663c2346 100644 --- a/imagepicker/src/main/res/values-de/strings.xml +++ b/imagepicker/src/main/res/values-de/strings.xml @@ -15,6 +15,7 @@ %1$d/%2$d ausgewählt Fehler beim Erstellen der Bilddatei + Videodatei konnte nicht erstellt werden Keine Kamera gefunden Ups, da ist was schiefgegangen! diff --git a/imagepicker/src/main/res/values-es-rES/strings.xml b/imagepicker/src/main/res/values-es-rES/strings.xml index 0f5b6c99..8f582336 100644 --- a/imagepicker/src/main/res/values-es-rES/strings.xml +++ b/imagepicker/src/main/res/values-es-rES/strings.xml @@ -15,6 +15,7 @@ %1$d/%2$d seleccionadas Error al crear el fichero de imágen + No se pudo crear el archivo de video No se encontró la cámara Oops, algo ha ido mal! diff --git a/imagepicker/src/main/res/values-fr/strings.xml b/imagepicker/src/main/res/values-fr/strings.xml index 66140301..ce4bb9af 100644 --- a/imagepicker/src/main/res/values-fr/strings.xml +++ b/imagepicker/src/main/res/values-fr/strings.xml @@ -15,6 +15,7 @@ %1$d/%2$d sélectionnées Impossible de créer le fichier photo + Échec de la création du fichier vidéo Aucune caméra détectée Oups, quelque chose s\'est mal déroulé! diff --git a/imagepicker/src/main/res/values-in/strings.xml b/imagepicker/src/main/res/values-in/strings.xml index 9c5b2384..dab79cf0 100644 --- a/imagepicker/src/main/res/values-in/strings.xml +++ b/imagepicker/src/main/res/values-in/strings.xml @@ -15,6 +15,7 @@ %1$d/%2$d terpilih Gagal membuat berkas gambar + Gagal membuat file video Kamera tidak ditemukan Ups, ada yang tidak beres! diff --git a/imagepicker/src/main/res/values-it/strings.xml b/imagepicker/src/main/res/values-it/strings.xml index 9b642425..4de0bcaa 100644 --- a/imagepicker/src/main/res/values-it/strings.xml +++ b/imagepicker/src/main/res/values-it/strings.xml @@ -14,6 +14,7 @@ %1$d/%2$d selezionate Si è verificato un problema nella creazione dell\'immagine + Impossibile creare il file video Nessuna fotocamera trovata Oops, qualcosa è andato storto! diff --git a/imagepicker/src/main/res/values-ja/strings.xml b/imagepicker/src/main/res/values-ja/strings.xml index c6faa5c3..fd9b75d5 100644 --- a/imagepicker/src/main/res/values-ja/strings.xml +++ b/imagepicker/src/main/res/values-ja/strings.xml @@ -17,6 +17,7 @@ エラーが発生しました 画像が見つかりません + 動画ファイルの作成に失敗しました 端末のファイルへのアクセスを許可してください 端末のカメラへのアクセスを許可してください 選択できる画像の上限です diff --git a/imagepicker/src/main/res/values-ko/strings.xml b/imagepicker/src/main/res/values-ko/strings.xml index 684d5e71..7e47d980 100644 --- a/imagepicker/src/main/res/values-ko/strings.xml +++ b/imagepicker/src/main/res/values-ko/strings.xml @@ -15,6 +15,7 @@ %1$d/%2$d 선택됨 이미지 생성에 실패하였습니다. + 동영상 파일 생성 실패 카메라를 찾을 수 없습니다. 알 수 없는 오류가 발생하였습니다. diff --git a/imagepicker/src/main/res/values-pt-rBR/strings.xml b/imagepicker/src/main/res/values-pt-rBR/strings.xml index 7e7544ef..79bc6b87 100644 --- a/imagepicker/src/main/res/values-pt-rBR/strings.xml +++ b/imagepicker/src/main/res/values-pt-rBR/strings.xml @@ -15,6 +15,7 @@ %1$d/%2$d selecionadas Erro ao criar arquivo de imagem + Falha ao criar arquivo de vídeo Câmera não encontrada Ops, algo deu errado! diff --git a/imagepicker/src/main/res/values-ro/strings.xml b/imagepicker/src/main/res/values-ro/strings.xml index 978c8873..a1c8abb3 100644 --- a/imagepicker/src/main/res/values-ro/strings.xml +++ b/imagepicker/src/main/res/values-ro/strings.xml @@ -14,6 +14,7 @@ %1$d/%2$d selectate Nu am putut crea imaginea + Nu s-a putut crea fișierul video Camera foto nu a fost găsită Hopa, ceva a mers prost! diff --git a/imagepicker/src/main/res/values-ru/strings.xml b/imagepicker/src/main/res/values-ru/strings.xml index 99b74d81..88b8fbcd 100644 --- a/imagepicker/src/main/res/values-ru/strings.xml +++ b/imagepicker/src/main/res/values-ru/strings.xml @@ -12,6 +12,7 @@ %d выбрано %1$d/%2$d выбрано Не удалось создать файл + Не удалось создать видеофайл Камера недоступна Ой! Что-то пошло не так! Изображений не найдено diff --git a/imagepicker/src/main/res/values-sv-rSE/strings.xml b/imagepicker/src/main/res/values-sv-rSE/strings.xml index 2374ac63..8bd35bb0 100644 --- a/imagepicker/src/main/res/values-sv-rSE/strings.xml +++ b/imagepicker/src/main/res/values-sv-rSE/strings.xml @@ -15,10 +15,12 @@ %1$d/%2$d valda Misslyckades att skapa bildfil + Det gick inte att skapa videofil + 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 + diff --git a/imagepicker/src/main/res/values-tr/strings.xml b/imagepicker/src/main/res/values-tr/strings.xml index df6c591d..7065e63f 100644 --- a/imagepicker/src/main/res/values-tr/strings.xml +++ b/imagepicker/src/main/res/values-tr/strings.xml @@ -9,6 +9,7 @@ Klasör Resimleri seçmek için hafifçe dokunun + Video dosyası oluşturulamadı İzin reddedildi %d seçili diff --git a/imagepicker/src/main/res/values-uk/strings.xml b/imagepicker/src/main/res/values-uk/strings.xml index dea55d89..09a57144 100644 --- a/imagepicker/src/main/res/values-uk/strings.xml +++ b/imagepicker/src/main/res/values-uk/strings.xml @@ -8,6 +8,7 @@ Папка Торкніться, щоб обрати + Не вдалося створити відеофайл Доступ заборонено %d обрано %1$d/%2$d обрано diff --git a/imagepicker/src/main/res/values-zh-rCN/strings.xml b/imagepicker/src/main/res/values-zh-rCN/strings.xml index 7fbe09cb..8a25e677 100644 --- a/imagepicker/src/main/res/values-zh-rCN/strings.xml +++ b/imagepicker/src/main/res/values-zh-rCN/strings.xml @@ -13,6 +13,8 @@ 已选择 %1$d/%2$d 建立照片文件失败 + 创建视频文件失败 + 找不到相机 啊哦,发生错误! diff --git a/imagepicker/src/main/res/values-zh-rTW/strings.xml b/imagepicker/src/main/res/values-zh-rTW/strings.xml index 6b353533..6505bbe1 100644 --- a/imagepicker/src/main/res/values-zh-rTW/strings.xml +++ b/imagepicker/src/main/res/values-zh-rTW/strings.xml @@ -13,6 +13,8 @@ 已選擇 %1$d/%2$d 建立相片檔案失敗 + 創建視頻文件失敗 + 找不到相機 噢,發生問題 diff --git a/imagepicker/src/main/res/values/strings.xml b/imagepicker/src/main/res/values/strings.xml index 92069d5c..6b5ae42d 100644 --- a/imagepicker/src/main/res/values/strings.xml +++ b/imagepicker/src/main/res/values/strings.xml @@ -15,6 +15,7 @@ %1$d/%2$d selected Failed to create image file + Failed to create video file No camera found Oops, something went wrong! diff --git a/sample/src/main/java/com/esafirm/sample/CustomUIActivity.kt b/sample/src/main/java/com/esafirm/sample/CustomUIActivity.kt index 388e8f82..72f77d2a 100644 --- a/sample/src/main/java/com/esafirm/sample/CustomUIActivity.kt +++ b/sample/src/main/java/com/esafirm/sample/CustomUIActivity.kt @@ -87,14 +87,13 @@ class CustomUIActivity : AppCompatActivity() { } override fun onPrepareOptionsMenu(menu: Menu): Boolean { - if (config == null) super.onPrepareOptionsMenu(menu) val menuCamera = menu.findItem(com.esafirm.imagepicker.R.id.menu_camera) if (menuCamera != null) { menuCamera.isVisible = config?.isShowCamera == true && config?.isOnlyVideo == false } val menuVideo = menu.findItem(com.esafirm.imagepicker.R.id.menu_video) if (menuVideo != null) { - menuVideo.isVisible = config!!.isShowVideo + menuVideo.isVisible = config?.isShowVideoCamera == true } val menuDone = menu.findItem(com.esafirm.imagepicker.R.id.menu_done) if (menuDone != null) { @@ -189,4 +188,4 @@ class CustomUIActivity : AppCompatActivity() { } } } -} \ No newline at end of file +} diff --git a/sample/src/main/java/com/esafirm/sample/MainActivity.kt b/sample/src/main/java/com/esafirm/sample/MainActivity.kt index 42b85f47..38d690ab 100644 --- a/sample/src/main/java/com/esafirm/sample/MainActivity.kt +++ b/sample/src/main/java/com/esafirm/sample/MainActivity.kt @@ -85,7 +85,7 @@ class MainActivity : AppCompatActivity() { showDoneButtonAlways = true // Show done button always or not limit = 10 // max images can be selected (99 by default) isShowCamera = true // show camera or not (true by default) - isShowVideo = true // show video or not (true by default) + isShowVideoCamera = true // show video 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 @@ -129,4 +129,4 @@ class MainActivity : AppCompatActivity() { ImageViewerActivity.start(this@MainActivity, images) } } -} \ No newline at end of file +}