Skip to content

Commit

Permalink
Merge pull request #116 from Mindinventory/develop
Browse files Browse the repository at this point in the history
v1.4.0
  • Loading branch information
sanjay-mi authored Mar 27, 2024
2 parents 2faf654 + e1ea9da commit c8e44e5
Show file tree
Hide file tree
Showing 24 changed files with 829 additions and 209 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
* Step 1.
To open a app color theme view then add Lassi in to your activity class:
To open an app color theme view then add Lassi in to your activity class:
```kotlin
val intent = Lassi(this)
Expand All @@ -73,14 +73,18 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
.setMaxTime(30) // for MediaType.VIDEO only
.setSupportedFileTypes("mp4", "mkv", "webm", "avi", "flv", "3gp") // Filter by limited media format (Optional)
.setMinFileSize(100) // Restrict by minimum file size
.setMaxFileSize(1024) // Restrict by maximum file size
.setMaxFileSize(1024) // Restrict by maximum file size
.disableCrop() // to remove crop from the single image selection (crop is enabled by default for single image)
/*
* Configuration for UI
*/
.setStatusBarColor(R.color.colorPrimaryDark)
.setToolbarResourceColor(R.color.colorPrimary)
.setProgressBarColor(R.color.colorAccent)
.setSortingCheckedRadioButtonColor(R.color.darkBlue) // To set color of the checked state radio button resource within sorting dialog
.setSortingUncheckedRadioButtonColor(R.color.regentStBlue) // To set color of the unchecked state radio button resource within sorting dialog
.setSortingCheckedTextColor(R.color.regentStBlue) // To set color of the checked state radio button resource within sorting dialog
.setSortingUncheckedTextColor(R.color.darkBlue) // To set color of the unchecked state radio button resource within sorting dialog
.setPlaceHolder(R.drawable.ic_image_placeholder)
.setErrorDrawable(R.drawable.ic_image_placeholder)
.setSelectionDrawable(R.drawable.ic_checked_media)
Expand Down Expand Up @@ -123,6 +127,24 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
}
}
```

* Option - 1. To set language's text programmatically based on the current language set on the device follow below mentioned approach of setting strings in your desired language.
* getMultiLngBuilder() exposes params which you can use to set texts.
* By default english (en) language is set so no need to follow this step.
```kotlin
val currentLang = Locale.getDefault().language.toString()
if (currentLang == "es") {
lassi.getMultiLngBuilder(
setOkLbl = "d'accord",
setCancelLbl = "Annuler",
setSortAscendingLbl = "Ascendant",
setSortDescendingLbl = "Descendant",
setSortByDateLbl = "Trier par date"
)
}
```
* Option - 2. To localize text content of Lassi picker with multiple language options, define language-specific string resource file in your project and update values of string resource keys mentioned in below link with your desired language.
* [Lassi String Resources](https://github.com/Mindinventory/Lassi-Android/blob/931e147ebe6282bd1629858b5a9f29fe5a0b8b32/lassi/src/main/res/values/strings.xml)
### Document access permission note
If Android device SDK is >= 30 and wants to access document (only for choose the non media file) then add ```android.permission.MANAGE_EXTERNAL_STORAGE``` permission in your app otherwise library won't allow to access documents. Kindly check sample app for more detail.
Expand Down
219 changes: 114 additions & 105 deletions app/src/main/java/com/lassi/app/MainActivity.kt

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,25 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/btnImageCapture"
app:layout_constraintTop_toBottomOf="@+id/btnDocumentSystemIntent" />

<Button
android:id="@+id/btnPhotoPicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/bg_rounded_button"
android:drawableStart="@drawable/ic_document"
android:padding="10dp"
android:text="@string/photo_picker"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:textSize="16sp"
android:textStyle="bold"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnVideoCapture" />
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.recyclerview.widget.RecyclerView
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Lassi sample</string>
<string name="selected_media">Medios seleccionados</string>
<string name="open_video_picker">Abrir selector de vídeos</string>
<string name="open_image_picker">Abrir selector de imágenes</string>
<string name="image">Imagen</string>
<string name="video">Video</string>
<string name="document">Documento</string>
<string name="audio">Audio</string>
<string name="open_system_view">"Abrir vista del sistema "</string>
<string name="photo_picker">Selector de fotos</string>

<string name="sort_by_date">Ordenar por fecha</string>
<string name="sort_ascending">Ascendente</string>
<string name="sort_descending">Descendente</string>
<string name="camera_permission_rational">No se concede el permiso de la cámara. Por favor, permita que se configure.</string>
<string name="crop_image_menu_crop">Cultivo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
<color name="cherry_red">#E9333C</color>
<color name="chartreuse">#DFFF00</color>
<color name="emerald_green">#50C878</color>
<color name="darkBlue">#22223b</color>
<color name="regentStBlue">#98c1d9</color>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@
<string name="document">Document</string>
<string name="audio">Audio</string>
<string name="open_system_view">Open System View</string>
<string name="photo_picker">Photo Picker</string>

<string name="sort_by_date">Sort by Date</string>
<string name="sort_ascending">Ascending</string>
<string name="sort_descending">Descending</string>
<string name="camera_permission_rational">Camera permission is not granted. Please allow it from setting.</string>
<string name="crop_image_menu_crop">Crop</string>
</resources>
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Aug 31 11:56:21 IST 2023
#Tue Mar 12 19:15:15 IST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions lassi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
defaultConfig {
minSdk 21
targetSdk 34
versionCode 26
versionName "1.3.0"
versionCode 27
versionName "1.4.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
Expand Down
3 changes: 3 additions & 0 deletions lassi/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

<!-- To handle the reselection within the app on Android 14 (API level 34) -->
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />

<!-- Required to maintain app compatibility. -->
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
Expand Down
1 change: 1 addition & 0 deletions lassi/src/main/java/com/lassi/common/utils/KeyUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ object KeyUtils {
const val DESCENDING_ORDER = 0
const val ASCENDING_ORDER = 1
const val DEFAULT_ORDER = 2
const val ERROR_EXCEEDING_MSG = "You are exceeding the defined Max limit."
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.os.Build
import android.provider.MediaStore
import android.util.Log
import android.webkit.MimeTypeMap
import com.lassi.R
import com.lassi.common.extenstions.catch
import com.lassi.common.utils.KeyUtils
import com.lassi.common.utils.Logger
Expand All @@ -21,6 +20,7 @@ import com.lassi.data.media.entity.MediaFileEntity
import com.lassi.domain.media.LassiConfig
import com.lassi.domain.media.MediaRepository
import com.lassi.domain.media.MediaType
import com.lassi.domain.media.MultiLangConfig
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers.IO
Expand Down Expand Up @@ -224,7 +224,7 @@ class MediaRepositoryImpl(private val context: Context) : MediaRepository {
dateAdded: Long,
mediaType: MediaType,
) {
val bucketName = bucket ?: context.getString(R.string.lassi_all)
val bucketName = bucket ?: MultiLangConfig.getConfig().lassiAll
if (isFileTypeSupported(miMedia.path)) {
CoroutineScope(IO).launch {
miMedia.path?.let { path ->
Expand Down
17 changes: 13 additions & 4 deletions lassi/src/main/java/com/lassi/domain/media/LassiConfig.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.lassi.domain.media

import android.content.res.Resources
import android.graphics.Color
import android.os.Parcelable
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import com.lassi.R
import com.lassi.common.utils.KeyUtils
import com.lassi.common.utils.KeyUtils.ERROR_EXCEEDING_MSG
import com.lassi.data.media.MiMedia
import com.lassi.presentation.cameraview.controls.AspectRatio
import com.lassi.presentation.cropper.CropImageView
Expand All @@ -18,6 +19,10 @@ data class LassiConfig(
var toolbarResourceColor: Int = Color.WHITE,
var progressBarColor: Int = Color.BLACK,
var galleryBackgroundColor: Int = Color.WHITE,
@ColorRes var sortingCheckedRadioButtonColor: Int = R.color.darkYellow,
@ColorRes var sortingUncheckedRadioButtonColor: Int = R.color.blackTrans50,
@ColorRes var sortingCheckedTextColor: Int = R.color.darkYellow,
@ColorRes var sortingUncheckedTextColor: Int = R.color.blackTrans50,
@DrawableRes var placeHolder: Int = R.drawable.ic_image_placeholder,
@DrawableRes var errorDrawable: Int = R.drawable.ic_image_placeholder,
@DrawableRes var selectionDrawable: Int = R.drawable.ic_checked_media,
Expand All @@ -31,7 +36,7 @@ data class LassiConfig(
var maxTime: Long = KeyUtils.DEFAULT_DURATION,
var cropType: CropImageView.CropShape = CropImageView.CropShape.RECTANGLE,
var supportedFileType: MutableList<String> = mutableListOf(),
var cropAspectRatio: AspectRatio? = null,
var cropAspectRatio: AspectRatio? = AspectRatio.of(1, 1),
var enableFlipImage: Boolean = false,
var enableRotateImage: Boolean = false,
var enableActualCircleCrop: Boolean = false,
Expand All @@ -41,7 +46,7 @@ data class LassiConfig(
var isCrop: Boolean = true,
var alertDialogNegativeButtonColor: Int = Color.BLACK,
var alertDialogPositiveButtonColor: Int = Color.BLACK,
var customLimitExceedingErrorMessage: Int = R.string.default_exceed_error_msg
var customLimitExceedingErrorMessage: String = ERROR_EXCEEDING_MSG
) : Parcelable {
companion object {

Expand All @@ -54,10 +59,14 @@ data class LassiConfig(
toolbarResourceColor = lassiConfig.toolbarResourceColor
progressBarColor = lassiConfig.progressBarColor
galleryBackgroundColor = lassiConfig.galleryBackgroundColor
sortingCheckedRadioButtonColor = lassiConfig.sortingCheckedRadioButtonColor
sortingUncheckedRadioButtonColor = lassiConfig.sortingUncheckedRadioButtonColor
sortingCheckedTextColor = lassiConfig.sortingCheckedTextColor
sortingUncheckedTextColor = lassiConfig.sortingUncheckedTextColor
selectedMedias = lassiConfig.selectedMedias
mediaType = lassiConfig.mediaType
maxCount = lassiConfig.maxCount
ascFlag= lassiConfig.ascFlag
ascFlag = lassiConfig.ascFlag
gridSize = lassiConfig.gridSize
lassiOption = lassiConfig.lassiOption
minTime = lassiConfig.minTime
Expand Down
3 changes: 2 additions & 1 deletion lassi/src/main/java/com/lassi/domain/media/MediaType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ enum class MediaType(val value: Int) {
VIDEO(2),
AUDIO(3),
DOC(4),
FILE_TYPE_WITH_SYSTEM_VIEW(5)
FILE_TYPE_WITH_SYSTEM_VIEW(5),
PHOTO_PICKER(6)
}
100 changes: 100 additions & 0 deletions lassi/src/main/java/com/lassi/domain/media/MultiLangModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.lassi.domain.media

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class MultiLangConfig(
var ok: String = "",
var cancel: String = "",
var lassiAll: String = "",
var cropImageMenuRotateLeft: String = "",
var cropImageMenuRotateRight: String = "",
var cropImageMenuFlip: String = "",
var cropImageMenuFlipHorizontally: String = "",
var cropImageMenuFlipVertically: String = "",
var pickImageIntentChooserTitle: String = "",
var cropImageActivityNoPermissions: String = "",
var cropImageActivityTitle: String = "",
var camera: String = "",
var sort: String = "",
var done: String = "",
var cameraAudioStoragePermissionRational: String = "",
var cameraStoragePermissionRational: String = "",
var cameraAudioPermissionRational: String = "",
var cameraPermissionRational: String = "",
var storagePermissionRational: String = "",
var readMediaImagesVideoPermissionRational: String = "",
var readMediaAudioPermissionRational: String = "",
var alreadySelectedMaxItems: String = "",
var errorExceedMsg: String = "",
var defaultExceedErrorMsg: String = "",
var noDataFound: String = "",
var sortByDate: String = "",
var sortAscending: String = "",
var sortDescending: String = "",
var icRotateLeft24: String = "",
var icRotateRight24: String = "",
var cropImageMenuCrop: String = "",
var icFlip24: String = "",
var icFlip24Horizontally: String = "",
var icFlip24Vertically: String = "",
var pickImageChooserTitle: String = "",
var pickImageCamera: String = "",
var pickImageGallery: String = "",
var mainActionRotate: String = "",
var mainActionCrop: String = ""
) : Parcelable {
companion object {
private var multiLangConfig = MultiLangConfig()

fun setMultiLangConfig(config: MultiLangConfig) {
multiLangConfig.apply {
ok = config.ok
cancel = config.cancel
lassiAll = config.lassiAll
cropImageMenuRotateLeft = config.cropImageMenuRotateLeft
cropImageMenuRotateRight = config.cropImageMenuRotateRight
cropImageMenuFlip = config.cropImageMenuFlip
cropImageMenuFlipHorizontally = config.cropImageMenuFlipHorizontally
cropImageMenuFlipVertically = config.cropImageMenuFlipVertically
pickImageIntentChooserTitle = config.pickImageIntentChooserTitle
cropImageActivityNoPermissions = config.cropImageActivityNoPermissions
cropImageActivityTitle = config.cropImageActivityTitle
camera = config.camera
sort = config.sort
done = config.done
cameraAudioStoragePermissionRational = config.cameraAudioStoragePermissionRational
cameraStoragePermissionRational = config.cameraStoragePermissionRational
cameraAudioPermissionRational = config.cameraAudioPermissionRational
cameraPermissionRational = config.cameraPermissionRational
storagePermissionRational = config.storagePermissionRational
readMediaImagesVideoPermissionRational =
config.readMediaImagesVideoPermissionRational
readMediaAudioPermissionRational = config.readMediaAudioPermissionRational
alreadySelectedMaxItems = config.alreadySelectedMaxItems
errorExceedMsg = config.errorExceedMsg
defaultExceedErrorMsg = config.defaultExceedErrorMsg
noDataFound = config.noDataFound
sortByDate = config.sortByDate
sortAscending = config.sortAscending
sortDescending = config.sortDescending
icRotateLeft24 = config.icRotateLeft24
icRotateRight24 = config.icRotateRight24
cropImageMenuCrop = config.cropImageMenuCrop
icFlip24 = config.icFlip24
icFlip24Horizontally = config.icFlip24Horizontally
icFlip24Vertically = config.icFlip24Vertically
pickImageChooserTitle = config.pickImageChooserTitle
pickImageCamera = config.pickImageCamera
pickImageGallery = config.pickImageGallery
mainActionRotate = config.mainActionRotate
mainActionCrop = config.mainActionCrop
}
}

fun getConfig(): MultiLangConfig {
return multiLangConfig
}
}
}
Loading

0 comments on commit c8e44e5

Please sign in to comment.