fixes
This commit is contained in:
parent
04b5dd5f72
commit
7a25a19127
7 changed files with 67 additions and 20 deletions
|
|
@ -198,7 +198,20 @@ class FolderSettingsFragment : BaseSettingsFragment() {
|
|||
downloadViewModel.getActiveDownloadsCount()
|
||||
}
|
||||
if (activeDownloadCount == 0){
|
||||
File(FileUtil.getCachePath(requireContext())).deleteRecursively()
|
||||
fun clearCacheFolder(folder: File) {
|
||||
if (folder.exists() && folder.isDirectory) {
|
||||
folder.listFiles()?.forEach { file ->
|
||||
if (file.isDirectory) {
|
||||
clearCacheFolder(file)
|
||||
file.delete()
|
||||
} else {
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
clearCacheFolder(File(FileUtil.getCachePath(requireContext())))
|
||||
|
||||
Snackbar.make(requireView(), getString(R.string.cache_cleared), Snackbar.LENGTH_SHORT).show()
|
||||
cacheSize = File(FileUtil.getCachePath(requireContext())).walkBottomUp().fold(0L) { acc, file -> acc + file.length() }
|
||||
clearCache!!.summary = "(${FileUtil.convertFileSize(cacheSize)}) ${resources.getString(R.string.clear_temporary_files_summary)}"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import androidx.navigation.fragment.findNavController
|
|||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
import com.afollestad.materialdialogs.utils.MDUtil.getStringArray
|
||||
import com.deniscerri.ytdl.R
|
||||
import com.deniscerri.ytdl.util.UiUtil
|
||||
|
|
@ -100,6 +101,23 @@ class ProcessingSettingsFragment : BaseSettingsFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
val recodeVideoPreference = findPreference<SwitchPreferenceCompat>("recode_video")!!
|
||||
val compatibleVideoPreference = findPreference<SwitchPreferenceCompat>("compatible_video")!!
|
||||
|
||||
recodeVideoPreference.setOnPreferenceClickListener {
|
||||
if (compatibleVideoPreference.isChecked && recodeVideoPreference.isChecked) {
|
||||
compatibleVideoPreference.performClick()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
compatibleVideoPreference.setOnPreferenceClickListener {
|
||||
if (compatibleVideoPreference.isChecked && recodeVideoPreference.isChecked) {
|
||||
recodeVideoPreference.performClick()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
findPreference<Preference>("reset_preferences")?.setOnPreferenceClickListener {
|
||||
UiUtil.showGenericConfirmDialog(requireContext(), getString(R.string.reset), getString(R.string.reset_preferences_in_screen)) {
|
||||
resetPreferences(editor, R.xml.processing_preferences)
|
||||
|
|
|
|||
|
|
@ -1457,25 +1457,35 @@ object UiUtil {
|
|||
val recodeVideo = view.findViewById<Chip>(R.id.recode_video)
|
||||
recodeVideo.setOnClickListener {
|
||||
val adjustVideoView = context.layoutInflater.inflate(R.layout.video_download_preferences_dialog, null)
|
||||
adjustVideoView.findViewById<MaterialSwitch>(R.id.recodeVideoSwitch).apply {
|
||||
|
||||
val recodeVideoSwitch = adjustVideoView.findViewById<MaterialSwitch>(R.id.recodeVideoSwitch)
|
||||
val compatibilityModeSwitch = adjustVideoView.findViewById<MaterialSwitch>(R.id.compatiblityModeSwitch)
|
||||
|
||||
recodeVideoSwitch.apply {
|
||||
isChecked = items.all { it.videoPreferences.recodeVideo }
|
||||
setOnCheckedChangeListener { _, b ->
|
||||
recodeVideoClicked(b)
|
||||
setOnClickListener { _ ->
|
||||
recodeVideoClicked(isChecked)
|
||||
|
||||
compatibilityModeSwitch.isChecked = false
|
||||
compatibilityModeClicked(false)
|
||||
}
|
||||
}
|
||||
|
||||
adjustVideoView.findViewById<MaterialSwitch>(R.id.compatiblityModeSwitch).apply {
|
||||
compatibilityModeSwitch.apply {
|
||||
isChecked = items.first().videoPreferences.compatibilityMode
|
||||
setOnCheckedChangeListener { _, b ->
|
||||
compatibilityModeClicked(b)
|
||||
setOnClickListener { _ ->
|
||||
compatibilityModeClicked(isChecked)
|
||||
|
||||
recodeVideoSwitch.isChecked = false
|
||||
recodeVideoClicked(false)
|
||||
}
|
||||
}
|
||||
|
||||
val adjustVideoDialog = MaterialAlertDialogBuilder(context)
|
||||
.setTitle(context.getString(R.string.recode_video))
|
||||
.setView(adjustVideoView)
|
||||
.setIcon(R.drawable.ic_video)
|
||||
.setNegativeButton(context.resources.getString(R.string.dismiss)) { _: DialogInterface?, _: Int -> }
|
||||
.setIcon(R.drawable.baseline_video_metadata)
|
||||
.setNegativeButton(context.resources.getString(R.string.ok)) { _: DialogInterface?, _: Int -> }
|
||||
|
||||
adjustVideoDialog.show()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1115,12 +1115,7 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
|
||||
var cont = ""
|
||||
val outputContainer = downloadItem.container
|
||||
if(
|
||||
outputContainer.isNotEmpty() &&
|
||||
outputContainer != "Default" &&
|
||||
outputContainer != context.getString(R.string.defaultValue) &&
|
||||
supportedContainers.contains(outputContainer)
|
||||
){
|
||||
if(outputContainer.isNotEmpty() && outputContainer != "Default" && outputContainer != context.getString(R.string.defaultValue) && supportedContainers.contains(outputContainer)){
|
||||
cont = outputContainer
|
||||
|
||||
val cantRecode = listOf("avi")
|
||||
|
|
@ -1150,7 +1145,7 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
//format logic
|
||||
var videoF = downloadItem.format.format_id
|
||||
var altAudioF = ""
|
||||
var audioF = downloadItem.videoPreferences.audioFormatIDs.map { f ->
|
||||
var audioF = downloadItem.videoPreferences.audioFormatIDs.joinToString("+") { f ->
|
||||
val format = downloadItem.allFormats.find { it.format_id == f }
|
||||
format?.run {
|
||||
if (this.format_id.matches(".*-[0-9]+".toRegex())) {
|
||||
|
|
@ -1162,7 +1157,7 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
}
|
||||
} else this.format_id
|
||||
} ?: f
|
||||
}.joinToString("+").ifBlank { "ba" }
|
||||
}.ifBlank { "ba" }
|
||||
val preferredAudioLanguage = sharedPreferences.getString("audio_language", "")!!
|
||||
if (downloadItem.videoPreferences.removeAudio) audioF = ""
|
||||
|
||||
|
|
@ -1175,7 +1170,6 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
val f = StringBuilder()
|
||||
|
||||
val preferredCodec = sharedPreferences.getString("video_codec", "")
|
||||
val preferredQuality = sharedPreferences.getString("video_quality", "best")
|
||||
val vCodecPrefIndex = context.getStringArray(R.array.video_codec_values).indexOf(preferredCodec)
|
||||
var vCodecPref = context.getStringArray(R.array.video_codec_values_ytdlp)[vCodecPrefIndex]
|
||||
|
||||
|
|
@ -1277,6 +1271,10 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
|
||||
if(!f.endsWith("b/")){
|
||||
//last fallback
|
||||
if (f.isBlank()) {
|
||||
f.append("bv/")
|
||||
}
|
||||
|
||||
f.append("b")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
app:chipIconVisible="true"
|
||||
app:chipIcon="@drawable/ic_video"
|
||||
app:chipIcon="@drawable/baseline_video_metadata"
|
||||
android:text="@string/recode_video" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@
|
|||
<string name="accents">Accents</string>
|
||||
<string name="high_contrast">High contrast</string>
|
||||
<string name="pure_theme_summary">Pure black / white theme</string>
|
||||
<string name="material_you">Material you</string>
|
||||
<string name="material_you">Material You</string>
|
||||
<string name="blue">Blue</string>
|
||||
<string name="red">Red</string>
|
||||
<string name="green">Green</string>
|
||||
|
|
|
|||
|
|
@ -243,6 +243,14 @@
|
|||
android:summary="@string/recode_video_summary"
|
||||
app:title="@string/recode_video" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:widgetLayout="@layout/preferece_material_switch"
|
||||
app:defaultValue="false"
|
||||
app:icon="@drawable/baseline_video_metadata"
|
||||
app:key="compatible_video"
|
||||
android:summary="@string/video_compatible_summary"
|
||||
app:title="@string/video_compatible" />
|
||||
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue=""
|
||||
|
|
|
|||
Loading…
Reference in a new issue