stuff
Fixed app crashing when selecting a format from playlist formats and they dont have audio formats in them made the context app bar close when you invert a fully selected list added syntax highlight to logs
This commit is contained in:
parent
e9f627030a
commit
bc10b8bb27
14 changed files with 109 additions and 41 deletions
|
|
@ -69,6 +69,17 @@
|
|||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".receiver.ShareFileActivity"
|
||||
android:configChanges="smallestScreenSize|layoutDirection|locale|orientation|screenSize"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@style/Theme.BottomSheet">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.more.settings.SettingsActivity"
|
||||
android:configChanges="smallestScreenSize|layoutDirection|locale|orientation|screenSize"
|
||||
|
|
@ -136,11 +147,6 @@
|
|||
android:name="autoStoreLocales"
|
||||
android:value="true" />
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".receiver.ShareFileService"
|
||||
android:exported="false" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.deniscerri.ytdl.fileprovider"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package com.deniscerri.ytdlnis.receiver
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import com.deniscerri.ytdlnis.ui.BaseActivity
|
||||
import com.deniscerri.ytdlnis.util.NotificationUtil
|
||||
import com.deniscerri.ytdlnis.util.ThemeUtil
|
||||
import com.deniscerri.ytdlnis.util.UiUtil
|
||||
|
||||
class ShareFileActivity : BaseActivity() {
|
||||
|
||||
lateinit var context: Context
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
ThemeUtil.updateTheme(this)
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { v, insets ->
|
||||
v.setPadding(0, 0, 0, 0)
|
||||
insets
|
||||
}
|
||||
window.run {
|
||||
setBackgroundDrawable(ColorDrawable(0))
|
||||
setLayout(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY)
|
||||
} else {
|
||||
setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT)
|
||||
}
|
||||
}
|
||||
|
||||
val paths = intent.getStringArrayExtra("path")
|
||||
val notificationId = intent.getIntExtra("notificationID", 0)
|
||||
NotificationUtil(this).cancelDownloadNotification(notificationId)
|
||||
UiUtil.shareFileIntent(this, paths!!.toList())
|
||||
finishAffinity()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package com.deniscerri.ytdlnis.receiver
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
import com.deniscerri.ytdlnis.util.NotificationUtil
|
||||
import com.deniscerri.ytdlnis.util.UiUtil
|
||||
|
||||
class ShareFileService : Service() {
|
||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||
val paths = intent.getStringArrayExtra("path")
|
||||
val notificationId = intent.getIntExtra("notificationID", 0)
|
||||
NotificationUtil(this).cancelDownloadNotification(notificationId)
|
||||
UiUtil.shareFileIntent(this, paths!!.toList())
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
override fun onBind(intent: Intent): IBinder? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
stopForeground(true)
|
||||
}
|
||||
}
|
||||
|
|
@ -658,6 +658,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, OnClickListene
|
|||
selectedObjects?.clear()
|
||||
selectedObjects?.addAll(invertedList)
|
||||
actionMode!!.title = "${selectedObjects!!.size} ${getString(R.string.selected)}"
|
||||
if (invertedList.isEmpty()) actionMode?.finish()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
|
|
|||
|
|
@ -268,8 +268,20 @@ class FormatSelectionBottomSheetDialog(private val items: List<DownloadItem?>, p
|
|||
(it as MaterialCardView).isChecked = selectedAudios.map { a -> "${a.format_id}${a.format_note}" }.contains(it.tag)
|
||||
}
|
||||
}else{
|
||||
//if its a simple audio format selection
|
||||
listener.onFormatClick(List(items.size){chosenFormats}, listOf(FormatTuple(format, null)))
|
||||
if (items.size == 1){
|
||||
listener.onFormatClick(List(items.size){chosenFormats}, listOf(FormatTuple(format, null)))
|
||||
}else{
|
||||
val selectedFormats = mutableListOf<Format>()
|
||||
formatCollection.forEach {
|
||||
selectedFormats.add(it.first{ f -> f.format_id == format.format_id})
|
||||
}
|
||||
if (selectedFormats.isEmpty()) {
|
||||
items.forEach {
|
||||
selectedFormats.add(format)
|
||||
}
|
||||
}
|
||||
listener.onFormatClick(formatCollection, selectedFormats.map { FormatTuple(it, null) })
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,6 +299,7 @@ class CancelledDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClic
|
|||
selectedObjects?.clear()
|
||||
selectedObjects?.addAll(invertedList)
|
||||
actionMode!!.title = "${selectedObjects!!.size} ${getString(R.string.selected)}"
|
||||
if (invertedList.isEmpty()) actionMode?.finish()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
|
|
|||
|
|
@ -306,6 +306,7 @@ class ErroredDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickL
|
|||
selectedObjects?.clear()
|
||||
selectedObjects?.addAll(invertedList)
|
||||
actionMode!!.title = "${selectedObjects!!.size} ${getString(R.string.selected)}"
|
||||
if (invertedList.isEmpty()) actionMode?.finish()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
|
|
|||
|
|
@ -606,6 +606,7 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
|
|||
selectedObjects?.clear()
|
||||
selectedObjects?.addAll(invertedList)
|
||||
actionMode!!.title = "${selectedObjects!!.size} ${getString(R.string.selected)}"
|
||||
if (invertedList.isEmpty()) actionMode?.finish()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
|
|
|||
|
|
@ -329,6 +329,7 @@ class QueuedDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickLi
|
|||
selectedObjects?.clear()
|
||||
selectedObjects?.addAll(invertedList)
|
||||
actionMode!!.title = "${selectedObjects!!.size} ${getString(R.string.selected)}"
|
||||
if (invertedList.isEmpty()) actionMode?.finish()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.deniscerri.ytdlnis.ui.more.downloadLogs
|
|||
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context.CLIPBOARD_SERVICE
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.FileObserver
|
||||
|
|
@ -15,7 +16,11 @@ import com.deniscerri.ytdlnis.MainActivity
|
|||
import com.deniscerri.ytdlnis.R
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
import com.neo.highlight.core.Highlight
|
||||
import com.neo.highlight.util.listener.HighlightTextWatcher
|
||||
import com.neo.highlight.util.scheme.ColorScheme
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
||||
class DownloadLogFragment : Fragment() {
|
||||
|
|
@ -92,6 +97,26 @@ class DownloadLogFragment : Fragment() {
|
|||
}
|
||||
observer.startWatching();
|
||||
}
|
||||
|
||||
//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.addTextChangedListener(highlightWatcher)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
|
|||
|
|
@ -822,6 +822,9 @@ class InfoUtil(private val context: Context) {
|
|||
chapters = Gson().fromJson(chaptersInJSON.toString(), listType)
|
||||
}
|
||||
|
||||
var urls = "";
|
||||
if(jsonObject.has("urls")) urls = jsonObject.getString("urls");
|
||||
|
||||
Log.e("aa", formats.toString())
|
||||
items.add(ResultItem(0,
|
||||
url,
|
||||
|
|
@ -832,7 +835,7 @@ class InfoUtil(private val context: Context) {
|
|||
website,
|
||||
playlistTitle!!,
|
||||
formats,
|
||||
jsonObject.getString("urls") ?: "",
|
||||
urls,
|
||||
chapters
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,12 +13,11 @@ import android.os.Bundle
|
|||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.navigation.NavDeepLinkBuilder
|
||||
import com.deniscerri.ytdlnis.MainActivity
|
||||
import com.deniscerri.ytdlnis.R
|
||||
import com.deniscerri.ytdlnis.receiver.CancelDownloadNotificationReceiver
|
||||
import com.deniscerri.ytdlnis.receiver.PauseDownloadNotificationReceiver
|
||||
import com.deniscerri.ytdlnis.receiver.ResumeActivity
|
||||
import com.deniscerri.ytdlnis.receiver.ShareFileService
|
||||
import com.deniscerri.ytdlnis.receiver.ShareFileActivity
|
||||
import java.io.File
|
||||
|
||||
|
||||
|
|
@ -213,10 +212,10 @@ class NotificationUtil(var context: Context) {
|
|||
}
|
||||
|
||||
//share intent
|
||||
val shareIntent = Intent(context, ShareFileService::class.java)
|
||||
val shareIntent = Intent(context, ShareFileActivity::class.java)
|
||||
shareIntent.putExtra("path", filepath.toTypedArray())
|
||||
shareIntent.putExtra("notificationID", DOWNLOAD_FINISHED_NOTIFICATION_ID)
|
||||
val shareNotificationPendingIntent: PendingIntent = PendingIntent.getService(
|
||||
val shareNotificationPendingIntent: PendingIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
shareIntent,
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class DownloadWorker(
|
|||
if (downloadItem.author.isNotBlank()){
|
||||
request.addCommands(listOf("--replace-in-metadata","uploader",".*.",downloadItem.author.take(25)))
|
||||
}
|
||||
request.addCommands(listOf("--replace-in-metadata","uploader"," - Topic",""))
|
||||
request.addCommands(listOf("--replace-in-metadata","uploader"," - Topic$",""))
|
||||
if (downloadItem.customFileNameTemplate.isBlank()) downloadItem.customFileNameTemplate = "%(uploader)s - %(title)s"
|
||||
|
||||
if (downloadItem.downloadSections.isNotBlank()){
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
android:scrollbars="none"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue