qol fixes

This commit is contained in:
deniscerri 2023-05-06 22:34:50 +02:00
parent fa341a53f2
commit 376ee73af2
No known key found for this signature in database
GPG key ID: 95C43D517D830350
33 changed files with 563 additions and 762 deletions

View file

@ -128,7 +128,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$appCompatVer" implementation "androidx.appcompat:appcompat:$appCompatVer"
implementation "androidx.constraintlayout:constraintlayout:2.1.4" implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation 'com.google.android.material:material:1.9.0-rc01' implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.3.0' implementation 'androidx.recyclerview:recyclerview:1.3.0'
implementation 'androidx.preference:preference:1.2.0' implementation 'androidx.preference:preference:1.2.0'
@ -176,7 +176,6 @@ dependencies {
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11' implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0' implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0'
implementation "com.google.android.exoplayer:exoplayer:2.18.5" implementation "com.google.android.exoplayer:exoplayer:2.18.6"
implementation 'it.xabaras.android:recyclerview-swipedecorator:1.4' implementation 'it.xabaras.android:recyclerview-swipedecorator:1.4'
} }

View file

@ -6,11 +6,14 @@ import android.app.UiModeManager.MODE_NIGHT_YES
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
import androidx.core.content.edit
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import androidx.work.Configuration import androidx.work.Configuration
import androidx.work.WorkManager import androidx.work.WorkManager
import com.deniscerri.ytdlnis.util.NotificationUtil import com.deniscerri.ytdlnis.util.NotificationUtil
import com.deniscerri.ytdlnis.util.UpdateUtil
import com.google.android.material.color.DynamicColors import com.google.android.material.color.DynamicColors
import com.google.android.material.snackbar.Snackbar
import com.yausername.aria2c.Aria2c import com.yausername.aria2c.Aria2c
import com.yausername.ffmpeg.FFmpeg import com.yausername.ffmpeg.FFmpeg
import com.yausername.youtubedl_android.YoutubeDL import com.yausername.youtubedl_android.YoutubeDL
@ -35,12 +38,19 @@ class App : Application() {
false false
) )
val sharedPreferences = getSharedPreferences("root_preferences", MODE_PRIVATE) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
applicationScope = CoroutineScope(SupervisorJob()) applicationScope = CoroutineScope(SupervisorJob())
applicationScope.launch((Dispatchers.IO)) { applicationScope.launch((Dispatchers.IO)) {
try { try {
initLibraries() initLibraries()
val appVer = sharedPreferences.getString("version", "")!!
if(appVer.isEmpty() || appVer != BuildConfig.VERSION_NAME){
UpdateUtil(this@App).updateYoutubeDL()
sharedPreferences.edit(commit = true){
putString("version", BuildConfig.VERSION_NAME)
}
}
}catch (e: Exception){ }catch (e: Exception){
Toast.makeText(this@App, e.message, Toast.LENGTH_SHORT).show() Toast.makeText(this@App, e.message, Toast.LENGTH_SHORT).show()
e.printStackTrace() e.printStackTrace()

View file

@ -1,7 +1,6 @@
package com.deniscerri.ytdlnis package com.deniscerri.ytdlnis
import android.Manifest import android.Manifest
import android.app.Activity
import android.content.Context import android.content.Context
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
@ -18,6 +17,7 @@ import android.view.View
import android.view.WindowInsets import android.view.WindowInsets
import android.widget.CheckBox import android.widget.CheckBox
import android.widget.TextView import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.forEach import androidx.core.view.forEach
@ -26,6 +26,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.NavHostFragment import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.database.viewmodel.CookieViewModel import com.deniscerri.ytdlnis.database.viewmodel.CookieViewModel
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel
import com.deniscerri.ytdlnis.database.viewmodel.ResultViewModel import com.deniscerri.ytdlnis.database.viewmodel.ResultViewModel
@ -69,7 +70,7 @@ class MainActivity : BaseActivity() {
resultViewModel = ViewModelProvider(this)[ResultViewModel::class.java] resultViewModel = ViewModelProvider(this)[ResultViewModel::class.java]
cookieViewModel = ViewModelProvider(this)[CookieViewModel::class.java] cookieViewModel = ViewModelProvider(this)[CookieViewModel::class.java]
downloadViewModel = ViewModelProvider(this)[DownloadViewModel::class.java] downloadViewModel = ViewModelProvider(this)[DownloadViewModel::class.java]
preferences = context.getSharedPreferences("root_preferences", MODE_PRIVATE) preferences = PreferenceManager.getDefaultSharedPreferences(context)
if (preferences.getBoolean("incognito", false)){ if (preferences.getBoolean("incognito", false)){
resultViewModel.deleteAll() resultViewModel.deleteAll()
@ -98,7 +99,7 @@ class MainActivity : BaseActivity() {
} }
} }
val sharedPreferences = getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val startDestination = sharedPreferences.getString("start_destination", "") val startDestination = sharedPreferences.getString("start_destination", "")
val graph = navController.navInflater.inflate(R.navigation.nav_graph) val graph = navController.navInflater.inflate(R.navigation.nav_graph)
@ -154,7 +155,7 @@ class MainActivity : BaseActivity() {
val dialogView = layoutInflater.inflate(R.layout.dialog_terminate_app, null) val dialogView = layoutInflater.inflate(R.layout.dialog_terminate_app, null)
val checkbox = dialogView.findViewById<CheckBox>(R.id.doNotShowAgain) val checkbox = dialogView.findViewById<CheckBox>(R.id.doNotShowAgain)
terminateDialog.setView(dialogView) terminateDialog.setView(dialogView)
checkbox.setOnCheckedChangeListener { compoundButton, b -> checkbox.setOnCheckedChangeListener { compoundButton, _ ->
doNotShowAgain = compoundButton.isChecked doNotShowAgain = compoundButton.isChecked
} }
@ -179,14 +180,6 @@ class MainActivity : BaseActivity() {
handleIntents(intent) handleIntents(intent)
} }
fun hideNav() {
navigationView.visibility = View.GONE
}
fun showNav() {
navigationView.visibility = View.VISIBLE
}
fun disableBottomNavigation(){ fun disableBottomNavigation(){
if (navigationView is NavigationBarView){ if (navigationView is NavigationBarView){
(navigationView as NavigationBarView).menu.forEach { it.isEnabled = false } (navigationView as NavigationBarView).menu.forEach { it.isEnabled = false }
@ -272,8 +265,10 @@ class MainActivity : BaseActivity() {
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE) permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE)
} }
} }
if (!checkNotificationPermission()){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
permissions.add(Manifest.permission.POST_NOTIFICATIONS) if (!checkNotificationPermission()){
permissions.add(Manifest.permission.POST_NOTIFICATIONS)
}
} }
if (permissions.isNotEmpty()){ if (permissions.isNotEmpty()){
@ -329,6 +324,7 @@ class MainActivity : BaseActivity() {
} }
} }
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private fun checkNotificationPermission(): Boolean { private fun checkNotificationPermission(): Boolean {
return (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) return (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS)
== PackageManager.PERMISSION_GRANTED) == PackageManager.PERMISSION_GRANTED)

View file

@ -8,7 +8,7 @@ interface SearchHistoryDao {
@Query("SELECT * from searchHistory ORDER BY id DESC LIMIT 10") @Query("SELECT * from searchHistory ORDER BY id DESC LIMIT 10")
fun getAll() : List<SearchHistoryItem> fun getAll() : List<SearchHistoryItem>
@Query("SELECT * from searchHistory WHERE query COLLATE NOCASE ='%'||:keyword||'%'") @Query("SELECT * from searchHistory WHERE `query` COLLATE NOCASE ='%'||:keyword||'%'")
fun getAllByKeyword(keyword: String) : List<SearchHistoryItem> fun getAllByKeyword(keyword: String) : List<SearchHistoryItem>
@Insert(onConflict = OnConflictStrategy.IGNORE) @Insert(onConflict = OnConflictStrategy.IGNORE)
@ -17,6 +17,6 @@ interface SearchHistoryDao {
@Query("DELETE FROM searchHistory") @Query("DELETE FROM searchHistory")
suspend fun deleteAll() suspend fun deleteAll()
@Query("DELETE FROM searchHistory WHERE query=:query") @Query("DELETE FROM searchHistory WHERE `query`=:query")
suspend fun delete(query: String) suspend fun delete(query: String)
} }

View file

@ -9,6 +9,7 @@ import android.widget.Toast
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import androidx.preference.PreferenceManager
import androidx.work.* import androidx.work.*
import com.deniscerri.ytdlnis.App import com.deniscerri.ytdlnis.App
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
@ -48,8 +49,7 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
init { init {
val dao = DBManager.getInstance(application).downloadDao val dao = DBManager.getInstance(application).downloadDao
repository = DownloadRepository(dao) repository = DownloadRepository(dao)
sharedPreferences = sharedPreferences = PreferenceManager.getDefaultSharedPreferences(application)
getApplication<App>().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
commandTemplateDao = DBManager.getInstance(application).commandTemplateDao commandTemplateDao = DBManager.getInstance(application).commandTemplateDao
allDownloads = repository.allDownloads allDownloads = repository.allDownloads

View file

@ -8,6 +8,7 @@ import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.App import com.deniscerri.ytdlnis.App
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.DBManager import com.deniscerri.ytdlnis.database.DBManager
@ -37,7 +38,7 @@ class ResultViewModel(application: Application) : AndroidViewModel(application)
items = repository.allResults items = repository.allResults
loadingItems.postValue(false) loadingItems.postValue(false)
itemCount = repository.itemCount itemCount = repository.itemCount
sharedPreferences = application.getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) sharedPreferences = PreferenceManager.getDefaultSharedPreferences(application)
} }
fun checkTrending() = viewModelScope.launch(Dispatchers.IO){ fun checkTrending() = viewModelScope.launch(Dispatchers.IO){

View file

@ -25,6 +25,7 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat import androidx.core.view.WindowCompat
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.MainActivity import com.deniscerri.ytdlnis.MainActivity
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.models.DownloadItem import com.deniscerri.ytdlnis.database.models.DownloadItem
@ -81,7 +82,7 @@ class ShareActivity : BaseActivity() {
resultViewModel = ViewModelProvider(this)[ResultViewModel::class.java] resultViewModel = ViewModelProvider(this)[ResultViewModel::class.java]
downloadViewModel = ViewModelProvider(this)[DownloadViewModel::class.java] downloadViewModel = ViewModelProvider(this)[DownloadViewModel::class.java]
cookieViewModel = ViewModelProvider(this)[CookieViewModel::class.java] cookieViewModel = ViewModelProvider(this)[CookieViewModel::class.java]
sharedPreferences = getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
cookieViewModel.updateCookiesFile() cookieViewModel.updateCookiesFile()
val intent = intent val intent = intent

View file

@ -25,6 +25,7 @@ import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.deniscerri.ytdlnis.MainActivity import com.deniscerri.ytdlnis.MainActivity
@ -48,14 +49,13 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
import com.google.android.material.search.SearchBar import com.google.android.material.search.SearchBar
import com.google.android.material.search.SearchView import com.google.android.material.search.SearchView
import com.google.android.material.search.SearchView.TransitionState
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.util.* import java.util.*
class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickListener { class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, OnClickListener {
private var inputQueries: MutableList<String>? = null private var inputQueries: MutableList<String>? = null
private var homeAdapter: HomeAdapter? = null private var homeAdapter: HomeAdapter? = null
@ -120,13 +120,13 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
resultsList = mutableListOf() resultsList = mutableListOf()
selectedObjects = ArrayList() selectedObjects = ArrayList()
sharedPreferences = requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
//initViews //initViews
shimmerCards = view.findViewById(R.id.shimmer_results_framelayout) shimmerCards = view.findViewById(R.id.shimmer_results_framelayout)
searchBar = view.findViewById(R.id.search_bar) searchBar = view.findViewById(R.id.search_bar)
searchView = view.findViewById(R.id.search_view) searchView = view.findViewById(R.id.search_view)
linkYouCopied = searchView?.findViewById<ConstraintLayout>(R.id.link_you_copied) linkYouCopied = searchView?.findViewById(R.id.link_you_copied)
appBarLayout = view.findViewById(R.id.home_appbarlayout) appBarLayout = view.findViewById(R.id.home_appbarlayout)
queriesChipGroup = view.findViewById(R.id.queries) queriesChipGroup = view.findViewById(R.id.queries)
searchSuggestions = view.findViewById(R.id.search_suggestions_scroll_view) searchSuggestions = view.findViewById(R.id.search_suggestions_scroll_view)
@ -279,12 +279,10 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
updateSearchViewItems(it, linkYouCopied) updateSearchViewItems(it, linkYouCopied)
} }
searchView!!.editText.setOnTouchListener(OnTouchListener { v, event -> searchView!!.editText.setOnTouchListener(OnTouchListener { _, event ->
try{ try{
val drawableLeft = 0 val drawableLeft = 0
val drawableTop = 1
val drawableRight = 2 val drawableRight = 2
val drawableBottom = 3
if (event.action == MotionEvent.ACTION_UP) { if (event.action == MotionEvent.ACTION_UP) {
if ( if (
(isRightToLeft && (event.x < (searchView!!.editText.left - searchView!!.editText.compoundDrawables[drawableLeft].bounds.width()))) || (isRightToLeft && (event.x < (searchView!!.editText.left - searchView!!.editText.compoundDrawables[drawableLeft].bounds.width()))) ||
@ -333,7 +331,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
} }
true true
} }
queriesChipGroup!!.addOnLayoutChangeListener { view, i, i2, i3, i4, i5, i6, i7, i8 -> queriesChipGroup!!.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
if (queriesChipGroup!!.childCount == 0) queriesConstraint.visibility = GONE if (queriesChipGroup!!.childCount == 0) queriesConstraint.visibility = GONE
else queriesConstraint.visibility = VISIBLE else queriesConstraint.visibility = VISIBLE
searchView!!.editText.setText("") searchView!!.editText.setText("")
@ -344,6 +342,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
} }
} }
@SuppressLint("InflateParams")
private fun updateSearchViewItems(it: Editable?, linkYouCopied: View?){ private fun updateSearchViewItems(it: Editable?, linkYouCopied: View?){
lifecycleScope.launch { lifecycleScope.launch {
searchSuggestionsLinearLayout!!.removeAllViews() searchSuggestionsLinearLayout!!.removeAllViews()
@ -499,7 +498,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
Log.e(TAG, type.toString() + " " + videoURL) Log.e(TAG, type.toString() + " " + videoURL)
val item = resultsList!!.find { it?.url == videoURL } val item = resultsList!!.find { it?.url == videoURL }
Log.e(TAG, resultsList!![0].toString() + " " + videoURL) Log.e(TAG, resultsList!![0].toString() + " " + videoURL)
val btn = recyclerView!!.findViewWithTag<MaterialButton>("""${item?.url}##$type""") recyclerView!!.findViewWithTag<MaterialButton>("""${item?.url}##$type""")
if (sharedPreferences!!.getBoolean("download_card", true)) { if (sharedPreferences!!.getBoolean("download_card", true)) {
showSingleDownloadSheet(item!!, type!!, false) showSingleDownloadSheet(item!!, type!!, false)
} else { } else {
@ -524,7 +523,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, View.OnClickLi
} }
override fun onCardClick(videoURL: String, add: Boolean) { override fun onCardClick(videoURL: String, add: Boolean) {
val item = resultsList?.find { it -> it?.url == videoURL } val item = resultsList?.find { it?.url == videoURL }
if (add) { if (add) {
selectedObjects!!.add(item!!) selectedObjects!!.add(item!!)
if (actionMode == null){ if (actionMode == null){

View file

@ -18,6 +18,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.models.DownloadItem import com.deniscerri.ytdlnis.database.models.DownloadItem
import com.deniscerri.ytdlnis.database.models.Format import com.deniscerri.ytdlnis.database.models.Format
@ -81,7 +82,7 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
} }
} }
val sharedPreferences = val sharedPreferences =
requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) PreferenceManager.getDefaultSharedPreferences(requireContext())
try { try {
title = view.findViewById(R.id.title_textinput) title = view.findViewById(R.id.title_textinput)

View file

@ -21,6 +21,7 @@ import androidx.core.widget.doOnTextChanged
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.models.DownloadItem import com.deniscerri.ytdlnis.database.models.DownloadItem
import com.deniscerri.ytdlnis.database.models.Format import com.deniscerri.ytdlnis.database.models.Format
@ -86,7 +87,7 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
} }
} }
val sharedPreferences = requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
try { try {
title = view.findViewById(R.id.title_textinput) title = view.findViewById(R.id.title_textinput)
title.editText!!.setText(downloadItem.title) title.editText!!.setText(downloadItem.title)

View file

@ -18,6 +18,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.models.DownloadItem import com.deniscerri.ytdlnis.database.models.DownloadItem
import com.deniscerri.ytdlnis.database.models.Format import com.deniscerri.ytdlnis.database.models.Format
@ -56,7 +57,7 @@ class FormatSelectionBottomSheetDialog(private val items: List<DownloadItem?>, p
infoUtil = InfoUtil(requireActivity().applicationContext) infoUtil = InfoUtil(requireActivity().applicationContext)
formatCollection = mutableListOf() formatCollection = mutableListOf()
chosenFormats = listOf() chosenFormats = listOf()
sharedPreferences = requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
} }

View file

@ -6,6 +6,8 @@ import android.graphics.Canvas
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import android.view.View
import android.widget.RelativeLayout
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
@ -23,6 +25,7 @@ import com.deniscerri.ytdlnis.util.UiUtil
import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.chip.Chip import com.google.android.material.chip.Chip
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import it.xabaras.android.recyclerview.swipedecorator.RecyclerViewSwipeDecorator import it.xabaras.android.recyclerview.swipedecorator.RecyclerViewSwipeDecorator
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -36,6 +39,7 @@ class CommandTemplatesActivity : BaseActivity(), TemplatesAdapter.OnItemClickLis
private lateinit var commandTemplateViewModel: CommandTemplateViewModel private lateinit var commandTemplateViewModel: CommandTemplateViewModel
private lateinit var uiUtil: UiUtil private lateinit var uiUtil: UiUtil
private lateinit var templatesList: List<CommandTemplate> private lateinit var templatesList: List<CommandTemplate>
private lateinit var noResults: RelativeLayout
var context: Context? = null var context: Context? = null
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
@ -46,6 +50,7 @@ class CommandTemplatesActivity : BaseActivity(), TemplatesAdapter.OnItemClickLis
topAppBar = findViewById(R.id.logs_toolbar) topAppBar = findViewById(R.id.logs_toolbar)
topAppBar.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() } topAppBar.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() }
noResults = findViewById(R.id.no_results)
templatesAdapter = templatesAdapter =
TemplatesAdapter( TemplatesAdapter(
@ -62,6 +67,8 @@ class CommandTemplatesActivity : BaseActivity(), TemplatesAdapter.OnItemClickLis
commandTemplateViewModel = ViewModelProvider(this)[CommandTemplateViewModel::class.java] commandTemplateViewModel = ViewModelProvider(this)[CommandTemplateViewModel::class.java]
commandTemplateViewModel.items.observe(this) { commandTemplateViewModel.items.observe(this) {
if (it.isEmpty()) noResults.visibility = View.VISIBLE
else noResults.visibility = View.GONE
templatesList = it templatesList = it
templatesAdapter.submitList(it) templatesAdapter.submitList(it)
} }
@ -73,15 +80,18 @@ class CommandTemplatesActivity : BaseActivity(), TemplatesAdapter.OnItemClickLis
topAppBar.setOnMenuItemClickListener { m: MenuItem -> topAppBar.setOnMenuItemClickListener { m: MenuItem ->
val itemId = m.itemId val itemId = m.itemId
if (itemId == R.id.export_clipboard) { if (itemId == R.id.export_clipboard) {
lifecycleScope.launch(Dispatchers.IO){ lifecycleScope.launch{
commandTemplateViewModel.exportToClipboard() withContext(Dispatchers.IO){
commandTemplateViewModel.exportToClipboard()
}
Snackbar.make(recyclerView, getString(R.string.copied_to_clipboard), Snackbar.LENGTH_LONG).show()
} }
}else if (itemId == R.id.import_clipboard){ }else if (itemId == R.id.import_clipboard){
lifecycleScope.launch{ lifecycleScope.launch{
withContext(Dispatchers.IO){ withContext(Dispatchers.IO){
val count = commandTemplateViewModel.importFromClipboard() val count = commandTemplateViewModel.importFromClipboard()
runOnUiThread{ runOnUiThread{
Toast.makeText(this@CommandTemplatesActivity, "${getString(R.string.items_imported)} (${count})", Toast.LENGTH_LONG).show() Snackbar.make(recyclerView, "${getString(R.string.items_imported)} (${count})", Snackbar.LENGTH_LONG).show()
} }
} }

View file

@ -7,8 +7,10 @@ import android.graphics.Canvas
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import android.view.View
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import android.widget.RelativeLayout
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.doOnTextChanged import androidx.core.widget.doOnTextChanged
@ -29,6 +31,7 @@ import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.chip.Chip import com.google.android.material.chip.Chip
import com.google.android.material.color.MaterialColors import com.google.android.material.color.MaterialColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import it.xabaras.android.recyclerview.swipedecorator.RecyclerViewSwipeDecorator import it.xabaras.android.recyclerview.swipedecorator.RecyclerViewSwipeDecorator
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -42,6 +45,7 @@ class CookiesActivity : BaseActivity(), CookieAdapter.OnItemClickListener {
private lateinit var cookiesViewModel: CookieViewModel private lateinit var cookiesViewModel: CookieViewModel
private lateinit var uiUtil: UiUtil private lateinit var uiUtil: UiUtil
private lateinit var cookiesList: List<CookieItem> private lateinit var cookiesList: List<CookieItem>
private lateinit var noResults : RelativeLayout
var context: Context? = null var context: Context? = null
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
@ -52,6 +56,7 @@ class CookiesActivity : BaseActivity(), CookieAdapter.OnItemClickListener {
topAppBar = findViewById(R.id.logs_toolbar) topAppBar = findViewById(R.id.logs_toolbar)
topAppBar.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() } topAppBar.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() }
cookiesList = listOf() cookiesList = listOf()
noResults = findViewById(R.id.no_results)
listAdapter = listAdapter =
CookieAdapter( CookieAdapter(
@ -68,6 +73,8 @@ class CookiesActivity : BaseActivity(), CookieAdapter.OnItemClickListener {
cookiesViewModel = ViewModelProvider(this)[CookieViewModel::class.java] cookiesViewModel = ViewModelProvider(this)[CookieViewModel::class.java]
cookiesViewModel.items.observe(this) { cookiesViewModel.items.observe(this) {
if (it.isEmpty()) noResults.visibility = View.VISIBLE
else noResults.visibility = View.GONE
cookiesList = it cookiesList = it
listAdapter.submitList(it) listAdapter.submitList(it)
} }
@ -98,6 +105,7 @@ class CookiesActivity : BaseActivity(), CookieAdapter.OnItemClickListener {
} }
R.id.export_clipboard -> { R.id.export_clipboard -> {
cookiesViewModel.exportToClipboard() cookiesViewModel.exportToClipboard()
Snackbar.make(recyclerView, getString(R.string.copied_to_clipboard), Snackbar.LENGTH_LONG).show()
} }
} }
true true

View file

@ -11,6 +11,7 @@ import android.view.ViewGroup
import android.widget.CheckBox import android.widget.CheckBox
import android.widget.TextView import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.MainActivity import com.deniscerri.ytdlnis.MainActivity
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.ui.downloads.DownloadQueueActivity import com.deniscerri.ytdlnis.ui.downloads.DownloadQueueActivity
@ -42,7 +43,7 @@ class MoreFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mainSharedPreferences = requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) mainSharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
mainSharedPreferencesEditor = mainSharedPreferences.edit() mainSharedPreferencesEditor = mainSharedPreferences.edit()
terminal = view.findViewById(R.id.terminal) terminal = view.findViewById(R.id.terminal)
logs = view.findViewById(R.id.logs) logs = view.findViewById(R.id.logs)

View file

@ -23,6 +23,7 @@ import androidx.core.view.forEach
import androidx.core.view.get import androidx.core.view.get
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import androidx.work.* import androidx.work.*
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.viewmodel.CommandTemplateViewModel import com.deniscerri.ytdlnis.database.viewmodel.CommandTemplateViewModel
@ -80,7 +81,7 @@ class TerminalActivity : BaseActivity() {
topAppBar!!.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() } topAppBar!!.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() }
commandTemplateViewModel = ViewModelProvider(this)[CommandTemplateViewModel::class.java] commandTemplateViewModel = ViewModelProvider(this)[CommandTemplateViewModel::class.java]
sharedPreferences = getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
bottomAppBar = findViewById(R.id.bottomAppBar) bottomAppBar = findViewById(R.id.bottomAppBar)

View file

@ -1,24 +1,30 @@
package com.deniscerri.ytdlnis.ui.more.settings package com.deniscerri.ytdlnis.ui.more.settings
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.ClipboardManager
import android.content.Context.POWER_SERVICE import android.content.Context.POWER_SERVICE
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Build
import android.os.Build.VERSION import android.os.Build.VERSION
import android.os.Build.VERSION_CODES import android.os.Build.VERSION_CODES
import android.os.Bundle import android.os.Bundle
import android.os.Environment import android.os.Environment
import android.os.Looper
import android.os.PowerManager import android.os.PowerManager
import android.provider.Settings import android.provider.Settings
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.edit
import androidx.core.os.LocaleListCompat import androidx.core.os.LocaleListCompat
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.* import androidx.preference.EditTextPreference
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import androidx.preference.SeekBarPreference
import androidx.preference.SwitchPreferenceCompat
import androidx.work.WorkInfo import androidx.work.WorkInfo
import androidx.work.WorkManager import androidx.work.WorkManager
import com.deniscerri.ytdlnis.BuildConfig import com.deniscerri.ytdlnis.BuildConfig
@ -28,13 +34,22 @@ import com.deniscerri.ytdlnis.util.FileUtil
import com.deniscerri.ytdlnis.util.ThemeUtil import com.deniscerri.ytdlnis.util.ThemeUtil
import com.deniscerri.ytdlnis.util.UpdateUtil import com.deniscerri.ytdlnis.util.UpdateUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.yausername.youtubedl_android.YoutubeDL import com.yausername.youtubedl_android.YoutubeDL
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.put
import kotlinx.serialization.json.putJsonArray
import java.io.File import java.io.File
import java.util.* import java.util.Locale
class SettingsFragment : PreferenceFragmentCompat() { class SettingsFragment : PreferenceFragmentCompat() {
@ -48,41 +63,15 @@ class SettingsFragment : PreferenceFragmentCompat() {
private var commandPath: Preference? = null private var commandPath: Preference? = null
private var accessAllFiles : Preference? = null private var accessAllFiles : Preference? = null
private var clearCache: Preference? = null private var clearCache: Preference? = null
private var keepCache: SwitchPreferenceCompat? = null
private var incognito: SwitchPreferenceCompat? = null
private var preferredDownloadType : ListPreference? = null
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
private var locale: ListPreference? = null private var locale: ListPreference? = null
private var concurrentFragments: SeekBarPreference? = null private var concurrentFragments: SeekBarPreference? = null
private var concurrentDownloads: SeekBarPreference? = null private var concurrentDownloads: SeekBarPreference? = null
private var limitRate: EditTextPreference? = null
private var aria2: SwitchPreferenceCompat? = null
private var logDownloads: SwitchPreferenceCompat? = null
private var sponsorblockFilters: MultiSelectListPreference? = null
private var filenameTemplate: EditTextPreference? = null
private var restrictFilenames: SwitchPreferenceCompat? = null
private var mtime: SwitchPreferenceCompat? = null
private var embedSubtitles: SwitchPreferenceCompat? = null
private var writeSubtitles: SwitchPreferenceCompat? = null
private var embedThumbnail: SwitchPreferenceCompat? = null
private var addChapters: SwitchPreferenceCompat? = null
private var writeThumbnail: SwitchPreferenceCompat? = null
private var audioFormat: ListPreference? = null private var audioFormat: ListPreference? = null
private var videoFormat: ListPreference? = null private var videoFormat: ListPreference? = null
private var audioQuality: SeekBarPreference? = null
private var videoQuality: ListPreference? = null private var videoQuality: ListPreference? = null
private var formatID: EditTextPreference? = null private var formatID: EditTextPreference? = null
private var updateYTDL: Preference? = null private var updateYTDL: Preference? = null
private var updateNightlyYTDL: SwitchPreferenceCompat? = null
private var updateFormats: SwitchPreferenceCompat? = null
private var formatSource: ListPreference? = null private var formatSource: ListPreference? = null
private var updateApp: SwitchPreferenceCompat? = null
private var exportPreferences : Preference? = null private var exportPreferences : Preference? = null
private var importPreferences : Preference? = null private var importPreferences : Preference? = null
private var ytdlVersion: Preference? = null private var ytdlVersion: Preference? = null
@ -111,8 +100,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
} }
private fun initPreferences() { private fun initPreferences() {
val preferences = val preferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
val editor = preferences.edit() val editor = preferences.edit()
language = findPreference("app_language") language = findPreference("app_language")
theme = findPreference("ytdlnis_theme") theme = findPreference("ytdlnis_theme")
@ -124,41 +112,17 @@ class SettingsFragment : PreferenceFragmentCompat() {
commandPath = findPreference("command_path") commandPath = findPreference("command_path")
accessAllFiles = findPreference("access_all_files") accessAllFiles = findPreference("access_all_files")
clearCache = findPreference("clear_cache") clearCache = findPreference("clear_cache")
keepCache = findPreference("keep_cache")
incognito = findPreference("incognito")
preferredDownloadType = findPreference("preferred_download_type")
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")
locale = findPreference("locale") locale = findPreference("locale")
concurrentFragments = findPreference("concurrent_fragments") concurrentFragments = findPreference("concurrent_fragments")
concurrentDownloads = findPreference("concurrent_downloads") concurrentDownloads = findPreference("concurrent_downloads")
limitRate = findPreference("limit_rate")
aria2 = findPreference("aria2")
logDownloads = findPreference("log_downloads")
sponsorblockFilters = findPreference("sponsorblock_filters")
mtime = findPreference("mtime")
embedSubtitles = findPreference("embed_subtitles")
writeSubtitles = findPreference("write_subtitles")
filenameTemplate = findPreference("file_name_template")
restrictFilenames = findPreference("restrict_filenames")
embedThumbnail = findPreference("embed_thumbnail")
addChapters = findPreference("add_chapters")
writeThumbnail = findPreference("write_thumbnail")
audioFormat = findPreference("audio_format") audioFormat = findPreference("audio_format")
videoFormat = findPreference("video_format") videoFormat = findPreference("video_format")
audioQuality = findPreference("audio_quality")
videoQuality = findPreference("video_quality") videoQuality = findPreference("video_quality")
formatID = findPreference("format_id") formatID = findPreference("format_id")
updateYTDL = findPreference("update_ytdl") updateYTDL = findPreference("update_ytdl")
updateNightlyYTDL = findPreference("nightly_ytdl")
updateFormats = findPreference("update_formats")
formatSource = findPreference("formats_source") formatSource = findPreference("formats_source")
updateApp = findPreference("update_app")
exportPreferences = findPreference("export_preferences") exportPreferences = findPreference("export_preferences")
importPreferences = findPreference("import_preferences") importPreferences = findPreference("import_preferences")
ytdlVersion = findPreference("ytdl-version") ytdlVersion = findPreference("ytdl-version")
@ -202,17 +166,17 @@ class SettingsFragment : PreferenceFragmentCompat() {
editor.apply() editor.apply()
} }
@SuppressLint("BatteryLife", "InlinedApi")
private fun initListeners() { private fun initListeners() {
val preferences = val preferences =
requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) PreferenceManager.getDefaultSharedPreferences(requireContext())
val editor = preferences.edit() val editor = preferences.edit()
if(language!!.value == null) language!!.value = Locale.getDefault().language if(language!!.value == null) language!!.value = Locale.getDefault().language
language!!.summary = Locale(language!!.value).getDisplayLanguage(Locale(language!!.value)) language!!.summary = Locale(language!!.value).getDisplayLanguage(Locale(language!!.value))
language!!.onPreferenceChangeListener = language!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("app_language", newValue.toString())
language!!.summary = Locale(newValue.toString()).getDisplayLanguage(Locale(newValue.toString())) language!!.summary = Locale(newValue.toString()).getDisplayLanguage(Locale(newValue.toString()))
editor.apply()
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(newValue.toString())) AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(newValue.toString()))
true true
} }
@ -231,10 +195,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
theme!!.summary = getString(R.string.light) theme!!.summary = getString(R.string.light)
} }
} }
editor.putString("ytdlnis_theme", newValue.toString())
editor.commit()
ThemeUtil.updateTheme(requireActivity() as AppCompatActivity) ThemeUtil.updateTheme(requireActivity() as AppCompatActivity)
val intent = Intent(requireContext(), MainActivity::class.java) val intent = Intent(requireContext(), MainActivity::class.java)
this.startActivity(intent) this.startActivity(intent)
requireActivity().finishAffinity() requireActivity().finishAffinity()
@ -242,25 +203,15 @@ class SettingsFragment : PreferenceFragmentCompat() {
} }
accent!!.summary = accent!!.entry accent!!.summary = accent!!.entry
accent!!.onPreferenceChangeListener = accent!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, _: Any ->
editor.putString("theme_accent", newValue.toString())
editor.apply().apply {
accent!!.summary = accent!!.entry
}
ThemeUtil.updateTheme(requireActivity() as AppCompatActivity) ThemeUtil.updateTheme(requireActivity() as AppCompatActivity)
val intent = Intent(requireContext(), MainActivity::class.java) val intent = Intent(requireContext(), MainActivity::class.java)
this.startActivity(intent) this.startActivity(intent)
requireActivity().finishAffinity() requireActivity().finishAffinity()
true true
} }
highContrast!!.onPreferenceChangeListener = highContrast!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, _: Any ->
val enable = newValue as Boolean
editor.putBoolean("high_contrast", enable)
editor.apply()
ThemeUtil.updateTheme(requireActivity() as AppCompatActivity) ThemeUtil.updateTheme(requireActivity() as AppCompatActivity)
val intent = Intent(requireContext(), MainActivity::class.java) val intent = Intent(requireContext(), MainActivity::class.java)
this.startActivity(intent) this.startActivity(intent)
@ -322,108 +273,25 @@ class SettingsFragment : PreferenceFragmentCompat() {
Preference.OnPreferenceClickListener { Preference.OnPreferenceClickListener {
if (activeDownloadCount == 0){ if (activeDownloadCount == 0){
File(requireContext().cacheDir.absolutePath + "/downloads").deleteRecursively() File(requireContext().cacheDir.absolutePath + "/downloads").deleteRecursively()
Toast.makeText(requireContext(), getString(R.string.cache_cleared), Toast.LENGTH_SHORT).show() Snackbar.make(requireView(), getString(R.string.cache_cleared), Snackbar.LENGTH_SHORT).show()
cacheSize = File(requireContext().cacheDir.absolutePath + "/downloads").walkBottomUp().fold(0L) { acc, file -> acc + file.length() } cacheSize = File(requireContext().cacheDir.absolutePath + "/downloads").walkBottomUp().fold(0L) { acc, file -> acc + file.length() }
clearCache!!.summary = "(${fileUtil!!.convertFileSize(cacheSize)}) ${resources.getString(R.string.clear_temporary_files_summary)}" clearCache!!.summary = "(${fileUtil!!.convertFileSize(cacheSize)}) ${resources.getString(R.string.clear_temporary_files_summary)}"
}else{ }else{
Toast.makeText(requireContext(), getString(R.string.downloads_running_try_later), Toast.LENGTH_SHORT).show() Snackbar.make(requireView(), getString(R.string.downloads_running_try_later), Snackbar.LENGTH_SHORT).show()
} }
true true
} }
keepCache!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val enable = newValue as Boolean
editor.putBoolean("keep_cache", enable)
editor.apply()
true
}
incognito!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val enable = newValue as Boolean
editor.putBoolean("incognito", enable)
editor.apply()
true
}
preferredDownloadType!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("preferred_download_type", newValue.toString())
editor.apply()
true
}
searchEngine!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("search_engine", newValue.toString())
editor.apply()
true
}
startDestination!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("start_destination", newValue.toString())
editor.apply()
true
}
downloadCard!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val enable = newValue as Boolean
editor.putBoolean("download_card", enable)
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
editor.putBoolean("metered_networks", enable)
editor.apply()
true
}
apiKey!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("api_key", newValue.toString())
editor.apply()
true
}
homeRecommendations!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val enable = newValue as Boolean
editor.putBoolean("home_recommendations", enable)
editor.apply()
true
}
locale!!.summary = locale!!.value
locale!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("locale", newValue.toString())
locale!!.summary = newValue.toString()
editor.apply()
true
}
concurrentFragments!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val value = newValue.toString().toInt()
editor.putInt("concurrent_fragments", value)
editor.apply()
true
}
concurrentDownloads!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val value = newValue.toString().toInt()
editor.putInt("concurrent_downloads", value)
editor.apply()
locale!!.summary = locale!!.value
concurrentDownloads!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, _: Any ->
MaterialAlertDialogBuilder(requireContext()) MaterialAlertDialogBuilder(requireContext())
.setTitle(resources.getString(R.string.warning)) .setTitle(resources.getString(R.string.warning))
.setMessage(resources.getString(R.string.workmanager_updated)) .setMessage(resources.getString(R.string.workmanager_updated))
.setNegativeButton(resources.getString(R.string.cancel)) { dialog, which -> .setNegativeButton(resources.getString(R.string.cancel)) { dialog, _ ->
dialog.cancel() dialog.cancel()
} }
.setPositiveButton(resources.getString(R.string.restart)) { dialog, which -> .setPositiveButton(resources.getString(R.string.restart)) { _, _ ->
val intent = Intent(context, MainActivity::class.java) val intent = Intent(context, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
requireContext().startActivity(intent) requireContext().startActivity(intent)
@ -436,257 +304,151 @@ class SettingsFragment : PreferenceFragmentCompat() {
true true
} }
limitRate!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("limit_rate", newValue.toString())
editor.apply()
true
}
aria2!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val enable = newValue as Boolean
editor.putBoolean("aria2", enable)
editor.apply()
true
}
logDownloads!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val enable = newValue as Boolean
editor.putBoolean("log_downloads", enable)
editor.apply()
true
}
sponsorblockFilters!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any? ->
sponsorblockFilters!!.values = newValue as Set<String?>?
editor.putStringSet("sponsorblock_filters", newValue)
editor.apply()
true
}
filenameTemplate!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("file_name_template", newValue.toString())
editor.apply()
true
}
restrictFilenames!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val embed = newValue as Boolean
editor.putBoolean("restrict_filenames", embed)
editor.apply()
true
}
mtime!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val embed = newValue as Boolean
editor.putBoolean("mtime", embed)
editor.apply()
true
}
embedSubtitles!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val embed = newValue as Boolean
editor.putBoolean("embed_subtitles", embed)
editor.apply()
true
}
writeSubtitles!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val embed = newValue as Boolean
editor.putBoolean("write_subtitles", embed)
editor.apply()
true
}
embedThumbnail!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val embed = newValue as Boolean
editor.putBoolean("embed_thumbnail", embed)
editor.apply()
true
}
addChapters!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val add = newValue as Boolean
editor.putBoolean("add_chapters", add)
editor.apply()
true
}
writeThumbnail!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val write = newValue as Boolean
editor.putBoolean("write_thumbnail", write)
editor.apply()
true
}
audioFormat!!.summary = preferences.getString("audio_format", "")!!.replace("Default", getString(R.string.defaultValue)) audioFormat!!.summary = preferences.getString("audio_format", "")!!.replace("Default", getString(R.string.defaultValue))
audioFormat!!.onPreferenceChangeListener = audioFormat!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("audio_format", newValue.toString())
audioFormat!!.summary = newValue.toString().replace("Default", getString(R.string.defaultValue)) audioFormat!!.summary = newValue.toString().replace("Default", getString(R.string.defaultValue))
editor.apply()
true true
} }
videoFormat!!.summary = preferences.getString("video_format", "")!!.replace("Default", getString(R.string.defaultValue)) videoFormat!!.summary = preferences.getString("video_format", "")!!.replace("Default", getString(R.string.defaultValue))
videoFormat!!.onPreferenceChangeListener = videoFormat!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("video_format", newValue.toString())
videoFormat!!.summary = newValue.toString().replace("Default", getString(R.string.defaultValue)) videoFormat!!.summary = newValue.toString().replace("Default", getString(R.string.defaultValue))
editor.apply()
true
}
audioQuality!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putInt("audio_quality", newValue.toString().toInt())
editor.apply()
true true
} }
videoQuality!!.summary = preferences.getString("video_quality", "") videoQuality!!.summary = preferences.getString("video_quality", "")
videoQuality!!.onPreferenceChangeListener = videoQuality!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("video_quality", newValue.toString())
videoQuality!!.summary = newValue.toString() videoQuality!!.summary = newValue.toString()
editor.apply()
true true
} }
formatID!!.summary = formatID!!.text formatID!!.summary = formatID!!.text
formatID!!.onPreferenceChangeListener = formatID!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
formatID!!.summary = newValue.toString() formatID!!.summary = newValue.toString()
editor.putString("format_id", newValue.toString())
editor.apply()
true true
} }
YoutubeDL.getInstance().version(context)?.let {
editor.putString("ytdl-version", it)
editor.apply()
ytdlVersion!!.summary = it
}
updateYTDL!!.onPreferenceClickListener = updateYTDL!!.onPreferenceClickListener =
Preference.OnPreferenceClickListener { Preference.OnPreferenceClickListener {
lifecycleScope.launch { lifecycleScope.launch {
Snackbar.make(requireView(),
requireContext().getString(R.string.ytdl_updating_started),
Snackbar.LENGTH_LONG).show()
when (updateUtil!!.updateYoutubeDL()) { when (updateUtil!!.updateYoutubeDL()) {
YoutubeDL.UpdateStatus.DONE -> { YoutubeDL.UpdateStatus.DONE -> {
Toast.makeText( Snackbar.make(requireView(),
context,
requireContext().getString(R.string.ytld_update_success), requireContext().getString(R.string.ytld_update_success),
Toast.LENGTH_LONG Snackbar.LENGTH_LONG).show()
).show()
YoutubeDL.getInstance().version(context)?.let { YoutubeDL.getInstance().version(context)?.let {
editor.putString("ytdl-version", it) editor.putString("ytdl-version", it)
editor.apply() editor.apply()
ytdlVersion!!.summary = it ytdlVersion!!.summary = it
} }
} }
YoutubeDL.UpdateStatus.ALREADY_UP_TO_DATE -> Toast.makeText( YoutubeDL.UpdateStatus.ALREADY_UP_TO_DATE -> Snackbar.make(requireView(),
context,
requireContext().getString(R.string.you_are_in_latest_version), requireContext().getString(R.string.you_are_in_latest_version),
Toast.LENGTH_LONG Snackbar.LENGTH_LONG).show()
).show() else -> {
else -> Toast.makeText(context, getString(R.string.errored), Toast.LENGTH_LONG).show() Snackbar.make(requireView(),
requireContext().getString(R.string.errored),
Snackbar.LENGTH_LONG).show()
}
} }
} }
true true
} }
updateFormats!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val enable = newValue as Boolean
editor.putBoolean("update_formats", enable)
editor.apply()
true
}
formatSource!!.summary = preferences.getString("formats_source", "")!!.replace("Default", getString(R.string.defaultValue)) formatSource!!.summary = preferences.getString("formats_source", "")!!.replace("Default", getString(R.string.defaultValue))
formatSource!!.onPreferenceChangeListener = formatSource!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("formats_source", newValue.toString())
formatSource!!.summary = newValue.toString().replace("Default", getString(R.string.defaultValue)) formatSource!!.summary = newValue.toString().replace("Default", getString(R.string.defaultValue))
editor.apply()
true true
} }
updateNightlyYTDL!!.onPreferenceChangeListener = exportPreferences!!.onPreferenceClickListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceClickListener {
val enable = newValue as Boolean val prefs = preferences.all
editor.putBoolean("nightly_ytdl", enable) val json = buildJsonObject {
editor.apply() putJsonArray("YTDLnis_Preferences") {
prefs.forEach {
add(buildJsonObject {
put("key", it.key)
put("value", it.value.toString())
put("type", it.value!!::class.simpleName)
})
}
}
}
val string = jsonFormat.encodeToString(json)
val clipboard: ClipboardManager =
requireContext().getSystemService(AppCompatActivity.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setText(string)
Snackbar.make(requireView(), getString(R.string.copied_to_clipboard), Snackbar.LENGTH_LONG).show()
true true
} }
updateApp!!.onPreferenceChangeListener = importPreferences!!.onPreferenceClickListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceClickListener {
val enable = newValue as Boolean val clipboard = requireContext().getSystemService(AppCompatActivity.CLIPBOARD_SERVICE) as ClipboardManager
editor.putBoolean("update_app", enable) val clip = clipboard.primaryClip!!.getItemAt(0).text.toString()
editor.apply() try{
PreferenceManager.getDefaultSharedPreferences(requireContext()).edit(commit = true) {
clear()
val preferencesKeys = preferences.all.map { it.key }
jsonFormat.decodeFromString<JsonObject>(clip).run {
val prefs = this.jsonObject["YTDLnis_Preferences"]!!.jsonArray
prefs.forEach {
val key : String = it.jsonObject["key"].toString().replace("\"", "")
if (preferencesKeys.contains(key)){
when(it.jsonObject["type"].toString().replace("\"", "")){
"String" -> {
val value = it.jsonObject["value"].toString().replace("\"", "")
putString(key, value)
}
"Boolean" -> {
val value = it.jsonObject["value"].toString().replace("\"", "").toBoolean()
putBoolean(key, value)
}
"Int" -> {
val value = it.jsonObject["value"].toString().replace("\"", "").toInt()
putInt(key, value)
}
"HashSet" -> {
val value = hashSetOf(it.jsonObject["value"].toString().replace("(\")|(\\[)|(])".toRegex(), ""))
putStringSet(key, value)
}
}
}
}
}
}
val intent = Intent(context, MainActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
requireContext().startActivity(intent)
if (context is Activity) {
(context as Activity).finish()
}
Runtime.getRuntime().exit(0)
}catch (e: Exception){
e.printStackTrace()
}
true true
} }
// exportPreferences!!.onPreferenceClickListener =
// Preference.OnPreferenceClickListener {
// val prefs = preferences.all
// val json = buildJsonObject {
// putJsonArray("YTDLnis_Preferences") {
// prefs.forEach {
// add(buildJsonObject {
// put("key", it.key)
// put("value", it.value.toString())
// put("type", it.value!!::class.simpleName)
// })
// }
// }
// }
// val string = jsonFormat.encodeToString(json)
// val clipboard: ClipboardManager =
// requireContext().getSystemService(AppCompatActivity.CLIPBOARD_SERVICE) as ClipboardManager
// clipboard.setText(string)
// true
// }
// importPreferences!!.onPreferenceClickListener =
// Preference.OnPreferenceClickListener {
// val clipboard = requireContext().getSystemService(AppCompatActivity.CLIPBOARD_SERVICE) as ClipboardManager
// val clip = clipboard.primaryClip!!.getItemAt(0).text.toString()
// try{
// val preferencesKeys = preferences.all.map { it.key }
// var count = 0
// jsonFormat.decodeFromString<JsonObject>(clip).run {
// val prefs = this.jsonObject["YTDLnis_Preferences"]!!.jsonArray
// prefs.forEach {
// val key : String = it.jsonObject["key"].toString().replace("\"", "")
// if (preferencesKeys.contains(key)){
// when(it.jsonObject["type"].toString().replace("\"", "")){
// "String" -> {
// val value = it.jsonObject["value"].toString().replace("\"", "")
// Log.e("aa", value.toString())
// editor.putString(key, value)
// editor.apply()
// }
// "Boolean" -> {
// val value = it.jsonObject["value"].toString().replace("\"", "").toBoolean()
// Log.e("aa", value.toString())
// editor.putBoolean(key, value)
// editor.apply()
// }
// "Int" -> {
// val value = it.jsonObject["value"].toString().replace("\"", "").toInt()
// Log.e("aa", value.toString())
// editor.putInt(key, value)
// editor.apply()
// }
// "HashSet" -> {
// val value = hashSetOf(it.jsonObject["value"].toString().replace("(\")|(\\[)|(])".toRegex(), ""))
// Log.e("aa", value.toString())
// editor.putStringSet(key, value)
// editor.apply()
// }
// }
// count++
// }
// }
// }
// Toast.makeText(requireContext(), "${getString(R.string.items_imported)} (${count})", Toast.LENGTH_LONG).show()
// }catch (e: Exception){
// e.printStackTrace()
// }
//
// true
// }
version!!.onPreferenceClickListener = version!!.onPreferenceClickListener =
Preference.OnPreferenceClickListener { Preference.OnPreferenceClickListener {
lifecycleScope.launch{ lifecycleScope.launch{
withContext(Dispatchers.IO){ withContext(Dispatchers.IO){
updateUtil!!.updateApp{ msg -> updateUtil!!.updateApp{ msg ->
lifecycleScope.launch(Dispatchers.Main){ lifecycleScope.launch(Dispatchers.Main){
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show() Snackbar.make(requireView(), msg, Snackbar.LENGTH_LONG).show()
} }
} }
} }
@ -742,8 +504,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
private fun changePath(p: Preference?, data: Intent?, requestCode: Int) { private fun changePath(p: Preference?, data: Intent?, requestCode: Int) {
val path = data!!.data.toString() val path = data!!.data.toString()
p!!.summary = fileUtil?.formatPath(data.data.toString()) p!!.summary = fileUtil?.formatPath(data.data.toString())
val sharedPreferences = val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
val editor = sharedPreferences.edit() val editor = sharedPreferences.edit()
when (requestCode) { when (requestCode) {
MUSIC_PATH_CODE -> editor.putString("music_path", path) MUSIC_PATH_CODE -> editor.putString("music_path", path)
@ -757,6 +518,5 @@ class SettingsFragment : PreferenceFragmentCompat() {
const val MUSIC_PATH_CODE = 33333 const val MUSIC_PATH_CODE = 33333
const val VIDEO_PATH_CODE = 55555 const val VIDEO_PATH_CODE = 55555
const val COMMAND_PATH_CODE = 77777 const val COMMAND_PATH_CODE = 77777
private const val TAG = "SettingsFragment"
} }
} }

View file

@ -6,6 +6,7 @@ import android.content.SharedPreferences
import android.os.Looper import android.os.Looper
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.models.Format import com.deniscerri.ytdlnis.database.models.Format
import com.deniscerri.ytdlnis.database.models.ResultItem import com.deniscerri.ytdlnis.database.models.ResultItem
@ -32,8 +33,7 @@ class InfoUtil(private val context: Context) {
init { init {
try { try {
sharedPreferences = sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
context.getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
key = sharedPreferences.getString("api_key", "") key = sharedPreferences.getString("api_key", "")
countryCODE = sharedPreferences.getString("locale", "")!! countryCODE = sharedPreferences.getString("locale", "")!!
} catch (e: Exception) { } catch (e: Exception) {

View file

@ -4,6 +4,7 @@ import android.app.Application
import android.util.Log import android.util.Log
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.google.android.material.color.DynamicColors import com.google.android.material.color.DynamicColors
@ -11,7 +12,7 @@ import com.google.android.material.color.DynamicColors
object ThemeUtil { object ThemeUtil {
fun updateTheme(activity: AppCompatActivity) { fun updateTheme(activity: AppCompatActivity) {
val sharedPreferences = activity.getSharedPreferences("root_preferences", Application.MODE_PRIVATE) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
//update accent //update accent
when (sharedPreferences.getString("theme_accent","blue")) { when (sharedPreferences.getString("theme_accent","blue")) {

View file

@ -11,6 +11,7 @@ import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.BuildConfig import com.deniscerri.ytdlnis.BuildConfig
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -146,7 +147,7 @@ class UpdateUtil(var context: Context) {
suspend fun updateYoutubeDL() : UpdateStatus? = suspend fun updateYoutubeDL() : UpdateStatus? =
withContext(Dispatchers.IO){ withContext(Dispatchers.IO){
val sharedPreferences = val sharedPreferences =
context.getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) PreferenceManager.getDefaultSharedPreferences(context)
if (updatingYTDL) { if (updatingYTDL) {
withContext(Dispatchers.Main){ withContext(Dispatchers.Main){
Toast.makeText( Toast.makeText(
@ -157,13 +158,6 @@ class UpdateUtil(var context: Context) {
} }
UpdateStatus.ALREADY_UP_TO_DATE UpdateStatus.ALREADY_UP_TO_DATE
} }
withContext(Dispatchers.Main){
Toast.makeText(
context,
context.getString(R.string.ytdl_updating_started),
Toast.LENGTH_SHORT
).show()
}
updatingYTDL = true updatingYTDL = true

View file

@ -8,6 +8,7 @@ import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.preference.PreferenceManager
import androidx.work.* import androidx.work.*
import com.deniscerri.ytdlnis.MainActivity import com.deniscerri.ytdlnis.MainActivity
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
@ -103,9 +104,7 @@ class DownloadWorker(
tempFileDir.delete() tempFileDir.delete()
tempFileDir.mkdirs() tempFileDir.mkdirs()
val sharedPreferences = context.getSharedPreferences("root_preferences", val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
Service.MODE_PRIVATE
)
val aria2 = sharedPreferences.getBoolean("aria2", false) val aria2 = sharedPreferences.getBoolean("aria2", false)
if (aria2) { if (aria2) {
request.addOption("--downloader", "libaria2c.so") request.addOption("--downloader", "libaria2c.so")

View file

@ -8,6 +8,7 @@ import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.Log import android.util.Log
import android.widget.Toast import android.widget.Toast
import androidx.preference.PreferenceManager
import androidx.work.* import androidx.work.*
import com.deniscerri.ytdlnis.MainActivity import com.deniscerri.ytdlnis.MainActivity
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
@ -40,9 +41,7 @@ class TerminalDownloadWorker(
setForegroundAsync(foregroundInfo) setForegroundAsync(foregroundInfo)
val request = YoutubeDLRequest(emptyList()) val request = YoutubeDLRequest(emptyList())
val sharedPreferences = context.getSharedPreferences("root_preferences", val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
Service.MODE_PRIVATE
)
val downloadLocation = sharedPreferences.getString("command_path", context.getString(R.string.command_path)) val downloadLocation = sharedPreferences.getString("command_path", context.getString(R.string.command_path))
val tempFileDir = File(context.cacheDir.absolutePath + "/downloads/" + itemId) val tempFileDir = File(context.cacheDir.absolutePath + "/downloads/" + itemId)

View file

@ -0,0 +1,5 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="?android:colorAccent" android:pathData="M14,2L6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6zM12,18c-2.05,0 -3.81,-1.24 -4.58,-3h1.71c0.63,0.9 1.68,1.5 2.87,1.5 1.93,0 3.5,-1.57 3.5,-3.5S13.93,9.5 12,9.5c-1.35,0 -2.52,0.78 -3.1,1.9l1.6,1.6h-4L6.5,9l1.3,1.3C8.69,8.92 10.23,8 12,8c2.76,0 5,2.24 5,5s-2.24,5 -5,5z"/>
</vector>

View file

@ -0,0 +1,5 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="?android:colorAccent" android:pathData="M19,12v7L5,19v-7L3,12v7c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2zM13,12.67l2.59,-2.58L17,11.5l-5,5 -5,-5 1.41,-1.41L11,12.67L11,3h2z"/>
</vector>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#ffffff" />
<padding
android:left="1dp"
android:right="1dp"
android:bottom="1dp"
android:top="1dp" />
<corners android:radius="3dp" />
</shape>

View file

@ -5,7 +5,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@ -13,139 +13,149 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:orientation="horizontal"
android:paddingTop="20dp">
<TextView
android:id="@+id/bottom_sheet_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/template"
android:textSize="25sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/bottom_sheet_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/create_template"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bottom_sheet_title" />
<Button
android:id="@+id/template_create"
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="all"
android:text="@string/create"
app:icon="@drawable/ic_check"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:padding="15dp">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/title"
style="@style/Widget.Material3.TextInputLayout.FilledBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title"
android:paddingBottom="10dp">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/content"
style="@style/Widget.Material3.TextInputLayout.FilledBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/command"
android:paddingBottom="10dp"
app:endIconDrawable="@drawable/ic_clipboard"
app:endIconMode="custom">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:maxLines="200" />
</com.google.android.material.textfield.TextInputLayout>
<View
style="@style/Divider.Horizontal"
android:layout_marginVertical="10dp" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:layout_marginHorizontal="20dp"
android:orientation="horizontal"
android:paddingTop="20dp">
<TextView <TextView
android:id="@+id/bottom_sheet_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/template" android:gravity="center"
android:textSize="25sp" android:paddingBottom="5dp"
android:text="@string/shortcuts"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/bottom_sheet_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/create_template"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bottom_sheet_title" />
<Button <Button
android:id="@+id/template_create" android:id="@+id/edit_shortcuts"
style="@style/Widget.Material3.Button.ElevatedButton.Icon" style="@style/Widget.Material3.Button.TextButton.Icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:autoLink="all" android:autoLink="all"
android:text="@string/create" android:text="@string/edit"
app:icon="@drawable/ic_check" app:icon="@drawable/ic_edit"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:orientation="vertical"
android:padding="15dp">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/title"
android:layout_width="match_parent"
android:paddingBottom="10dp"
android:layout_height="wrap_content"
android:hint="@string/title"
style="@style/Widget.Material3.TextInputLayout.FilledBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:inputType="text"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
app:endIconMode="custom"
app:endIconDrawable="@drawable/ic_clipboard"
android:hint="@string/command"
style="@style/Widget.Material3.TextInputLayout.FilledBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:maxLines="200"
android:inputType="textMultiLine"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<View
android:layout_marginVertical="10dp"
style="@style/Divider.Horizontal"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="5dp"
android:text="@string/shortcuts"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/edit_shortcuts"
style="@style/Widget.Material3.Button.TextButton.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="all"
android:text="@string/edit"
app:icon="@drawable/ic_edit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.chip.ChipGroup <com.google.android.material.chip.ChipGroup
android:id="@+id/shortcutsChipGroup" android:id="@+id/shortcutsChipGroup"
android:layout_width="wrap_content" android:layout_width="wrap_content"
app:chipSpacingVertical="-10dp"
app:chipSpacing="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:chipSpacing="0dp"
app:chipSpacingVertical="-10dp"
app:singleLine="false"> app:singleLine="false">
</com.google.android.material.chip.ChipGroup> </com.google.android.material.chip.ChipGroup>
</LinearLayout> </androidx.core.widget.NestedScrollView>
</LinearLayout> </LinearLayout>
</LinearLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View file

@ -1,199 +1,195 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.material.card.MaterialCardView android:id="@+id/download_card_view"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/downloads_card_constraintLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:backgroundTint="@android:color/transparent"
android:checkable="true"
android:clickable="true"
android:focusable="true"
app:cardPreventCornerOverlap="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/ShapeAppearanceOverlay.Avatar"
app:strokeWidth="0dp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.card.MaterialCardView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/download_card_view" android:layout_width="match_parent"
android:layout_width="0dp" android:paddingHorizontal="20dp"
app:shapeAppearance="@style/ShapeAppearanceOverlay.Avatar" android:paddingVertical="10dp"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:layout_marginHorizontal="20dp"
android:layout_marginVertical="10dp" <com.google.android.material.imageview.ShapeableImageView
android:checkable="true" android:id="@+id/downloads_image_view"
android:clickable="true" android:layout_width="0dp"
android:focusable="true" android:layout_height="0dp"
android:backgroundTint="@android:color/transparent" android:adjustViewBounds="true"
app:cardPreventCornerOverlap="true" android:background="?attr/colorSurfaceVariant"
app:layout_constraintBottom_toBottomOf="parent" android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintDimensionRatio="H,16:9"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toStartOf="@+id/download_item_data"
app:strokeWidth="0dp"> app:layout_constraintHorizontal_weight="0.3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearance="@style/ShapeAppearanceOverlay.Avatar" />
<TextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#80000000"
android:clickable="false"
android:ellipsize="end"
android:gravity="center"
android:maxLength="17"
android:maxLines="1"
android:minWidth="30dp"
android:paddingHorizontal="5dp"
android:textColor="@color/white"
android:textSize="12sp"
android:textStyle="bold"
app:cornerRadius="10dp"
app:layout_constraintBottom_toBottomOf="@+id/downloads_image_view"
app:layout_constraintEnd_toEndOf="@+id/downloads_image_view" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:id="@+id/download_item_data"
android:layout_height="wrap_content"> android:layout_width="0dp"
android:layout_height="wrap_content"
<com.google.android.material.imageview.ShapeableImageView app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/downloads_image_view" app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp" app:layout_constraintHorizontal_weight="0.7"
android:layout_height="0dp" app:layout_constraintStart_toEndOf="@+id/downloads_image_view"
app:layout_constraintHorizontal_weight="0.3" app:layout_constraintTop_toTopOf="parent"
android:adjustViewBounds="true" app:layout_constraintVertical_bias="0.0">
android:scaleType="centerCrop"
android:background="?attr/colorSurfaceVariant"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="H,16:9"
app:layout_constraintEnd_toStartOf="@+id/download_item_data"
app:layout_constraintStart_toStartOf="parent"
app:shapeAppearance="@style/ShapeAppearanceOverlay.Avatar"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/duration" android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#80000000"
android:clickable="false"
android:layout_margin="5dp"
android:ellipsize="end"
android:gravity="center"
android:textStyle="bold"
android:maxLength="17"
android:maxLines="1"
android:minWidth="30dp"
android:paddingHorizontal="5dp"
android:textColor="@color/white"
android:textSize="12sp"
app:cornerRadius="10dp"
app:layout_constraintBottom_toBottomOf="@+id/downloads_image_view"
app:layout_constraintEnd_toEndOf="@+id/downloads_image_view" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/download_item_data"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:paddingHorizontal="5dp"
android:scrollbars="none"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/action_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="title,action_button" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:paddingStart="5dp"
android:paddingEnd="0dp"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="0.7" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintVertical_bias="0.0" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@+id/downloads_image_view" app:layout_constraintTop_toBottomOf="@+id/barrier">
app:layout_constraintTop_toTopOf="parent">
<TextView <LinearLayout
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:paddingHorizontal="5dp"
android:scrollbars="none"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/action_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
app:barrierDirection="bottom"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent">
app:constraint_referenced_ids="title,action_button"/>
<HorizontalScrollView <TextView
android:layout_width="wrap_content" android:id="@+id/format_note"
android:layout_height="wrap_content" style="@style/Widget.Material3.FloatingActionButton.Large.Secondary"
android:gravity="bottom"
android:paddingStart="5dp"
android:paddingEnd="0dp"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/barrier">
<LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent"> android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:background="@drawable/rounded_corner"
android:backgroundTint="?attr/colorSecondary"
android:clickable="false"
android:ellipsize="end"
android:gravity="center"
android:maxLength="17"
android:maxLines="1"
android:minWidth="30dp"
android:paddingHorizontal="5dp"
android:textSize="12sp"
android:textStyle="bold"
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/codec"
style="@style/Widget.Material3.FloatingActionButton.Large.Secondary" style="@style/Widget.Material3.FloatingActionButton.Large.Secondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:background="?attr/colorSecondary" android:background="@drawable/rounded_corner"
android:clickable="false" android:backgroundTint="?attr/colorSecondary"
android:ellipsize="end" android:clickable="false"
android:gravity="center" android:gravity="center"
android:maxLength="17" android:minWidth="30dp"
android:maxLines="1" android:paddingHorizontal="5dp"
android:minWidth="30dp" android:textSize="12sp"
android:paddingHorizontal="5dp" android:textStyle="bold"
android:textSize="12sp" app:cornerRadius="10dp"
android:textStyle="bold" app:layout_constraintBottom_toBottomOf="parent"
app:cornerRadius="10dp" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/codec" android:id="@+id/file_size"
style="@style/Widget.Material3.FloatingActionButton.Large.Secondary" style="@style/Widget.Material3.FloatingActionButton.Large.Secondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:background="?attr/colorSecondary" android:background="@drawable/rounded_corner"
android:clickable="false" android:backgroundTint="?attr/colorSecondary"
android:gravity="center" android:clickable="false"
android:minWidth="30dp" android:gravity="center"
android:paddingHorizontal="5dp" android:minWidth="30dp"
android:textSize="12sp" android:paddingHorizontal="5dp"
android:textStyle="bold" android:textSize="12sp"
app:cornerRadius="10dp" android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent" app:cornerRadius="10dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/file_size"
style="@style/Widget.Material3.FloatingActionButton.Large.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:background="?attr/colorSecondary"
android:clickable="false"
android:gravity="center"
android:minWidth="30dp"
android:paddingHorizontal="5dp"
android:textSize="12sp"
android:textStyle="bold"
app:cornerRadius="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout> </LinearLayout>
</HorizontalScrollView> </HorizontalScrollView>
<com.google.android.material.button.MaterialButton
android:id="@+id/action_button"
style="?attr/materialIconButtonStyle"
android:layout_width="0dp"
android:padding="0dp"
android:minHeight="0dp"
android:layout_height="wrap_content"
app:cornerRadius="10dp"
app:iconTint="?attr/colorAccent"
app:icon="@drawable/ic_video"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/action_button"
style="?attr/materialIconButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:minHeight="0dp"
android:padding="0dp"
app:cornerRadius="10dp"
app:icon="@drawable/ic_video"
app:iconTint="?attr/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

View file

@ -13,7 +13,8 @@
<TextView <TextView
android:id="@+id/container" android:id="@+id/container"
android:layout_width="60dp" android:layout_width="60dp"
android:background="?attr/colorPrimaryInverse" android:background="@drawable/rounded_corner"
android:backgroundTint="?attr/colorPrimaryInverse"
android:textColor="@color/white" android:textColor="@color/white"
android:clickable="false" android:clickable="false"
android:layout_height="55dp" android:layout_height="55dp"
@ -62,7 +63,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:background="?attr/colorSecondary" android:background="@drawable/rounded_corner"
android:backgroundTint="?attr/colorSecondary"
android:clickable="false" android:clickable="false"
android:gravity="center" android:gravity="center"
android:minWidth="30dp" android:minWidth="30dp"
@ -79,7 +81,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:background="?attr/colorSecondary" android:background="@drawable/rounded_corner"
android:backgroundTint="?attr/colorSecondary"
android:clickable="false" android:clickable="false"
android:gravity="center" android:gravity="center"
android:minWidth="30dp" android:minWidth="30dp"

View file

@ -44,49 +44,42 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<ScrollView <com.google.android.material.textfield.TextInputLayout
android:id="@+id/title"
android:padding="15dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:paddingBottom="10dp"
android:layout_height="wrap_content"
app:endIconMode="custom"
app:endIconDrawable="@drawable/ic_plus"
android:hint="@string/create_shortcut"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:maxLines="4"
android:inputType="textMultiLine"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:paddingHorizontal="15dp"
android:scrollbars="none"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <com.google.android.material.chip.ChipGroup
android:layout_width="match_parent" android:id="@+id/shortcutsChipGroup"
android:layout_width="wrap_content"
app:chipSpacingVertical="-10dp"
app:chipSpacing="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" app:singleLine="false">
android:padding="15dp">
<com.google.android.material.chip.ChipGroup </com.google.android.material.chip.ChipGroup>
android:id="@+id/shortcutsChipGroup"
android:layout_width="wrap_content"
app:chipSpacingVertical="-10dp"
app:chipSpacing="0dp"
android:layout_height="wrap_content"
app:singleLine="false">
</com.google.android.material.chip.ChipGroup> </androidx.core.widget.NestedScrollView>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/title"
android:layout_width="match_parent"
android:paddingBottom="10dp"
android:layout_height="wrap_content"
app:endIconMode="custom"
app:endIconDrawable="@drawable/ic_plus"
android:hint="@string/create_shortcut"
style="@style/Widget.Material3.TextInputLayout.FilledBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:maxLines="4"
android:inputType="textMultiLine"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout> </LinearLayout>

View file

@ -44,29 +44,22 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<ScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:padding="15dp"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <com.google.android.material.chip.ChipGroup
android:layout_width="match_parent" android:id="@+id/shortcutsChipGroup"
android:layout_width="wrap_content"
app:chipSpacingVertical="-10dp"
app:chipSpacing="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" app:singleLine="false">
android:padding="15dp">
<com.google.android.material.chip.ChipGroup </com.google.android.material.chip.ChipGroup>
android:id="@+id/shortcutsChipGroup"
android:layout_width="wrap_content"
app:chipSpacingVertical="-10dp"
app:chipSpacing="0dp"
android:layout_height="wrap_content"
app:singleLine="false">
</com.google.android.material.chip.ChipGroup> </androidx.core.widget.NestedScrollView>
</LinearLayout>
</ScrollView>
</LinearLayout> </LinearLayout>

View file

@ -6,6 +6,7 @@
<item name="android:color">@android:color/transparent</item> <item name="android:color">@android:color/transparent</item>
<item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item> <item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item>
<item name="dialogCornerRadius">28dp</item> <item name="dialogCornerRadius">28dp</item>
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">false</item>
<item name="switchPreferenceCompatStyle">@style/Preference.SwitchPreferenceCompat.Material3</item> <item name="switchPreferenceCompatStyle">@style/Preference.SwitchPreferenceCompat.Material3</item>
<item name="snackbarStyle">@style/snackBarStyle</item> <item name="snackbarStyle">@style/snackBarStyle</item>
</style> </style>

View file

@ -253,4 +253,6 @@
<string name="updating_download_data">Updating Download Item Data</string> <string name="updating_download_data">Updating Download Item Data</string>
<string name="keep_cache">Keep Cache</string> <string name="keep_cache">Keep Cache</string>
<string name="keep_cache_summary">Don\'t delete temporary files after the download is finished</string> <string name="keep_cache_summary">Don\'t delete temporary files after the download is finished</string>
<string name="backup">Backup</string>
<string name="restore">Restore</string>
</resources> </resources>

View file

@ -5,6 +5,7 @@
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
<item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item> <item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item>
<item name="dialogCornerRadius">28dp</item> <item name="dialogCornerRadius">28dp</item>
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">true</item>
<item name="switchPreferenceCompatStyle">@style/Preference.SwitchPreferenceCompat.Material3</item> <item name="switchPreferenceCompatStyle">@style/Preference.SwitchPreferenceCompat.Material3</item>
<item name="snackbarStyle">@style/snackBarStyle</item> <item name="snackbarStyle">@style/snackBarStyle</item>
</style> </style>

View file

@ -383,17 +383,15 @@
<PreferenceCategory android:title="@string/about"> <PreferenceCategory android:title="@string/about">
<!-- <Preference--> <Preference
<!-- app:isPreferenceVisible="false"--> app:icon="@drawable/baseline_save_alt_24"
<!-- app:icon="@drawable/ic_clipboard"--> app:key="export_preferences"
<!-- app:key="export_preferences"--> app:title="@string/backup"/>
<!-- app:title="@string/export_from_clipboard"/>-->
<!-- <Preference--> <Preference
<!-- app:isPreferenceVisible="false"--> app:icon="@drawable/baseline_restore_page_24"
<!-- app:icon="@drawable/ic_copy"--> app:key="import_preferences"
<!-- app:key="import_preferences"--> app:title="@string/restore"/>
<!-- app:title="@string/import_from_clipboard"/>-->
<Preference <Preference
app:icon="@drawable/ic_discord" app:icon="@drawable/ic_discord"