added share file from history card details
This commit is contained in:
parent
d3887dd7d9
commit
a2a6869585
3 changed files with 23 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ package com.deniscerri.ytdlnis.ui.downloads
|
|||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
|
|
@ -418,6 +419,12 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
|
|||
btn.icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_terminal)
|
||||
}
|
||||
|
||||
if (isPresent){
|
||||
btn.setOnClickListener {
|
||||
uiUtil!!.shareFileIntent(requireContext(),item.downloadPath)
|
||||
}
|
||||
}
|
||||
|
||||
val time = bottomSheet!!.findViewById<TextView>(R.id.time)
|
||||
val formatNote = bottomSheet!!.findViewById<TextView>(R.id.format_note)
|
||||
val container = bottomSheet!!.findViewById<TextView>(R.id.container_chip)
|
||||
|
|
|
|||
|
|
@ -223,6 +223,19 @@ class UiUtil(private val fileUtil: FileUtil) {
|
|||
fragmentContext.startActivity(i)
|
||||
}
|
||||
|
||||
fun shareFileIntent(fragmentContext: Context, downloadPath: String){
|
||||
val file = File(downloadPath)
|
||||
val uri = FileProvider.getUriForFile(
|
||||
fragmentContext,
|
||||
fragmentContext.packageName + ".fileprovider",
|
||||
file
|
||||
)
|
||||
val mime = fragmentContext.contentResolver.getType(uri)
|
||||
val i = Intent(Intent.ACTION_SEND)
|
||||
i.setDataAndType(uri, mime)
|
||||
fragmentContext.startActivity(i)
|
||||
}
|
||||
|
||||
fun showDatePicker(fragmentManager: FragmentManager , onSubmit : (chosenDate: Calendar) -> Unit ){
|
||||
val currentDate = Calendar.getInstance()
|
||||
val date = Calendar.getInstance()
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class DownloadWorker(
|
|||
if (downloadItem.author.isNotEmpty()){
|
||||
request.addCommands(listOf("--replace-in-metadata","uploader",".*.",downloadItem.author))
|
||||
}
|
||||
if (downloadItem.customFileNameTemplate.isEmpty()) downloadItem.customFileNameTemplate = "%(uploader)s - %(title)s"
|
||||
if (downloadItem.customFileNameTemplate.isBlank()) downloadItem.customFileNameTemplate = "%(uploader)s - %(title)s"
|
||||
}
|
||||
|
||||
if (sharedPreferences.getBoolean("restrict_filenames", true)) {
|
||||
|
|
@ -119,8 +119,8 @@ class DownloadWorker(
|
|||
DownloadViewModel.Type.audio -> {
|
||||
request.addOption("-x")
|
||||
var audioQualityId : String = downloadItem.format.format_id
|
||||
if (audioQualityId.isEmpty() || audioQualityId == "0" || audioQualityId == context.getString(R.string.best_quality)) audioQualityId = ""
|
||||
if (audioQualityId.isNotEmpty()){
|
||||
if (audioQualityId.isBlank() || audioQualityId == "0" || audioQualityId == context.getString(R.string.best_quality)) audioQualityId = ""
|
||||
if (audioQualityId.isNotBlank()){
|
||||
request.addOption("-f", audioQualityId)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue