stuff
This commit is contained in:
parent
f6c712d1d2
commit
726ad19cf8
7 changed files with 34 additions and 33 deletions
|
|
@ -22,6 +22,7 @@ import androidx.core.view.isVisible
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.deniscerri.ytdl.MainActivity
|
||||
import com.deniscerri.ytdl.R
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ import com.deniscerri.ytdl.database.viewmodel.ResultViewModel
|
|||
import com.deniscerri.ytdl.database.viewmodel.SettingsViewModel
|
||||
import com.deniscerri.ytdl.ui.more.settings.FolderSettingsFragment.Companion.COMMAND_PATH_CODE
|
||||
import com.deniscerri.ytdl.util.FileUtil
|
||||
import com.deniscerri.ytdl.util.ThemeUtil
|
||||
import com.deniscerri.ytdl.util.UiUtil
|
||||
import com.deniscerri.ytdl.util.UpdateUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
|
@ -492,27 +493,19 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
|
|||
val builder = MaterialAlertDialogBuilder(requireContext())
|
||||
builder.setTitle(getString(R.string.restore))
|
||||
builder.setMessage("${getString(R.string.restore_complete)}\n $restoreDataMessage")
|
||||
builder.setCancelable(false)
|
||||
builder.setPositiveButton(
|
||||
getString(R.string.restart)
|
||||
) { _: DialogInterface?, _: Int ->
|
||||
val intent = Intent(requireContext(), MainActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
requireActivity().finishAffinity()
|
||||
if(data.settings != null){
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(preferences.getString("app_language", "en")))
|
||||
}
|
||||
activity?.finishAffinity()
|
||||
}
|
||||
|
||||
// handle the negative button of the alert dialog
|
||||
builder.setNegativeButton(
|
||||
getString(R.string.cancel)
|
||||
getString(R.string.ok)
|
||||
) { _: DialogInterface?, _: Int ->
|
||||
if(data.settings != null){
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(preferences.getString("app_language", "en")))
|
||||
val languageValue = preferences.getString("app_language", "en")
|
||||
if (languageValue == "system") {
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(null))
|
||||
}else{
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(languageValue.toString()))
|
||||
}
|
||||
}
|
||||
ThemeUtil.recreateAllActivities()
|
||||
}
|
||||
|
||||
val dialog = builder.create()
|
||||
|
|
|
|||
|
|
@ -77,6 +77,12 @@ object ThemeUtil {
|
|||
activities.firstOrNull { it.javaClass == MainActivity::class.java }?.recreate()
|
||||
}
|
||||
|
||||
fun recreateAllActivities() {
|
||||
activities.forEach {
|
||||
it.recreate()
|
||||
}
|
||||
}
|
||||
|
||||
fun updateThemes() {
|
||||
activities.forEach {
|
||||
updateTheme(it)
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
request.applyDefaultOptionsForFetchingData(url)
|
||||
if (url.isYoutubeURL()) {
|
||||
request.setYoutubeExtractorArgs(url)
|
||||
request.addOption("--extractor-args", "youtube:player_skip=webpage,configs,js;player_client=android,web")
|
||||
}
|
||||
|
||||
val youtubeDLResponse = YoutubeDL.getInstance().execute(request)
|
||||
|
|
@ -1327,9 +1328,7 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
}
|
||||
|
||||
if (downloadItem.videoPreferences.embedSubs) {
|
||||
if (sharedPreferences.getBoolean("write_subs_when_embed_subs", false) && !downloadItem.videoPreferences.writeSubs && !downloadItem.videoPreferences.writeAutoSubs) {
|
||||
request.addOption("--write-subs")
|
||||
request.addOption("--write-auto-subs")
|
||||
if (sharedPreferences.getBoolean("no_keep_subs", false) && !downloadItem.videoPreferences.writeSubs && !downloadItem.videoPreferences.writeAutoSubs) {
|
||||
request.addOption("--compat-options", "no-keep-subs")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -232,8 +232,8 @@ class DownloadWorker(
|
|||
CoroutineScope(Dispatchers.IO).launch {
|
||||
if (logDownloads) {
|
||||
logRepo.update(line, logItem.id)
|
||||
logString.append("$line\n")
|
||||
}
|
||||
logString.append("$line\n")
|
||||
}
|
||||
}
|
||||
}.onSuccess {
|
||||
|
|
@ -378,17 +378,17 @@ class DownloadWorker(
|
|||
FileUtil.deleteFile("${cachePath}/${infoJsonName}.info.json")
|
||||
}
|
||||
|
||||
if(it.message != null){
|
||||
if (logDownloads){
|
||||
logRepo.update(it.message!!, logItem.id)
|
||||
}else{
|
||||
logString.append("${it.message}\n")
|
||||
logItem.content = logString.toString()
|
||||
val logID = logRepo.insert(logItem)
|
||||
downloadItem.logID = logID
|
||||
}
|
||||
|
||||
if (logDownloads){
|
||||
logRepo.update(it.message ?: "", logItem.id)
|
||||
}else{
|
||||
logString.append("${it.message ?: it.stackTraceToString()}\n")
|
||||
logItem.content = logString.toString()
|
||||
val logID = logRepo.insert(logItem)
|
||||
downloadItem.logID = logID
|
||||
}
|
||||
|
||||
|
||||
tempFileDir.delete()
|
||||
|
||||
Log.e(TAG, context.getString(R.string.failed_download), it)
|
||||
|
|
|
|||
|
|
@ -481,4 +481,6 @@
|
|||
<string name="potoken">PO Token</string>
|
||||
<string name="web_client_po_token">Web Client PO Token</string>
|
||||
<string name="reverse">Reverse</string>
|
||||
<string name="no_keep_subs">Delete subtitle files after embedding</string>
|
||||
<string name="no_keep_subs_summary">When using both Embed Subtitles and Write Subtitles, don\'t keep the subtitle files after embedding</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -179,9 +179,9 @@
|
|||
android:widgetLayout="@layout/preferece_material_switch"
|
||||
app:defaultValue="true"
|
||||
app:icon="@drawable/ic_subtitles"
|
||||
app:key="write_subs_when_embed_subs"
|
||||
app:summary="@string/write_subs_when_embed_subs_summary"
|
||||
app:title="@string/write_subs_when_embed_subs" />
|
||||
app:key="no_keep_subs"
|
||||
app:summary="@string/no_keep_subs_summary"
|
||||
app:title="@string/no_keep_subs" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/baseline_subject_24"
|
||||
|
|
|
|||
Loading…
Reference in a new issue