Skip to content

Commit

Permalink
Naming convention: Property names
Browse files Browse the repository at this point in the history
  • Loading branch information
Caio99BR committed Jul 2, 2024
1 parent b97758e commit 0bd6a93
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import tachiyomi.presentation.core.i18n.stringResource
class BackupSchemaScreen : Screen() {

companion object {
const val title = "Backup file schema"
const val TITLE = "Backup file schema"
}

@Composable
Expand All @@ -41,7 +41,7 @@ class BackupSchemaScreen : Screen() {
Scaffold(
topBar = {
AppBar(
title = title,
title = TITLE,
navigateUp = navigator::pop,
actions = {
AppBarActions(
Expand All @@ -50,7 +50,7 @@ class BackupSchemaScreen : Screen() {
title = stringResource(MR.strings.action_copy_to_clipboard),
icon = Icons.Default.ContentCopy,
onClick = {
context.copyToClipboard(title, schema)
context.copyToClipboard(TITLE, schema)
},
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class DebugInfoScreen : Screen() {
itemsProvider = {
listOf(
Preference.PreferenceItem.TextPreference(
title = WorkerInfoScreen.title,
title = WorkerInfoScreen.TITLE,
onClick = { navigator.push(WorkerInfoScreen()) },
),
Preference.PreferenceItem.TextPreference(
title = BackupSchemaScreen.title,
title = BackupSchemaScreen.TITLE,
onClick = { navigator.push(BackupSchemaScreen()) },
),
getAppInfoGroup(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import java.time.ZoneId
class WorkerInfoScreen : Screen() {

companion object {
const val title = "Worker info"
const val TITLE = "Worker info"
}

@Composable
Expand All @@ -65,7 +65,7 @@ class WorkerInfoScreen : Screen() {
Scaffold(
topBar = {
AppBar(
title = title,
title = TITLE,
navigateUp = navigator::pop,
actions = {
AppBarActions(
Expand All @@ -74,7 +74,7 @@ class WorkerInfoScreen : Screen() {
title = stringResource(MR.strings.action_copy_to_clipboard),
icon = Icons.Default.ContentCopy,
onClick = {
context.copyToClipboard(title, enqueued + finished + running)
context.copyToClipboard(TITLE, enqueued + finished + running)
},
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
with(json) {
authClient.newCall(
POST(
apiUrl,
API_URL,
body = payload.toString().toRequestBody(jsonMime),
),
)
Expand Down Expand Up @@ -109,7 +109,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
put("completedAt", createDate(track.finished_reading_date))
}
}
authClient.newCall(POST(apiUrl, body = payload.toString().toRequestBody(jsonMime)))
authClient.newCall(POST(API_URL, body = payload.toString().toRequestBody(jsonMime)))
.awaitSuccess()
track
}
Expand All @@ -131,7 +131,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
put("listId", track.libraryId)
}
}
authClient.newCall(POST(apiUrl, body = payload.toString().toRequestBody(jsonMime)))
authClient.newCall(POST(API_URL, body = payload.toString().toRequestBody(jsonMime)))
.awaitSuccess()
}
}
Expand Down Expand Up @@ -172,7 +172,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
with(json) {
authClient.newCall(
POST(
apiUrl,
API_URL,
body = payload.toString().toRequestBody(jsonMime),
),
)
Expand Down Expand Up @@ -242,7 +242,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
with(json) {
authClient.newCall(
POST(
apiUrl,
API_URL,
body = payload.toString().toRequestBody(jsonMime),
),
)
Expand Down Expand Up @@ -286,7 +286,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
with(json) {
authClient.newCall(
POST(
apiUrl,
API_URL,
body = payload.toString().toRequestBody(jsonMime),
),
)
Expand Down Expand Up @@ -364,17 +364,17 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
}

companion object {
private const val clientId = "16329"
private const val apiUrl = "https://graphql.anilist.co/"
private const val baseUrl = "https://anilist.co/api/v2/"
private const val baseMangaUrl = "https://anilist.co/manga/"
private const val CLIENT_ID = "16329"
private const val API_URL = "https://graphql.anilist.co/"
private const val BASE_URL = "https://anilist.co/api/v2/"
private const val BASE_MANGA_URL = "https://anilist.co/manga/"

fun mangaUrl(mediaId: Long): String {
return baseMangaUrl + mediaId
return BASE_MANGA_URL + mediaId
}

fun authUrl(): Uri = "${baseUrl}oauth/authorize".toUri().buildUpon()
.appendQueryParameter("client_id", clientId)
fun authUrl(): Uri = "${BASE_URL}oauth/authorize".toUri().buildUpon()
.appendQueryParameter("client_id", CLIENT_ID)
.appendQueryParameter("response_type", "token")
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class BangumiApi(
.add("rating", track.score.toInt().toString())
.add("status", track.toBangumiStatus())
.build()
authClient.newCall(POST("$apiUrl/collection/${track.remote_id}/update", body = body))
authClient.newCall(POST("$API_URL/collection/${track.remote_id}/update", body = body))
.awaitSuccess()
track
}
Expand All @@ -55,7 +55,7 @@ class BangumiApi(
.add("rating", track.score.toInt().toString())
.add("status", track.toBangumiStatus())
.build()
authClient.newCall(POST("$apiUrl/collection/${track.remote_id}/update", body = sbody))
authClient.newCall(POST("$API_URL/collection/${track.remote_id}/update", body = sbody))
.awaitSuccess()

// chapter update
Expand All @@ -64,7 +64,7 @@ class BangumiApi(
.build()
authClient.newCall(
POST(
"$apiUrl/subject/${track.remote_id}/update/watched_eps",
"$API_URL/subject/${track.remote_id}/update/watched_eps",
body = body,
),
).awaitSuccess()
Expand All @@ -75,7 +75,7 @@ class BangumiApi(

suspend fun search(search: String): List<TrackSearch> {
return withIOContext {
val url = "$apiUrl/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}"
val url = "$API_URL/search/subject/${URLEncoder.encode(search, StandardCharsets.UTF_8.name())}"
.toUri()
.buildUpon()
.appendQueryParameter("max_results", "20")
Expand Down Expand Up @@ -124,7 +124,7 @@ class BangumiApi(
suspend fun findLibManga(track: Track): Track? {
return withIOContext {
with(json) {
authClient.newCall(GET("$apiUrl/subject/${track.remote_id}"))
authClient.newCall(GET("$API_URL/subject/${track.remote_id}"))
.awaitSuccess()
.parseAs<JsonObject>()
.let { jsonToSearch(it) }
Expand All @@ -134,7 +134,7 @@ class BangumiApi(

suspend fun statusLibManga(track: Track): Track? {
return withIOContext {
val urlUserRead = "$apiUrl/collection/${track.remote_id}"
val urlUserRead = "$API_URL/collection/${track.remote_id}"
val requestUserRead = Request.Builder()
.url(urlUserRead)
.cacheControl(CacheControl.FORCE_NETWORK)
Expand Down Expand Up @@ -171,41 +171,41 @@ class BangumiApi(
}

private fun accessTokenRequest(code: String) = POST(
oauthUrl,
OAUTH_URL,
body = FormBody.Builder()
.add("grant_type", "authorization_code")
.add("client_id", clientId)
.add("client_secret", clientSecret)
.add("client_id", CLIENT_ID)
.add("client_secret", CLIENT_SECRET)
.add("code", code)
.add("redirect_uri", redirectUrl)
.add("redirect_uri", REDIRECT_URL)
.build(),
)

companion object {
private const val clientId = "bgm291665acbd06a4c28"
private const val clientSecret = "43e5ce36b207de16e5d3cfd3e79118db"
private const val CLIENT_ID = "bgm291665acbd06a4c28"
private const val CLIENT_SECRET = "43e5ce36b207de16e5d3cfd3e79118db"

private const val apiUrl = "https://api.bgm.tv"
private const val oauthUrl = "https://bgm.tv/oauth/access_token"
private const val loginUrl = "https://bgm.tv/oauth/authorize"
private const val API_URL = "https://api.bgm.tv"
private const val OAUTH_URL = "https://bgm.tv/oauth/access_token"
private const val LOGIN_URL = "https://bgm.tv/oauth/authorize"

private const val redirectUrl = "mihon://bangumi-auth"
private const val REDIRECT_URL = "mihon://bangumi-auth"

fun authUrl(): Uri =
loginUrl.toUri().buildUpon()
.appendQueryParameter("client_id", clientId)
LOGIN_URL.toUri().buildUpon()
.appendQueryParameter("client_id", CLIENT_ID)
.appendQueryParameter("response_type", "code")
.appendQueryParameter("redirect_uri", redirectUrl)
.appendQueryParameter("redirect_uri", REDIRECT_URL)
.build()

fun refreshTokenRequest(token: String) = POST(
oauthUrl,
OAUTH_URL,
body = FormBody.Builder()
.add("grant_type", "refresh_token")
.add("client_id", clientId)
.add("client_secret", clientSecret)
.add("client_id", CLIENT_ID)
.add("client_secret", CLIENT_SECRET)
.add("refresh_token", token)
.add("redirect_uri", redirectUrl)
.add("redirect_uri", REDIRECT_URL)
.build(),
)
}
Expand Down
Loading

0 comments on commit 0bd6a93

Please sign in to comment.