This commit is contained in:
zaednasr 2023-11-11 00:03:52 +01:00
parent 3a25dbc07b
commit 80edfbb0a1
No known key found for this signature in database
GPG key ID: 92B1DE23AD3D0E9E
15 changed files with 108 additions and 103 deletions

View file

@ -93,12 +93,15 @@ class ResultViewModel(application: Application) : AndroidViewModel(application)
else -> res.addAll(repository.getDefault(inputQuery, resetResults))
}
} catch (e: Exception) {
uiState.update {it.copy(
processing = false,
errorMessage = Pair(R.string.no_results, e.message.toString()),
actions = mutableListOf(Pair(R.string.copy_log, ResultAction.COPY_LOG))
)}
Log.e(tag, e.toString())
if (e !is kotlinx.coroutines.CancellationException){
uiState.update {it.copy(
processing = false,
errorMessage = Pair(R.string.no_results, e.message.toString()),
actions = mutableListOf(Pair(R.string.copy_log, ResultAction.COPY_LOG))
)}
Log.e(tag, e.toString())
}
}
}
uiState.update {it.copy(processing = false)}

View file

@ -1,7 +1,6 @@
package com.deniscerri.ytdlnis.receiver
import android.Manifest
import android.content.ComponentName
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
@ -17,30 +16,26 @@ import android.util.Log
import android.util.Patterns
import android.view.WindowManager
import androidx.core.app.ActivityCompat
import androidx.core.content.IntentSanitizer
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController
import androidx.preference.PreferenceManager
import com.deniscerri.ytdlnis.MainActivity
import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.models.DownloadItem
import com.deniscerri.ytdlnis.database.models.ResultItem
import com.deniscerri.ytdlnis.database.viewmodel.CookieViewModel
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel
import com.deniscerri.ytdlnis.database.viewmodel.ResultViewModel
import com.deniscerri.ytdlnis.ui.BaseActivity
import com.deniscerri.ytdlnis.ui.downloadcard.DownloadBottomSheetDialog
import com.deniscerri.ytdlnis.ui.downloadcard.SelectPlaylistItemsDialog
import com.deniscerri.ytdlnis.util.ThemeUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@ -91,29 +86,6 @@ class ShareActivity : BaseActivity() {
val intent = intent
handleIntents(intent)
}
override fun onResume() {
super.onResume()
navController.addOnDestinationChangedListener(object: NavController.OnDestinationChangedListener{
override fun onDestinationChanged(
controller: NavController,
destination: NavDestination,
arguments: Bundle?
) {
if (navController.currentBackStack.value.isEmpty()) return
navController.removeOnDestinationChangedListener(this)
lifecycleScope.launch {
navController.currentBackStack.collectLatest {
if (it.isEmpty()){
this@ShareActivity.finish()
}
}
}
}
})
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntents(intent)
@ -124,6 +96,22 @@ class ShareActivity : BaseActivity() {
val navHostFragment = supportFragmentManager.findFragmentById(R.id.frame_layout) as NavHostFragment
navController = navHostFragment.findNavController()
navController.addOnDestinationChangedListener(object: NavController.OnDestinationChangedListener{
override fun onDestinationChanged(
controller: NavController,
destination: NavDestination,
arguments: Bundle?
) {
navController.removeOnDestinationChangedListener(this)
CoroutineScope(SupervisorJob()).launch {
navController.currentBackStack.collectLatest {
if (it.isEmpty()){
this@ShareActivity.finish()
}
}
}
}
})
val action = intent.action
Log.e("aa", intent.toString())

View file

@ -81,7 +81,6 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
private var historyList: List<HistoryItem?>? = null
private var allhistoryList: List<HistoryItem?>? = null
private var selectedObjects: ArrayList<HistoryItem>? = null
private var _binding : FragmentHistoryBinding? = null
private var actionMode : ActionMode? = null
private lateinit var sortChip: Chip
@ -90,7 +89,6 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentHistoryBinding.inflate(inflater, container, false)
fragmentView = inflater.inflate(R.layout.fragment_history, container, false)
activity = getActivity()
mainActivity = activity as MainActivity?

View file

@ -1,6 +1,7 @@
package com.deniscerri.ytdlnis.ui.more.downloadLogs
import android.annotation.SuppressLint
import android.app.ActionBar
import android.content.ClipboardManager
import android.content.Context.CLIPBOARD_SERVICE
import android.graphics.Color
@ -26,6 +27,7 @@ import androidx.lifecycle.lifecycleScope
import com.deniscerri.ytdlnis.MainActivity
import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.viewmodel.LogViewModel
import com.deniscerri.ytdlnis.util.UiUtil.enableTextHighlight
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.bottomappbar.BottomAppBar
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
@ -70,6 +72,7 @@ class DownloadLogFragment : Fragment() {
content = view.findViewById(R.id.content)
content.setTextIsSelectable(true)
content.layoutParams!!.width = ActionBar.LayoutParams.WRAP_CONTENT
contentScrollView = view.findViewById(R.id.content_scrollview)
val bottomAppBar = view.findViewById<BottomAppBar>(R.id.bottomAppBar)
@ -100,41 +103,29 @@ class DownloadLogFragment : Fragment() {
topAppBar.title = logItem.title
}
//init syntax highlighter
val highlight = Highlight()
val highlightWatcher = HighlightTextWatcher()
val schemes = listOf(
ColorScheme(Pattern.compile("([\"'])(?:\\\\1|.)*?\\1"), Color.parseColor("#FC8500")),
ColorScheme(Pattern.compile("yt-dlp"), Color.parseColor("#00FF00")),
ColorScheme(Pattern.compile("(https?://(?:www\\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|www\\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|https?://(?:www\\.|(?!www))[a-zA-Z0-9]+\\.[^\\s]{2,}|www\\.[a-zA-Z0-9]+\\.[^\\s]{2,})"), Color.parseColor("#b5942f")),
ColorScheme(Pattern.compile("\\d+(\\.\\d)?%"), Color.parseColor("#43a564"))
)
highlight.addScheme(
*schemes.map { it }.toTypedArray()
)
highlightWatcher.addScheme(
*schemes.map { it }.toTypedArray()
)
highlight.setSpan(content)
content.isFocusable = true
content.addTextChangedListener(highlightWatcher)
content.setHorizontallyScrolling(false)
content.enableTextHighlight()
bottomAppBar?.setOnMenuItemClickListener { m: MenuItem ->
when(m.itemId){
R.id.wrap -> {
var scrollView = view.findViewById<HorizontalScrollView>(R.id.horizontalscroll_output)
var scrollView = requireView().findViewById<HorizontalScrollView>(R.id.horizontalscroll_output)
if(scrollView != null){
val parent = (scrollView.parent as ViewGroup)
scrollView.removeAllViews()
parent.removeView(scrollView)
parent.addView(content, 0)
contentScrollView.setPadding(0,0,0,
(requireContext().resources.displayMetrics.density * 150).toInt()
)
}else{
val parent = content.parent as ViewGroup
parent.removeView(content)
scrollView = HorizontalScrollView(requireContext())
scrollView.setPadding(0,0,0,
(requireContext().resources.displayMetrics.density * 150).toInt()
)
contentScrollView.setPadding(0,0,0,0)
scrollView.layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
@ -143,7 +134,6 @@ class DownloadLogFragment : Fragment() {
scrollView.id = R.id.horizontalscroll_output
parent.addView(scrollView, 0)
}
content.setHorizontallyScrolling(!content.canScrollHorizontally(1))
}
R.id.scroll_down -> {
@ -162,10 +152,16 @@ class DownloadLogFragment : Fragment() {
logViewModel.getLogFlowByID(id!!).observe(viewLifecycleOwner){logItem ->
lifecycleScope.launch {
content.text = logItem.content
content.scrollTo(content.scrollX, content.height)
contentScrollView.fullScroll(View.FOCUS_DOWN)
kotlin.runCatching {
requireActivity().runOnUiThread{
if (logItem != null){
if (logItem.content.isNotBlank()) {
content.text = logItem.content
}
content.scrollTo(0, content.height)
contentScrollView.fullScroll(View.FOCUS_DOWN)
}
}
}
}
}

View file

@ -192,7 +192,6 @@ class TerminalFragment : Fragment() {
}
output = view.findViewById(R.id.custom_command_output)
output!!.movementMethod = ScrollingMovementMethod()
output!!.setTextIsSelectable(true)
output!!.layoutParams!!.width = LayoutParams.WRAP_CONTENT
input!!.requestFocus()
@ -222,7 +221,6 @@ class TerminalFragment : Fragment() {
initMenu()
input?.enableTextHighlight()
output?.enableTextHighlight()
input?.append(bundle?.getString("input") ?: "")
input!!.requestFocus()
@ -308,9 +306,7 @@ class TerminalFragment : Fragment() {
output?.text = it.log
}
output?.scrollTo(0, output!!.height)
if (!scrollView!!.canScrollVertically(1) && !scrollView!!.canScrollHorizontally(-1)){
scrollView?.fullScroll(View.FOCUS_DOWN)
}
scrollView?.fullScroll(View.FOCUS_DOWN)
input!!.visibility = View.GONE
showCancelFab()
}

View file

@ -87,7 +87,7 @@ object FileUtil {
if (it.isDirectory && it.absolutePath == originDir.absolutePath) return@forEach
var destFile: DocumentFile
try {
if (it.name.matches("(^config.*.\\.txt\$)|(rList)|(.*.part-Frag)|(.*.live_chat)".toRegex())){
if (it.name.matches("(^config.*.\\.txt\$)|(rList)|(.*.part-Frag.*)|(.*.live_chat)|(.*.ytdl)".toRegex())){
return@forEach
}

View file

@ -112,10 +112,12 @@ class InfoUtil(private val context: Context) {
val dataArray = res.getJSONArray("relatedStreams")
var nextpage = res.getString("nextpage")
for (i in 0 until dataArray.length()){
val obj = dataArray.getJSONObject(i)
val itm = createVideoFromPipedJSON(obj, "https://youtube.com" + obj.getString("url"))
itm?.playlistTitle = res.getString("name") + "[${i+1}]"
items.add(itm)
kotlin.runCatching {
val obj = dataArray.getJSONObject(i)
val itm = createVideoFromPipedJSON(obj, "https://youtube.com" + obj.getString("url"))
itm?.playlistTitle = res.getString("name") + "[${i+1}]"
items.add(itm)
}
}
if (nextpage == "null") nextpage = ""
return PlaylistTuple(nextpage, items)
@ -1398,19 +1400,21 @@ class InfoUtil(private val context: Context) {
val audioFormats = resources.getStringArray(R.array.audio_formats)
val formats = mutableListOf<Format>()
val containerPreference = sharedPreferences.getString("audio_format", "")
audioFormats.reversed().forEach { formats.add(Format(it, containerPreference!!,"","", "",0, it)) }
audioFormatIDPreference.forEach { formats.add(Format(it, containerPreference!!,"","", "",1, it)) }
val acodecPreference = sharedPreferences.getString("audio_codec", "m4a|mp4a|aac")
audioFormats.reversed().forEach { formats.add(Format(it, containerPreference!!,"",acodecPreference!!, "",0, it)) }
audioFormatIDPreference.forEach { formats.add(Format(it, containerPreference!!,"",acodecPreference!!, "",1, it)) }
return formats
}
fun getGenericVideoFormats(resources: Resources) : MutableList<Format>{
val formatIDPreference = sharedPreferences.getString("format_id", "").toString().split(",").filter { it.isNotEmpty() }
val videoFormats = resources.getStringArray(R.array.video_formats_values)
val formats = mutableListOf<Format>()
val containerPreference = sharedPreferences.getString("video_format", "")
videoFormats.reversed().forEach { formats.add(Format(it, containerPreference!!,"Default","", "",0, it.split("_")[0])) }
formatIDPreference.forEach { formats.add(Format(it, containerPreference!!,"Default","", "",1, it)) }
val acodecPreference = sharedPreferences.getString("audio_codec", "m4a|mp4a|aac")
val vcodecPreference = sharedPreferences.getString("video_codec", "avc|h264")!!.ifEmpty { resources.getString(R.string.defaultValue) }
videoFormats.reversed().forEach { formats.add(Format(it, containerPreference!!,vcodecPreference,acodecPreference!!, "",0, it.split("_")[0])) }
formatIDPreference.forEach { formats.add(Format(it, containerPreference!!,vcodecPreference,acodecPreference!!, "",1, it)) }
return formats
}

View file

@ -102,7 +102,7 @@ object UiUtil {
val audioFormatsTextView = formatCard.findViewById<TextView>(R.id.audio_formats)
if (!audioFormats.isNullOrEmpty()) {
audioFormatsTextView.text = audioFormats.joinToString("+") { it.format_id }
audioFormatsTextView.text = "id: " + audioFormats.joinToString("+") { it.format_id }
audioFormatsTextView.visibility = View.VISIBLE
}else{
audioFormatsTextView.visibility = View.GONE

View file

@ -23,34 +23,48 @@
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
<FrameLayout
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="match_parent">
<ScrollView
android:id="@+id/content_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingBottom="150dp"
>
<TextView
android:id="@+id/content"
android:padding="10dp"
android:fontFamily="monospace"
android:textSize="15sp"
android:gravity="bottom"
android:scrollbars="none"
android:layout_width="wrap_content"
android:textIsSelectable="true"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical">
<HorizontalScrollView
android:id="@+id/horizontalscroll_output"
android:layout_width="match_parent"
android:paddingBottom="150dp"
android:layout_height="match_parent">
<TextView
android:id="@+id/content"
android:padding="10dp"
android:fontFamily="monospace"
android:textSize="15sp"
android:gravity="bottom"
android:scrollbars="none"
android:layout_width="wrap_content"
android:textIsSelectable="true"
android:layout_height="wrap_content" />
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
</LinearLayout>
</FrameLayout>
<include layout="@layout/no_results"
android:visibility="gone" />

View file

@ -122,7 +122,9 @@
android:visibility="gone" />
<include layout="@layout/history_item_details_bottom_sheet"
<include
android:id="@+id/no_results"
layout="@layout/history_item_details_bottom_sheet"
android:visibility="gone" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -308,7 +308,7 @@
<string name="schedule">스케쥴</string>
<string name="user_agent_header">사용자 에이전트 헤더</string>
<string name="search_command_hint">명령어로 검색</string>
<string name="skip">건너뜀</string>
<string name="ignore">건너뜀</string>
<string name="license">라이선스</string>
<string name="download_already_exists_summary">아직도 다운로드하시겠습니까\?</string>
<string name="modify_download_card">다운로드 카드 수정</string>

View file

@ -308,7 +308,7 @@
<string name="schedule">Harmonogram</string>
<string name="user_agent_header">Nagłówek User-Agent</string>
<string name="search_command_hint">Szukaj z poleceń</string>
<string name="skip">Pomiń</string>
<string name="ignore">Pomiń</string>
<string name="license">Licencja</string>
<string name="download_already_exists_summary">Czy nadal chcesz pobrać\?</string>
<string name="modify_download_card">Modyfikowanie karty pobierania</string>

View file

@ -309,7 +309,7 @@
<string name="remember_download_type_summary">Selecionar o último tipo de download aberto para o item atual</string>
<string name="schedule">Agendar</string>
<string name="search_command_hint">Pesquisar com comandos</string>
<string name="skip">Saltar</string>
<string name="ignore">Saltar</string>
<string name="license">Licença</string>
<string name="download_already_exists_summary">Ainda queres descarregar\?</string>
<string name="modify_download_card">Modificar o cartão de descarregamento</string>

View file

@ -116,6 +116,7 @@
<item>fr</item>
<item>hi</item>
<item>hr</item>
<item>hu</item>
<item>in</item>
<item>it</item>
<item>ja</item>
@ -132,6 +133,7 @@
<item>ru</item>
<item>ro</item>
<item>sk</item>
<item>sr</item>
<item>sq</item>
<item>ta</item>
<item>te</item>
@ -826,9 +828,9 @@
<item>%(title)s___(string): Video title)</item>
<item>%(id)s___(string): Video identifier)</item>
<item>%(fulltitle)s___(string): Video title ignoring live timestamp and generic title)</item>
<item>%(ext)s___(string): Video filename extension)</item>
<!-- <item>%(ext)s___(string): Video filename extension)</item>-->
<item>%(alt_title)s___(string): A secondary title of the video)</item>
<item>%(description)s___(string): The description of the video)</item>
<!-- <item>%(description)s___(string): The description of the video)</item>-->
<item>%(display_id)s___(string): An alternative identifier for the video)</item>
<item>%(license)s___(string): License name the video is licensed under)</item>
<item>%(creator)s___(string): The creator of the video)</item>
@ -841,7 +843,7 @@
<item>%(uploader_id)s___(string): Nickname or id of the video uploader)</item>
<item>%(channel)s___(string): Full name of the channel the video is uploaded on)</item>
<item>%(channel_id)s___(string): Id of the channel)</item>
<item>%(channel_follower_count)s___(numeric): Number of followers of the channel)</item>
<!-- <item>%(channel_follower_count)s___(numeric): Number of followers of the channel)</item>-->
<item>%(channel_is_verified)s___(boolean): Whether the channel is verified on the platform)</item>
<item>%(location)s___(string): Physical location where the video was filmed)</item>
<item>%(duration)s___(numeric): Length of the video in seconds)</item>

View file

@ -13,6 +13,7 @@
<locale android:name="fr"/>
<locale android:name="hi"/>
<locale android:name="hr"/>
<locale android:name="hu"/>
<locale android:name="in"/>
<locale android:name="it"/>
<locale android:name="ja"/>
@ -29,6 +30,7 @@
<locale android:name="ru"/>
<locale android:name="ro-RO"/>
<locale android:name="sk"/>
<locale android:name="sr"/>
<locale android:name="sq-AL"/>
<locale android:name="ta"/>
<locale android:name="te"/>