Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix zzz #473

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest
runs-on: macos-latest-large
timeout-minutes: 120

# Steps represent a sequence of tasks that will be executed as part of the job
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest
runs-on: macos-latest-large
timeout-minutes: 120

# Steps represent a sequence of tasks that will be executed as part of the job
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {

defaultConfig {
applicationId = "com.joeloewi.croissant"
versionCode = 61
versionName = "1.3.0"
versionCode = 62
versionName = "1.3.1"
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ fun SelectGames(
HoYoLABGame.HonkaiImpact3rd,
HoYoLABGame.GenshinImpact,
HoYoLABGame.TearsOfThemis,
HoYoLABGame.HonkaiStarRail
HoYoLABGame.HonkaiStarRail,
HoYoLABGame.ZenlessZoneZero
).toImmutableList()
}
val containsNotSupportedGame = stringResource(id = R.string.contains_not_supported_game)
Expand Down Expand Up @@ -424,7 +425,7 @@ fun ConnectedGamesContentListItem(

val enabled by remember(hoYoLABGame, gameRecord) {
derivedStateOf {
hoYoLABGame == HoYoLABGame.TearsOfThemis || hoYoLABGame == HoYoLABGame.HonkaiStarRail || currentGameRecord.value.gameId != GameRecord.INVALID_GAME_ID
hoYoLABGame == HoYoLABGame.TearsOfThemis || currentGameRecord.value.gameId != GameRecord.INVALID_GAME_ID
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,14 @@ fun SettingsContent(
value = !isUnusedAppRestrictionEnabled().getOrDefault(false),
role = Role.Switch,
onValueChange = {
activityResult.launch(
IntentCompat.createManageUnusedAppRestrictionsIntent(
activity,
activity.packageName
runCatching {
activityResult.launch(
IntentCompat.createManageUnusedAppRestrictionsIntent(
activity,
activity.packageName
)
)
)
}
}
),
leadingContent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ fun HoYoLABGame.gameNameStringResId(): Int = when (this) {
R.string.honkai_star_rail_game_name
}

HoYoLABGame.ZenlessZoneZero -> {
R.string.zenless_zone_zero_game_name
}

HoYoLABGame.Unknown -> {
R.string.unknown_game_name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class AttendCheckInEventWorker @AssistedInject constructor(
private val attendCheckInGenshinImpactUseCase: CheckInUseCase.AttendCheckInGenshinImpact,
private val attendCheckInHonkaiImpact3rdUseCase: CheckInUseCase.AttendCheckInHonkaiImpact3rd,
private val attendCheckInTearsOfThemisUseCase: CheckInUseCase.AttendCheckInTearsOfThemis,
private val attendCheckInHonkaiStarRail: CheckInUseCase.AttendCheckInHonkaiStarRail,
private val attendCheckInHonkaiStarRailUseCase: CheckInUseCase.AttendCheckInHonkaiStarRailUseCase,
private val attendCheckInZenlessZoneZeroUseCase: CheckInUseCase.AttendCheckInZenlessZoneZeroUseCase,
private val insertWorkerExecutionLogUseCase: WorkerExecutionLogUseCase.Insert,
private val hasExecutedAtLeastOnce: WorkerExecutionLogUseCase.HasExecutedAtLeastOnce,
private val insertSuccessLogUseCase: SuccessLogUseCase.Insert,
Expand Down Expand Up @@ -159,7 +160,11 @@ class AttendCheckInEventWorker @AssistedInject constructor(
}

HoYoLABGame.HonkaiStarRail -> {
attendCheckInHonkaiStarRail(cookie = cookie)
attendCheckInHonkaiStarRailUseCase(cookie = cookie)
}

HoYoLABGame.ZenlessZoneZero -> {
attendCheckInZenlessZoneZeroUseCase(cookie = cookie)
}

HoYoLABGame.Unknown -> {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-en-rUS/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@
<string name="execution_notice">To ensure accuracy, the scheduled task will be executed 30 seconds after the specified time. For example, if you schedule a task for 12:34 PM, it will actually be executed at 12:34:30 PM.</string>
<string name="attendance_retry_unknown_error">Attendance failed due to unknown error. Retry has scheduled.</string>
<string name="attendance_retry_too_many_requests_error">Attendance failed due to too many requests. Retry has scheduled.</string>
<string name="zenless_zone_zero_game_name">Zenless Zone Zero</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,5 @@
<string name="execution_notice">작업을 정확하게 실행하기 위해, 지정된 시간보다 30초 늦게 실행됩니다. 예를 들어, 12시 34분에 작업을 예약하면 실제로는 12시 34분 30초에 실행됩니다.</string>
<string name="attendance_retry_unknown_error">알 수 없는 문제로 인해 출석하지 못했습니다. 재시도를 예약합니다.</string>
<string name="attendance_retry_too_many_requests_error">요청이 빈번하여 출석하지 못 했습니다. 재시도를 예약합니다.</string>
<string name="zenless_zone_zero_game_name">젠레스 존 제로</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,5 @@
<string name="execution_notice">To ensure accuracy, the scheduled task will be executed 30 seconds after the specified time. For example, if you schedule a task for 12:34 PM, it will actually be executed at 12:34:30 PM.</string>
<string name="attendance_retry_unknown_error">Attendance failed due to unknown error. Retry has scheduled.</string>
<string name="attendance_retry_too_many_requests_error">Attendance failed due to too many requests. Retry has scheduled.</string>
<string name="zenless_zone_zero_game_name">Zenless Zone Zero</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import retrofit2.http.Query
interface ArcaLiveAppService {
@GET("view/article/{slug}/{articleId}")
suspend fun getArticle(
@Header("User-Agent") userAgent: String = "live.arca.android.playstore/0.8.331-playstore",
@Header("User-Agent") userAgent: String = "net.umanle.arca.android.playstore/0.9.57",
@Path("slug") slug: String,
@Path("articleId") articleId: Long,
@Query("viewCount") viewCount: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import com.skydoves.sandwich.ApiResponse
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Query
import java.util.Locale

interface GenshinImpactCheckInService {

@POST("event/sol/sign")
suspend fun attend(
@Query("lang") language: String = Locale.getDefault().toLanguageTag().lowercase(),
@Header("Cookie") cookie: String,
@Body params: Map<String, String> = mapOf("act_id" to "e202102251931481")
@Body params: Map<String, String> = mapOf(
"act_id" to "e202102251931481",
"lang" to Locale.getDefault().toLanguageTag().lowercase()
)
): ApiResponse<AttendanceResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.joeloewi.croissant.data.api.dao

import com.joeloewi.croissant.data.api.model.response.AttendanceResponse
import com.skydoves.sandwich.ApiResponse
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.POST
import java.util.Locale

/*
* Copyright (C) 2024 joeloewi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface ZenlessZoneZeroCheckInService {

@POST("event/luna/zzz/os/sign")
suspend fun attend(
@Header("Cookie") cookie: String,
@Body params: Map<String, String> = mapOf(
"act_id" to "e202406031448091",
"lang" to Locale.getDefault().toLanguageTag().lowercase()
)
): ApiResponse<AttendanceResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ fun generateGameIntent(
}
}

HoYoLABGame.ZenlessZoneZero -> {
with("com.HoYoverse.Nap") {
this to "market://details?id=${this}".toUri()
}
}

HoYoLABGame.Unknown -> {
"" to Uri.EMPTY
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.joeloewi.croissant.data.api.dao.ArcaLiveAppService
import com.joeloewi.croissant.data.api.dao.CheckInService
import com.joeloewi.croissant.data.api.dao.GenshinImpactCheckInService
import com.joeloewi.croissant.data.api.dao.HoYoLABService
import com.joeloewi.croissant.data.api.dao.ZenlessZoneZeroCheckInService
import com.joeloewi.croissant.data.api.model.response.AttendanceResponse
import com.joeloewi.croissant.data.api.model.response.ChangeDataSwitchResponse
import com.joeloewi.croissant.data.api.model.response.GameRecordCardResponse
Expand Down Expand Up @@ -145,4 +146,12 @@ object ApiModule {
.baseUrl("https://arca.live/api/app/")
.build()
.create()

@Singleton
@Provides
fun providesZenlessZoneZeroCheckInService(retrofitBuilder: Retrofit.Builder): ZenlessZoneZeroCheckInService =
retrofitBuilder
.baseUrl("https://sg-act-nap-api.hoyolab.com")
.build()
.create()
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ class CheckInRepositoryImpl @Inject constructor(
): Result<BaseResponse> = checkInDataSource.runCatching {
attendCheckInHonkaiImpact3rd(cookie).getOrThrow().throwIfNotOk()
}

override suspend fun attendCheckInZenlessZoneZero(
cookie: String
): Result<BaseResponse> = checkInDataSource.runCatching {
attendCheckInZenlessZoneZero(cookie).getOrThrow().throwIfNotOk()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ interface CheckInDataSource {
suspend fun attendCheckInGenshinImpact(cookie: String): ApiResponse<AttendanceResponse>

suspend fun attendCheckInHonkaiImpact3rd(cookie: String): ApiResponse<AttendanceResponse>

suspend fun attendCheckInZenlessZoneZero(cookie: String): ApiResponse<AttendanceResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ class ArcaLiveAppDataSourceImpl @Inject constructor(
}
}

HoYoLABGame.ZenlessZoneZero -> {
arcaLiveAppService.getArticle(
slug = "zenlesszonezero",
articleId = 109976603
).mapSuccess {
Jsoup.parse(content)
.apply { select("img").remove() }
.html()
.replace("https://oo.pe/", "")
}
}

HoYoLABGame.TearsOfThemis, HoYoLABGame.Unknown -> throw IllegalStateException()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.joeloewi.croissant.data.repository.remote.impl

import com.joeloewi.croissant.data.api.dao.CheckInService
import com.joeloewi.croissant.data.api.dao.GenshinImpactCheckInService
import com.joeloewi.croissant.data.api.dao.ZenlessZoneZeroCheckInService
import com.joeloewi.croissant.data.api.model.response.AttendanceResponse
import com.joeloewi.croissant.data.repository.remote.CheckInDataSource
import com.joeloewi.croissant.data.util.runAndRetryWithExponentialBackOff
Expand All @@ -28,7 +29,8 @@ import javax.inject.Inject

class CheckInDataSourceImpl @Inject constructor(
private val checkInService: CheckInService,
private val genshinImpactCheckInService: GenshinImpactCheckInService
private val genshinImpactCheckInService: GenshinImpactCheckInService,
private val zenlessZoneZeroCheckInService: ZenlessZoneZeroCheckInService
) : CheckInDataSource {

override suspend fun attend(actId: String, cookie: String): ApiResponse<AttendanceResponse> =
Expand All @@ -53,4 +55,12 @@ class CheckInDataSourceImpl @Inject constructor(
checkInService.attendCheckInHonkaiImpact3rd(cookie = cookie)
}
}

override suspend fun attendCheckInZenlessZoneZero(
cookie: String
): ApiResponse<AttendanceResponse> = withContext(Dispatchers.IO) {
runAndRetryWithExponentialBackOff {
zenlessZoneZeroCheckInService.attend(cookie = cookie)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ enum class HoYoLABGame(
) {
HonkaiImpact3rd(
gameId = 1,
gameIconUrl = "https://webstatic-sea.hoyolab.com/communityweb/business/bh3_hoyoverse.png",
gameIconUrl = "https://hyl-static-res-prod.hoyolab.com/communityweb/business/bh3_hoyoverse.png",
),
GenshinImpact(
gameId = 2,
gameIconUrl = "https://webstatic-sea.hoyolab.com/communityweb/business/ys_hoyoverse.png",
gameIconUrl = "https://hyl-static-res-prod.hoyolab.com/communityweb/business/ys_hoyoverse.png",
),
TearsOfThemis(
gameId = 4,
gameIconUrl = "https://webstatic-sea.hoyolab.com/communityweb/business/nxx_hoyoverse.png",
gameIconUrl = "https://hyl-static-res-prod.hoyolab.com/communityweb/business/nxx_hoyoverse.png",
),
HonkaiStarRail(
gameId = 6,
gameIconUrl = "https://webstatic-sea.hoyolab.com/communityweb/business/starrail_hoyoverse.png"
gameIconUrl = "https://hyl-static-res-prod.hoyolab.com/communityweb/business/starrail_hoyoverse.png"
),
ZenlessZoneZero(
gameId = 8,
gameIconUrl = "https://hyl-static-res-prod.hoyolab.com/communityweb/business/nap.png"
),
Unknown(
gameId = -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ interface CheckInRepository {
suspend fun attendCheckInGenshinImpact(cookie: String): Result<BaseResponse>

suspend fun attendCheckInHonkaiImpact3rd(cookie: String): Result<BaseResponse>

suspend fun attendCheckInZenlessZoneZero(cookie: String): Result<BaseResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sealed class CheckInUseCase {
) = checkInRepository.attend(actId, cookie)
}

class AttendCheckInHonkaiStarRail @Inject constructor(
class AttendCheckInHonkaiStarRailUseCase @Inject constructor(
private val checkInRepository: CheckInRepository
) : CheckInUseCase() {
suspend operator fun invoke(
Expand All @@ -54,4 +54,12 @@ sealed class CheckInUseCase {
cookie: String
) = checkInRepository.attendCheckInGenshinImpact(cookie)
}

class AttendCheckInZenlessZoneZeroUseCase @Inject constructor(
private val checkInRepository: CheckInRepository
) : CheckInUseCase() {
suspend operator fun invoke(
cookie: String
) = checkInRepository.attendCheckInZenlessZoneZero(cookie)
}
}
Loading