added share file from history card details

This commit is contained in:
deniscerri 2023-03-19 16:42:13 +01:00
parent d3887dd7d9
commit a2a6869585
No known key found for this signature in database
GPG key ID: 95C43D517D830350
3 changed files with 23 additions and 3 deletions

View file

@ -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)

View file

@ -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()

View file

@ -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)
}