diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5eefefd44..3e3eca0b8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -124,8 +124,8 @@ android:exported="false" /> @@ -133,54 +133,12 @@ - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - + @@ -210,7 +168,8 @@ android:name=".data.updater.AppUpdateService" android:exported="false" /> - handleAnilist(data) + "bangumi-auth" -> handleBangumi(data) + "myanimelist-auth" -> handleMyAnimeList(data) + "shikimori-auth" -> handleShikimori(data) + } + } + + private fun handleAnilist(data: Uri) { + val regex = "(?:access_token=)(.*?)(?:&)".toRegex() + val matchResult = regex.find(data.fragment.toString()) + if (matchResult?.groups?.get(1) != null) { + lifecycleScope.launchIO { + trackManager.aniList.login(matchResult.groups[1]!!.value) + returnToSettings() + } + } else { + trackManager.aniList.logout() + returnToSettings() + } + } + + private fun handleBangumi(data: Uri) { + val code = data.getQueryParameter("code") + if (code != null) { + lifecycleScope.launchIO { + trackManager.bangumi.login(code) + returnToSettings() + } + } else { + trackManager.bangumi.logout() + returnToSettings() + } + } + + private fun handleMyAnimeList(data: Uri) { + val code = data.getQueryParameter("code") + if (code != null) { + lifecycleScope.launchIO { + trackManager.myAnimeList.login(code) + returnToSettings() + } + } else { + trackManager.myAnimeList.logout() + returnToSettings() + } + } + + private fun handleShikimori(data: Uri) { + val code = data.getQueryParameter("code") + if (code != null) { + lifecycleScope.launchIO { + trackManager.shikimori.login(code) + returnToSettings() + } + } else { + trackManager.shikimori.logout() + returnToSettings() + } + } +} diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 596de0f94..4ae199538 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -462,6 +462,7 @@ Available but source not installed: %s Services that provide enhanced features for specific sources. Entries are automatically tracked when added to your library. Track + Tracking login Hide entries already in library