Skip to content

Commit 24e137b

Browse files
authored
FilePicker.kt
1 parent ba76e16 commit 24e137b

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1-
package com.subpilot.util
1+
package com.geekneuron.subpilot.util
22

3-
fun rememberSubtitlePicker(...) { ... }
3+
import android.app.Activity
4+
import android.content.Intent
5+
import android.net.Uri
6+
import androidx.activity.result.contract.ActivityResultContracts
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.runtime.remember
9+
import androidx.compose.runtime.rememberUpdatedState
10+
11+
class FilePicker(private val activity: Activity) {
12+
fun pickSubtitleFile(onFilePicked: (Uri?) -> Unit): Intent {
13+
val intent = Intent(Intent.ACTION_GET_CONTENT)
14+
intent.type = "*/*"
15+
intent.putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("application/x-subrip", "text/plain", "application/octet-stream"))
16+
return Intent.createChooser(intent, "Select Subtitle File")
17+
}
18+
19+
fun pickVideoFile(): Intent {
20+
val intent = Intent(Intent.ACTION_GET_CONTENT)
21+
intent.type = "video/*"
22+
intent.putExtra(Intent.EXTRA_MIME_TYPES, arrayOf("video/mp4", "video/x-matroska"))
23+
return Intent.createChooser(intent, "Select Video File")
24+
}
25+
}

0 commit comments

Comments
 (0)