fixes
This commit is contained in:
parent
53bc051bc1
commit
6f09746f96
7 changed files with 87 additions and 69 deletions
|
|
@ -268,6 +268,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
||||||
R.id.delete_results -> {
|
R.id.delete_results -> {
|
||||||
resultViewModel.getTrending()
|
resultViewModel.getTrending()
|
||||||
selectedObjects = ArrayList()
|
selectedObjects = ArrayList()
|
||||||
|
searchBar!!.text = ""
|
||||||
downloadAllFabCoordinator!!.visibility = GONE
|
downloadAllFabCoordinator!!.visibility = GONE
|
||||||
downloadFabs!!.visibility = GONE
|
downloadFabs!!.visibility = GONE
|
||||||
}
|
}
|
||||||
|
|
@ -287,9 +288,10 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initSearch(searchView: com.google.android.material.search.SearchView){
|
private fun initSearch(searchView: com.google.android.material.search.SearchView){
|
||||||
|
val inputQuery = searchView.text!!.trim { it <= ' '}
|
||||||
|
if (inputQuery.isEmpty()) return
|
||||||
searchBar!!.text = searchView.text
|
searchBar!!.text = searchView.text
|
||||||
searchView.hide()
|
searchView.hide()
|
||||||
val inputQuery = searchView.text!!.trim { it <= ' '}
|
|
||||||
if(!sharedPreferences!!.getBoolean("incognito", false)){
|
if(!sharedPreferences!!.getBoolean("incognito", false)){
|
||||||
resultViewModel.addSearchQueryToHistory(inputQuery.toString())
|
resultViewModel.addSearchQueryToHistory(inputQuery.toString())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,12 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
|
||||||
|
|
||||||
var formats = mutableListOf<Format>()
|
var formats = mutableListOf<Format>()
|
||||||
formats.addAll(resultItem.formats.filter { !it.format_note.contains("audio", ignoreCase = true) })
|
formats.addAll(resultItem.formats.filter { !it.format_note.contains("audio", ignoreCase = true) })
|
||||||
|
val videoFormats = resources.getStringArray(R.array.video_formats)
|
||||||
|
val containerPreference = sharedPreferences.getString("video_format", "Default")
|
||||||
|
|
||||||
if (formats.isEmpty()) {
|
if (formats.isEmpty()) {
|
||||||
val videoFormats = resources.getStringArray(R.array.video_formats)
|
|
||||||
val container = sharedPreferences.getString("video_format", "Default")
|
videoFormats.forEach { formats.add(Format(it, containerPreference!!,"","", "",0, it)) }
|
||||||
videoFormats.forEach { formats.add(Format(it, container!!,"","", "",0, it)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val containers = requireContext().resources.getStringArray(R.array.video_containers)
|
val containers = requireContext().resources.getStringArray(R.array.video_containers)
|
||||||
|
|
@ -136,14 +138,14 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
|
||||||
containers
|
containers
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
downloadItem.format.container = containerPreference!!
|
||||||
|
|
||||||
(container!!.editText as AutoCompleteTextView?)!!.onItemClickListener =
|
(container!!.editText as AutoCompleteTextView?)!!.onItemClickListener =
|
||||||
AdapterView.OnItemClickListener { _: AdapterView<*>?, _: View?, index: Int, _: Long ->
|
AdapterView.OnItemClickListener { _: AdapterView<*>?, _: View?, index: Int, _: Long ->
|
||||||
downloadItem.format.container = containers[index]
|
downloadItem.format.container = containers[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
val selectedContainer: String = downloadItem.format.container
|
containerAutoCompleteTextView!!.setText(downloadItem.format.container, false)
|
||||||
containerAutoCompleteTextView!!.setText(selectedContainer, false)
|
|
||||||
|
|
||||||
val formatCard = view.findViewById<ConstraintLayout>(R.id.format_card_constraintLayout)
|
val formatCard = view.findViewById<ConstraintLayout>(R.id.format_card_constraintLayout)
|
||||||
val chosenFormat = downloadItem.format
|
val chosenFormat = downloadItem.format
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
|
import android.graphics.ColorMatrix
|
||||||
|
import android.graphics.ColorMatrixColorFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
|
@ -13,6 +15,7 @@ import android.view.*
|
||||||
import android.view.View.*
|
import android.view.View.*
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
|
@ -24,6 +27,7 @@ import com.deniscerri.ytdlnis.adapter.HistoryAdapter
|
||||||
import com.deniscerri.ytdlnis.database.models.HistoryItem
|
import com.deniscerri.ytdlnis.database.models.HistoryItem
|
||||||
import com.deniscerri.ytdlnis.database.repository.HistoryRepository
|
import com.deniscerri.ytdlnis.database.repository.HistoryRepository
|
||||||
import com.deniscerri.ytdlnis.database.repository.HistoryRepository.HistorySort
|
import com.deniscerri.ytdlnis.database.repository.HistoryRepository.HistorySort
|
||||||
|
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel
|
||||||
import com.deniscerri.ytdlnis.database.viewmodel.HistoryViewModel
|
import com.deniscerri.ytdlnis.database.viewmodel.HistoryViewModel
|
||||||
import com.deniscerri.ytdlnis.databinding.FragmentHistoryBinding
|
import com.deniscerri.ytdlnis.databinding.FragmentHistoryBinding
|
||||||
import com.deniscerri.ytdlnis.util.FileUtil
|
import com.deniscerri.ytdlnis.util.FileUtil
|
||||||
|
|
@ -32,6 +36,7 @@ import com.facebook.shimmer.ShimmerFrameLayout
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import com.google.android.material.chip.ChipGroup
|
import com.google.android.material.chip.ChipGroup
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
@ -385,13 +390,22 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
|
||||||
val author = bottomSheet!!.findViewById<TextView>(R.id.bottom_sheet_author)
|
val author = bottomSheet!!.findViewById<TextView>(R.id.bottom_sheet_author)
|
||||||
author!!.text = item.author
|
author!!.text = item.author
|
||||||
|
|
||||||
val type = bottomSheet!!.findViewById<TextView>(R.id.type)
|
// BUTTON ----------------------------------
|
||||||
|
val buttonLayout = bottomSheet!!.findViewById<LinearLayout>(R.id.downloads_download_button_layout)
|
||||||
|
val btn = buttonLayout!!.findViewById<MaterialButton>(R.id.downloads_download_button_type)
|
||||||
|
|
||||||
|
if (item.type == DownloadViewModel.Type.audio) {
|
||||||
|
if (isPresent) btn.icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_music_downloaded) else btn.icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_music)
|
||||||
|
} else if (item.type == DownloadViewModel.Type.video) {
|
||||||
|
if (isPresent) btn.icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_video_downloaded) else btn.icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_video)
|
||||||
|
}else{
|
||||||
|
btn.icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_terminal)
|
||||||
|
}
|
||||||
|
|
||||||
val formatNote = bottomSheet!!.findViewById<TextView>(R.id.format_note)
|
val formatNote = bottomSheet!!.findViewById<TextView>(R.id.format_note)
|
||||||
val codec = bottomSheet!!.findViewById<TextView>(R.id.codec)
|
val codec = bottomSheet!!.findViewById<TextView>(R.id.codec)
|
||||||
val fileSize = bottomSheet!!.findViewById<TextView>(R.id.file_size)
|
val fileSize = bottomSheet!!.findViewById<TextView>(R.id.file_size)
|
||||||
|
|
||||||
type!!.text = item.type.toString().uppercase()
|
|
||||||
|
|
||||||
if (item.format.format_note == "?" || item.format.format_note == "") formatNote!!.visibility = View.GONE
|
if (item.format.format_note == "?" || item.format.format_note == "") formatNote!!.visibility = View.GONE
|
||||||
else formatNote!!.text = item.format.format_note
|
else formatNote!!.text = item.format.format_note
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import android.provider.DocumentsContract
|
||||||
import android.webkit.MimeTypeMap
|
import android.webkit.MimeTypeMap
|
||||||
import com.deniscerri.ytdlnis.R
|
import com.deniscerri.ytdlnis.R
|
||||||
import okhttp3.internal.closeQuietly
|
import okhttp3.internal.closeQuietly
|
||||||
|
import okhttp3.internal.format
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URLDecoder
|
import java.net.URLDecoder
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
@ -78,8 +79,10 @@ class FileUtil() {
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun moveFile(originDir: File, context: Context, destDir: String, progress: (p: Int) -> Unit) : String {
|
fun moveFile(originDir: File, context: Context, destDir: String, progress: (p: Int) -> Unit) : String {
|
||||||
val fileList = mutableListOf<File>()
|
val fileList = mutableListOf<File>()
|
||||||
|
val dir = File(formatPath(destDir))
|
||||||
|
if (!dir.exists()) dir.mkdirs()
|
||||||
originDir.listFiles()?.forEach {
|
originDir.listFiles()?.forEach {
|
||||||
val destFile = File(formatPath(destDir) + "/${it.name}")
|
val destFile = File(dir.absolutePath + "/${it.name}")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (it.name.equals("rList")){
|
if (it.name.equals("rList")){
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@
|
||||||
android:layout_width="55dp"
|
android:layout_width="55dp"
|
||||||
android:layout_height="55dp"
|
android:layout_height="55dp"
|
||||||
app:cornerRadius="10dp"
|
app:cornerRadius="10dp"
|
||||||
|
android:clickable="false"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout android:id="@+id/downloads_element_bottom_sheet"
|
<FrameLayout xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/downloads_element_bottom_sheet"
|
||||||
style="@style/Widget.Material3.BottomSheet"
|
style="@style/Widget.Material3.BottomSheet"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -12,29 +13,60 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="20dp"
|
android:padding="20dp">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/bottom_sheet_title"
|
android:id="@+id/linearLayout4"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:textSize="25sp"
|
|
||||||
android:textColor="?attr/colorOnSurface"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/app_name" />
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/downloads_download_button_layout"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bottom_sheet_author"
|
android:id="@+id/bottom_sheet_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textColor="?attr/colorOnSurface"
|
||||||
|
android:textSize="25sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bottom_sheet_author"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/downloads_download_button_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:paddingTop="5dp"
|
android:layout_height="match_parent"
|
||||||
android:textSize="15sp"
|
android:orientation="horizontal"
|
||||||
android:layout_height="wrap_content"
|
android:paddingVertical="20dp"
|
||||||
android:text="@string/app_name" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
</LinearLayout>
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/downloads_download_button_type"
|
||||||
|
style="@style/Widget.Material3.ExtendedFloatingActionButton.Icon.Secondary"
|
||||||
|
android:layout_width="55dp"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:clickable="false"
|
||||||
|
app:cornerRadius="10dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
@ -51,22 +83,6 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/url">
|
app:layout_constraintTop_toBottomOf="@+id/url">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/type"
|
|
||||||
style="@style/Widget.Material3.FloatingActionButton.Large.Primary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="5dp"
|
|
||||||
android:background="?attr/colorAccent"
|
|
||||||
android:clickable="false"
|
|
||||||
android:gravity="center"
|
|
||||||
android:minWidth="30dp"
|
|
||||||
android:paddingHorizontal="10dp"
|
|
||||||
app:cornerRadius="10dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/format_note"
|
android:id="@+id/format_note"
|
||||||
style="@style/Widget.Material3.FloatingActionButton.Large.Primary"
|
style="@style/Widget.Material3.FloatingActionButton.Large.Primary"
|
||||||
|
|
@ -121,14 +137,14 @@
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
style="@style/Widget.Material3.Button.TextButton.Icon"
|
|
||||||
android:id="@+id/bottom_sheet_link"
|
android:id="@+id/bottom_sheet_link"
|
||||||
android:layout_width="wrap_content"
|
style="@style/Widget.Material3.Button.TextButton.Icon"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="10dp"
|
||||||
|
android:text="@string/app_name"
|
||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
android:layout_gravity="center"
|
app:icon="@drawable/ic_link" />
|
||||||
app:icon="@drawable/ic_link"
|
|
||||||
android:text="@string/app_name" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -81,26 +81,6 @@
|
||||||
android:shadowDy="4"
|
android:shadowDy="4"
|
||||||
android:shadowColor="@color/black" />
|
android:shadowColor="@color/black" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="50dp"
|
|
||||||
android:layout_height="10dp"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:layout_marginBottom="20dp"
|
|
||||||
android:layout_marginLeft="65dp"
|
|
||||||
android:background="@color/light_grey"
|
|
||||||
android:gravity="bottom"
|
|
||||||
android:paddingTop="10dp"
|
|
||||||
android:paddingRight="20dp"
|
|
||||||
android:paddingBottom="20dp"
|
|
||||||
android:paddingLeft="20dp"
|
|
||||||
android:textSize="15sp"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:shadowRadius="1.5"
|
|
||||||
android:shadowDx="4"
|
|
||||||
android:shadowDy="4"
|
|
||||||
android:shadowColor="@color/black" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/download_button_layout"
|
android:id="@+id/download_button_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue