소스 검색

Require Komga to be installed when attempting to setup tracker (closes #5491)

arkon 3 년 전
부모
커밋
a69a833716

+ 0 - 1
app/src/main/java/eu/kanade/tachiyomi/data/track/EnhancedTrackService.kt

@@ -1,7 +1,6 @@
 package eu.kanade.tachiyomi.data.track
 
 import eu.kanade.tachiyomi.data.database.models.Manga
-import eu.kanade.tachiyomi.data.track.komga.Komga
 import eu.kanade.tachiyomi.data.track.model.TrackSearch
 import eu.kanade.tachiyomi.source.Source
 

+ 0 - 1
app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt

@@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.data.track.EnhancedTrackService
 import eu.kanade.tachiyomi.data.track.NoLoginTrackService
 import eu.kanade.tachiyomi.data.track.TrackService
 import eu.kanade.tachiyomi.data.track.model.TrackSearch
-import eu.kanade.tachiyomi.source.Source
 import okhttp3.Dns
 import okhttp3.OkHttpClient
 

+ 12 - 3
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt

@@ -4,10 +4,10 @@ import android.app.Activity
 import android.view.Menu
 import android.view.MenuInflater
 import android.view.MenuItem
+import android.widget.Toast
 import androidx.preference.PreferenceGroup
 import androidx.preference.PreferenceScreen
 import eu.kanade.tachiyomi.R
-import eu.kanade.tachiyomi.data.track.EnhancedTrackService
 import eu.kanade.tachiyomi.data.track.NoLoginTrackService
 import eu.kanade.tachiyomi.data.track.TrackManager
 import eu.kanade.tachiyomi.data.track.TrackService
@@ -27,6 +27,7 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory
 import eu.kanade.tachiyomi.util.preference.switchPreference
 import eu.kanade.tachiyomi.util.preference.titleRes
 import eu.kanade.tachiyomi.util.system.openInBrowser
+import eu.kanade.tachiyomi.util.system.toast
 import eu.kanade.tachiyomi.widget.preference.LoginPreference
 import uy.kohesive.injekt.injectLazy
 import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
@@ -82,8 +83,16 @@ class SettingsTrackingController :
             }
 
             trackPreference(trackManager.komga) {
-                trackManager.komga.loginNoop()
-                updatePreference(trackManager.komga.id)
+                val acceptedSources = trackManager.komga.getAcceptedSources()
+                val hasValidSourceInstalled = sourceManager.getCatalogueSources()
+                    .any { it::class.qualifiedName in acceptedSources }
+
+                if (hasValidSourceInstalled) {
+                    trackManager.komga.loginNoop()
+                    updatePreference(trackManager.komga.id)
+                } else {
+                    context.toast(R.string.tracker_komga_warning, Toast.LENGTH_LONG)
+                }
             }
 
             infoPreference(R.string.enhanced_tracking_info)

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -586,6 +586,7 @@
     <string name="tracker_myanimelist" translatable="false">MyAnimeList</string>
     <string name="tracker_kitsu" translatable="false">Kitsu</string>
     <string name="tracker_komga" translatable="false">Komga</string>
+    <string name="tracker_komga_warning">This tracker is only compatible with the Komga source.</string>
     <string name="tracker_bangumi" translatable="false">Bangumi</string>
     <string name="tracker_shikimori" translatable="false">Shikimori</string>
     <string name="manga_tracking_tab">Tracking</string>