diff --git a/app/build.gradle b/app/build.gradle
index d8ecc81bb..90abd0c27 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -25,15 +25,6 @@ android {
arg 'room.schemaLocation', "$projectDir/schemas".toString()
}
}
-
- // define this values in your local.properties file
- buildConfigField 'String', 'SHIKIMORI_CLIENT_ID', "\"${localProperty('shikimori.clientId')}\""
- buildConfigField 'String', 'SHIKIMORI_CLIENT_SECRET', "\"${localProperty('shikimori.clientSecret')}\""
- buildConfigField 'String', 'ANILIST_CLIENT_ID', "\"${localProperty('anilist.clientId')}\""
- buildConfigField 'String', 'ANILIST_CLIENT_SECRET', "\"${localProperty('anilist.clientSecret')}\""
- buildConfigField 'String', 'MAL_CLIENT_ID', "\"${localProperty('mal.clientId')}\""
- resValue "string", "acra_login", "${localProperty('acra.login')}"
- resValue "string", "acra_password", "${localProperty('acra.password')}"
}
buildTypes {
debug {
diff --git a/app/src/main/java/org/koitharu/kotatsu/scrobbling/ScrobblingModule.kt b/app/src/main/java/org/koitharu/kotatsu/scrobbling/ScrobblingModule.kt
index 18d484565..f4300792b 100644
--- a/app/src/main/java/org/koitharu/kotatsu/scrobbling/ScrobblingModule.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/scrobbling/ScrobblingModule.kt
@@ -36,6 +36,7 @@ object ScrobblingModule {
@Provides
@Singleton
fun provideShikimoriRepository(
+ @ApplicationContext context: Context,
@ScrobblerType(ScrobblerService.SHIKIMORI) storage: ScrobblerStorage,
database: MangaDatabase,
authenticator: ShikimoriAuthenticator,
@@ -47,12 +48,13 @@ object ScrobblingModule {
addInterceptor(CurlLoggingInterceptor())
}
}.build()
- return ShikimoriRepository(okHttp, storage, database)
+ return ShikimoriRepository(context, okHttp, storage, database)
}
@Provides
@Singleton
fun provideMALRepository(
+ @ApplicationContext context: Context,
@ScrobblerType(ScrobblerService.MAL) storage: ScrobblerStorage,
database: MangaDatabase,
authenticator: MALAuthenticator,
@@ -64,12 +66,13 @@ object ScrobblingModule {
addInterceptor(CurlLoggingInterceptor())
}
}.build()
- return MALRepository(okHttp, storage, database)
+ return MALRepository(context, okHttp, storage, database)
}
@Provides
@Singleton
fun provideAniListRepository(
+ @ApplicationContext context: Context,
@ScrobblerType(ScrobblerService.ANILIST) storage: ScrobblerStorage,
database: MangaDatabase,
authenticator: AniListAuthenticator,
@@ -81,7 +84,7 @@ object ScrobblingModule {
addInterceptor(CurlLoggingInterceptor())
}
}.build()
- return AniListRepository(okHttp, storage, database)
+ return AniListRepository(context, okHttp, storage, database)
}
@Provides
diff --git a/app/src/main/java/org/koitharu/kotatsu/scrobbling/anilist/data/AniListRepository.kt b/app/src/main/java/org/koitharu/kotatsu/scrobbling/anilist/data/AniListRepository.kt
index 571a8bef0..97d93c7b1 100644
--- a/app/src/main/java/org/koitharu/kotatsu/scrobbling/anilist/data/AniListRepository.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/scrobbling/anilist/data/AniListRepository.kt
@@ -1,12 +1,14 @@
package org.koitharu.kotatsu.scrobbling.anilist.data
+import android.content.Context
+import dagger.hilt.android.qualifiers.ApplicationContext
import okhttp3.FormBody
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject
-import org.koitharu.kotatsu.BuildConfig
+import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.db.MangaDatabase
import org.koitharu.kotatsu.parsers.exception.GraphQLException
import org.koitharu.kotatsu.parsers.model.MangaChapter
@@ -15,6 +17,7 @@ import org.koitharu.kotatsu.parsers.util.json.getStringOrNull
import org.koitharu.kotatsu.parsers.util.json.mapJSON
import org.koitharu.kotatsu.parsers.util.parseJson
import org.koitharu.kotatsu.parsers.util.toIntUp
+import org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository
import org.koitharu.kotatsu.scrobbling.common.data.ScrobblerStorage
import org.koitharu.kotatsu.scrobbling.common.data.ScrobblingEntity
import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerManga
@@ -32,13 +35,17 @@ private const val REQUEST_MUTATION = "mutation"
private const val KEY_SCORE_FORMAT = "score_format"
class AniListRepository(
+ @ApplicationContext context: Context,
private val okHttp: OkHttpClient,
private val storage: ScrobblerStorage,
private val db: MangaDatabase,
-) : org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository {
+) : ScrobblerRepository {
+
+ private val clientId = context.getString(R.string.anilist_clientId)
+ private val clientSecret = context.getString(R.string.anilist_clientSecret)
override val oauthUrl: String
- get() = "${BASE_URL}oauth/authorize?client_id=${BuildConfig.ANILIST_CLIENT_ID}&" +
+ get() = "${BASE_URL}oauth/authorize?client_id=$clientId&" +
"redirect_uri=${REDIRECT_URI}&response_type=code"
override val isAuthorized: Boolean
@@ -48,8 +55,8 @@ class AniListRepository(
override suspend fun authorize(code: String?) {
val body = FormBody.Builder()
- body.add("client_id", BuildConfig.ANILIST_CLIENT_ID)
- body.add("client_secret", BuildConfig.ANILIST_CLIENT_SECRET)
+ body.add("client_id", clientId)
+ body.add("client_secret", clientSecret)
if (code != null) {
body.add("grant_type", "authorization_code")
body.add("redirect_uri", REDIRECT_URI)
diff --git a/app/src/main/java/org/koitharu/kotatsu/scrobbling/mal/data/MALRepository.kt b/app/src/main/java/org/koitharu/kotatsu/scrobbling/mal/data/MALRepository.kt
index b4f026298..1a5b78080 100644
--- a/app/src/main/java/org/koitharu/kotatsu/scrobbling/mal/data/MALRepository.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/scrobbling/mal/data/MALRepository.kt
@@ -1,16 +1,19 @@
package org.koitharu.kotatsu.scrobbling.mal.data
+import android.content.Context
+import dagger.hilt.android.qualifiers.ApplicationContext
import okhttp3.FormBody
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import org.json.JSONObject
-import org.koitharu.kotatsu.BuildConfig
+import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.db.MangaDatabase
import org.koitharu.kotatsu.parsers.model.MangaChapter
import org.koitharu.kotatsu.parsers.util.await
import org.koitharu.kotatsu.parsers.util.json.mapJSONNotNull
import org.koitharu.kotatsu.parsers.util.parseJson
+import org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository
import org.koitharu.kotatsu.scrobbling.common.data.ScrobblerStorage
import org.koitharu.kotatsu.scrobbling.common.data.ScrobblingEntity
import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblerManga
@@ -25,17 +28,19 @@ private const val BASE_API_URL = "https://api.myanimelist.net/v2"
private const val AVATAR_STUB = "https://cdn.myanimelist.net/images/questionmark_50.gif"
class MALRepository(
+ @ApplicationContext context: Context,
private val okHttp: OkHttpClient,
private val storage: ScrobblerStorage,
private val db: MangaDatabase,
-) : org.koitharu.kotatsu.scrobbling.common.data.ScrobblerRepository {
+) : ScrobblerRepository {
+ private val clientId = context.getString(R.string.mal_clientId)
private var codeVerifier: String = getPKCEChallengeCode()
override val oauthUrl: String
get() = "$BASE_WEB_URL/v1/oauth2/authorize?" +
"response_type=code" +
- "&client_id=${BuildConfig.MAL_CLIENT_ID}" +
+ "&client_id=$clientId" +
"&redirect_uri=$REDIRECT_URI" +
"&code_challenge=$codeVerifier" +
"&code_challenge_method=plain"
@@ -51,7 +56,7 @@ class MALRepository(
override suspend fun authorize(code: String?) {
val body = FormBody.Builder()
if (code != null) {
- body.add("client_id", BuildConfig.MAL_CLIENT_ID)
+ body.add("client_id", clientId)
body.add("grant_type", "authorization_code")
body.add("code", code)
body.add("redirect_uri", REDIRECT_URI)
@@ -205,5 +210,4 @@ class MALRepository(
avatar = json.getString("picture") ?: AVATAR_STUB,
service = ScrobblerService.MAL,
)
-
}
diff --git a/app/src/main/java/org/koitharu/kotatsu/scrobbling/shikimori/data/ShikimoriRepository.kt b/app/src/main/java/org/koitharu/kotatsu/scrobbling/shikimori/data/ShikimoriRepository.kt
index ecee1125a..fb843b20e 100644
--- a/app/src/main/java/org/koitharu/kotatsu/scrobbling/shikimori/data/ShikimoriRepository.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/scrobbling/shikimori/data/ShikimoriRepository.kt
@@ -1,11 +1,13 @@
package org.koitharu.kotatsu.scrobbling.shikimori.data
+import android.content.Context
+import dagger.hilt.android.qualifiers.ApplicationContext
import okhttp3.FormBody
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import org.json.JSONObject
-import org.koitharu.kotatsu.BuildConfig
+import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.db.MangaDatabase
import org.koitharu.kotatsu.parsers.model.MangaChapter
import org.koitharu.kotatsu.parsers.util.await
@@ -28,13 +30,17 @@ private const val BASE_URL = "https://shikimori.one/"
private const val MANGA_PAGE_SIZE = 10
class ShikimoriRepository(
+ @ApplicationContext context: Context,
private val okHttp: OkHttpClient,
private val storage: ScrobblerStorage,
private val db: MangaDatabase,
) : ScrobblerRepository {
+ private val clientId = context.getString(R.string.shikimori_clientId)
+ private val clientSecret = context.getString(R.string.shikimori_clientSecret)
+
override val oauthUrl: String
- get() = "${BASE_URL}oauth/authorize?client_id=${BuildConfig.SHIKIMORI_CLIENT_ID}&" +
+ get() = "${BASE_URL}oauth/authorize?client_id=$clientId&" +
"redirect_uri=$REDIRECT_URI&response_type=code&scope="
override val isAuthorized: Boolean
@@ -42,8 +48,8 @@ class ShikimoriRepository(
override suspend fun authorize(code: String?) {
val body = FormBody.Builder()
- body.add("client_id", BuildConfig.SHIKIMORI_CLIENT_ID)
- body.add("client_secret", BuildConfig.SHIKIMORI_CLIENT_SECRET)
+ body.add("client_id", clientId)
+ body.add("client_secret", clientSecret)
if (code != null) {
body.add("grant_type", "authorization_code")
body.add("redirect_uri", REDIRECT_URI)
@@ -98,13 +104,13 @@ class ShikimoriRepository(
return if (pageOffset != 0) list.drop(pageOffset) else list
}
- override suspend fun createRate(mangaId: Long, shikiMangaId: Long) {
+ override suspend fun createRate(mangaId: Long, scrobblerMangaId: Long) {
val user = cachedUser ?: loadUser()
val payload = JSONObject()
payload.put(
"user_rate",
JSONObject().apply {
- put("target_id", shikiMangaId)
+ put("target_id", scrobblerMangaId)
put("target_type", "Manga")
put("user_id", user.id)
},
diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml
index a7f1cd3ff..b81ad52cc 100644
--- a/app/src/main/res/values/constants.xml
+++ b/app/src/main/res/values/constants.xml
@@ -9,6 +9,13 @@
https://acra.rumblur.space/report
org.kotatsu.sync
http://86.57.183.214:8081
+ Mw6F0tPEOgyV7F9U9Twg50Q8SndMY7hzIOfXg0AX_XU
+ euBMt1GGRSDpVIFQVPxZrO7Kh6X4gWyv0dABuj4B-M8
+ 9887
+ wrMqFosItQWsmB8dtAHfIFPDt15FfQi2ZGiKkJoW
+ 6cd8e6349e9a36bc1fc1ab97703c9fd1
+ SxhkCVnqVLbGogvi
+ xPDACTLHnHU9Nfjv
- -1
- 1
diff --git a/build.gradle b/build.gradle
index db65af4c4..e5b0395d7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -20,15 +20,6 @@ allprojects {
}
}
-String localProperty(String name, String defaultValue = 'null') {
- Properties localProperties = new Properties()
- project.rootProject.file('local.properties').withInputStream { localProperties.load(it) }
-
- def value = localProperties[name]
-
- return value != null ? value : defaultValue
-}
-
String currentBranch() {
def branchName = ""
try {