mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-14 06:22:49 +01:00
Combine tracking OAuth login activities
This commit is contained in:
parent
10b0ef9b6d
commit
9dc66c7c8d
@ -124,8 +124,8 @@
|
|||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.setting.track.AnilistLoginActivity"
|
android:name=".ui.setting.track.TrackLoginActivity"
|
||||||
android:label="Anilist"
|
android:label="@string/track_activity_name"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
@ -133,54 +133,12 @@
|
|||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data
|
<data android:host="anilist-auth"/>
|
||||||
android:host="anilist-auth"
|
<data android:host="bangumi-auth"/>
|
||||||
android:scheme="tachiyomi" />
|
<data android:host="myanimelist-auth"/>
|
||||||
</intent-filter>
|
<data android:host="shikimori-auth"/>
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name=".ui.setting.track.MyAnimeListLoginActivity"
|
|
||||||
android:label="MyAnimeList"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<data android:scheme="tachiyomi"/>
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
|
|
||||||
<data
|
|
||||||
android:host="myanimelist-auth"
|
|
||||||
android:scheme="tachiyomi" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name=".ui.setting.track.ShikimoriLoginActivity"
|
|
||||||
android:label="Shikimori"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
|
|
||||||
<data
|
|
||||||
android:host="shikimori-auth"
|
|
||||||
android:scheme="tachiyomi" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name=".ui.setting.track.BangumiLoginActivity"
|
|
||||||
android:label="Bangumi"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
|
|
||||||
<data
|
|
||||||
android:host="bangumi-auth"
|
|
||||||
android:scheme="tachiyomi" />
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
@ -210,7 +168,8 @@
|
|||||||
android:name=".data.updater.AppUpdateService"
|
android:name=".data.updater.AppUpdateService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<service android:name=".extension.util.ExtensionInstallService"
|
<service
|
||||||
|
android:name=".extension.util.ExtensionInstallService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.setting.track
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import tachiyomi.core.util.lang.launchIO
|
|
||||||
|
|
||||||
class AnilistLoginActivity : BaseOAuthLoginActivity() {
|
|
||||||
|
|
||||||
override fun handleResult(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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.setting.track
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import tachiyomi.core.util.lang.launchIO
|
|
||||||
|
|
||||||
class BangumiLoginActivity : BaseOAuthLoginActivity() {
|
|
||||||
|
|
||||||
override fun handleResult(data: Uri?) {
|
|
||||||
val code = data?.getQueryParameter("code")
|
|
||||||
if (code != null) {
|
|
||||||
lifecycleScope.launchIO {
|
|
||||||
trackManager.bangumi.login(code)
|
|
||||||
returnToSettings()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
trackManager.bangumi.logout()
|
|
||||||
returnToSettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.setting.track
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import tachiyomi.core.util.lang.launchIO
|
|
||||||
|
|
||||||
class MyAnimeListLoginActivity : BaseOAuthLoginActivity() {
|
|
||||||
|
|
||||||
override fun handleResult(data: Uri?) {
|
|
||||||
val code = data?.getQueryParameter("code")
|
|
||||||
if (code != null) {
|
|
||||||
lifecycleScope.launchIO {
|
|
||||||
trackManager.myAnimeList.login(code)
|
|
||||||
returnToSettings()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
trackManager.myAnimeList.logout()
|
|
||||||
returnToSettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.setting.track
|
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import tachiyomi.core.util.lang.launchIO
|
|
||||||
|
|
||||||
class ShikimoriLoginActivity : BaseOAuthLoginActivity() {
|
|
||||||
|
|
||||||
override fun handleResult(data: Uri?) {
|
|
||||||
val code = data?.getQueryParameter("code")
|
|
||||||
if (code != null) {
|
|
||||||
lifecycleScope.launchIO {
|
|
||||||
trackManager.shikimori.login(code)
|
|
||||||
returnToSettings()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
trackManager.shikimori.logout()
|
|
||||||
returnToSettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,70 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.setting.track
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import tachiyomi.core.util.lang.launchIO
|
||||||
|
|
||||||
|
class TrackLoginActivity : BaseOAuthLoginActivity() {
|
||||||
|
|
||||||
|
override fun handleResult(data: Uri?) {
|
||||||
|
when (data?.host) {
|
||||||
|
"anilist-auth" -> 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -462,6 +462,7 @@
|
|||||||
<string name="enhanced_services_not_installed">Available but source not installed: %s</string>
|
<string name="enhanced_services_not_installed">Available but source not installed: %s</string>
|
||||||
<string name="enhanced_tracking_info">Services that provide enhanced features for specific sources. Entries are automatically tracked when added to your library.</string>
|
<string name="enhanced_tracking_info">Services that provide enhanced features for specific sources. Entries are automatically tracked when added to your library.</string>
|
||||||
<string name="action_track">Track</string>
|
<string name="action_track">Track</string>
|
||||||
|
<string name="track_activity_name">Tracking login</string>
|
||||||
|
|
||||||
<!-- Browse section -->
|
<!-- Browse section -->
|
||||||
<string name="pref_hide_in_library_items">Hide entries already in library</string>
|
<string name="pref_hide_in_library_items">Hide entries already in library</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user