Skip to content

Commit f721691

Browse files
author
Majid Arabi
committed
added - audio type
1 parent ef9e015 commit f721691

File tree

26 files changed

+435
-410
lines changed

26 files changed

+435
-410
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
[![Latestver](https://lv.binarybabel.org/catalog-api/gradle/latest.svg?v=7.2)](https://lv.binarybabel.org/catalog/gradle/latest)
77
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
88

9-
## Simple, Powerful and Beautiful Android Image or Video Picker 😎
9+
## Simple, Powerful and Beautiful Android Image/Video/Audio Picker 😎
1010
**Features** 😍
1111
- No need check storage permission 😉
1212
- Single and multiple selection
1313
- Supported RTL and LTR list direction (default=LTR)
14-
- Supported image and video (default=image)
14+
- Supported image, video or audio (default=image)
1515
- Supported custom title
1616
- Supported custom colors
1717
- Supported dynamic span count (default=2)
@@ -23,7 +23,7 @@
2323

2424
| Image | Image | Video
2525
|--|--|--|
26-
| <img src="https://github.com/MajidArabi/FilePicker/blob/master/screenshots/image-2col-full.jpg" width="250" /> | <img src="https://github.com/MajidArabi/FilePicker/blob/master/screenshots/image-3col.jpg" width="250" /> | <img src="https://github.com/MajidArabi/FilePicker/blob/master/screenshots/video-2col-full.jpg" width="250" />
26+
| <img src="https://github.com/MajidArabi/FilePicker/blob/master/screenshots/image.png" width="250" /> | <img src="https://github.com/MajidArabi/FilePicker/blob/master/screenshots/video.png" width="250" /> | <img src="https://github.com/MajidArabi/FilePicker/blob/master/screenshots/audio.png" width="250" />
2727

2828
## Download
2929

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
<category android:name="android.intent.category.LAUNCHER" />
1919
</intent-filter>
2020
</activity>
21-
<activity
22-
android:name=".JavaActivity"
23-
android:exported="true" />
2421
</application>
2522

2623
</manifest>

app/src/main/java/ir/one_developer/filepickerlibrary/JavaActivity.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

app/src/main/java/ir/one_developer/filepickerlibrary/MainActivity.kt

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package ir.one_developer.filepickerlibrary
22

3-
import android.content.Intent
43
import android.os.Bundle
54
import androidx.appcompat.app.AppCompatActivity
65
import androidx.core.content.ContextCompat
6+
import com.github.file_picker.FileType
7+
import com.github.file_picker.adapter.ItemAdapter
78
import com.github.file_picker.listener.OnItemClickListener
89
import com.github.file_picker.listener.OnSubmitClickListener
9-
import com.github.file_picker.adapter.ItemAdapter
1010
import com.github.file_picker.model.Media
1111
import com.github.file_picker.showFilePicker
1212
import ir.one_developer.filepickerlibrary.databinding.ActivityMainBinding
@@ -16,10 +16,10 @@ class MainActivity : AppCompatActivity() {
1616
private lateinit var adapter: FileAdapter
1717
private val selectedFiles = arrayListOf<Media>()
1818
private lateinit var binding: ActivityMainBinding
19-
20-
companion object {
21-
private const val TAG = "MainActivity"
22-
}
19+
20+
private var fileType: FileType = FileType.IMAGE
21+
private var accentColor: Int = R.color.purple_500
22+
private var spanCount: Int = 2
2323

2424
override fun onCreate(savedInstanceState: Bundle?) {
2525
super.onCreate(savedInstanceState)
@@ -34,16 +34,35 @@ class MainActivity : AppCompatActivity() {
3434
btnOpenFiles.setOnClickListener {
3535
showFiles()
3636
}
37-
fab.setOnClickListener {
38-
startActivity(Intent(this@MainActivity, JavaActivity::class.java))
37+
radioGroups.setOnCheckedChangeListener { _, i ->
38+
fileType = when (i) {
39+
1 -> {
40+
spanCount = 2
41+
accentColor = R.color.purple_500
42+
FileType.IMAGE
43+
}
44+
2 -> {
45+
spanCount = 2
46+
accentColor = R.color.pink_500
47+
FileType.VIDEO
48+
}
49+
3 -> {
50+
spanCount = 3
51+
accentColor = R.color.blue_500
52+
FileType.AUDIO
53+
}
54+
else -> FileType.IMAGE
55+
}
3956
}
4057
}
4158

4259
private fun showFiles(): Unit = showFilePicker(
60+
fileType = fileType,
4361
limitItemSelection = 2,
62+
gridSpanCount = spanCount,
4463
selectedFiles = selectedFiles,
45-
accentColor = ContextCompat.getColor(this@MainActivity, R.color.purple_700),
46-
titleTextColor = ContextCompat.getColor(this@MainActivity, R.color.purple_700),
64+
accentColor = ContextCompat.getColor(this@MainActivity, accentColor),
65+
titleTextColor = ContextCompat.getColor(this@MainActivity, accentColor),
4766
onSubmitClickListener = object : OnSubmitClickListener {
4867
override fun onClick(files: List<Media>) {
4968
adapter.submitList(files)

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

Lines changed: 0 additions & 49 deletions
This file was deleted.

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

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,50 @@
77
android:orientation="vertical"
88
tools:context=".MainActivity">
99

10+
<androidx.appcompat.widget.LinearLayoutCompat
11+
android:id="@+id/settings_container"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
android:orientation="vertical"
15+
android:padding="16dp">
16+
17+
<RadioGroup
18+
android:id="@+id/radio_groups"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:orientation="horizontal">
22+
23+
<com.google.android.material.textview.MaterialTextView
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:text="Type : "
27+
android:textSize="22sp" />
28+
29+
<com.google.android.material.radiobutton.MaterialRadioButton
30+
android:layout_width="wrap_content"
31+
android:layout_height="wrap_content"
32+
android:text="Image" />
33+
34+
<com.google.android.material.radiobutton.MaterialRadioButton
35+
android:layout_width="wrap_content"
36+
android:layout_height="wrap_content"
37+
android:text="Video" />
38+
39+
<com.google.android.material.radiobutton.MaterialRadioButton
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:text="Audio" />
43+
44+
</RadioGroup>
45+
46+
</androidx.appcompat.widget.LinearLayoutCompat>
47+
1048
<androidx.recyclerview.widget.RecyclerView
1149
android:id="@+id/rv_files"
1250
android:layout_width="match_parent"
1351
android:layout_height="match_parent"
1452
android:layout_above="@id/btn_open_files"
53+
android:layout_below="@+id/settings_container"
1554
android:clipToPadding="false"
1655
android:layoutDirection="rtl"
1756
android:padding="2dp"
@@ -35,15 +74,4 @@
3574
app:backgroundTint="@color/purple_700"
3675
app:cornerRadius="16dp" />
3776

38-
<com.google.android.material.floatingactionbutton.FloatingActionButton
39-
android:id="@+id/fab"
40-
android:layout_width="wrap_content"
41-
android:layout_height="wrap_content"
42-
android:layout_above="@id/btn_open_files"
43-
android:layout_alignParentEnd="true"
44-
android:layout_marginEnd="16dp"
45-
app:backgroundTint="@color/purple_700"
46-
app:srcCompat="@drawable/ic_chevron_right"
47-
app:tint="@color/white" />
48-
4977
</RelativeLayout>

app/src/main/res/values/colors.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<resources>
2+
<resources xmlns:tools="http://schemas.android.com/tools">
33
<color name="purple_200">#FFBB86FC</color>
44
<color name="purple_500">#FF6200EE</color>
55
<color name="purple_700">#FF3700B3</color>
66
<color name="teal_200">#FF03DAC5</color>
77
<color name="teal_700">#FF018786</color>
88
<color name="black">#FF000000</color>
99
<color name="white">#FFFFFFFF</color>
10+
<color name="pink_500">#E91E63</color>
11+
<color name="blue_500">#2196F3</color>
1012
</resources>

file-picker/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ afterEvaluate {
5858
from components.release
5959
groupId = 'com.github.majidarabi'
6060
artifactId = 'file-picker'
61-
version = '0.0.7'
61+
version = '0.0.8'
6262
}
6363
}
6464
}
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
package ir.one_developer.file_picker
22

3-
import androidx.test.platform.app.InstrumentationRegistry
4-
import androidx.test.ext.junit.runners.AndroidJUnit4
5-
6-
import org.junit.Test
7-
import org.junit.runner.RunWith
8-
9-
import org.junit.Assert.*
10-
113
/**
124
* Instrumented test, which will execute on an Android device.
135
*
146
* See [testing documentation](http://d.android.com/tools/testing).
157
*/
16-
@RunWith(AndroidJUnit4::class)
8+
//@RunWith(AndroidJUnit4::class)
179
class ExampleInstrumentedTest {
18-
@Test
19-
fun useAppContext() {
20-
// Context of the app under test.
21-
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22-
assertEquals("ir.one_developer.file_picker.test", appContext.packageName)
23-
}
10+
// @Test
11+
// fun useAppContext() {
12+
// // Context of the app under test.
13+
// val appContext = InstrumentationRegistry.getInstrumentation().targetContext
14+
// assertEquals("ir.one_developer.file_picker.test", appContext.packageName)
15+
// }
2416
}

file-picker/src/main/java/com/github/file_picker/Const.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ enum class ListDirection : Parcelable {
1212
@Parcelize
1313
enum class FileType : Parcelable {
1414
VIDEO,
15-
IMAGE
15+
IMAGE,
16+
AUDIO,
1617
}

0 commit comments

Comments
 (0)