feat: update AndroidManifest for auth support, modify auth-related classes, and add Hikka to tracker list

This commit is contained in:
Lorg0n 2024-10-17 17:55:18 +03:00
parent f6d8d415cc
commit 06f01de4b5
4 changed files with 25 additions and 1 deletions

View file

@ -180,6 +180,7 @@
<data android:host="bangumi-auth" /> <data android:host="bangumi-auth" />
<data android:host="myanimelist-auth" /> <data android:host="myanimelist-auth" />
<data android:host="shikimori-auth" /> <data android:host="shikimori-auth" />
<data android:host="hikka-auth" />
</intent-filter> </intent-filter>
</activity> </activity>

View file

@ -47,6 +47,7 @@ import eu.kanade.tachiyomi.data.track.Tracker
import eu.kanade.tachiyomi.data.track.TrackerManager import eu.kanade.tachiyomi.data.track.TrackerManager
import eu.kanade.tachiyomi.data.track.anilist.AnilistApi import eu.kanade.tachiyomi.data.track.anilist.AnilistApi
import eu.kanade.tachiyomi.data.track.bangumi.BangumiApi import eu.kanade.tachiyomi.data.track.bangumi.BangumiApi
import eu.kanade.tachiyomi.data.track.hikka.HikkaApi
import eu.kanade.tachiyomi.data.track.myanimelist.MyAnimeListApi import eu.kanade.tachiyomi.data.track.myanimelist.MyAnimeListApi
import eu.kanade.tachiyomi.data.track.shikimori.ShikimoriApi import eu.kanade.tachiyomi.data.track.shikimori.ShikimoriApi
import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.openInBrowser
@ -164,6 +165,12 @@ object SettingsTrackingScreen : SearchableSettings {
login = { context.openInBrowser(BangumiApi.authUrl(), forceDefaultBrowser = true) }, login = { context.openInBrowser(BangumiApi.authUrl(), forceDefaultBrowser = true) },
logout = { dialog = LogoutDialog(trackerManager.bangumi) }, logout = { dialog = LogoutDialog(trackerManager.bangumi) },
), ),
Preference.PreferenceItem.TrackerPreference(
title = trackerManager.hikka.name,
tracker = trackerManager.hikka,
login = { context.openInBrowser(HikkaApi.authUrl(), forceDefaultBrowser = true) },
logout = { dialog = LogoutDialog(trackerManager.hikka) },
),
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.tracking_info)), Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.tracking_info)),
), ),
), ),

View file

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.data.track
import eu.kanade.tachiyomi.data.track.anilist.Anilist import eu.kanade.tachiyomi.data.track.anilist.Anilist
import eu.kanade.tachiyomi.data.track.bangumi.Bangumi import eu.kanade.tachiyomi.data.track.bangumi.Bangumi
import eu.kanade.tachiyomi.data.track.hikka.Hikka
import eu.kanade.tachiyomi.data.track.kavita.Kavita import eu.kanade.tachiyomi.data.track.kavita.Kavita
import eu.kanade.tachiyomi.data.track.kitsu.Kitsu import eu.kanade.tachiyomi.data.track.kitsu.Kitsu
import eu.kanade.tachiyomi.data.track.komga.Komga import eu.kanade.tachiyomi.data.track.komga.Komga
@ -28,8 +29,9 @@ class TrackerManager {
val mangaUpdates = MangaUpdates(7L) val mangaUpdates = MangaUpdates(7L)
val kavita = Kavita(KAVITA) val kavita = Kavita(KAVITA)
val suwayomi = Suwayomi(9L) val suwayomi = Suwayomi(9L)
val hikka = Hikka(10L)
val trackers = listOf(myAnimeList, aniList, kitsu, shikimori, bangumi, komga, mangaUpdates, kavita, suwayomi) val trackers = listOf(myAnimeList, aniList, kitsu, shikimori, bangumi, komga, mangaUpdates, kavita, suwayomi, hikka)
fun loggedInTrackers() = trackers.filter { it.isLoggedIn } fun loggedInTrackers() = trackers.filter { it.isLoggedIn }

View file

@ -12,6 +12,7 @@ class TrackLoginActivity : BaseOAuthLoginActivity() {
"bangumi-auth" -> handleBangumi(data) "bangumi-auth" -> handleBangumi(data)
"myanimelist-auth" -> handleMyAnimeList(data) "myanimelist-auth" -> handleMyAnimeList(data)
"shikimori-auth" -> handleShikimori(data) "shikimori-auth" -> handleShikimori(data)
"hikka-auth" -> handleHikka(data)
} }
} }
@ -67,4 +68,17 @@ class TrackLoginActivity : BaseOAuthLoginActivity() {
returnToSettings() returnToSettings()
} }
} }
private fun handleHikka(data: Uri) {
val code = data.getQueryParameter("code")
if (code != null) {
lifecycleScope.launchIO {
trackerManager.hikka.login(code)
returnToSettings()
}
} else {
trackerManager.hikka.logout()
returnToSettings()
}
}
} }