Skip to content

Commit 4d37779

Browse files
sanjay-miakashmi
andauthored
Develop (#55)
- issues fixes and improvements. Co-authored-by: AKASH PATEL <[email protected]>
1 parent 4934336 commit 4d37779

File tree

23 files changed

+224
-29
lines changed

23 files changed

+224
-29
lines changed

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
1717
* Filter by particular media type
1818
* Filter videos by min and max time
1919
* Enable/disable camera from LassiOption
20+
* You can open System Default view for file selection by using MediaType.FILE_TYPE_WITH_SYSTEM_VIEW
2021

2122
# Usage
2223

@@ -51,18 +52,19 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
5152
```groovy
5253
dependencies {
5354
...
54-
implementation 'com.github.Mindinventory:Lassi:0.3.0'
55+
implementation 'com.github.Mindinventory:Lassi:X.X.X'
5556
}
5657
```
5758
5859
### Implementation
5960
6061
61-
* Step 1. Add Lassi in to your activity class:
62+
* Step 1.
63+
To open a app color theme view then add Lassi in to your activity class:
6264
6365
```kotlin
6466
val intent = Lassi(this)
65-
.with(LassiOption.CAMERA_AND_GALLERY) // choose Option CAMERA, GALLERY or CAMERA_AND_GALLERY
67+
.with(LassiOption.CAMERA_AND_GALLERY) // choose Option CAMERA or CAMERA_AND_GALLERY
6668
.setMaxCount(5)
6769
.setGridSize(3)
6870
.setMediaType(MediaType.VIDEO) // MediaType : VIDEO IMAGE, AUDIO OR DOC
@@ -90,7 +92,18 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
9092
.build()
9193
receiveData.launch(intent)
9294
```
95+
`OR` To open a system default view then add Lassi in to your activity class:
9396
97+
```kotlin
98+
val intent = Lassi(this)
99+
.setMediaType(MediaType.FILE_TYPE_WITH_SYSTEM_VIEW)
100+
.setSupportedFileTypes(
101+
"jpg", "jpeg", "png", "webp", "gif", "mp4", "mkv", "webm", "avi", "flv", "3gp",
102+
"pdf", "odt", "doc", "docs", "docx", "txt", "ppt", "pptx", "rtf", "xlsx", "xls"
103+
) // Filter by required media format (Mandatory)
104+
.build()
105+
receiveData.launch(intent)
106+
```
94107

95108
* Step 2. Get Lassi result in ActivityResultCallback lambda function.
96109

@@ -110,6 +123,10 @@ Lassi is simplest way to pick media (either image, video, audio or doc)
110123

111124
### Document access permission note
112125
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.
126+
If you don't want to give Manage External Storage permission and wants to get files with system default view then You can use `OR` option from Step 1 and give required file type of document.
127+
128+
### MediaType.FILE_TYPE_WITH_SYSTEM_VIEW (for System Default View)
129+
Using this MediaType you can choose multiple files from system default view. You can't set max count limit for file choose. Give file type into setSupportedFileTypes and you can choose only those types of file from system view.
113130
114131
### Guideline for contributors
115132
Contribution towards our repository is always welcome, we request contributors to create a pull request to the **develop** branch only.
@@ -125,7 +142,7 @@ It would be great for us if the reporter can share the below things to understan
125142
126143
### Requirements
127144
128-
* minSdkVersion >= 17
145+
* minSdkVersion >= 19
129146
* Androidx
130147
131148
### Library used

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
compileSdkVersion 32
99
defaultConfig {
1010
applicationId "com.lassi.app"
11-
minSdkVersion 17
11+
minSdkVersion 19
1212
targetSdkVersion 32
1313
versionCode 1
1414
versionName "1.0"

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
3737
btnVideoPicker.setOnClickListener(this)
3838
btnAudioPicker.setOnClickListener(this)
3939
btnDocPicker.setOnClickListener(this)
40+
btnDocumentSystemIntent.setOnClickListener(this)
4041
rvSelectedMedia.adapter = selectedMediaAdapter
4142
rvSelectedMedia.addItemDecoration(GridSpacingItemDecoration(2, 10))
4243
}
@@ -108,6 +109,36 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
108109
R.id.btnDocPicker -> {
109110
requestPermissionForDocument()
110111
}
112+
R.id.btnDocumentSystemIntent -> {
113+
val intent = Lassi(this)
114+
.setMediaType(MediaType.FILE_TYPE_WITH_SYSTEM_VIEW)
115+
.setSupportedFileTypes(
116+
"jpg",
117+
"jpeg",
118+
"png",
119+
"webp",
120+
"gif",
121+
"mp4",
122+
"mkv",
123+
"webm",
124+
"avi",
125+
"flv",
126+
"3gp",
127+
"pdf",
128+
"odt",
129+
"doc",
130+
"docs",
131+
"docx",
132+
"txt",
133+
"ppt",
134+
"pptx",
135+
"rtf",
136+
"xlsx",
137+
"xls"
138+
)
139+
.build()
140+
receiveData.launch(intent)
141+
}
111142
}
112143
}
113144

@@ -206,7 +237,6 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
206237
}
207238
}
208239
}
209-
210240
else -> {
211241
launchDocPicker()
212242
}

app/src/main/res/layout/activity_main.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@
8686
app:layout_constraintHorizontal_bias="0.5"
8787
app:layout_constraintStart_toStartOf="parent"
8888
app:layout_constraintTop_toBottomOf="@+id/btnImagePicker" />
89+
90+
<Button
91+
android:id="@+id/btnDocumentSystemIntent"
92+
android:layout_width="wrap_content"
93+
android:layout_height="wrap_content"
94+
android:layout_marginTop="16dp"
95+
android:background="@drawable/bg_rounded_button"
96+
android:drawableStart="@drawable/ic_document"
97+
android:padding="10dp"
98+
android:text="@string/open_system_view"
99+
android:textAllCaps="false"
100+
android:textColor="@android:color/white"
101+
android:textSize="16sp"
102+
android:textStyle="bold"
103+
app:layout_constraintHorizontal_bias="0.5"
104+
app:layout_constraintStart_toStartOf="parent"
105+
app:layout_constraintEnd_toEndOf="parent"
106+
app:layout_constraintTop_toBottomOf="@+id/btnAudioPicker" />
89107
</androidx.constraintlayout.widget.ConstraintLayout>
90108

91109
<androidx.recyclerview.widget.RecyclerView

app/src/main/res/mipmap-hdpi/ic_launcher.png

100644100755
File mode changed.

app/src/main/res/mipmap-hdpi/ic_launcher_round.png

100644100755
File mode changed.

app/src/main/res/mipmap-mdpi/ic_launcher.png

100644100755
File mode changed.

app/src/main/res/mipmap-mdpi/ic_launcher_round.png

100644100755
File mode changed.

app/src/main/res/mipmap-xhdpi/ic_launcher.png

100644100755
File mode changed.

app/src/main/res/mipmap-xhdpi/ic_launcher_round.png

100644100755
File mode changed.

0 commit comments

Comments
 (0)