fixed ytm playlist links not showing all items and more theme fixes
This commit is contained in:
parent
f28e438df9
commit
4b921bd6c7
18 changed files with 49 additions and 22 deletions
|
|
@ -128,7 +128,7 @@ dependencies {
|
|||
|
||||
implementation "androidx.appcompat:appcompat:$appCompatVer"
|
||||
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||
implementation 'com.google.android.material:material:1.9.0-beta01'
|
||||
implementation 'com.google.android.material:material:1.9.0-rc01'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.0'
|
||||
implementation 'androidx.preference:preference:1.2.0'
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import android.content.Intent
|
|||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
|
|
@ -16,6 +17,7 @@ import android.provider.Settings
|
|||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowManager
|
||||
import android.widget.CheckBox
|
||||
import android.widget.TextView
|
||||
import androidx.core.app.ActivityCompat
|
||||
|
|
@ -35,6 +37,7 @@ import com.deniscerri.ytdlnis.ui.more.settings.SettingsActivity
|
|||
import com.deniscerri.ytdlnis.util.ThemeUtil
|
||||
import com.deniscerri.ytdlnis.util.UpdateUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.elevation.SurfaceColors
|
||||
import com.google.android.material.navigation.NavigationBarView
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -47,6 +50,7 @@ import java.nio.charset.Charset
|
|||
import java.nio.charset.StandardCharsets
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
class MainActivity : BaseActivity() {
|
||||
|
||||
lateinit var context: Context
|
||||
|
|
@ -156,6 +160,8 @@ class MainActivity : BaseActivity() {
|
|||
true
|
||||
}
|
||||
}
|
||||
window.navigationBarColor = SurfaceColors.SURFACE_2.getColor(this)
|
||||
|
||||
cookieViewModel.updateCookiesFile()
|
||||
val intent = intent
|
||||
handleIntents(intent)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class ResultRepository(private val resultDao: ResultDao, private val commandTemp
|
|||
|
||||
suspend fun getPlaylist(inputQuery: String, resetResults: Boolean) : ArrayList<ResultItem?>{
|
||||
val query = inputQuery.split("list=".toRegex()).dropLastWhile { it.isEmpty() }
|
||||
.toTypedArray()[1]
|
||||
.toTypedArray()[1].split("&").first()
|
||||
var nextPageToken = ""
|
||||
if (resetResults) deleteAll()
|
||||
val infoUtil = InfoUtil(context)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
|||
erroredDownloads = repository.erroredDownloads
|
||||
|
||||
val videoFormat = getApplication<App>().resources.getStringArray(R.array.video_formats)
|
||||
val videoContainer = sharedPreferences.getString("video_format", "Default")
|
||||
var videoContainer = sharedPreferences.getString("video_format", "Default")
|
||||
if (videoContainer == "Default") videoContainer = application.getString(R.string.defaultValue)
|
||||
|
||||
defaultVideoFormats = mutableListOf()
|
||||
videoFormat.forEach {
|
||||
|
|
@ -77,7 +78,8 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
|||
|
||||
bestVideoFormat = defaultVideoFormats.last()
|
||||
|
||||
val audioContainer = sharedPreferences.getString("audio_format", "mp3")
|
||||
var audioContainer = sharedPreferences.getString("audio_format", "mp3")
|
||||
if (audioContainer == "Default") audioContainer = application.getString(R.string.defaultValue)
|
||||
bestAudioFormat = Format(
|
||||
getApplication<App>().resources.getString(R.string.best_quality),
|
||||
audioContainer!!,
|
||||
|
|
@ -228,7 +230,7 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
|||
try {
|
||||
val theFormats = formats.ifEmpty { defaultVideoFormats }
|
||||
|
||||
val qualityPreference = sharedPreferences.getString("video_quality", getApplication<App>().resources.getString(R.string.best_quality))
|
||||
val qualityPreference = sharedPreferences.getString("video_quality", application.getString(R.string.best_quality))
|
||||
if (qualityPreference == getApplication<App>().resources.getString(R.string.worst_quality)){
|
||||
theFormats.first { !it.format_note.contains("audio", ignoreCase = true) }
|
||||
}
|
||||
|
|
@ -267,7 +269,8 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
|||
fun getGenericAudioFormats() : MutableList<Format>{
|
||||
val audioFormats = application.resources.getStringArray(R.array.audio_formats)
|
||||
val formats = mutableListOf<Format>()
|
||||
val containerPreference = sharedPreferences.getString("audio_format", "Default")
|
||||
var containerPreference = sharedPreferences.getString("audio_format", "Default")
|
||||
if (containerPreference == "Default") containerPreference = application.getString(R.string.defaultValue)
|
||||
audioFormats.forEach { formats.add(Format(it, containerPreference!!,"","", "",0, it)) }
|
||||
return formats
|
||||
}
|
||||
|
|
@ -275,7 +278,8 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
|||
fun getGenericVideoFormats() : MutableList<Format>{
|
||||
val videoFormats = application.resources.getStringArray(R.array.video_formats)
|
||||
val formats = mutableListOf<Format>()
|
||||
val containerPreference = sharedPreferences.getString("video_format", "Default")
|
||||
var containerPreference = sharedPreferences.getString("video_format", "Default")
|
||||
if (containerPreference == "Default") containerPreference = application.getString(R.string.defaultValue)
|
||||
videoFormats.forEach { formats.add(Format(it, containerPreference!!,"","", "",0, it)) }
|
||||
return formats
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class ResultViewModel(application: Application) : AndroidViewModel(application)
|
|||
}
|
||||
fun getQueryType(inputQuery: String) : String {
|
||||
var type = "Search"
|
||||
val p = Pattern.compile("^(https?)://(www.)?youtu(.be)?")
|
||||
val p = Pattern.compile("^(https?)://(www.)?(music.)?youtu(.be)?")
|
||||
val m = p.matcher(inputQuery)
|
||||
if (m.find()) {
|
||||
type = "Video"
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import android.provider.Settings
|
|||
import android.util.Log
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
|
@ -34,6 +35,7 @@ import com.deniscerri.ytdlnis.database.viewmodel.ResultViewModel
|
|||
import com.deniscerri.ytdlnis.ui.BaseActivity
|
||||
import com.deniscerri.ytdlnis.ui.downloadcard.DownloadBottomSheetDialog
|
||||
import com.deniscerri.ytdlnis.ui.downloadcard.SelectPlaylistItemsBottomSheetDialog
|
||||
import com.deniscerri.ytdlnis.util.ThemeUtil
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -53,6 +55,7 @@ class ShareActivity : BaseActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeUtil.updateTheme(this)
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { v, insets ->
|
||||
v.setPadding(0, 0, 0, 0)
|
||||
|
|
|
|||
|
|
@ -126,7 +126,8 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
|
|||
if (formats.isEmpty()) formats.addAll(downloadItem.allFormats.filter { it.format_note.contains("audio", ignoreCase = true) })
|
||||
|
||||
val containers = requireContext().resources.getStringArray(R.array.audio_containers)
|
||||
val containerPreference = sharedPreferences.getString("audio_format", "Default")
|
||||
var containerPreference = sharedPreferences.getString("audio_format", "Default")
|
||||
if (containerPreference == "Default") containerPreference = getString(R.string.defaultValue)
|
||||
val container = view.findViewById<TextInputLayout>(R.id.downloadContainer)
|
||||
val containerAutoCompleteTextView =
|
||||
view.findViewById<AutoCompleteTextView>(R.id.container_textview)
|
||||
|
|
@ -154,7 +155,7 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
|
|||
formats = allFormats.first().toMutableList()
|
||||
}
|
||||
}
|
||||
formatCard.setOnClickListener{_ ->
|
||||
formatCard.setOnClickListener{
|
||||
if (parentFragmentManager.findFragmentByTag("formatSheet") == null){
|
||||
val bottomSheet = FormatSelectionBottomSheetDialog(listOf(downloadItem), listOf(formats), listener)
|
||||
bottomSheet.show(parentFragmentManager, "formatSheet")
|
||||
|
|
@ -215,13 +216,13 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
|
|||
builder.setMultiChoiceItems(
|
||||
entries,
|
||||
checkedItems.toBooleanArray()
|
||||
) { dialog, which, isChecked ->
|
||||
) { _, which, isChecked ->
|
||||
checkedItems[which] = isChecked
|
||||
}
|
||||
|
||||
builder.setPositiveButton(
|
||||
getString(R.string.ok)
|
||||
) { dialog: DialogInterface?, which: Int ->
|
||||
) { _: DialogInterface?, _: Int ->
|
||||
downloadItem.audioPreferences.sponsorBlockFilters.clear()
|
||||
for (i in 0 until checkedItems.size) {
|
||||
if (checkedItems[i]) {
|
||||
|
|
@ -233,7 +234,7 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
|
|||
// handle the negative button of the alert dialog
|
||||
builder.setNegativeButton(
|
||||
getString(R.string.cancel)
|
||||
) { dialog: DialogInterface?, which: Int -> }
|
||||
) { _: DialogInterface?, _: Int -> }
|
||||
|
||||
|
||||
val dialog = builder.create()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.content.DialogInterface
|
|||
import android.os.Bundle
|
||||
import android.text.format.DateFormat
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
|
@ -220,7 +221,9 @@ class DownloadBottomSheetDialog(private val resultItem: ResultItem, private val
|
|||
parentFragmentManager.beginTransaction().remove(parentFragmentManager.findFragmentByTag("downloadSingleSheet")!!).commit()
|
||||
parentFragmentManager.beginTransaction().remove(downloadVideoFragment).commit()
|
||||
parentFragmentManager.beginTransaction().remove(downloadVideoFragment).commit()
|
||||
parentFragmentManager.beginTransaction().remove(downloadCommandFragment).commit()
|
||||
if (this::downloadCommandFragment.isInitialized){
|
||||
parentFragmentManager.beginTransaction().remove(downloadCommandFragment).commit()
|
||||
}
|
||||
if (activity is ShareActivity){
|
||||
(activity as ShareActivity).finish()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,8 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
|
|||
val container = view.findViewById<TextInputLayout>(R.id.downloadContainer)
|
||||
val containerAutoCompleteTextView =
|
||||
view.findViewById<AutoCompleteTextView>(R.id.container_textview)
|
||||
val containerPreference = sharedPreferences.getString("video_format", "Default")
|
||||
var containerPreference = sharedPreferences.getString("video_format", "Default")
|
||||
if (containerPreference == "Default") containerPreference = getString(R.string.defaultValue)
|
||||
|
||||
if (formats.isEmpty()) formats = downloadViewModel.getGenericVideoFormats()
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import androidx.work.WorkManager
|
|||
import com.deniscerri.ytdlnis.R
|
||||
import com.deniscerri.ytdlnis.adapter.ActiveDownloadAdapter
|
||||
import com.deniscerri.ytdlnis.database.models.DownloadItem
|
||||
import com.deniscerri.ytdlnis.database.repository.DownloadRepository
|
||||
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel
|
||||
import com.deniscerri.ytdlnis.databinding.FragmentHomeBinding
|
||||
import com.deniscerri.ytdlnis.ui.more.downloadLogs.DownloadLogActivity
|
||||
|
|
@ -26,6 +27,7 @@ import com.deniscerri.ytdlnis.util.FileUtil
|
|||
import com.deniscerri.ytdlnis.util.NotificationUtil
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
import com.yausername.youtubedl_android.YoutubeDL
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
|
||||
class ActiveDownloadsFragment() : Fragment(), ActiveDownloadAdapter.OnItemClickListener, OnClickListener {
|
||||
|
|
@ -124,7 +126,12 @@ class ActiveDownloadsFragment() : Fragment(), ActiveDownloadAdapter.OnItemClickL
|
|||
}
|
||||
|
||||
private fun cancelDownload(itemID: Long){
|
||||
list.find { it.id == itemID }?.let { downloadViewModel.deleteDownload(it) }
|
||||
list.find { it.id == itemID }?.let {
|
||||
it.status = DownloadRepository.Status.Cancelled.toString()
|
||||
downloadViewModel.updateDownload(it)
|
||||
}
|
||||
|
||||
|
||||
val id = itemID.toInt()
|
||||
YoutubeDL.getInstance().destroyProcessById(id.toString())
|
||||
WorkManager.getInstance(requireContext()).cancelUniqueWork(id.toString())
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ class NotificationUtil(var context: Context) {
|
|||
notificationBuilder
|
||||
.setContentTitle("${context.getString(R.string.failed_download)}: $title")
|
||||
.setContentText(error)
|
||||
.setContentIntent(errorPendingIntent)
|
||||
.setSmallIcon(R.drawable.ic_app_icon)
|
||||
.setLargeIcon(
|
||||
BitmapFactory.decodeResource(
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ class DownloadWorker(
|
|||
else if (audioQualityId == context.getString(R.string.worst_quality)) audioQualityId = "worstaudio"
|
||||
|
||||
val ext = downloadItem.format.container
|
||||
if (audioQualityId.isBlank() || ext == "Default") request.addOption("-x")
|
||||
if (audioQualityId.isBlank() || ext == "Default" || ext == context.getString(R.string.defaultValue)) request.addOption("-x")
|
||||
else request.addOption("-f", audioQualityId)
|
||||
|
||||
if(ext != "webm"){
|
||||
|
|
@ -217,7 +217,7 @@ class DownloadWorker(
|
|||
Log.e(TAG, formatArgument)
|
||||
request.addOption("-f", formatArgument)
|
||||
val format = downloadItem.format.container
|
||||
if(format.isNotEmpty() && format != "Default"){
|
||||
if(format.isNotEmpty() && format != "Default" && format != context.getString(R.string.defaultValue)){
|
||||
request.addOption("--merge-output-format", format)
|
||||
if (format != "webm") {
|
||||
val embedThumb = sharedPreferences.getBoolean("embed_thumbnail", false)
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@
|
|||
>
|
||||
|
||||
<TextView
|
||||
android:paddingTop="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:textSize="15sp"
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="none"
|
||||
app:simpleItems="@array/video_formats"
|
||||
/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@
|
|||
android:paddingHorizontal="10dp">
|
||||
|
||||
<TextView
|
||||
android:paddingTop="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@
|
|||
<Button
|
||||
android:id="@+id/bottom_sheet_link"
|
||||
style="@style/Widget.Material3.Button.TextButton.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:text="@string/app_name"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="icon_bg">@android:color/background_dark</color>
|
||||
<color name="icon_bg">#1c1d23</color>
|
||||
<color name="black">#000000</color>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<color name="black">#000000</color>
|
||||
<color name="grey">#323232</color>
|
||||
<color name="light_grey">#A6A6A6</color>
|
||||
<color name="icon_bg">@android:color/background_dark</color>
|
||||
<color name="icon_bg">#1c1d23</color>
|
||||
<color name="icon_fg">#d43c3c</color>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue