fix: smol fixes
This commit is contained in:
parent
773b7f5dd0
commit
3d187a01ec
8 changed files with 67 additions and 19 deletions
|
@ -129,7 +129,7 @@ dependencies {
|
|||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
|
||||
implementation 'com.alexvasilkov:gesture-views:2.8.3'
|
||||
implementation 'com.github.VipulOG:ebook-reader:0.1.6'
|
||||
implementation 'androidx.paging:paging-runtime-ktx:3.3.0'
|
||||
implementation 'androidx.paging:paging-runtime-ktx:3.2.1'
|
||||
implementation 'com.github.eltos:simpledialogfragments:v3.7'
|
||||
implementation 'com.github.AAChartModel:AAChartCore-Kotlin:7.2.1'
|
||||
|
||||
|
|
|
@ -96,10 +96,12 @@ import ani.dantotsu.connections.bakaupdates.MangaUpdates
|
|||
import ani.dantotsu.connections.crashlytics.CrashlyticsInterface
|
||||
import ani.dantotsu.databinding.ItemCountDownBinding
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
import ani.dantotsu.notifications.IncognitoNotificationClickReceiver
|
||||
import ani.dantotsu.others.ImageViewDialog
|
||||
import ani.dantotsu.others.SpoilerPlugin
|
||||
import ani.dantotsu.parsers.ShowResponse
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.settings.saving.internal.PreferenceKeystore
|
||||
|
@ -118,6 +120,7 @@ import com.bumptech.glide.load.resource.gif.GifDrawable
|
|||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.bumptech.glide.request.target.ViewTarget
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
|
@ -344,7 +347,8 @@ open class BottomSheetDialogFragment : BottomSheetDialogFragment() {
|
|||
val behavior = BottomSheetBehavior.from(requireView().parent as View)
|
||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
}
|
||||
window.navigationBarColor = requireContext().getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
window.navigationBarColor =
|
||||
requireContext().getThemeColor(com.google.android.material.R.attr.colorSurface)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -643,7 +647,8 @@ fun ImageView.loadImage(file: FileUrl?, width: Int = 0, height: Int = 0) {
|
|||
.override(width, height).into(this)
|
||||
} else {
|
||||
val glideUrl = GlideUrl(file.url) { file.headers }
|
||||
Glide.with(this.context).load(glideUrl).transition(withCrossFade()).override(width, height)
|
||||
Glide.with(this.context).load(glideUrl).transition(withCrossFade())
|
||||
.override(width, height)
|
||||
.into(this)
|
||||
}
|
||||
}
|
||||
|
@ -1389,18 +1394,21 @@ fun blurImage(imageView: ImageView, banner: String?) {
|
|||
imageView.setImageResource(R.drawable.linear_gradient_bg)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.getThemeColor(@AttrRes attribute: Int): Int {
|
||||
val typedValue = TypedValue()
|
||||
theme.resolveAttribute(attribute, typedValue, true)
|
||||
return typedValue.data
|
||||
}
|
||||
|
||||
fun ImageView.openImage(title: String, image: String) {
|
||||
setOnLongClickListener{
|
||||
setOnLongClickListener {
|
||||
ImageViewDialog.newInstance(
|
||||
context as FragmentActivity, title, image
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the markwon instance with all the plugins
|
||||
* @return the markwon instance
|
||||
|
@ -1416,8 +1424,37 @@ fun buildMarkwon(
|
|||
.usePlugin(object : AbstractMarkwonPlugin() {
|
||||
override fun configureConfiguration(builder: MarkwonConfiguration.Builder) {
|
||||
builder.linkResolver { _, link ->
|
||||
if (link.startsWith("https://anilist.co/anime/") || link.startsWith("https://anilist.co/manga/")) {
|
||||
val mangaAnime = link.substringAfter("https://anilist.co/").substringBefore("/")
|
||||
val id =
|
||||
link.substringAfter("https://anilist.co/$mangaAnime/").substringBefore("/")
|
||||
.toIntOrNull()
|
||||
if (id != null && currContext() != null) {
|
||||
ContextCompat.startActivity(
|
||||
currContext()!!,
|
||||
Intent(currContext()!!, MediaDetailsActivity::class.java)
|
||||
.putExtra("mediaId", id),
|
||||
null
|
||||
)
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
} else if (link.startsWith("https://anilist.co/user/")) {
|
||||
val username = link.substringAfter("https://anilist.co/user/").substringBefore("/")
|
||||
if (currContext() != null) {
|
||||
ContextCompat.startActivity(
|
||||
currContext()!!,
|
||||
Intent(currContext()!!, ProfileActivity::class.java)
|
||||
.putExtra("username", username),
|
||||
null
|
||||
)
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -35,4 +35,6 @@ interface DownloadAddonApiV2 {
|
|||
fun getStackTrace(sessionId: Long): String?
|
||||
|
||||
fun hadError(sessionId: Long): Boolean
|
||||
|
||||
fun getFileExtension(): Pair<String, String> = Pair("mkv", "video/x-matroska")
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ class DownloadCompat {
|
|||
}
|
||||
|
||||
@Deprecated("external storage is deprecated, use SAF instead")
|
||||
fun removeDownloadCompat(context: Context, downloadedType: DownloadedType) {
|
||||
fun removeDownloadCompat(context: Context, downloadedType: DownloadedType, toast: Boolean) {
|
||||
val directory = if (downloadedType.type == MediaType.MANGA) {
|
||||
File(
|
||||
context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
|
@ -368,10 +368,13 @@ class DownloadCompat {
|
|||
// Check if the directory exists and delete it recursively
|
||||
if (directory.exists()) {
|
||||
val deleted = directory.deleteRecursively()
|
||||
if (toast) {
|
||||
if (deleted) {
|
||||
Toast.makeText(context, "Successfully deleted", Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(context, "Failed to delete directory", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, "Failed to delete directory", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class DownloadsManager(private val context: Context) {
|
|||
toast: Boolean = true,
|
||||
onFinished: () -> Unit
|
||||
) {
|
||||
removeDownloadCompat(context, downloadedType)
|
||||
removeDownloadCompat(context, downloadedType, toast)
|
||||
downloadsList.remove(downloadedType)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
removeDirectory(downloadedType, toast)
|
||||
|
|
|
@ -225,14 +225,16 @@ class AnimeDownloaderService : Service() {
|
|||
task.episode
|
||||
) ?: throw Exception("Failed to create output directory")
|
||||
|
||||
outputDir.findFile("${task.getTaskName().findValidName()}.mkv")?.delete()
|
||||
val extension = ffExtension!!.getFileExtension()
|
||||
outputDir.findFile("${task.getTaskName().findValidName()}.${extension.first}")?.delete()
|
||||
|
||||
val outputFile =
|
||||
outputDir.createFile("video/x-matroska", "${task.getTaskName()}.mkv")
|
||||
outputDir.createFile(extension.second, "${task.getTaskName()}.${extension.first}")
|
||||
?: throw Exception("Failed to create output file")
|
||||
|
||||
var percent = 0
|
||||
var totalLength = 0.0
|
||||
val path = ffExtension!!.setDownloadPath(
|
||||
val path = ffExtension.setDownloadPath(
|
||||
this@AnimeDownloaderService,
|
||||
outputFile.uri
|
||||
)
|
||||
|
@ -339,8 +341,9 @@ class AnimeDownloaderService : Service() {
|
|||
DownloadedType(
|
||||
task.title,
|
||||
task.episode,
|
||||
MediaType.ANIME,
|
||||
)
|
||||
MediaType.ANIME
|
||||
),
|
||||
false
|
||||
) {}
|
||||
Injekt.get<CrashlyticsInterface>().logException(
|
||||
Exception(
|
||||
|
|
|
@ -528,10 +528,11 @@ class AnimeWatchFragment : Fragment() {
|
|||
}
|
||||
toast(context.getString(R.string.success) + " (1)")
|
||||
} else {
|
||||
val tempFile =
|
||||
directory.createFile("video/x-matroska", "temp.mkv")
|
||||
?: throw Exception("Temp file is null")
|
||||
val ffExtension = Injekt.get<DownloadAddonManager>().extension?.extension!!
|
||||
val extension = ffExtension.getFileExtension()
|
||||
val tempFile =
|
||||
directory.createFile(extension.second, "temp.${extension.first}")
|
||||
?: throw Exception("Temp file is null")
|
||||
val tempPath = ffExtension.setDownloadPath(
|
||||
context,
|
||||
tempFile.uri
|
||||
|
|
|
@ -101,6 +101,7 @@ import androidx.mediarouter.app.MediaRouteButton
|
|||
import ani.dantotsu.GesturesListener
|
||||
import ani.dantotsu.NoPaddingArrayAdapter
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.addons.download.DownloadAddonManager
|
||||
import ani.dantotsu.brightnessConverter
|
||||
import ani.dantotsu.circularReveal
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
|
@ -1507,6 +1508,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
println(files)
|
||||
val docFile = directory.listFiles().firstOrNull {
|
||||
it.name?.endsWith(".mp4") == true || it.name?.endsWith(".mkv") == true
|
||||
|| it.name?.endsWith(".${Injekt.get<DownloadAddonManager>().extension?.extension?.getFileExtension()?.first ?: "ts"}") == true
|
||||
}
|
||||
if (docFile != null) {
|
||||
val uri = docFile.uri
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue