Skip to content

Commit 17aff35

Browse files
sanjay-mibhoomishah20akashmimalikmotanimilanvadhel-mi
authored
Develop (#62)
* -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]>
1 parent 4d37779 commit 17aff35

31 files changed

+939
-205
lines changed

app/src/main/java/com/lassi/app/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
6060
.setCropAspectRatio(1, 1)
6161
.setCompressionRation(10)
6262
.setMinFileSize(0)
63-
.setMaxFileSize(1000)
63+
.setMaxFileSize(10000)
6464
.enableActualCircleCrop()
6565
.setSupportedFileTypes("jpg", "jpeg", "png", "webp", "gif")
6666
.enableFlip()

app/src/main/java/com/lassi/app/adapter/SelectedMediaAdapter.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import com.lassi.common.extenstions.loadImage
99
import com.lassi.common.utils.ImageUtils
1010
import com.lassi.data.media.MiMedia
1111
import kotlinx.android.synthetic.main.row_selected_media.view.*
12-
import java.util.*
1312

1413
class SelectedMediaAdapter(private val onItemClicked: (miMedia: MiMedia) -> Unit) :
1514
RecyclerView.Adapter<SelectedMediaAdapter.MediaViewHolder>() {

lassi/build.gradle

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
defaultConfig {
1313
minSdkVersion 19
1414
targetSdkVersion 32
15-
versionCode 21
16-
versionName "0.4.0"
15+
versionCode 22
16+
versionName "1.0.0"
1717
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1818
vectorDrawables.useSupportLibrary = true
1919
multiDexEnabled true
@@ -72,6 +72,17 @@ dependencies {
7272
implementation 'androidx.fragment:fragment-ktx:1.4.1'
7373

7474
implementation "androidx.multidex:multidex:2.0.1"
75+
76+
// Room DB
77+
implementation 'androidx.room:room-runtime:2.4.2'
78+
kapt 'androidx.room:room-compiler:2.4.2'
79+
implementation 'androidx.room:room-ktx:2.4.2'
80+
81+
//Coroutine
82+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0'
83+
84+
//Gson
85+
implementation 'com.google.code.gson:gson:2.8.8'
7586
}
7687
repositories {
7788
mavenCentral()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.lassi.common.extenstions
2+
3+
import androidx.lifecycle.LifecycleOwner
4+
import androidx.lifecycle.LiveData
5+
import androidx.lifecycle.MutableLiveData
6+
import com.lassi.common.utils.Logger
7+
import com.lassi.data.common.Response
8+
9+
fun <T> LiveData<T>.safeObserve(owner: LifecycleOwner, observer: (T) -> Unit) {
10+
observe(owner) { it?.let(observer) ?: Logger.d("TAG", "Live data value is null") }
11+
}
12+
13+
fun <T> MutableLiveData<Response<T>>.setSuccess(data: T) = postValue(Response.Success(data))
14+
15+
fun <T> MutableLiveData<Response<T>>.setLoading() = postValue(Response.Loading())
16+
17+
fun <T> MutableLiveData<Response<T>>.setError(throwable: Throwable) =
18+
postValue(Response.Error(throwable))
19+
20+
fun <T> MutableLiveData<Response<T>>.isLoading() = value is Response.Loading<T>
21+
22+
fun <T> LiveData<Response<T>>.isLoading() = value is Response.Loading<T>

lassi/src/main/java/com/lassi/common/utils/ImageUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ object ImageUtils {
1212
miMedia.path
1313
}
1414
}
15-
}
15+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.lassi.data.database
2+
3+
import android.content.Context
4+
import androidx.room.Database
5+
import androidx.room.Room
6+
import androidx.room.RoomDatabase
7+
import com.lassi.data.media.entity.AlbumCoverPathEntity
8+
import com.lassi.data.media.entity.DurationEntity
9+
import com.lassi.data.media.entity.MediaFileDao
10+
import com.lassi.data.media.entity.MediaFileEntity
11+
12+
@Database(
13+
entities = arrayOf(
14+
MediaFileEntity::class,
15+
DurationEntity::class,
16+
AlbumCoverPathEntity::class
17+
), version = 1, exportSchema = false
18+
)
19+
abstract class MediaFileDatabase : RoomDatabase() {
20+
abstract fun mediaFileDao(): MediaFileDao
21+
22+
companion object {
23+
@Volatile
24+
private var INSTANCE: MediaFileDatabase? = null
25+
private val LOCK = Any()
26+
27+
operator fun invoke(context: Context) = INSTANCE ?: synchronized(LOCK) {
28+
buildDatabase(context).also {
29+
INSTANCE = it
30+
}
31+
}
32+
33+
private fun buildDatabase(context: Context): MediaFileDatabase = Room.databaseBuilder(
34+
context, MediaFileDatabase::class.java, "media_file_database"
35+
).build()
36+
}
37+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.lassi.data.media
2+
3+
import android.os.Parcelable
4+
import kotlinx.android.parcel.Parcelize
5+
6+
@Parcelize
7+
data class MiItemMedia(
8+
var bucketName: String? = null,
9+
var latestItemPathForBucket: String? = null,
10+
var totalItemSizeForBucket: Long = 0L
11+
) : Parcelable
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.lassi.data.media.entity
2+
3+
import android.os.Parcelable
4+
import androidx.room.ColumnInfo
5+
import androidx.room.Entity
6+
import androidx.room.ForeignKey
7+
import androidx.room.PrimaryKey
8+
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_ENTITY
9+
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_MEDIA_ID
10+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_ID
11+
import kotlinx.android.parcel.Parcelize
12+
13+
@Parcelize
14+
@Entity(
15+
tableName = ALBUM_COVER_ENTITY,
16+
foreignKeys = arrayOf(
17+
ForeignKey(
18+
entity = MediaFileEntity::class,
19+
parentColumns = arrayOf(MEDIA_ID),
20+
childColumns = arrayOf(ALBUM_COVER_MEDIA_ID),
21+
onDelete = ForeignKey.CASCADE
22+
)
23+
)
24+
)
25+
data class AlbumCoverPathEntity(
26+
@PrimaryKey
27+
@ColumnInfo(name = ALBUM_COVER_MEDIA_ID)
28+
var mediaId: Long,
29+
30+
@ColumnInfo(name = ALBUM_COVER_MEDIA_PATH, defaultValue = "default_media_album_cover_path")
31+
var mediaAlbumCoverPath: String,
32+
33+
) : Parcelable {
34+
companion object {
35+
const val ALBUM_COVER_ENTITY = "album_cover"
36+
const val ALBUM_COVER_MEDIA_ID = "album_cover_media_id"
37+
const val ALBUM_COVER_MEDIA_PATH = "album_cover_path"
38+
}
39+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.lassi.data.media.entity
2+
3+
import android.os.Parcelable
4+
import androidx.room.ColumnInfo
5+
import androidx.room.Entity
6+
import androidx.room.ForeignKey
7+
import androidx.room.ForeignKey.CASCADE
8+
import androidx.room.PrimaryKey
9+
import com.lassi.data.media.entity.DurationEntity.Companion.DURATION_ENTITY
10+
import com.lassi.data.media.entity.DurationEntity.Companion.DURATION_MEDIA_ID
11+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_ID
12+
import kotlinx.android.parcel.Parcelize
13+
14+
@Parcelize
15+
@Entity(
16+
tableName = DURATION_ENTITY,
17+
foreignKeys = arrayOf(
18+
ForeignKey(
19+
entity = MediaFileEntity::class,
20+
parentColumns = arrayOf(MEDIA_ID),
21+
childColumns = arrayOf(DURATION_MEDIA_ID),
22+
onDelete = CASCADE
23+
)
24+
)
25+
)
26+
data class DurationEntity(
27+
@PrimaryKey
28+
@ColumnInfo(name = DURATION_MEDIA_ID)
29+
var mediaId: Long,
30+
31+
@ColumnInfo(name = DURATION_MEDIA_DURATION, defaultValue = "default_media_duration")
32+
var mediaDuration: Long,
33+
34+
) : Parcelable {
35+
companion object {
36+
const val DURATION_ENTITY = "duration"
37+
const val DURATION_MEDIA_ID = "duration_media_id"
38+
const val DURATION_MEDIA_DURATION = "media_duration"
39+
}
40+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.lassi.data.media.entity
2+
3+
import androidx.room.Dao
4+
import androidx.room.Insert
5+
import androidx.room.OnConflictStrategy
6+
import androidx.room.Query
7+
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_ENTITY
8+
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_MEDIA_ID
9+
import com.lassi.data.media.entity.AlbumCoverPathEntity.Companion.ALBUM_COVER_MEDIA_PATH
10+
import com.lassi.data.media.entity.DurationEntity.Companion.DURATION_ENTITY
11+
import com.lassi.data.media.entity.DurationEntity.Companion.DURATION_MEDIA_DURATION
12+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_BUCKET
13+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_DATE_ADDED
14+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_FILE_ENTITY
15+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_ID
16+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_NAME
17+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_PATH
18+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_SIZE
19+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_TYPE
20+
import kotlinx.coroutines.flow.Flow
21+
22+
@Dao
23+
interface MediaFileDao {
24+
25+
@Insert(onConflict = OnConflictStrategy.REPLACE)
26+
suspend fun insertMediaFile(mediaFileEntity: MediaFileEntity)
27+
28+
@Insert(onConflict = OnConflictStrategy.REPLACE)
29+
suspend fun insertDuration(durationEntity: DurationEntity)
30+
31+
@Insert(onConflict = OnConflictStrategy.REPLACE)
32+
suspend fun insertAlbumCover(albumCoverPathEntity: AlbumCoverPathEntity)
33+
34+
@Query("SELECT MAX($MEDIA_DATE_ADDED) as LargestDate FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_TYPE = :mediaType")
35+
suspend fun getMaxDateFromMediaTable(mediaType: Int): Long
36+
37+
@Query("SELECT COUNT(*) == 0 FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_TYPE = :mediaType")
38+
suspend fun getDataCount(mediaType: Int): Boolean
39+
40+
@Query("SELECT DISTINCT $MEDIA_BUCKET FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_TYPE = :mediaType")
41+
fun getDistinctBucketList(mediaType: Int): Flow<List<String>>
42+
43+
@Query("SELECT MAX($MEDIA_DATE_ADDED) as LargestDate FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_BUCKET = :bucket")
44+
suspend fun getLatestDateForBucket(bucket: String): Long
45+
46+
@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)")
47+
suspend fun getLatestItemForBucket(bucket: String, mediaType: Int): String
48+
49+
@Query("SELECT COUNT($MEDIA_ID) FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_BUCKET = :bucket AND $MEDIA_TYPE = :mediaType")
50+
suspend fun getTotalItemSizeForBucket(bucket: String, mediaType: Int): Long
51+
52+
@Query(
53+
"SELECT $MEDIA_FILE_ENTITY.$MEDIA_ID as mediaId, $MEDIA_FILE_ENTITY.$MEDIA_NAME as mediaName, " +
54+
"$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" +
55+
" FROM $MEDIA_FILE_ENTITY" +
56+
" INNER JOIN $DURATION_ENTITY" +
57+
" ON $MEDIA_FILE_ENTITY.$MEDIA_ID = $DURATION_ENTITY.duration_media_id" +
58+
" INNER JOIN $ALBUM_COVER_ENTITY" +
59+
" ON $MEDIA_FILE_ENTITY.$MEDIA_ID = $ALBUM_COVER_ENTITY.$ALBUM_COVER_MEDIA_ID" +
60+
" WHERE $MEDIA_BUCKET = :bucket AND $MEDIA_TYPE = :mediaType"
61+
)
62+
fun getSelectedMediaFile(bucket: String, mediaType: Int): List<SelectedMediaModel>
63+
64+
@Query("SELECT * FROM $MEDIA_FILE_ENTITY WHERE $MEDIA_BUCKET = :bucket AND $MEDIA_TYPE = :mediaType")
65+
fun getSelectedImageMediaFile(bucket: String, mediaType: Int): List<MediaFileEntity>
66+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.lassi.data.media.entity
2+
3+
import android.os.Parcelable
4+
import androidx.room.ColumnInfo
5+
import androidx.room.Entity
6+
import androidx.room.Index
7+
import androidx.room.PrimaryKey
8+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_FILE_ENTITY
9+
import com.lassi.data.media.entity.MediaFileEntity.Companion.MEDIA_ID
10+
import kotlinx.android.parcel.Parcelize
11+
12+
@Parcelize
13+
@Entity(tableName = MEDIA_FILE_ENTITY, indices = [Index(value = [MEDIA_ID], unique = true)])
14+
data class MediaFileEntity(
15+
16+
@PrimaryKey
17+
@ColumnInfo(name = MEDIA_ID)
18+
var mediaId: Long,
19+
20+
@ColumnInfo(name = MEDIA_NAME)
21+
var mediaName: String,
22+
23+
@ColumnInfo(name = MEDIA_PATH)
24+
var mediaPath: String,
25+
26+
@ColumnInfo(name = MEDIA_BUCKET, defaultValue = "default_media_bucket")
27+
var mediaBucket: String,
28+
29+
@ColumnInfo(name = MEDIA_SIZE)
30+
var mediaSize: Long,
31+
32+
@ColumnInfo(name = MEDIA_DATE_ADDED)
33+
var mediaDateAdded: Long,
34+
35+
@ColumnInfo(name = MEDIA_TYPE)
36+
var mediaType: Int,
37+
38+
) : Parcelable {
39+
companion object {
40+
const val MEDIA_FILE_ENTITY = "media"
41+
const val MEDIA_ID = "media_id"
42+
const val MEDIA_NAME = "media_name"
43+
const val MEDIA_PATH = "media_path"
44+
const val MEDIA_BUCKET = "media_bucket"
45+
const val MEDIA_SIZE = "media_size"
46+
const val MEDIA_TYPE = "media_type"
47+
const val MEDIA_DATE_ADDED = "media_date_added"
48+
}
49+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.lassi.data.media.entity
2+
3+
import android.os.Parcelable
4+
import com.google.gson.annotations.SerializedName
5+
import kotlinx.android.parcel.Parcelize
6+
7+
@Parcelize
8+
data class SelectedMediaModel(
9+
@SerializedName("mediaId")
10+
var mediaId: Long,
11+
@SerializedName("mediaName")
12+
var mediaName: String,
13+
@SerializedName("mediaPath")
14+
var mediaPath: String,
15+
@SerializedName("mediaSize")
16+
var mediaSize: Long,
17+
@SerializedName("mediaDuration")
18+
var mediaDuration: Long,
19+
@SerializedName("mediaAlbumCoverPath")
20+
var mediaAlbumCoverPath: String,
21+
) : Parcelable

0 commit comments

Comments
 (0)