Skip to content

Commit 960f066

Browse files
malikmotanibhoomishah20akashmimilanvadhel-mi
authored
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 <bhoomishah20495@gmail.com> Co-authored-by: AKASH PATEL <akash.mindinventory@gmail.com> Co-authored-by: milanvadhel-mi <73939866+milanvadhel-mi@users.noreply.github.com>
1 parent 12a634b commit 960f066

12 files changed

Lines changed: 190 additions & 87 deletions

File tree

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
3838
```groovy
3939
dependencies {
4040
...
41-
implementation 'com.github.Mindinventory:Lassi:0.1.5'
41+
implementation 'com.github.Mindinventory:Lassi:0.1.6'
4242
}
4343
```
4444
@@ -57,6 +57,8 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
5757
.setMinTime(15) // for MediaType.VIDEO only
5858
.setMaxTime(30) // for MediaType.VIDEO only
5959
.setSupportedFileTypes("mp4", "mkv", "webm", "avi", "flv", "3gp") // Filter by limited media format (Optional)
60+
.setMinFileSize(100) // Restrict by minimum file size
61+
.setMaxFileSize(1024) // Restrict by maximum file size
6062
/*
6163
* Configuration for UI
6264
*/
@@ -91,6 +93,19 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
9193
}
9294
```
9395
96+
97+
### Guideline for contributors
98+
Contribution towards our repository is always welcome, we request contributors to create a pull request to the **develop** branch only.
99+
100+
### Guideline to report an issue/feature request
101+
It would be great for us if the reporter can share the below things to understand the root cause of the issue.
102+
103+
* Library version
104+
* Code snippet
105+
* Logs if applicable
106+
* Device specification like (Manufacturer, OS version, etc)
107+
* Screenshot/video with steps to reproduce the issue
108+
94109
### Requirements
95110
96111
* minSdkVersion >= 17

app/build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ android {
3232
dependencies {
3333
implementation fileTree(dir: 'libs', include: ['*.jar'])
3434
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
35-
implementation 'androidx.appcompat:appcompat:1.0.2'
36-
implementation 'androidx.core:core-ktx:1.0.2'
37-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
38-
testImplementation 'junit:junit:4.12'
39-
androidTestImplementation 'androidx.test:runner:1.1.1'
40-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
35+
implementation 'androidx.appcompat:appcompat:1.2.0'
36+
implementation 'androidx.core:core-ktx:1.3.2'
37+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
38+
testImplementation 'junit:junit:4.13.1'
39+
androidTestImplementation 'androidx.test:runner:1.3.0'
40+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
4141
implementation project(path: ':lassi')
42-
implementation 'androidx.recyclerview:recyclerview:1.0.0'
42+
implementation 'androidx.recyclerview:recyclerview:1.1.0'
4343
implementation 'androidx.cardview:cardview:1.0.0'
4444

4545
// glide
46-
implementation 'com.github.bumptech.glide:glide:4.9.0'
47-
kapt 'com.github.bumptech.glide:compiler:4.9.0'
46+
implementation 'com.github.bumptech.glide:glide:4.11.0'
47+
kapt 'com.github.bumptech.glide:compiler:4.11.0'
4848

4949
}

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
5252
.setCropType(CropImageView.CropShape.OVAL)
5353
.setCropAspectRatio(1, 1)
5454
.setCompressionRation(10)
55+
.setMinFileSize(100)
56+
.setMaxFileSize(200)
5557
.enableActualCircleCrop()
5658
.setSupportedFileTypes("jpg", "jpeg", "png", "webp", "gif")
5759
.enableFlip()
@@ -66,14 +68,16 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
6668
.setGridSize(3)
6769
.setMinTime(15)
6870
.setMaxTime(30)
71+
.setMinFileSize(1024 * 5)
72+
.setMaxFileSize(1024 * 12)
6973
.setMediaType(MediaType.VIDEO)
7074
.setStatusBarColor(R.color.colorPrimaryDark)
7175
.setToolbarColor(R.color.colorPrimary)
7276
.setToolbarResourceColor(android.R.color.white)
7377
.setProgressBarColor(R.color.colorAccent)
7478
.setPlaceHolder(R.drawable.ic_video_placeholder)
7579
.setErrorDrawable(R.drawable.ic_video_placeholder)
76-
.setSupportedFileTypes("mp4", "mkv", "webm", "avi", "flv", "3gp")
80+
//.setSupportedFileTypes("mp4", "mkv", "webm", "avi", "flv", "3gp")
7781
.build()
7882
startActivityForResult(intent, MEDIA_REQUEST_CODE)
7983
}
@@ -123,27 +127,24 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
123127
return if (ContentResolver.SCHEME_CONTENT == uri.scheme) {
124128
contentResolver.getType(uri)
125129
} else {
126-
val fileExtension = MimeTypeMap.getFileExtensionFromUrl(
127-
uri.toString()
128-
)
129-
MimeTypeMap.getSingleton().getMimeTypeFromExtension(
130-
fileExtension.toLowerCase()
131-
)
130+
val fileExtension = MimeTypeMap.getFileExtensionFromUrl(uri.toString())
131+
MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.toLowerCase())
132132
}
133133
}
134134

135135
private fun onItemClicked(miMedia: MiMedia) {
136-
val file = File(miMedia.path)
137-
val fileUri = FileProvider.getUriForFile(
138-
this,
139-
applicationContext.packageName + ".fileprovider",
140-
file
141-
)
136+
miMedia.path?.let {
137+
val file = File(it)
138+
val fileUri = FileProvider.getUriForFile(
139+
this,
140+
applicationContext.packageName + ".fileprovider", file
141+
)
142142

143-
val intent = Intent(Intent.ACTION_VIEW).apply {
144-
setDataAndType(fileUri, getMimeType(fileUri))
143+
val intent = Intent(Intent.ACTION_VIEW).apply {
144+
setDataAndType(fileUri, getMimeType(fileUri))
145+
}
146+
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
147+
startActivity(Intent.createChooser(intent, "Open file"))
145148
}
146-
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
147-
startActivity(Intent.createChooser(intent, "Open file"))
148149
}
149150
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.72'
4+
ext.kotlin_version = '1.4.21'
55
repositories {
66
google()
77
jcenter()
88
maven { url "https://jitpack.io" }
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:4.1.0'
11+
classpath 'com.android.tools.build:gradle:4.1.1'
1212
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1313
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1414
// NOTE: Do not place your application dependencies here; they belong

lassi/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
defaultConfig {
1313
minSdkVersion 17
1414
targetSdkVersion 29
15-
versionCode 15
16-
versionName "0.1.5"
15+
versionCode 16
16+
versionName "0.1.6"
1717
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1818
vectorDrawables.useSupportLibrary = true
1919
}
@@ -42,7 +42,7 @@ android {
4242

4343
dependencies {
4444
implementation fileTree(dir: 'libs', include: ['*.jar'])
45-
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10'
45+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.21'
4646
implementation 'androidx.appcompat:appcompat:1.2.0'
4747
implementation 'androidx.core:core-ktx:1.3.2'
4848
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
@@ -62,7 +62,7 @@ dependencies {
6262
// glide
6363
implementation 'com.github.bumptech.glide:glide:4.11.0'
6464
kapt 'com.github.bumptech.glide:compiler:4.11.0'
65-
implementation 'androidx.exifinterface:exifinterface:1.3.1'
65+
implementation 'androidx.exifinterface:exifinterface:1.3.2'
6666
}
6767
repositories {
6868
mavenCentral()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ object KeyUtils {
99
const val DEFAULT_MEDIA_COUNT = 1
1010
const val DEFAULT_GRID_SIZE = 2
1111
const val MAX_GRID_SIZE = 4
12-
const val DEFAULT_VIDEO_DURATION = 0L
12+
const val DEFAULT_DURATION = 0L
1313
const val ONE_SECOND_INTERVAL = 1000L
1414
const val FIVE_SECOND_INTERVAL = 5 * 1000L
1515
const val TEN_SECOND_INTERVAL = 10 * 1000L
1616
const val SETTINGS_REQUEST_CODE = 100
17+
const val DEFAULT_FILE_SIZE = 0L
1718
}

0 commit comments

Comments
 (0)