Skip to content

Commit

Permalink
Develop (#62)
Browse files Browse the repository at this point in the history
* -Enabled actual circular crop
-Optimized the attributes

* Upgrade lib version and README.md

* Updated dependencies versions, Minor changes in style (#18)

- Used ViewModelProvider constructor to build the ViewModel instead of ViewModelProviders

* Update library version and README.md

* Added file size limit restriction to display in grid

* Optional crop (#23)

Make single image selection cropping optional

* Update library version and README.md

* Update README.md

* Feature/latest version support (#26)

* Latest Android 11 support 
- Gradle version updated to v4.1.3 instead of v4.1.1
- Kotlin version updated to v1.4.32 instead of v1.4.21
- Multidex added
- CompileSdkVersion updated to android-S instead of 30
- buildToolVersion 30.0.3 added
- ViewModelProviders code changes due to deprecation
- request permission and start activity for result code changes in docsFragment and FolderFragment

* PDF and other non media files not listing issue solved for Android 11 and 12

* Camera not working issue resolved and Camera permission changes applied

* Android 10 Non media file choose from system file explorer feature implementation
- Gradle version updated to v4.2.0 instead of 4.1.3
- Kotlin version updated to v1.5.0 instead of 1.4.32

* Lassi picker version updated to v0.2.0 instead of v0.1.7

* CompileSdkVersion changed to 30 instead of android-S due to APK file not installed issue
- BuildToolVersion changed to v30.0.3 instead of v31.0.0 rc3

* Cropping image URI not working issue resolved

* Feature/latest version support (#28)

* Added file size limit restriction to display in grid (#22)

* -Enabled actual circular crop
-Optimized the attributes

* Upgrade lib version and README.md

* Updated dependencies versions, Minor changes in style (#18)

- Used ViewModelProvider constructor to build the ViewModel instead of ViewModelProviders

* Update library version and README.md

* Added file size limit restriction to display in grid

Co-authored-by: Bhoomi Shah <[email protected]>
Co-authored-by: AKASH PATEL <[email protected]>
Co-authored-by: milanvadhel-mi <[email protected]>

* Optional crop (#23)

Make single image selection cropping optional

* Update library version and README.md

* Update README.md

* Latest Android 11 support [WIP]
- Gradle version updated to v4.1.3 instead of v4.1.1
- Kotlin version updated to v1.4.32 instead of v1.4.21
- Multidex added
- CompileSdkVersion updated to android-S instead of 30
- buildToolVersion 30.0.3 added
- ViewModelProviders code changes due to deprecation
- request permission and start activity for result code changes in docsFragment and FolderFragment

* PDF and other non media files not listing issue solved for Android 11 and 12

* Camera not working issue resolved and Camera permission changes applied

* Android 10 Non media file choose from system file explorer feature implementation
- Gradle version updated to v4.2.0 instead of 4.1.3
- Kotlin version updated to v1.5.0 instead of 1.4.32

* Lassi picker version updated to v0.2.0 instead of v0.1.7

* CompileSdkVersion changed to 30 instead of android-S due to APK file not installed issue
- BuildToolVersion changed to v30.0.3 instead of v31.0.0 rc3

* Cropping image URI not working issue resolved

Co-authored-by: Malik Motani <[email protected]>
Co-authored-by: Bhoomi Shah <[email protected]>
Co-authored-by: AKASH PATEL <[email protected]>
Co-authored-by: milanvadhel-mi <[email protected]>
Co-authored-by: Faiyaz meghreji <[email protected]>

* - Resolved albumId exception in audio picker (#36)

- Added selectionDrawable attribute option in xml
- Updated UI
- Updated library version and plugins
- Updated README.md

* Update README.md

* fixed crash on reject permission. (#48)

* ANR issue resolved for Folder listing

* Library version updated to 0.3.0 instead of 0.2.2
- target sdk version updated to 32

* Feature/doc enhancement (#54)

* Develop (#52)

- ANR issue was resolved.
- Reject permission crash issue resolved.
- Library version updated to 0.3.0
- Target SDK version updated, Android 12 support.

* - System default view support given with defined view type
- Min SDK version updated to 19
- Lassi version updated to v0.4.0

Co-authored-by: milanvadhel-mi <[email protected]>
Co-authored-by: Chirag Prajapati <[email protected]>
Co-authored-by: Nkgohil007 <[email protected]>
Co-authored-by: AKASH PATEL <[email protected]>

* Bug fixes (#59)

Co-authored-by: Akash Patel<[email protected]>

* - version upgrade

* - version upgrade to 1.0.0 from 0.5.0

Co-authored-by: Bhoomi Shah <[email protected]>
Co-authored-by: AKASH PATEL <[email protected]>
Co-authored-by: Malik Motani <[email protected]>
Co-authored-by: milanvadhel-mi <[email protected]>
Co-authored-by: Faiyaz meghreji <[email protected]>
Co-authored-by: Chirag Prajapati <[email protected]>
Co-authored-by: Chirag Prajapati <[email protected]>
Co-authored-by: Nkgohil007 <[email protected]>
Co-authored-by: AKASH PATEL <[email protected]>
Co-authored-by: vrajendraBhavsar <[email protected]>
Co-authored-by: Vrajendra <[email protected]>
  • Loading branch information
12 people authored Jul 18, 2022
1 parent 4d37779 commit 17aff35
Show file tree
Hide file tree
Showing 31 changed files with 939 additions and 205 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/lassi/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
.setCropAspectRatio(1, 1)
.setCompressionRation(10)
.setMinFileSize(0)
.setMaxFileSize(1000)
.setMaxFileSize(10000)
.enableActualCircleCrop()
.setSupportedFileTypes("jpg", "jpeg", "png", "webp", "gif")
.enableFlip()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.lassi.common.extenstions.loadImage
import com.lassi.common.utils.ImageUtils
import com.lassi.data.media.MiMedia
import kotlinx.android.synthetic.main.row_selected_media.view.*
import java.util.*

class SelectedMediaAdapter(private val onItemClicked: (miMedia: MiMedia) -> Unit) :
RecyclerView.Adapter<SelectedMediaAdapter.MediaViewHolder>() {
Expand Down
15 changes: 13 additions & 2 deletions lassi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 32
versionCode 21
versionName "0.4.0"
versionCode 22
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
Expand Down Expand Up @@ -72,6 +72,17 @@ dependencies {
implementation 'androidx.fragment:fragment-ktx:1.4.1'

implementation "androidx.multidex:multidex:2.0.1"

// Room DB
implementation 'androidx.room:room-runtime:2.4.2'
kapt 'androidx.room:room-compiler:2.4.2'
implementation 'androidx.room:room-ktx:2.4.2'

//Coroutine
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0'

//Gson
implementation 'com.google.code.gson:gson:2.8.8'
}
repositories {
mavenCentral()
Expand Down
22 changes: 22 additions & 0 deletions lassi/src/main/java/com/lassi/common/extenstions/LiveDataExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.lassi.common.extenstions

import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.lassi.common.utils.Logger
import com.lassi.data.common.Response

fun <T> LiveData<T>.safeObserve(owner: LifecycleOwner, observer: (T) -> Unit) {
observe(owner) { it?.let(observer) ?: Logger.d("TAG", "Live data value is null") }
}

fun <T> MutableLiveData<Response<T>>.setSuccess(data: T) = postValue(Response.Success(data))

fun <T> MutableLiveData<Response<T>>.setLoading() = postValue(Response.Loading())

fun <T> MutableLiveData<Response<T>>.setError(throwable: Throwable) =
postValue(Response.Error(throwable))

fun <T> MutableLiveData<Response<T>>.isLoading() = value is Response.Loading<T>

fun <T> LiveData<Response<T>>.isLoading() = value is Response.Loading<T>
2 changes: 1 addition & 1 deletion lassi/src/main/java/com/lassi/common/utils/ImageUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ object ImageUtils {
miMedia.path
}
}
}
}
37 changes: 37 additions & 0 deletions lassi/src/main/java/com/lassi/data/database/MediaFileDatabase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.lassi.data.database

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.lassi.data.media.entity.AlbumCoverPathEntity
import com.lassi.data.media.entity.DurationEntity
import com.lassi.data.media.entity.MediaFileDao
import com.lassi.data.media.entity.MediaFileEntity

@Database(
entities = arrayOf(
MediaFileEntity::class,
DurationEntity::class,
AlbumCoverPathEntity::class
), version = 1, exportSchema = false
)
abstract class MediaFileDatabase : RoomDatabase() {
abstract fun mediaFileDao(): MediaFileDao

companion object {
@Volatile
private var INSTANCE: MediaFileDatabase? = null
private val LOCK = Any()

operator fun invoke(context: Context) = INSTANCE ?: synchronized(LOCK) {
buildDatabase(context).also {
INSTANCE = it
}
}

private fun buildDatabase(context: Context): MediaFileDatabase = Room.databaseBuilder(
context, MediaFileDatabase::class.java, "media_file_database"
).build()
}
}
11 changes: 11 additions & 0 deletions lassi/src/main/java/com/lassi/data/media/MiItemMedia.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.lassi.data.media

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

@Parcelize
data class MiItemMedia(
var bucketName: String? = null,
var latestItemPathForBucket: String? = null,
var totalItemSizeForBucket: Long = 0L
) : Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.lassi.data.media.entity

import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.PrimaryKey
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_ENTITY
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_MEDIA_ID
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_ID
import kotlinx.android.parcel.Parcelize

@Parcelize
@Entity(
tableName = ALBUM_COVER_ENTITY,
foreignKeys = arrayOf(
ForeignKey(
entity = MediaFileEntity::class,
parentColumns = arrayOf(MEDIA_ID),
childColumns = arrayOf(ALBUM_COVER_MEDIA_ID),
onDelete = ForeignKey.CASCADE
)
)
)
data class AlbumCoverPathEntity(
@PrimaryKey
@ColumnInfo(name = ALBUM_COVER_MEDIA_ID)
var mediaId: Long,

@ColumnInfo(name = ALBUM_COVER_MEDIA_PATH, defaultValue = "default_media_album_cover_path")
var mediaAlbumCoverPath: String,

) : Parcelable {
companion object {
const val ALBUM_COVER_ENTITY = "album_cover"
const val ALBUM_COVER_MEDIA_ID = "album_cover_media_id"
const val ALBUM_COVER_MEDIA_PATH = "album_cover_path"
}
}
40 changes: 40 additions & 0 deletions lassi/src/main/java/com/lassi/data/media/entity/DurationEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.lassi.data.media.entity

import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.ForeignKey.CASCADE
import androidx.room.PrimaryKey
import com.lassi.data.media.entity.DurationEntity.Companion.DURATION_ENTITY
import com.lassi.data.media.entity.DurationEntity.Companion.DURATION_MEDIA_ID
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_ID
import kotlinx.android.parcel.Parcelize

@Parcelize
@Entity(
tableName = DURATION_ENTITY,
foreignKeys = arrayOf(
ForeignKey(
entity = MediaFileEntity::class,
parentColumns = arrayOf(MEDIA_ID),
childColumns = arrayOf(DURATION_MEDIA_ID),
onDelete = CASCADE
)
)
)
data class DurationEntity(
@PrimaryKey
@ColumnInfo(name = DURATION_MEDIA_ID)
var mediaId: Long,

@ColumnInfo(name = DURATION_MEDIA_DURATION, defaultValue = "default_media_duration")
var mediaDuration: Long,

) : Parcelable {
companion object {
const val DURATION_ENTITY = "duration"
const val DURATION_MEDIA_ID = "duration_media_id"
const val DURATION_MEDIA_DURATION = "media_duration"
}
}
66 changes: 66 additions & 0 deletions lassi/src/main/java/com/lassi/data/media/entity/MediaFileDao.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.lassi.data.media.entity

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_ENTITY
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_MEDIA_ID
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_MEDIA_PATH
import com.lassi.data.media.entity.DurationEntity.Companion.DURATION_ENTITY
import com.lassi.data.media.entity.DurationEntity.Companion.DURATION_MEDIA_DURATION
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_BUCKET
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_DATE_ADDED
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_FILE_ENTITY
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_ID
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_NAME
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_PATH
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_SIZE
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_TYPE
import kotlinx.coroutines.flow.Flow

@Dao
interface MediaFileDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertMediaFile(mediaFileEntity: MediaFileEntity)

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertDuration(durationEntity: DurationEntity)

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertAlbumCover(albumCoverPathEntity: AlbumCoverPathEntity)

@Query("SELECT MAX($MEDIA_DATE_ADDED) as LargestDate FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_TYPE = :mediaType")
suspend fun getMaxDateFromMediaTable(mediaType: Int): Long

@Query("SELECT COUNT(*) == 0 FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_TYPE = :mediaType")
suspend fun getDataCount(mediaType: Int): Boolean

@Query("SELECT DISTINCT $MEDIA_BUCKET FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_TYPE = :mediaType")
fun getDistinctBucketList(mediaType: Int): Flow<List<String>>

@Query("SELECT MAX($MEDIA_DATE_ADDED) as LargestDate FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_BUCKET = :bucket")
suspend fun getLatestDateForBucket(bucket: String): Long

@Query("SELECT $MEDIA_PATH as LatestItem FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_BUCKET = :bucket AND $MEDIA_TYPE = :mediaType AND $MEDIA_DATE_ADDED = (SELECT MAX($MEDIA_DATE_ADDED) as LargestDate FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_BUCKET = :bucket)")
suspend fun getLatestItemForBucket(bucket: String, mediaType: Int): String

@Query("SELECT COUNT($MEDIA_ID) FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_BUCKET = :bucket AND $MEDIA_TYPE = :mediaType")
suspend fun getTotalItemSizeForBucket(bucket: String, mediaType: Int): Long

@Query(
"SELECT $MEDIA_FILE_ENTITY.$MEDIA_ID as mediaId, $MEDIA_FILE_ENTITY.$MEDIA_NAME as mediaName, " +
"$MEDIA_FILE_ENTITY.$MEDIA_PATH as mediaPath, $MEDIA_FILE_ENTITY.$MEDIA_SIZE as mediaSize, $DURATION_ENTITY.$DURATION_MEDIA_DURATION as mediaDuration, $ALBUM_COVER_ENTITY.$ALBUM_COVER_MEDIA_PATH as mediaAlbumCoverPath" +
" FROM $MEDIA_FILE_ENTITY" +
" INNER JOIN $DURATION_ENTITY" +
" ON $MEDIA_FILE_ENTITY.$MEDIA_ID = $DURATION_ENTITY.duration_media_id" +
" INNER JOIN $ALBUM_COVER_ENTITY" +
" ON $MEDIA_FILE_ENTITY.$MEDIA_ID = $ALBUM_COVER_ENTITY.$ALBUM_COVER_MEDIA_ID" +
" WHERE $MEDIA_BUCKET = :bucket AND $MEDIA_TYPE = :mediaType"
)
fun getSelectedMediaFile(bucket: String, mediaType: Int): List<SelectedMediaModel>

@Query("SELECT * FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_BUCKET = :bucket AND $MEDIA_TYPE = :mediaType")
fun getSelectedImageMediaFile(bucket: String, mediaType: Int): List<MediaFileEntity>
}
49 changes: 49 additions & 0 deletions lassi/src/main/java/com/lassi/data/media/entity/MediaFileEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.lassi.data.media.entity

import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_FILE_ENTITY
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_ID
import kotlinx.android.parcel.Parcelize

@Parcelize
@Entity(tableName = MEDIA_FILE_ENTITY, indices = [Index(value = [MEDIA_ID], unique = true)])
data class MediaFileEntity(

@PrimaryKey
@ColumnInfo(name = MEDIA_ID)
var mediaId: Long,

@ColumnInfo(name = MEDIA_NAME)
var mediaName: String,

@ColumnInfo(name = MEDIA_PATH)
var mediaPath: String,

@ColumnInfo(name = MEDIA_BUCKET, defaultValue = "default_media_bucket")
var mediaBucket: String,

@ColumnInfo(name = MEDIA_SIZE)
var mediaSize: Long,

@ColumnInfo(name = MEDIA_DATE_ADDED)
var mediaDateAdded: Long,

@ColumnInfo(name = MEDIA_TYPE)
var mediaType: Int,

) : Parcelable {
companion object {
const val MEDIA_FILE_ENTITY = "media"
const val MEDIA_ID = "media_id"
const val MEDIA_NAME = "media_name"
const val MEDIA_PATH = "media_path"
const val MEDIA_BUCKET = "media_bucket"
const val MEDIA_SIZE = "media_size"
const val MEDIA_TYPE = "media_type"
const val MEDIA_DATE_ADDED = "media_date_added"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.lassi.data.media.entity

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize

@Parcelize
data class SelectedMediaModel(
@SerializedName("mediaId")
var mediaId: Long,
@SerializedName("mediaName")
var mediaName: String,
@SerializedName("mediaPath")
var mediaPath: String,
@SerializedName("mediaSize")
var mediaSize: Long,
@SerializedName("mediaDuration")
var mediaDuration: Long,
@SerializedName("mediaAlbumCoverPath")
var mediaAlbumCoverPath: String,
) : Parcelable
Loading

0 comments on commit 17aff35

Please sign in to comment.