fix: smol changes

This commit is contained in:
rebelonion 2024-04-30 19:39:19 -05:00
parent 2d2f058d27
commit 1431027cf3
6 changed files with 26 additions and 28 deletions

View file

@ -377,7 +377,7 @@
<activity
android:name="eu.kanade.tachiyomi.extension.util.ExtensionInstallActivity"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
android:theme="@style/Theme.AppCompat" />
<receiver
android:name=".notifications.AlarmPermissionStateReceiver"
@ -441,7 +441,7 @@
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name=".addons.torrent.ServerService"
android:name=".addons.torrent.TorrentServerService"
android:exported="false"
android:foregroundServiceType="dataSync"
android:stopWithTask="true" />

View file

@ -13,7 +13,6 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.provider.Settings
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.AnticipateInterpolator
@ -34,8 +33,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.media3.common.util.UnstableApi
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.work.OneTimeWorkRequest
import ani.dantotsu.addons.torrent.ServerService
import ani.dantotsu.addons.torrent.TorrentServerService
import ani.dantotsu.addons.torrent.TorrentAddonManager
import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.connections.anilist.AnilistHomeViewModel
@ -49,8 +47,6 @@ import ani.dantotsu.home.MangaFragment
import ani.dantotsu.home.NoInternet
import ani.dantotsu.media.MediaDetailsActivity
import ani.dantotsu.notifications.TaskScheduler
import ani.dantotsu.notifications.anilist.AnilistNotificationWorker
import ani.dantotsu.notifications.comment.CommentNotificationWorker
import ani.dantotsu.others.CustomBottomDialog
import ani.dantotsu.profile.ProfileActivity
import ani.dantotsu.profile.activity.FeedActivity
@ -456,8 +452,8 @@ class MainActivity : AppCompatActivity() {
fun startTorrent() {
if (torrentManager.isAvailable() && PrefManager.getVal(PrefName.TorrentEnabled)) {
launchIO {
if (!ServerService.isRunning()) {
ServerService.start()
if (!TorrentServerService.isRunning()) {
TorrentServerService.start()
}
}
}

View file

@ -22,10 +22,10 @@ import uy.kohesive.injekt.api.get
import kotlin.coroutines.EmptyCoroutineContext
class ServerService : Service() {
class TorrentServerService : Service() {
private val serviceScope = CoroutineScope(EmptyCoroutineContext)
private val applicationContext = Injekt.get<Application>()
private val extension = Injekt.get<TorrentAddonManager>().extension!!.extension
private lateinit var extension: TorrentAddonApi
override fun onBind(intent: Intent?): IBinder? = null
@ -34,6 +34,7 @@ class ServerService : Service() {
flags: Int,
startId: Int,
): Int {
extension = Injekt.get<TorrentAddonManager>().extension?.extension ?: return START_NOT_STICKY
intent?.let {
if (it.action != null) {
when (it.action) {
@ -75,7 +76,7 @@ class ServerService : Service() {
PendingIntent.getService(
applicationContext,
0,
Intent(applicationContext, ServerService::class.java).apply {
Intent(applicationContext, TorrentServerService::class.java).apply {
action = ACTION_STOP
},
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
@ -113,7 +114,7 @@ class ServerService : Service() {
with(Injekt.get<Application>().getSystemService(ACTIVITY_SERVICE) as ActivityManager) {
@Suppress("DEPRECATION") // We only need our services
getRunningServices(Int.MAX_VALUE).forEach {
if (ServerService::class.java.name.equals(it.service.className)) {
if (TorrentServerService::class.java.name.equals(it.service.className)) {
return true
}
}
@ -122,9 +123,12 @@ class ServerService : Service() {
}
fun start() {
if (Injekt.get<TorrentAddonManager>().extension?.extension == null) {
return
}
try {
val intent =
Intent(Injekt.get<Application>(), ServerService::class.java).apply {
Intent(Injekt.get<Application>(), TorrentServerService::class.java).apply {
action = ACTION_START
}
Injekt.get<Application>().startService(intent)
@ -137,7 +141,7 @@ class ServerService : Service() {
fun stop() {
try {
val intent =
Intent(Injekt.get<Application>(), ServerService::class.java).apply {
Intent(Injekt.get<Application>(), TorrentServerService::class.java).apply {
action = ACTION_STOP
}
Injekt.get<Application>().startService(intent)

View file

@ -11,7 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import ani.dantotsu.R
import ani.dantotsu.addons.AddonDownloader
import ani.dantotsu.addons.download.DownloadAddonManager
import ani.dantotsu.addons.torrent.ServerService
import ani.dantotsu.addons.torrent.TorrentServerService
import ani.dantotsu.addons.torrent.TorrentAddonManager
import ani.dantotsu.databinding.ActivitySettingsAddonsBinding
import ani.dantotsu.databinding.ItemSettingsBinding
@ -141,7 +141,7 @@ class SettingsAddonActivity : AppCompatActivity() {
}
it.settingsIconRight.setOnClickListener { _ ->
if (it.settingsDesc.text == getString(R.string.installed)) {
ServerService.stop()
TorrentServerService.stop()
torrentAddonManager.uninstall()
return@setOnClickListener
} else {
@ -190,14 +190,14 @@ class SettingsAddonActivity : AppCompatActivity() {
Injekt.get<TorrentAddonManager>().extension?.let {
if (isChecked) {
lifecycleScope.launchIO {
if (!ServerService.isRunning()) {
ServerService.start()
if (!TorrentServerService.isRunning()) {
TorrentServerService.start()
}
}
} else {
lifecycleScope.launchIO {
if (ServerService.isRunning()) {
ServerService.stop()
if (TorrentServerService.isRunning()) {
TorrentServerService.stop()
}
}
}

View file

@ -10,7 +10,6 @@ import ani.dantotsu.addons.torrent.TorrentAddonManager
import ani.dantotsu.media.AddonType
import ani.dantotsu.media.MediaType
import ani.dantotsu.parsers.novel.NovelExtensionManager
import ani.dantotsu.themes.ThemeManager
import eu.kanade.tachiyomi.extension.InstallStep
import eu.kanade.tachiyomi.extension.anime.AnimeExtensionManager
import eu.kanade.tachiyomi.extension.manga.MangaExtensionManager
@ -38,8 +37,6 @@ class ExtensionInstallActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ThemeManager(this).applyTheme()
if (intent.hasExtra(ExtensionInstaller.EXTRA_EXTENSION_TYPE))
mediaType =
intent.getSerializableExtraCompat<MediaType>(ExtensionInstaller.EXTRA_EXTENSION_TYPE)
@ -86,6 +83,7 @@ class ExtensionInstallActivity : AppCompatActivity() {
}
}
@Suppress("all")
private fun checkInstallationResult(resultCode: Int) {
val downloadId = intent.extras!!.getLong(ExtensionInstaller.EXTRA_DOWNLOAD_ID)
val newStep = when (resultCode) {
@ -103,11 +101,9 @@ class ExtensionInstallActivity : AppCompatActivity() {
Injekt.get<MangaExtensionManager>().updateInstallStep(downloadId, newStep)
}
MediaType.NOVEL -> {
else -> {
Injekt.get<NovelExtensionManager>().updateInstallStep(downloadId, newStep)
}
null -> {}
}
} else {
when (addonType) {

View file

@ -62,7 +62,9 @@ class ExtensionInstaller(private val context: Context) {
* step in the installation process.
*
* @param url The url of the apk.
* @param extension The extension to install.
* @param pkgName The package name of the extension.
* @param name The name of the extension.
* @param type The type of the extension.
*/
fun <T : Type> downloadAndInstall(
url: String,