fixed provider, fixed toast stacking, updated quality API for better sorting

This commit is contained in:
LagradOst 2021-08-25 00:19:15 +02:00
parent 0967fe7600
commit efa95ddbe6
17 changed files with 165 additions and 143 deletions

View File

@ -51,16 +51,12 @@
<receiver
android:name=".receivers.VideoDownloadRestartReceiver"
android:enabled="true"
android:enabled="false"
android:exported="true">
<intent-filter>
<action android:name="restart_service" />
</intent-filter>
</receiver>
<service
android:name=".services.VideoDownloadKeepAliveService"
android:enabled="false" >
</service>
<service
android:name=".services.VideoDownloadService"
android:enabled="true"

View File

@ -1,13 +1,18 @@
package com.lagradost.cloudstream3
import android.app.Activity
import android.app.PictureInPictureParams
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.ColorStateList
import android.os.Build
import android.os.Bundle
import android.view.WindowManager
import android.view.*
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavOptions
import androidx.navigation.findNavController
@ -15,11 +20,6 @@ import androidx.navigation.fragment.NavHostFragment
import com.google.android.gms.cast.framework.CastButtonFactory
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor
import com.lagradost.cloudstream3.utils.UIHelper.hasPIPPermission
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode
import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
import com.lagradost.cloudstream3.ui.download.DownloadChildFragment
@ -33,10 +33,17 @@ import com.lagradost.cloudstream3.utils.DataStore.removeKey
import com.lagradost.cloudstream3.utils.DataStoreHelper.setViewPos
import com.lagradost.cloudstream3.utils.Event
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor
import com.lagradost.cloudstream3.utils.UIHelper.hasPIPPermission
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode
import com.lagradost.cloudstream3.utils.UIHelper.toPx
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_result.*
import kotlin.concurrent.thread
const val VLC_PACKAGE = "org.videolan.vlc"
const val VLC_INTENT_ACTION_RESULT = "org.videolan.vlc.player.result"
val VLC_COMPONENT: ComponentName =
@ -67,6 +74,41 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
val onColorSelectedEvent = Event<Pair<Int, Int>>()
val onDialogDismissedEvent = Event<Int>()
lateinit var navOptions: NavOptions
var currentToast: Toast? = null
fun showToast(act: Activity?, @StringRes message: Int, duration: Int) {
if (act == null) return
showToast(act, act.getString(message), duration)
}
fun showToast(act: Activity?, message: String, duration: Int) {
if (act == null) return
try {
currentToast?.cancel()
} catch (e: Exception) {
e.printStackTrace()
}
try {
val inflater = act.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
val layout: View = inflater.inflate(
R.layout.toast,
act.findViewById<View>(R.id.toast_layout_root) as ViewGroup?
)
val text = layout.findViewById(R.id.text) as TextView
text.text = message.trim()
val toast = Toast(act)
toast.setGravity(Gravity.CENTER_HORIZONTAL or Gravity.BOTTOM, 0, 5.toPx)
toast.duration = duration
toast.view = layout
toast.show()
currentToast = toast
} catch (e: Exception) {
}
}
}
private fun enterPIPMode() {

View File

@ -2,7 +2,8 @@ package com.lagradost.cloudstream3.animeproviders
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.getQualityFromName
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.extractorApis
import org.jsoup.Jsoup
import java.util.*
@ -65,14 +66,15 @@ class AnimeFlickProvider : MainAPI() {
val title = doc.selectFirst("h2.title").text()
val yearText = doc.selectFirst(".trending-year")?.text()
val year = if(yearText != null) Regex("""(\d{4})""").find(yearText)?.destructured?.component1()?.toIntOrNull() else null
val year = if (yearText != null) Regex("""(\d{4})""").find(yearText)?.destructured?.component1()
?.toIntOrNull() else null
val description = doc.selectFirst("p").text()
val genres = doc.select("a[href*=\"genre-\"]").map { it.text() }
val episodes = doc.select("#collapseOne .block-space > .row > div:nth-child(2)").map {
val name = it.selectFirst("a").text()
val link = mainUrl + it.selectFirst("a").attr("href")
val link = mainUrl + it.selectFirst("a").attr("href")
AnimeEpisode(link, name)
}.reversed()
@ -102,19 +104,33 @@ class AnimeFlickProvider : MainAPI() {
val html = khttp.get(data).text
val episodeRegex = Regex("""(https://.*?\.mp4)""")
episodeRegex.findAll(html).map {
val links = episodeRegex.findAll(html).map {
it.value
}.toList().forEach {
callback(
ExtractorLink(
"Animeflick",
"Animeflick - Auto",
it,
"",
getQualityFromName("1080")
}.toList()
for (link in links) {
var alreadyAdded = false
for (extractor in extractorApis) {
if (link.startsWith(extractor.mainUrl)) {
extractor.getSafeUrl(link, data)?.forEach {
callback(it)
}
alreadyAdded = true
break
}
}
if (!alreadyAdded) {
callback(
ExtractorLink(
this.name,
"${this.name} - Auto",
link,
"",
Qualities.P1080.value
)
)
)
}
}
return true
}
}

View File

@ -5,9 +5,6 @@ import android.content.Context
import android.content.Intent
import android.os.Build
import android.util.Log
import com.lagradost.cloudstream3.services.RESTART_ALL_DOWNLOADS_AND_QUEUE
import com.lagradost.cloudstream3.services.START_VALUE_KEY
import com.lagradost.cloudstream3.services.VideoDownloadKeepAliveService
class VideoDownloadRestartReceiver : BroadcastReceiver() {

View File

@ -1,54 +0,0 @@
package com.lagradost.cloudstream3.services
import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.util.Log
import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver
import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.getKeys
import com.lagradost.cloudstream3.utils.VideoDownloadManager
const val RESTART_ALL_DOWNLOADS_AND_QUEUE = 1
const val RESTART_NONE = 0
const val START_VALUE_KEY = "start_value"
class VideoDownloadKeepAliveService : Service() {
override fun onBind(p0: Intent?): IBinder? {
return null
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val startValue = intent?.getIntExtra(START_VALUE_KEY, RESTART_NONE) ?: RESTART_NONE
Log.i("Service", "Restarted with start value of $startValue")
if (startValue == RESTART_ALL_DOWNLOADS_AND_QUEUE) {
val keys = this.getKeys(VideoDownloadManager.KEY_RESUME_PACKAGES)
val resumePkg = keys.mapNotNull { k -> this.getKey<VideoDownloadManager.DownloadResumePackage>(k) }
for (pkg in resumePkg) { // ADD ALL CURRENT DOWNLOADS
VideoDownloadManager.downloadFromResume(this, pkg)
}
// ADD QUEUE
val resumeQueue =
this.getKey<List<VideoDownloadManager.DownloadQueueResumePackage>>(VideoDownloadManager.KEY_RESUME_QUEUE_PACKAGES)
if (resumeQueue != null && resumeQueue.isNotEmpty()) {
val sorted = resumeQueue.sortedBy { item -> item.index }
for (queueItem in sorted) {
VideoDownloadManager.downloadFromResume(this, queueItem.pkg)
}
}
}
return START_STICKY//super.onStartCommand(intent, flags, startId)
}
override fun onDestroy() {
val broadcastIntent = Intent()
broadcastIntent.action = "restart_service"
broadcastIntent.setClass(this, VideoDownloadRestartReceiver::class.java)
this.sendBroadcast(broadcastIntent)
super.onDestroy()
}
}

View File

@ -57,6 +57,7 @@ import com.google.android.material.button.MaterialButton
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.MainActivity.Companion.canEnterPipMode
import com.lagradost.cloudstream3.MainActivity.Companion.isInPIPMode
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.observe
@ -1242,7 +1243,8 @@ class PlayerFragment : Fragment() {
}
}
val startIndexFromMap = currentSubtitles.map { it.removeSuffix(" ") }.indexOf(preferredSubtitles.removeSuffix(" ")) + 1
val startIndexFromMap =
currentSubtitles.map { it.removeSuffix(" ") }.indexOf(preferredSubtitles.removeSuffix(" ")) + 1
var subtitleIndex = startIndexFromMap
if (currentSubtitles.isEmpty()) {
@ -1805,33 +1807,30 @@ class PlayerFragment : Fragment() {
when (error.type) {
ExoPlaybackException.TYPE_SOURCE -> {
if (currentUrl?.url != "") {
Toast.makeText(
showToast(
activity,
"Source error\n" + error.sourceException.message,
LENGTH_SHORT
)
.show()
tryNextMirror()
}
}
ExoPlaybackException.TYPE_REMOTE -> {
Toast.makeText(activity, "Remote error", LENGTH_SHORT)
.show()
showToast(activity, "Remote error", LENGTH_SHORT)
}
ExoPlaybackException.TYPE_RENDERER -> {
Toast.makeText(
showToast(
activity,
"Renderer error\n" + error.rendererException.message,
LENGTH_SHORT
)
.show()
}
ExoPlaybackException.TYPE_UNEXPECTED -> {
Toast.makeText(
showToast(
activity,
"Unexpected player error\n" + error.unexpectedException.message,
LENGTH_SHORT
).show()
)
}
}
}
@ -1840,8 +1839,8 @@ class PlayerFragment : Fragment() {
println("Warning: Illegal state exception in PlayerFragment")
} finally {
setPreferredSubLanguage(
if(isDownloadedFile) {
if(activeSubtitles.isNotEmpty()) {
if (isDownloadedFile) {
if (activeSubtitles.isNotEmpty()) {
activeSubtitles.first()
} else null
} else {
@ -1877,9 +1876,7 @@ class PlayerFragment : Fragment() {
initPlayer(getCurrentUrl())
}
} else {
context?.let { ctx ->
Toast.makeText(ctx, "No Links Found", LENGTH_SHORT).show()
}
showToast(activity, "No Links Found", LENGTH_SHORT)
}
}
}

View File

@ -39,6 +39,7 @@ const val ACTION_COPY_LINK = 9
const val ACTION_SHOW_OPTIONS = 10
const val ACTION_CLICK_DEFAULT = 11
const val ACTION_SHOW_TOAST = 12
data class EpisodeClickEvent(val action: Int, val data: ResultEpisode)
@ -173,7 +174,7 @@ class EpisodeAdapter(
}
episodePoster?.setOnLongClickListener {
Toast.makeText(it.context, R.string.play_episode_toast, Toast.LENGTH_SHORT).show()
clickCallback.invoke(EpisodeClickEvent(ACTION_SHOW_TOAST, card))
return@setOnLongClickListener true
}

View File

@ -31,25 +31,16 @@ import com.google.android.material.button.MaterialButton
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.getApiFromName
import com.lagradost.cloudstream3.APIHolder.getId
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.utils.UIHelper.getStatusBarHeight
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.observe
import com.lagradost.cloudstream3.ui.WatchType
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_DOWNLOAD
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
import com.lagradost.cloudstream3.ui.download.EasyDownloadButton
import com.lagradost.cloudstream3.ui.download.DownloadButtonSetup.handleDownloadClick
import com.lagradost.cloudstream3.ui.download.EasyDownloadButton
import com.lagradost.cloudstream3.ui.player.PlayerData
import com.lagradost.cloudstream3.ui.player.PlayerFragment
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getDownloadSubsLanguageISO639_1
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.isAppInstalled
@ -60,16 +51,22 @@ import com.lagradost.cloudstream3.utils.Coroutines.main
import com.lagradost.cloudstream3.utils.DataStore.getFolderName
import com.lagradost.cloudstream3.utils.DataStore.setKey
import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import com.lagradost.cloudstream3.utils.UIHelper.getStatusBarHeight
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
import com.lagradost.cloudstream3.utils.UIHelper.setImage
import com.lagradost.cloudstream3.utils.VideoDownloadManager.sanitizeFilename
import kotlinx.android.synthetic.main.fragment_result.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.withContext
import java.io.File
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
const val MAX_SYNO_LENGH = 300
@ -278,7 +275,7 @@ class ResultFragment : Fragment() {
media_route_button?.alpha = if (chromecastSupport) 1f else 0.3f
if (!chromecastSupport) {
media_route_button.setOnClickListener {
Toast.makeText(it.context, "This provider has no chromecast support", Toast.LENGTH_LONG).show()
showToast(activity, "This provider has no chromecast support", Toast.LENGTH_LONG)
}
}
@ -369,7 +366,11 @@ class ResultFragment : Fragment() {
return true
}
is Resource.Failure -> {
Toast.makeText(requireContext(), R.string.error_loading_links, Toast.LENGTH_SHORT).show()
showToast(
activity,
R.string.error_loading_links,
Toast.LENGTH_SHORT
)
}
else -> {
@ -476,7 +477,7 @@ class ResultFragment : Fragment() {
// DOWNLOAD VIDEO
VideoDownloadManager.downloadEpisode(
ctx,
activity,
src,//url ?: return,
folder,
meta,
@ -525,6 +526,10 @@ class ResultFragment : Fragment() {
if (!isLoaded) return@main // CANT LOAD
when (episodeClick.action) {
ACTION_SHOW_TOAST -> {
showToast(activity, R.string.play_episode_toast, Toast.LENGTH_SHORT)
}
ACTION_CLICK_DEFAULT -> {
context?.let { ctx ->
if (ctx.isConnectedToChromecast()) {
@ -584,7 +589,7 @@ class ResultFragment : Fragment() {
?: return@acquireSingeExtractorLink
val clip = ClipData.newPlainText(link.name, link.url)
serviceClipboard.setPrimaryClip(clip)
Toast.makeText(requireContext(), "Text Copied", Toast.LENGTH_SHORT).show()
showToast(activity, "Link copied to clipboard", Toast.LENGTH_SHORT)
}
}
@ -1012,7 +1017,7 @@ class ResultFragment : Fragment() {
}
}
is Resource.Failure -> {
result_error_text.text = data.errorString
result_error_text.text = url?.plus("\n") + data.errorString
updateVisStatus(1)
}
is Resource.Loading -> {

View File

@ -2,6 +2,7 @@ package com.lagradost.cloudstream3.ui.search
import android.app.Activity
import android.widget.Toast
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult
object SearchHelper {
@ -12,9 +13,7 @@ object SearchHelper {
activity.loadSearchResult(card)
}
SEARCH_ACTION_SHOW_METADATA -> {
activity?.let { act ->
Toast.makeText(act, callback.card.name, Toast.LENGTH_SHORT).show()
}
showToast(activity, callback.card.name, Toast.LENGTH_SHORT)
}
}
}

View File

@ -4,6 +4,7 @@ import android.os.Bundle
import android.widget.Toast
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
@ -19,7 +20,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
thread {
if (!requireActivity().runAutoUpdate(false)) {
activity?.runOnUiThread {
Toast.makeText(this.context, "No Update Found", Toast.LENGTH_SHORT).show()
showToast(activity, "No Update Found", Toast.LENGTH_SHORT)
}
}
}

View File

@ -21,6 +21,7 @@ import com.google.android.exoplayer2.text.Cue
import com.google.android.exoplayer2.ui.CaptionStyleCompat
import com.jaredrummler.android.colorpicker.ColorPickerDialog
import com.lagradost.cloudstream3.MainActivity
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.setKey
@ -207,7 +208,7 @@ class SubtitlesFragment : Fragment() {
this.setOnLongClickListener {
it.context.setColor(id, null)
Toast.makeText(it.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
}
}
@ -248,7 +249,7 @@ class SubtitlesFragment : Fragment() {
subs_subtitle_elevation.setOnLongClickListener {
state.elevation = 0
it.context.updateState()
Toast.makeText(it.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
}
@ -276,7 +277,7 @@ class SubtitlesFragment : Fragment() {
subs_edge_type.setOnLongClickListener {
state.edgeType = CaptionStyleCompat.EDGE_TYPE_OUTLINE
it.context.updateState()
Toast.makeText(it.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
}
@ -312,7 +313,7 @@ class SubtitlesFragment : Fragment() {
subs_font.setOnLongClickListener { textView ->
state.typeface = null
textView.context.updateState()
Toast.makeText(textView.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
}
@ -336,7 +337,7 @@ class SubtitlesFragment : Fragment() {
subs_auto_select_language.setOnLongClickListener { textView ->
textView.context.setKey(SUBTITLE_AUTO_SELECT_KEY, "en")
Toast.makeText(textView.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
}
@ -359,7 +360,7 @@ class SubtitlesFragment : Fragment() {
subs_download_languages.setOnLongClickListener { textView ->
textView.context.setKey(SUBTITLE_DOWNLOAD_KEY, listOf("en"))
Toast.makeText(textView.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
}

View File

@ -15,8 +15,8 @@ import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.BuildConfig
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
import java.io.*
import java.net.URL
import java.net.URLConnection
@ -178,7 +178,7 @@ class InAppUpdater {
} catch (e: Exception) {
println(e)
runOnUiThread {
Toast.makeText(this, "Permission error", Toast.LENGTH_SHORT).show()
showToast(this, "Permission error", Toast.LENGTH_SHORT)
}
return false
}
@ -291,14 +291,14 @@ class InAppUpdater {
val context = this
builder.apply {
setPositiveButton("Update") { _, _ ->
Toast.makeText(context, "Download started", Toast.LENGTH_LONG).show()
showToast(context, "Download started", Toast.LENGTH_LONG)
thread {
val downloadStatus = context.downloadUpdate(update.updateURL)
if (!downloadStatus) {
runOnUiThread {
Toast.makeText(context,
showToast(context,
"Download Failed",
Toast.LENGTH_LONG).show()
Toast.LENGTH_LONG)
}
} /*else {
activity.runOnUiThread {

View File

@ -1,9 +1,6 @@
package com.lagradost.cloudstream3.utils
import android.app.ActivityManager
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.*
import android.content.*
import android.graphics.Bitmap
import android.net.Uri
@ -19,6 +16,7 @@ import androidx.core.app.NotificationManagerCompat
import androidx.core.net.toUri
import com.bumptech.glide.Glide
import com.lagradost.cloudstream3.MainActivity
import com.lagradost.cloudstream3.MainActivity.Companion.showToast
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
@ -908,15 +906,15 @@ object VideoDownloadManager {
return context.getKey(KEY_RESUME_PACKAGES, id.toString())
}
fun downloadFromResume(context: Context, pkg: DownloadResumePackage, setKey: Boolean = true) {
fun downloadFromResume(context: Activity, pkg: DownloadResumePackage, setKey: Boolean = true) {
if (!currentDownloads.any { it == pkg.item.ep.id }) {
if (currentDownloads.size == maxConcurrentDownloads) {
main {
Toast.makeText(
showToast( // can be replaced with regular Toast
context,
"${pkg.item.ep.mainName}${pkg.item.ep.episode?.let { " Episode $it " } ?: " "}queued",
Toast.LENGTH_SHORT
).show()
)
}
}
downloadQueue.addLast(pkg)
@ -947,12 +945,13 @@ object VideoDownloadManager {
}
fun downloadEpisode(
context: Context,
context: Activity?,
source: String?,
folder: String?,
ep: DownloadEpisodeMetadata,
links: List<ExtractorLink>
) {
if(context == null) return
val validLinks = links.filter { !it.isM3u8 }
if (validLinks.isNotEmpty()) {
downloadFromResume(context, DownloadResumePackage(DownloadItem(source, folder, ep, validLinks), null))

View File

@ -49,7 +49,6 @@
android:id="@+id/overlay_loading_skip_button"
android:text="@string/skip_loading"
app:rippleColor="?attr/colorPrimary"
android:textColor="?attr/textColor"
app:iconTint="?attr/textColor"

View File

@ -389,10 +389,13 @@
</TextView>
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:gravity="center_vertical"
android:layout_width="match_parent" android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:visibility="visible"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:id="@+id/result_season_button"
tools:text="Season 1"
@ -409,7 +412,7 @@
android:layout_height="50dp">
</com.google.android.material.button.MaterialButton>
<com.google.android.material.button.MaterialButton
android:visibility="visible"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:id="@+id/result_episode_select"
tools:text="50-100"

View File

@ -0,0 +1,19 @@
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toast_layout_root"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
app:cardCornerRadius="10dp"
android:background="?attr/bitDarkerGrayBackground">
<TextView
android:padding="20dp"
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="?attr/textColor"/>
</androidx.cardview.widget.CardView>

View File

@ -7,6 +7,7 @@
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@drawable/splash_background</item>
<item name="android:navigationBarColor">?attr/bitDarkerGrayBackground</item>
<item name="android:colorEdgeEffect">?attr/textColor</item>
<!--<item name="android:navigationBarColor">@color/darkBackground</item>-->
<item name="android:statusBarColor">@color/grayBackground</item>