Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Commit

Permalink
Merge pull request #119 from AnyGogin31/feature/app-update-check
Browse files Browse the repository at this point in the history
feat(app): integrate GitHub release update checker for app
  • Loading branch information
AnyGogin31 authored Jan 1, 2025
2 parents 14a73b6 + 8f2adbf commit 7a3267d
Show file tree
Hide file tree
Showing 18 changed files with 455 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ import kotlinx.serialization.json.Json
import neilt.mobile.pixiv.data.remote.common.addAuthorizationInterceptor
import neilt.mobile.pixiv.data.remote.services.auth.AuthService
import neilt.mobile.pixiv.data.remote.services.details.illustration.IllustrationService
import neilt.mobile.pixiv.data.remote.services.github.GitHubService
import neilt.mobile.pixiv.data.remote.services.home.HomeService
import neilt.mobile.pixiv.data.remote.services.profile.ProfileService
import neilt.mobile.pixiv.data.remote.services.search.SearchService
import neilt.mobile.pixiv.data.repositories.auth.ActiveUserTokenProvider
import neilt.mobile.pixiv.data.sources.auth.AuthRemoteDataSource
import neilt.mobile.pixiv.data.sources.github.GitHubRemoteDataSource
import neilt.mobile.pixiv.data.sources.home.HomeRemoteDataSource
import neilt.mobile.pixiv.data.sources.illustration.IllustrationRemoteDataSource
import neilt.mobile.pixiv.data.sources.profile.ProfileRemoteDataSource
Expand Down Expand Up @@ -89,7 +91,7 @@ private fun provideHttpClient(
internal val remoteModule = module {

singleOf(::AuthRemoteDataSource)
singleOf(::HomeRemoteDataSource)
singleOf(::GitHubRemoteDataSource)
singleOf(::HomeRemoteDataSource)
singleOf(::IllustrationRemoteDataSource)
singleOf(::ProfileRemoteDataSource)
Expand All @@ -106,6 +108,7 @@ internal val remoteModule = module {
}

single { AuthService(get<HttpClient>(named("OAuthApi"))) }
singleOf(::GitHubService)
single { HomeService(get<HttpClient>(named("PixivApi"))) }
single { SearchService(get<HttpClient>(named("PixivApi"))) }
single { ProfileService(get<HttpClient>(named("PixivApi"))) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
package neilt.mobile.pixiv.data.di

import neilt.mobile.pixiv.data.repositories.auth.AuthRepositoryImpl
import neilt.mobile.pixiv.data.repositories.github.GitHubRepositoryImpl
import neilt.mobile.pixiv.data.repositories.home.HomeRepositoryImpl
import neilt.mobile.pixiv.data.repositories.illustration.IllustrationRepositoryImpl
import neilt.mobile.pixiv.data.repositories.profile.ProfileRepositoryImpl
import neilt.mobile.pixiv.data.repositories.search.SearchRepositoryImpl
import neilt.mobile.pixiv.domain.repositories.auth.AuthRepository
import neilt.mobile.pixiv.domain.repositories.details.illustration.IllustrationRepository
import neilt.mobile.pixiv.domain.repositories.github.GitHubRepository
import neilt.mobile.pixiv.domain.repositories.home.HomeRepository
import neilt.mobile.pixiv.domain.repositories.profile.ProfileRepository
import neilt.mobile.pixiv.domain.repositories.search.SearchRepository
Expand All @@ -43,6 +45,7 @@ val repositoryModule = module {
includes(localModule, remoteModule)

singleOf(::AuthRepositoryImpl) bind AuthRepository::class
singleOf(::GitHubRepositoryImpl) bind GitHubRepository::class
singleOf(::HomeRepositoryImpl) bind HomeRepository::class
singleOf(::SearchRepositoryImpl) bind SearchRepository::class
singleOf(::ProfileRepositoryImpl) bind ProfileRepository::class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* MIT License
*
* Copyright (c) 2024 AnyGogin31
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package neilt.mobile.pixiv.data.mapper.github

import neilt.mobile.pixiv.data.remote.responses.github.GitHubReleaseResponse
import neilt.mobile.pixiv.domain.models.github.GitHubRelease

fun GitHubReleaseResponse.toModel() = GitHubRelease(
tagName = tagName,
name = name,
body = body,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* MIT License
*
* Copyright (c) 2024 AnyGogin31
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package neilt.mobile.pixiv.data.remote.responses.github

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class GitHubReleaseResponse(
@SerialName("tag_name") val tagName: String,
@SerialName("name") val name: String? = null,
@SerialName("body") val body: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* MIT License
*
* Copyright (c) 2024 AnyGogin31
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package neilt.mobile.pixiv.data.remote.services.github

import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.engine.cio.CIO
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.request.get
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.json.Json
import neilt.mobile.pixiv.data.remote.responses.github.GitHubReleaseResponse

class GitHubService {
suspend fun fetchLatestGitHubRelease(): GitHubReleaseResponse {
val client = HttpClient(CIO) {
install(ContentNegotiation) {
json(
Json {
ignoreUnknownKeys = true
isLenient = true
},
)
}
}
return client
.get("https://api.github.com/repos/AnyGogin31/PixivCompose/releases/latest")
.body()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* MIT License
*
* Copyright (c) 2024 AnyGogin31
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package neilt.mobile.pixiv.data.repositories.github

import neilt.mobile.pixiv.data.sources.github.GitHubRemoteDataSource
import neilt.mobile.pixiv.domain.models.github.GitHubRelease
import neilt.mobile.pixiv.domain.repositories.github.GitHubRepository

class GitHubRepositoryImpl(
private val githubRemoteDataSource: GitHubRemoteDataSource,
) : GitHubRepository {
override suspend fun getLatestGitHubRelease(): GitHubRelease {
return githubRemoteDataSource.getLatestGitHubRelease()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* MIT License
*
* Copyright (c) 2024 AnyGogin31
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package neilt.mobile.pixiv.data.sources.github

import neilt.mobile.pixiv.data.mapper.github.toModel
import neilt.mobile.pixiv.data.remote.services.github.GitHubService
import neilt.mobile.pixiv.domain.models.github.GitHubRelease

class GitHubRemoteDataSource(
private val gitHubService: GitHubService,
) {
suspend fun getLatestGitHubRelease(): GitHubRelease {
return gitHubService.fetchLatestGitHubRelease().toModel()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* MIT License
*
* Copyright (c) 2024 AnyGogin31
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package neilt.mobile.pixiv.domain.models.github

data class GitHubRelease(
val tagName: String,
val name: String? = null,
val body: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* MIT License
*
* Copyright (c) 2024 AnyGogin31
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package neilt.mobile.pixiv.domain.repositories.github

import neilt.mobile.pixiv.domain.models.github.GitHubRelease

interface GitHubRepository {
suspend fun getLatestGitHubRelease(): GitHubRelease
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<!-- トーストメッセージ -->
<string name="toast_downloading">ダウンロード中...</string>
<string name="toast_download_complete">ダウンロードが完了しました</string>
<string name="new_version_available">アプリの新しいバージョンが利用可能です</string>

<!-- 検索 -->
<string name="search_illustrations_placeholder">イラストを検索...</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<!-- Уведомления -->
<string name="toast_downloading">Загрузка...</string>
<string name="toast_download_complete">Загрузка завершена</string>
<string name="new_version_available">Доступна новая версия приложения</string>

<!-- Поиск -->
<string name="search_illustrations_placeholder">Искать иллюстрации...</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<!-- Toast Messages -->
<string name="toast_downloading">Downloading...</string>
<string name="toast_download_complete">Download complete</string>
<string name="new_version_available">New version of application available</string>

<!-- Search -->
<string name="search_illustrations_placeholder">Search illustrations...</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* MIT License
*
* Copyright (c) 2024 AnyGogin31
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package neilt.mobile.pixiv.shared.di

import neilt.mobile.pixiv.shared.provider.AndroidUpdateCheckerProvider
import neilt.mobile.pixiv.shared.provider.UpdateCheckerProvider
import org.koin.core.module.dsl.factoryOf
import org.koin.dsl.bind
import org.koin.dsl.module

internal actual val platformSharedModule = module {
factoryOf(::AndroidUpdateCheckerProvider) bind UpdateCheckerProvider::class
}
Loading

0 comments on commit 7a3267d

Please sign in to comment.