added quick download mode
This commit is contained in:
parent
7073a358eb
commit
ed0a01f5fc
21 changed files with 265 additions and 145 deletions
|
|
@ -26,7 +26,6 @@ class App : Application() {
|
|||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
DynamicColors.applyToActivitiesIfAvailable(this)
|
||||
createNotificationChannels()
|
||||
PreferenceManager.setDefaultValues(
|
||||
this,
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class ActiveDownloadAdapter(onItemClickListener: OnItemClickListener, activity:
|
|||
if (title.length > 100) {
|
||||
title = title.substring(0, 40) + "..."
|
||||
}
|
||||
itemTitle.text = title
|
||||
itemTitle.text = title.ifEmpty { "`${activity.getString(R.string.defaultValue)}`" }
|
||||
|
||||
// Author ----------------------------------
|
||||
val author = card.findViewById<TextView>(R.id.author)
|
||||
|
|
@ -86,7 +86,7 @@ class ActiveDownloadAdapter(onItemClickListener: OnItemClickListener, activity:
|
|||
if (item.author.isNotEmpty()) info += " • "
|
||||
info += item.duration
|
||||
}
|
||||
author.text = info
|
||||
author.text = info.ifEmpty { "`${activity.getString(R.string.defaultValue)}`" }
|
||||
|
||||
val type = card.findViewById<MaterialButton>(R.id.download_type)
|
||||
when(item.type){
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ class CookieAdapter(onItemClickListener: OnItemClickListener, activity: Activity
|
|||
onItemClickListener.onItemClick(item!!)
|
||||
}
|
||||
|
||||
card.setOnLongClickListener {
|
||||
onItemClickListener.onDelete(item!!); true
|
||||
}
|
||||
}
|
||||
|
||||
interface OnItemClickListener {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class GenericDownloadAdapter(onItemClickListener: OnItemClickListener, activity:
|
|||
if (title.length > 100) {
|
||||
title = title.substring(0, 40) + "..."
|
||||
}
|
||||
itemTitle.text = title
|
||||
itemTitle.text = title.ifEmpty { "`${activity.getString(R.string.defaultValue)}`" }
|
||||
|
||||
val formatNote = card.findViewById<TextView>(R.id.format_note)
|
||||
if (item.format.format_note == "?" || item.format.format_note == "") formatNote!!.visibility =
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ class TemplatesAdapter(onItemClickListener: OnItemClickListener, activity: Activ
|
|||
card.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item!!, position)
|
||||
}
|
||||
|
||||
card.setOnLongClickListener {
|
||||
onItemClickListener.onDelete(item!!); true
|
||||
}
|
||||
}
|
||||
|
||||
interface OnItemClickListener {
|
||||
|
|
|
|||
|
|
@ -171,6 +171,22 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
|||
|
||||
}
|
||||
|
||||
fun createEmptyResultItem(url: String) : ResultItem {
|
||||
return ResultItem(
|
||||
0,
|
||||
url,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
arrayListOf(),
|
||||
System.currentTimeMillis()
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
fun switchDownloadType(list: List<DownloadItem>, type: Type) : List<DownloadItem>{
|
||||
list.forEach {
|
||||
val format = getFormat(it.allFormats, type)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import kotlin.properties.Delegates
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class ShareActivity : BaseActivity() {
|
||||
|
|
@ -51,6 +52,7 @@ class ShareActivity : BaseActivity() {
|
|||
private lateinit var downloadViewModel: DownloadViewModel
|
||||
private lateinit var cookieViewModel: CookieViewModel
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
private var quickDownload by Delegates.notNull<Boolean>()
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
@ -61,7 +63,6 @@ class ShareActivity : BaseActivity() {
|
|||
v.setPadding(0, 0, 0, 0)
|
||||
insets
|
||||
}
|
||||
|
||||
window.run {
|
||||
setBackgroundDrawable(ColorDrawable(0))
|
||||
setLayout(
|
||||
|
|
@ -106,6 +107,8 @@ class ShareActivity : BaseActivity() {
|
|||
return
|
||||
}
|
||||
|
||||
quickDownload = intent.getBooleanExtra("quick_download", sharedPreferences.getBoolean("quick_download", false))
|
||||
|
||||
val loadingBottomSheet = BottomSheetDialog(this)
|
||||
loadingBottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
loadingBottomSheet.setContentView(R.layout.please_wait_bottom_sheet)
|
||||
|
|
@ -118,24 +121,29 @@ class ShareActivity : BaseActivity() {
|
|||
val inputQuery = intent.getStringExtra(Intent.EXTRA_TEXT)
|
||||
try {
|
||||
val result = resultViewModel.getItemByURL(inputQuery!!)
|
||||
loadingBottomSheet.cancel()
|
||||
loadingBottomSheet.dismiss()
|
||||
showDownloadSheet(result)
|
||||
}catch (e: Exception){
|
||||
resultViewModel.deleteAll()
|
||||
lifecycleScope.launch {
|
||||
var res: ArrayList<ResultItem?>
|
||||
withContext(Dispatchers.IO){
|
||||
res = resultViewModel.parseQuery(inputQuery!!, true)
|
||||
}
|
||||
if (res.isEmpty()) {
|
||||
Toast.makeText(this@ShareActivity, "No Results Found!", Toast.LENGTH_SHORT).show()
|
||||
exit()
|
||||
}else{
|
||||
loadingBottomSheet.cancel()
|
||||
if (res.size == 1){
|
||||
showDownloadSheet(res[0]!!)
|
||||
if (quickDownload && inputQuery!!.matches("(https?://(?:www\\.|(?!www))[a-zA-Z\\d][a-zA-Z\\d-]+[a-zA-Z\\d]\\.\\S{2,}|www\\.[a-zA-Z\\d][a-zA-Z\\d-]+[a-zA-Z\\d]\\.\\S{2,}|https?://(?:www\\.|(?!www))[a-zA-Z\\d]+\\.\\S{2,}|www\\.[a-zA-Z\\d]+\\.\\S{2,})".toRegex())){
|
||||
val result = downloadViewModel.createEmptyResultItem(inputQuery)
|
||||
loadingBottomSheet.dismiss()
|
||||
showDownloadSheet(result)
|
||||
}else{
|
||||
lifecycleScope.launch {
|
||||
val res = withContext(Dispatchers.IO){
|
||||
resultViewModel.parseQuery(inputQuery!!, true)
|
||||
}
|
||||
if (res.isEmpty()) {
|
||||
Toast.makeText(this@ShareActivity, "No Results Found!", Toast.LENGTH_SHORT).show()
|
||||
exit()
|
||||
}else{
|
||||
showSelectPlaylistItems(res.toList())
|
||||
loadingBottomSheet.dismiss()
|
||||
if (res.size == 1){
|
||||
showDownloadSheet(res[0]!!)
|
||||
}else{
|
||||
showSelectPlaylistItems(res.toList())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -145,7 +153,7 @@ class ShareActivity : BaseActivity() {
|
|||
|
||||
private fun showDownloadSheet(it: ResultItem){
|
||||
if (sharedPreferences.getBoolean("download_card", true)){
|
||||
val bottomSheet = DownloadBottomSheetDialog(it, DownloadViewModel.Type.valueOf(sharedPreferences.getString("preferred_download_type", "video")!!), null)
|
||||
val bottomSheet = DownloadBottomSheetDialog(it, DownloadViewModel.Type.valueOf(sharedPreferences.getString("preferred_download_type", "video")!!), null, quickDownload)
|
||||
bottomSheet.show(supportFragmentManager, "downloadSingleSheet")
|
||||
}else{
|
||||
lifecycleScope.launch(Dispatchers.IO){
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
|||
}else if (resultViewModel.itemCount.value!! == 1){
|
||||
if (sharedPreferences!!.getBoolean("download_card", true)){
|
||||
if(it.size == 1 && quickLaunchSheet && parentFragmentManager.findFragmentByTag("downloadSingleSheet") == null){
|
||||
showSingleDownloadSheet(it[0], DownloadViewModel.Type.valueOf(sharedPreferences!!.getString("preferred_download_type", "video")!!))
|
||||
showSingleDownloadSheet(it[0], DownloadViewModel.Type.valueOf(sharedPreferences!!.getString("preferred_download_type", "video")!!), false)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
|
@ -450,7 +450,28 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
|||
}
|
||||
resultViewModel.deleteAll()
|
||||
lifecycleScope.launch(Dispatchers.IO){
|
||||
resultViewModel.parseQueries(queryList)
|
||||
Thread.sleep(300)
|
||||
if(sharedPreferences!!.getBoolean("quick_download", false)){
|
||||
if (queryList.size == 1 && queryList.first().matches("(https?://(?:www\\.|(?!www))[a-zA-Z\\d][a-zA-Z\\d-]+[a-zA-Z\\d]\\.\\S{2,}|www\\.[a-zA-Z\\d][a-zA-Z\\d-]+[a-zA-Z\\d]\\.\\S{2,}|https?://(?:www\\.|(?!www))[a-zA-Z\\d]+\\.\\S{2,}|www\\.[a-zA-Z\\d]+\\.\\S{2,})".toRegex())){
|
||||
val resultItem = downloadViewModel.createEmptyResultItem(queryList.first())
|
||||
if (sharedPreferences!!.getBoolean("download_card", true)) {
|
||||
showSingleDownloadSheet(resultItem, DownloadViewModel.Type.valueOf(sharedPreferences!!.getString("preferred_download_type", "video")!!), true)
|
||||
} else {
|
||||
lifecycleScope.launch{
|
||||
val downloadItem = withContext(Dispatchers.IO){
|
||||
downloadViewModel.createDownloadItemFromResult(resultItem, DownloadViewModel.Type.valueOf(sharedPreferences!!.getString("preferred_download_type", "video")!!))
|
||||
}
|
||||
downloadViewModel.queueDownloads(listOf(downloadItem))
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
resultViewModel.parseQueries(queryList)
|
||||
}
|
||||
}else{
|
||||
resultViewModel.parseQueries(queryList)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -470,7 +491,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
|||
Log.e(TAG, resultsList!![0].toString() + " " + videoURL)
|
||||
val btn = recyclerView!!.findViewWithTag<MaterialButton>("""${item?.url}##$type""")
|
||||
if (sharedPreferences!!.getBoolean("download_card", true)) {
|
||||
showSingleDownloadSheet(item!!, type!!)
|
||||
showSingleDownloadSheet(item!!, type!!, false)
|
||||
} else {
|
||||
lifecycleScope.launch{
|
||||
val downloadItem = withContext(Dispatchers.IO){
|
||||
|
|
@ -484,11 +505,11 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
|
|||
override fun onLongButtonClick(videoURL: String, type: DownloadViewModel.Type?) {
|
||||
Log.e(TAG, type.toString() + " " + videoURL)
|
||||
val item = resultsList!!.find { it?.url == videoURL }
|
||||
showSingleDownloadSheet(item!!, type!!)
|
||||
showSingleDownloadSheet(item!!, type!!, false)
|
||||
}
|
||||
|
||||
private fun showSingleDownloadSheet(resultItem : ResultItem, type: DownloadViewModel.Type){
|
||||
val bottomSheet = DownloadBottomSheetDialog(resultItem, type, null)
|
||||
private fun showSingleDownloadSheet(resultItem : ResultItem, type: DownloadViewModel.Type, quickDownload: Boolean){
|
||||
val bottomSheet = DownloadBottomSheetDialog(resultItem, type, null, quickDownload)
|
||||
bottomSheet.show(parentFragmentManager, "downloadSingleSheet")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,20 +3,19 @@ package com.deniscerri.ytdlnis.ui.downloadcard
|
|||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
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
|
||||
import android.widget.Button
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.deniscerri.ytdlnis.R
|
||||
import com.deniscerri.ytdlnis.database.DBManager
|
||||
|
|
@ -25,28 +24,26 @@ import com.deniscerri.ytdlnis.database.models.DownloadItem
|
|||
import com.deniscerri.ytdlnis.database.models.ResultItem
|
||||
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel
|
||||
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel.Type
|
||||
import com.deniscerri.ytdlnis.database.viewmodel.ResultViewModel
|
||||
import com.deniscerri.ytdlnis.receiver.ShareActivity
|
||||
import com.deniscerri.ytdlnis.ui.downloads.DownloadQueueActivity
|
||||
import com.deniscerri.ytdlnis.util.FileUtil
|
||||
import com.deniscerri.ytdlnis.util.UiUtil
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayout.TabLayoutOnPageChangeListener
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.*
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
|
||||
class DownloadBottomSheetDialog(private val resultItem: ResultItem, private val type: Type, private val downloadItem: DownloadItem?) : BottomSheetDialogFragment() {
|
||||
class DownloadBottomSheetDialog(private val resultItem: ResultItem, private val type: Type, private val downloadItem: DownloadItem?,private val quickDownload: Boolean) : BottomSheetDialogFragment() {
|
||||
private lateinit var tabLayout: TabLayout
|
||||
private lateinit var viewPager2: ViewPager2
|
||||
private lateinit var fragmentAdapter : DownloadFragmentAdapter
|
||||
private lateinit var downloadViewModel: DownloadViewModel
|
||||
private lateinit var resultViewModel: ResultViewModel
|
||||
private lateinit var behavior: BottomSheetBehavior<View>
|
||||
private lateinit var commandTemplateDao : CommandTemplateDao
|
||||
private lateinit var uiUtil: UiUtil
|
||||
|
|
@ -58,6 +55,7 @@ class DownloadBottomSheetDialog(private val resultItem: ResultItem, private val
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
downloadViewModel = ViewModelProvider(this)[DownloadViewModel::class.java]
|
||||
resultViewModel = ViewModelProvider(this)[ResultViewModel::class.java]
|
||||
commandTemplateDao = DBManager.getInstance(requireContext()).commandTemplateDao
|
||||
uiUtil = UiUtil(FileUtil())
|
||||
}
|
||||
|
|
@ -186,6 +184,29 @@ class DownloadBottomSheetDialog(private val resultItem: ResultItem, private val
|
|||
uiUtil.copyLinkToClipBoard(requireContext(), resultItem.url, null)
|
||||
true
|
||||
}
|
||||
|
||||
val updateItem = view.findViewById<Button>(R.id.update_item)
|
||||
if (quickDownload) {
|
||||
(updateItem.parent as LinearLayout).visibility = View.VISIBLE
|
||||
updateItem.setOnClickListener {
|
||||
lifecycleScope.launch(Dispatchers.IO){
|
||||
if (activity is ShareActivity) {
|
||||
val intent = Intent(context, ShareActivity::class.java)
|
||||
intent.action = Intent.ACTION_SEND
|
||||
intent.type = "text/plain"
|
||||
intent.putExtra(Intent.EXTRA_TEXT, resultItem.url)
|
||||
intent.putExtra("quick_download", false)
|
||||
startActivity(intent)
|
||||
dismiss()
|
||||
}else{
|
||||
resultViewModel.parseQueries(listOf(resultItem.url))
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
(updateItem.parent as LinearLayout).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDownloadItem() : DownloadItem{
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ class SelectPlaylistItemsBottomSheetDialog(private val items: List<ResultItem?>,
|
|||
val checkedResultItems = items.filter { item -> checkedItems.contains(item!!.url) }
|
||||
if (checkedResultItems.size == 1){
|
||||
val resultItem = resultViewModel.getItemByURL(checkedResultItems[0]!!.url)
|
||||
val bottomSheet = DownloadBottomSheetDialog(resultItem, type, null)
|
||||
val bottomSheet = DownloadBottomSheetDialog(resultItem, type, null, false)
|
||||
bottomSheet.show(parentFragmentManager, "downloadSingleSheet")
|
||||
}else{
|
||||
val downloadItems = mutableListOf<DownloadItem>()
|
||||
|
|
|
|||
|
|
@ -113,9 +113,9 @@ class CancelledDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClic
|
|||
bottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
bottomSheet.setContentView(R.layout.history_item_details_bottom_sheet)
|
||||
val title = bottomSheet.findViewById<TextView>(R.id.bottom_sheet_title)
|
||||
title!!.text = item.title
|
||||
title!!.text = item.title.ifEmpty { "`${requireContext().getString(R.string.defaultValue)}`" }
|
||||
val author = bottomSheet.findViewById<TextView>(R.id.bottom_sheet_author)
|
||||
author!!.text = item.author
|
||||
author!!.text = item.author.ifEmpty { "`${requireContext().getString(R.string.defaultValue)}`" }
|
||||
|
||||
// BUTTON ----------------------------------
|
||||
val btn = bottomSheet.findViewById<MaterialButton>(R.id.downloads_download_button_type)
|
||||
|
|
@ -196,7 +196,7 @@ class CancelledDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClic
|
|||
|
||||
redownload.setOnLongClickListener {
|
||||
bottomSheet.cancel()
|
||||
val sheet = DownloadBottomSheetDialog(downloadViewModel.createResultItemFromDownload(item), item.type, item)
|
||||
val sheet = DownloadBottomSheetDialog(downloadViewModel.createResultItemFromDownload(item), item.type, item, false)
|
||||
sheet.show(parentFragmentManager, "downloadSingleSheet")
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,9 +113,9 @@ class ErroredDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickL
|
|||
bottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
bottomSheet.setContentView(R.layout.history_item_details_bottom_sheet)
|
||||
val title = bottomSheet.findViewById<TextView>(R.id.bottom_sheet_title)
|
||||
title!!.text = item.title
|
||||
title!!.text = item.title.ifEmpty { "`${requireContext().getString(R.string.defaultValue)}`" }
|
||||
val author = bottomSheet.findViewById<TextView>(R.id.bottom_sheet_author)
|
||||
author!!.text = item.author
|
||||
author!!.text = item.author.ifEmpty { "`${requireContext().getString(R.string.defaultValue)}`" }
|
||||
|
||||
// BUTTON ----------------------------------
|
||||
val btn = bottomSheet.findViewById<MaterialButton>(R.id.downloads_download_button_type)
|
||||
|
|
@ -196,7 +196,7 @@ class ErroredDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickL
|
|||
|
||||
redownload.setOnLongClickListener {
|
||||
bottomSheet.cancel()
|
||||
val sheet = DownloadBottomSheetDialog(downloadViewModel.createResultItemFromDownload(item), item.type, item)
|
||||
val sheet = DownloadBottomSheetDialog(downloadViewModel.createResultItemFromDownload(item), item.type, item, false)
|
||||
sheet.show(parentFragmentManager, "downloadSingleSheet")
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
|
|||
|
||||
redownload.setOnLongClickListener {
|
||||
bottomSheet!!.cancel()
|
||||
val sheet = DownloadBottomSheetDialog(downloadViewModel.createResultItemFromHistory(item), item.type, downloadViewModel.createDownloadItemFromHistory(item))
|
||||
val sheet = DownloadBottomSheetDialog(downloadViewModel.createResultItemFromHistory(item), item.type, downloadViewModel.createDownloadItemFromHistory(item), false)
|
||||
sheet.show(parentFragmentManager, "downloadSingleSheet")
|
||||
true
|
||||
}
|
||||
|
|
@ -640,7 +640,7 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
|
|||
ItemTouchHelper.RIGHT -> {
|
||||
val item = historyList!![position]!!
|
||||
historyAdapter!!.notifyItemChanged(position)
|
||||
val sheet = DownloadBottomSheetDialog(downloadViewModel.createResultItemFromHistory(item), item.type, downloadViewModel.createDownloadItemFromHistory(item))
|
||||
val sheet = DownloadBottomSheetDialog(downloadViewModel.createResultItemFromHistory(item), item.type, downloadViewModel.createDownloadItemFromHistory(item), false)
|
||||
sheet.show(parentFragmentManager, "downloadSingleSheet")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ class QueuedDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickLi
|
|||
bottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
bottomSheet.setContentView(R.layout.history_item_details_bottom_sheet)
|
||||
val title = bottomSheet.findViewById<TextView>(R.id.bottom_sheet_title)
|
||||
title!!.text = item.title
|
||||
title!!.text = item.title.ifEmpty { "`${requireContext().getString(R.string.defaultValue)}`" }
|
||||
val author = bottomSheet.findViewById<TextView>(R.id.bottom_sheet_author)
|
||||
author!!.text = item.author
|
||||
author!!.text = item.author.ifEmpty { "`${requireContext().getString(R.string.defaultValue)}`" }
|
||||
|
||||
// BUTTON ----------------------------------
|
||||
val btn = bottomSheet.findViewById<MaterialButton>(R.id.downloads_download_button_type)
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
private var searchEngine : ListPreference? = null
|
||||
private var startDestination : ListPreference? = null
|
||||
private var downloadCard: SwitchPreferenceCompat? = null
|
||||
private var quickDownload: SwitchPreferenceCompat? = null
|
||||
private var meteredNetwork: SwitchPreferenceCompat? = null
|
||||
private var apiKey: EditTextPreference? = null
|
||||
private var homeRecommendations: SwitchPreferenceCompat? = null
|
||||
|
|
@ -121,6 +122,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
searchEngine = findPreference("search_engine")
|
||||
startDestination = findPreference("start_destination")
|
||||
downloadCard = findPreference("download_card")
|
||||
quickDownload = findPreference("quick_download")
|
||||
meteredNetwork = findPreference("metered_networks")
|
||||
apiKey = findPreference("api_key")
|
||||
homeRecommendations = findPreference("home_recommendations")
|
||||
|
|
@ -193,6 +195,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
editor.putString("search_engine", searchEngine!!.value)
|
||||
editor.putString("start_destination", startDestination!!.value)
|
||||
editor.putBoolean("download_card", downloadCard!!.isChecked)
|
||||
editor.putBoolean("quick_download", quickDownload!!.isChecked)
|
||||
editor.putBoolean("metered_networks", meteredNetwork!!.isChecked)
|
||||
editor.putString("api_key", apiKey!!.text)
|
||||
editor.putBoolean("home_recommendations", homeRecommendations!!.isChecked)
|
||||
|
|
@ -382,6 +385,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
editor.apply()
|
||||
true
|
||||
}
|
||||
quickDownload!!.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
|
||||
val enable = newValue as Boolean
|
||||
editor.putBoolean("quick_download", enable)
|
||||
editor.apply()
|
||||
true
|
||||
}
|
||||
meteredNetwork!!.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
|
||||
val enable = newValue as Boolean
|
||||
|
|
|
|||
|
|
@ -5,120 +5,150 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="20dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottom_sheet_title"
|
||||
android:layout_width="0dp"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:text="@string/download"
|
||||
android:textSize="25sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bottomsheet_schedule_button"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottom_sheet_subtitle"
|
||||
android:layout_width="0dp"
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottom_sheet_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:text="@string/download"
|
||||
android:textSize="25sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bottomsheet_schedule_button"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottom_sheet_subtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:text="@string/configure_download"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bottomsheet_schedule_button"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bottom_sheet_title" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bottomsheet_schedule_button"
|
||||
style="?attr/materialIconButtonFilledTonalStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
app:icon="@drawable/ic_clock"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bottomsheet_download_button"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bottomsheet_download_button"
|
||||
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="all"
|
||||
android:text="@string/download"
|
||||
app:icon="@drawable/ic_down"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/download_tablayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:text="@string/configure_download"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bottomsheet_schedule_button"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bottom_sheet_title" />
|
||||
android:layout_margin="10dp"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
app:tabGravity="fill"
|
||||
app:tabMode="scrollable">
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/audio" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/video" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/command" />
|
||||
|
||||
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/download_viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bottomsheet_schedule_button"
|
||||
style="?attr/materialIconButtonFilledTonalStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/bottom_sheet_link"
|
||||
style="@style/Widget.Material3.Button.TextButton.Icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
app:icon="@drawable/ic_clock"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bottomsheet_download_button"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_margin="10dp"
|
||||
android:textAlignment="textStart"
|
||||
android:singleLine="true"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="15sp"
|
||||
app:icon="@drawable/ic_link" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bottomsheet_download_button"
|
||||
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="all"
|
||||
android:text="@string/download"
|
||||
app:icon="@drawable/ic_down"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:gravity="end"
|
||||
android:visibility="gone"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/update_item"
|
||||
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="all"
|
||||
android:text="@string/update"
|
||||
app:icon="@drawable/ic_update"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/download_tablayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
app:tabGravity="fill"
|
||||
app:tabMode="scrollable">
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/audio" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/video" />
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/command" />
|
||||
|
||||
|
||||
</com.google.android.material.tabs.TabLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/download_viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bottom_sheet_link"
|
||||
style="@style/Widget.Material3.Button.TextButton.Icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:textAlignment="textStart"
|
||||
android:singleLine="true"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="15sp"
|
||||
app:icon="@drawable/ic_link" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="icon_bg">#1c1d23</color>
|
||||
<color name="icon_bg">#000</color>
|
||||
<color name="black">#000000</color>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
<item name="android:windowLightStatusBar">@android:color/transparent</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:color">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
<item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item>
|
||||
<item name="dialogCornerRadius">28dp</item>
|
||||
<item name="switchPreferenceCompatStyle">@style/Preference.SwitchPreferenceCompat.Material3</item>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<color name="black">#000000</color>
|
||||
<color name="grey">#323232</color>
|
||||
<color name="light_grey">#A6A6A6</color>
|
||||
<color name="icon_bg">#1c1d23</color>
|
||||
<color name="icon_bg">#FFFFFF</color>
|
||||
<color name="icon_fg">#d43c3c</color>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -241,4 +241,6 @@
|
|||
<string name="downloaded">"Downloaded: "</string>
|
||||
<string name="finished_download_notification_channel_name">Finished Downloads</string>
|
||||
<string name="finished_download_notification_channel_description">Notification for finished or faulty downloads</string>
|
||||
<string name="quick_download">Quick Download</string>
|
||||
<string name="quick_download_summary">Don\'t fetch data beforehand</string>
|
||||
</resources>
|
||||
|
|
@ -91,6 +91,14 @@
|
|||
app:summary="@string/download_card_summary"
|
||||
app:title="@string/show_download_card" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:widgetLayout="@layout/preferece_material_switch"
|
||||
app:defaultValue="false"
|
||||
android:icon="@drawable/ic_speed"
|
||||
android:key="quick_download"
|
||||
app:summary="@string/quick_download_summary"
|
||||
app:title="@string/quick_download" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:widgetLayout="@layout/preferece_material_switch"
|
||||
app:defaultValue="true"
|
||||
|
|
|
|||
Loading…
Reference in a new issue