Open Kitsu auth activity

feature/kitsu
Koitharu 3 years ago
parent 7a2ad47405
commit 56de725cf1
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -158,13 +158,21 @@
<data android:host="shikimori-auth" /> <data android:host="shikimori-auth" />
<data android:host="anilist-auth" /> <data android:host="anilist-auth" />
<data android:host="mal-auth" /> <data android:host="mal-auth" />
<data android:host="kitsu-auth" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".scrobbling.kitsu.ui.KitsuAuthActivity" android:name=".scrobbling.kitsu.ui.KitsuAuthActivity"
android:exported="false" android:exported="false"
android:label="@string/kitsu" /> android:label="@string/kitsu"
tools:ignore="AppLinkUrlError">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="kotatsu+kitsu" />
</intent-filter>
</activity>
<service <service
android:name="org.koitharu.kotatsu.download.ui.service.DownloadService" android:name="org.koitharu.kotatsu.download.ui.service.DownloadService"

@ -29,7 +29,7 @@ class KitsuRepository(
private val clientId = context.getString(R.string.kitsu_clientId) private val clientId = context.getString(R.string.kitsu_clientId)
private val clientSecret = context.getString(R.string.kitsu_clientSecret) private val clientSecret = context.getString(R.string.kitsu_clientSecret)
override val oauthUrl: String = "" override val oauthUrl: String = "kotatsu+kitsu://auth"
override val isAuthorized: Boolean override val isAuthorized: Boolean
get() = storage.accessToken != null get() = storage.accessToken != null

@ -15,10 +15,10 @@ import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.base.ui.BasePreferenceFragment import org.koitharu.kotatsu.base.ui.BasePreferenceFragment
import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.core.prefs.AppSettings
import org.koitharu.kotatsu.scrobbling.anilist.data.AniListRepository import org.koitharu.kotatsu.scrobbling.anilist.data.AniListRepository
import org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository
import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerService import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerService
import org.koitharu.kotatsu.scrobbling.common.ui.config.ScrobblerConfigActivity import org.koitharu.kotatsu.scrobbling.common.ui.config.ScrobblerConfigActivity
import org.koitharu.kotatsu.scrobbling.kitsu.data.KitsuRepository import org.koitharu.kotatsu.scrobbling.kitsu.data.KitsuRepository
import org.koitharu.kotatsu.scrobbling.kitsu.ui.KitsuAuthActivity
import org.koitharu.kotatsu.scrobbling.mal.data.MALRepository import org.koitharu.kotatsu.scrobbling.mal.data.MALRepository
import org.koitharu.kotatsu.scrobbling.shikimori.data.ShikimoriRepository import org.koitharu.kotatsu.scrobbling.shikimori.data.ShikimoriRepository
import org.koitharu.kotatsu.sync.domain.SyncController import org.koitharu.kotatsu.sync.domain.SyncController
@ -119,7 +119,7 @@ class ServicesSettingsFragment : BasePreferenceFragment(R.string.services) {
private fun bindScrobblerSummary( private fun bindScrobblerSummary(
key: String, key: String,
repository: org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository repository: ScrobblerRepository
) { ) {
val pref = findPreference<Preference>(key) ?: return val pref = findPreference<Preference>(key) ?: return
if (!repository.isAuthorized) { if (!repository.isAuthorized) {
@ -145,11 +145,8 @@ class ServicesSettingsFragment : BasePreferenceFragment(R.string.services) {
} }
} }
private fun launchScrobblerAuth(repository: org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository) { private fun launchScrobblerAuth(repository: ScrobblerRepository) {
runCatching { runCatching {
if (repository.oauthUrl.isBlank()) {
startActivity(KitsuAuthActivity.newIntent(requireContext()))
}
val intent = Intent(Intent.ACTION_VIEW) val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(repository.oauthUrl) intent.data = Uri.parse(repository.oauthUrl)
startActivity(intent) startActivity(intent)

Loading…
Cancel
Save