Skip to content

Commit 3ac3be6

Browse files
sanjay-mibhoomishah20akashmimalikmotanimilanvadhel-mi
authored
Develop (#29)
* -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 <bhoomishah20495@gmail.com> Co-authored-by: AKASH PATEL <akash.mindinventory@gmail.com> Co-authored-by: milanvadhel-mi <73939866+milanvadhel-mi@users.noreply.github.com> * 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 <mjmotani@gmail.com> 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> Co-authored-by: Faiyaz meghreji <50236417+faiyaz92@users.noreply.github.com> Co-authored-by: Bhoomi Shah <bhoomishah20495@gmail.com> Co-authored-by: AKASH PATEL <akash.mindinventory@gmail.com> Co-authored-by: Malik Motani <mjmotani@gmail.com> Co-authored-by: milanvadhel-mi <73939866+milanvadhel-mi@users.noreply.github.com> Co-authored-by: Faiyaz meghreji <50236417+faiyaz92@users.noreply.github.com>
1 parent b022a3e commit 3ac3be6

File tree

18 files changed

+381
-204
lines changed

18 files changed

+381
-204
lines changed

app/build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@ apply plugin: 'kotlin-kapt'
88

99
android {
1010
compileSdkVersion 30
11+
buildToolsVersion '30.0.3'
1112
defaultConfig {
1213
applicationId "com.lassi.app"
1314
minSdkVersion 17
1415
targetSdkVersion 30
1516
versionCode 1
1617
versionName "1.0"
1718
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19+
multiDexEnabled true
1820
}
1921
buildTypes {
22+
debug{
23+
debuggable true
24+
minifyEnabled false
25+
shrinkResources false
26+
}
2027
release {
2128
minifyEnabled false
2229
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
@@ -35,15 +42,17 @@ dependencies {
3542
implementation 'androidx.appcompat:appcompat:1.2.0'
3643
implementation 'androidx.core:core-ktx:1.3.2'
3744
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
38-
testImplementation 'junit:junit:4.13.1'
45+
testImplementation 'junit:junit:4.13.2'
3946
androidTestImplementation 'androidx.test:runner:1.3.0'
4047
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
4148
implementation project(path: ':lassi')
42-
implementation 'androidx.recyclerview:recyclerview:1.1.0'
49+
implementation 'androidx.recyclerview:recyclerview:1.2.0'
4350
implementation 'androidx.cardview:cardview:1.0.0'
4451

4552
// glide
46-
implementation 'com.github.bumptech.glide:glide:4.11.0'
47-
kapt 'com.github.bumptech.glide:compiler:4.11.0'
53+
implementation 'com.github.bumptech.glide:glide:4.12.0'
54+
kapt 'com.github.bumptech.glide:compiler:4.12.0'
55+
56+
implementation "androidx.multidex:multidex:2.0.1"
4857

4958
}

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
android:supportsRtl="true"
1212
android:preserveLegacyExternalStorage="true"
1313
android:theme="@style/AppTheme">
14-
<activity android:name=".MainActivity">
14+
15+
<activity
16+
android:name=".MainActivity"
17+
android:exported="true">
1518
<intent-filter>
1619
<action android:name="android.intent.action.MAIN" />
1720
<action android:name="android.intent.action.VIEW" />

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

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import com.lassi.presentation.common.decoration.GridSpacingItemDecoration
1919
import com.lassi.presentation.cropper.CropImageView
2020
import kotlinx.android.synthetic.main.activity_main.*
2121
import java.io.File
22+
import java.util.*
2223

2324
class MainActivity : AppCompatActivity(), View.OnClickListener {
2425

@@ -52,8 +53,8 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
5253
.setCropType(CropImageView.CropShape.OVAL)
5354
.setCropAspectRatio(1, 1)
5455
.setCompressionRation(10)
55-
.setMinFileSize(100)
56-
.setMaxFileSize(200)
56+
.setMinFileSize(0)
57+
.setMaxFileSize(1000)
5758
.enableActualCircleCrop()
5859
.setSupportedFileTypes("jpg", "jpeg", "png", "webp", "gif")
5960
.enableFlip()
@@ -64,20 +65,20 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
6465
R.id.btnVideoPicker -> {
6566
val intent = Lassi(this)
6667
.with(LassiOption.CAMERA_AND_GALLERY)
67-
.setMaxCount(4)
68+
.setMaxCount(1)
6869
.setGridSize(3)
69-
.setMinTime(15)
70+
.setMinTime(5)
7071
.setMaxTime(30)
71-
.setMinFileSize(1024 * 5)
72-
.setMaxFileSize(1024 * 12)
72+
.setMinFileSize(0)
73+
.setMaxFileSize(2000)
7374
.setMediaType(MediaType.VIDEO)
7475
.setStatusBarColor(R.color.colorPrimaryDark)
7576
.setToolbarColor(R.color.colorPrimary)
7677
.setToolbarResourceColor(android.R.color.white)
7778
.setProgressBarColor(R.color.colorAccent)
7879
.setPlaceHolder(R.drawable.ic_video_placeholder)
7980
.setErrorDrawable(R.drawable.ic_video_placeholder)
80-
//.setSupportedFileTypes("mp4", "mkv", "webm", "avi", "flv", "3gp")
81+
.setSupportedFileTypes("mp4", "mkv", "webm", "avi", "flv", "3gp")
8182
.build()
8283
startActivityForResult(intent, MEDIA_REQUEST_CODE)
8384
}
@@ -106,7 +107,19 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
106107
.setStatusBarColor(R.color.colorPrimaryDark)
107108
.setToolbarColor(R.color.colorPrimary)
108109
.setToolbarResourceColor(android.R.color.white)
109-
.setSupportedFileTypes("pdf", "odt", "doc", "docs", "txt", "ppt", "pptx")
110+
.setSupportedFileTypes(
111+
"pdf",
112+
"odt",
113+
"doc",
114+
"docs",
115+
"docx",
116+
"txt",
117+
"ppt",
118+
"pptx",
119+
"rtf",
120+
"xlsx",
121+
"xls"
122+
)
110123
.setProgressBarColor(R.color.colorAccent)
111124
.build()
112125
startActivityForResult(intent, MEDIA_REQUEST_CODE)
@@ -128,21 +141,26 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
128141
contentResolver.getType(uri)
129142
} else {
130143
val fileExtension = MimeTypeMap.getFileExtensionFromUrl(uri.toString())
131-
MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.toLowerCase())
144+
MimeTypeMap.getSingleton()
145+
.getMimeTypeFromExtension(fileExtension.lowercase(Locale.getDefault()))
132146
}
133147
}
134148

135149
private fun onItemClicked(miMedia: MiMedia) {
136150
miMedia.path?.let {
137-
val file = File(it)
138-
val fileUri = FileProvider.getUriForFile(
139-
this,
140-
applicationContext.packageName + ".fileprovider", file
141-
)
142-
143-
val intent = Intent(Intent.ACTION_VIEW).apply {
144-
setDataAndType(fileUri, getMimeType(fileUri))
151+
val intent = Intent(Intent.ACTION_VIEW)
152+
if (miMedia.doesUri) {
153+
val uri = Uri.parse(it)
154+
intent.setDataAndType(uri, getMimeType(uri))
155+
} else {
156+
val file = File(it)
157+
val fileUri = FileProvider.getUriForFile(
158+
this,
159+
applicationContext.packageName + ".fileprovider", file
160+
)
161+
intent.setDataAndType(fileUri, getMimeType(fileUri))
145162
}
163+
146164
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
147165
startActivity(Intent.createChooser(intent, "Open file"))
148166
}

build.gradle

Lines changed: 4 additions & 4 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.4.21'
4+
ext.kotlin_version = '1.5.0'
55
repositories {
66
google()
7-
jcenter()
7+
mavenCentral()
88
maven { url "https://jitpack.io" }
99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:4.1.1'
11+
classpath 'com.android.tools.build:gradle:4.2.0'
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
@@ -19,7 +19,7 @@ buildscript {
1919
allprojects {
2020
repositories {
2121
google()
22-
jcenter()
22+
mavenCentral()
2323
maven { url "https://jitpack.io" }
2424
}
2525
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Nov 04 15:54:44 IST 2020
1+
#Fri Apr 30 18:22:17 IST 2021
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

lassi/build.gradle

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ android {
1212
defaultConfig {
1313
minSdkVersion 17
1414
targetSdkVersion 30
15-
versionCode 17
16-
versionName "0.1.7"
15+
versionCode 18
16+
versionName "0.2.0"
1717
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1818
vectorDrawables.useSupportLibrary = true
19+
multiDexEnabled true
1920
}
2021

2122
buildTypes {
23+
debug{
24+
debuggable true
25+
minifyEnabled false
26+
shrinkResources false
27+
}
2228
release {
2329
minifyEnabled false
2430
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
@@ -37,32 +43,36 @@ android {
3743
androidExtensions {
3844
experimental = true
3945
}
40-
4146
}
4247

4348
dependencies {
4449
implementation fileTree(dir: 'libs', include: ['*.jar'])
45-
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.21'
50+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.0'
4651
implementation 'androidx.appcompat:appcompat:1.2.0'
4752
implementation 'androidx.core:core-ktx:1.3.2'
4853
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
4954
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
50-
implementation "androidx.recyclerview:recyclerview:1.1.0"
55+
implementation "androidx.recyclerview:recyclerview:1.2.0"
5156
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
5257
implementation 'com.github.livefront:bridge:v1.2.0'
53-
testImplementation 'junit:junit:4.13.1'
58+
testImplementation 'junit:junit:4.13.2'
5459

5560
// Rx
5661
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
57-
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
62+
implementation 'io.reactivex.rxjava2:rxjava:2.2.12'
5863

5964
// Google material
60-
implementation 'com.google.android.material:material:1.2.1'
65+
implementation 'com.google.android.material:material:1.3.0'
6166

6267
// glide
63-
implementation 'com.github.bumptech.glide:glide:4.11.0'
64-
kapt 'com.github.bumptech.glide:compiler:4.11.0'
68+
implementation 'com.github.bumptech.glide:glide:4.12.0'
69+
kapt 'com.github.bumptech.glide:compiler:4.12.0'
6570
implementation 'androidx.exifinterface:exifinterface:1.3.2'
71+
72+
implementation "androidx.activity:activity-ktx:1.3.0-alpha07"
73+
implementation 'androidx.fragment:fragment-ktx:1.3.3'
74+
75+
implementation "androidx.multidex:multidex:2.0.1"
6676
}
6777
repositories {
6878
mavenCentral()

lassi/src/main/AndroidManifest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
23
package="com.lassi">
34

45
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
56
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7+
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
68
<uses-permission android:name="android.permission.CAMERA" />
79
<uses-permission android:name="android.permission.RECORD_AUDIO" />
810

@@ -19,7 +21,8 @@
1921
android:resizeableActivity="false"
2022
android:screenOrientation="portrait"
2123
android:supportsPictureInPicture="false"
22-
android:theme="@style/AppTheme" />
24+
android:theme="@style/AppTheme"
25+
tools:targetApi="n" />
2326
<activity
2427
android:name=".presentation.videopreview.VideoPreviewActivity"
2528
android:screenOrientation="portrait"

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.lassi.common.utils
22

33
import android.content.Context
44
import android.net.Uri
5-
import android.os.Environment
65
import androidx.fragment.app.FragmentActivity
76
import com.lassi.domain.media.LassiConfig
87
import com.lassi.presentation.cropper.CropImage
@@ -36,19 +35,23 @@ object CropUtils {
3635
)
3736
}
3837

39-
private fun getPath(context: Context): String {
40-
return Environment.getExternalStorageDirectory().absolutePath + File.separator + getApplicationName(
41-
context
42-
)
38+
private fun getDirectory(context: Context): File {
39+
val root = context.applicationContext.filesDir
40+
val myDir = File("$root" + File.separator + getApplicationName(context))
41+
if (!myDir.exists()) {
42+
myDir.mkdirs()
43+
}
44+
return myDir
45+
// return context.getExternalFilesDir(null)?.absolutePath + File.separator + getApplicationName(
46+
// context
47+
// )
48+
4349
}
4450

4551
private fun createDirectory(context: Context): Uri? {
46-
getPath(context).let {
47-
val storageDir = File(it)
48-
if (!storageDir.exists()) {
49-
storageDir.mkdirs()
50-
}
51-
52+
getDirectory(context).let {
53+
val storageDir = it
54+
Logger.d("CropUtils", "Directory path is ${it.absolutePath}")
5255
if (!storageDir.exists()) {
5356
val isDirectoryCreated = File(storageDir.path).mkdirs()
5457
Logger.d("CropUtils", "isDirectoryCreated >> $isDirectoryCreated")
@@ -77,15 +80,16 @@ object CropUtils {
7780
// Create an image file name
7881
val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(Date())
7982
// val storageDir: File? = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
80-
val storageDir =
81-
Environment.getExternalStorageDirectory().absolutePath + File.separator + getApplicationName(
82-
context
83-
)
83+
val storageDir = getDirectory(context)
84+
// context.getExternalFilesDir(null)?.absolutePath + File.separator + getApplicationName(
85+
// context
86+
// )
87+
8488

8589
return File.createTempFile(
8690
"IMG-${timeStamp}_", /* prefix */
8791
".jpeg", /* suffix */
88-
File(storageDir) /* directory */
92+
storageDir//File(storageDir) /* directory */
8993
)
9094
}
9195
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ import android.content.Context
44
import android.media.MediaScannerConnection
55
import android.net.Uri
66
import android.util.Log
7+
import java.util.*
78

89
object FilePickerUtils {
910

1011
fun contains(types: Array<String>, path: String): Boolean {
1112
for (string in types) {
12-
if (path.toLowerCase().endsWith(string)) return true
13+
if (path.lowercase(Locale.getDefault()).endsWith(string)) return true
1314
}
1415
return false
1516
}
1617

1718
fun notifyGalleryUpdateNewFile(
1819
context: Context,
1920
filePath: String,
20-
mimeType: String = "image/jpeg",
21-
onFileScanComplete: (uri: Uri) -> Unit
21+
mimeType: String = "image/*",
22+
onFileScanComplete: (uri: Uri?, path:String?) -> Unit
2223
) {
2324
context.let {
2425
MediaScannerConnection.scanFile(
@@ -27,7 +28,7 @@ object FilePickerUtils {
2728
arrayOf(mimeType)
2829
) { path, uri ->
2930
Log.d("ExternalStorage", "Scanned $path")
30-
onFileScanComplete(uri)
31+
onFileScanComplete(uri, path)
3132
}
3233
}
3334
}

0 commit comments

Comments
 (0)