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

Development #407

Merged
merged 72 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
17849e3
chore(deps): update kotlin monorepo to v1.9.23
renovate[bot] Mar 11, 2024
1b3fa1e
chore(deps): update kspplugin to v1.9.23-1.0.19
renovate[bot] Mar 11, 2024
86c43c5
chore(deps): update actions/setup-java action to v4.2.0
renovate[bot] Mar 13, 2024
6bb6b49
fix(deps): update protobuf to v4
renovate[bot] Mar 13, 2024
1b38114
mod: let retryTask run on ApiResponse.Failure
joeloewi7178 Mar 14, 2024
3ac4052
Merge pull request #378 from joeloewi7178/renovate/actions-setup-java…
joeloewi7178 Mar 14, 2024
80b0376
Merge pull request #379 from joeloewi7178/renovate/major-protobuf
joeloewi7178 Mar 14, 2024
6b047e2
chore(deps): update actions/setup-java action to v4.2.1
renovate[bot] Mar 14, 2024
37def21
fix(deps): update sandwich to v2.0.6
renovate[bot] Mar 14, 2024
7319381
Merge pull request #380 from joeloewi7178/renovate/actions-setup-java…
joeloewi7178 Mar 15, 2024
ab01296
Merge pull request #381 from joeloewi7178/renovate/sandwich
joeloewi7178 Mar 15, 2024
8ef8e94
mod: use 'in' to check state
joeloewi7178 Mar 15, 2024
8a03abf
Merge remote-tracking branch 'origin/development' into development
joeloewi7178 Mar 15, 2024
1f7e5a8
chore(deps): update androidgradleplugin to v8.3.1
renovate[bot] Mar 18, 2024
4e5ce3b
fix(deps): update dependency com.android.tools:common to v31.3.1
renovate[bot] Mar 18, 2024
b582d96
fix(deps): update retrofit to v2.10.0
renovate[bot] Mar 18, 2024
0c6d42c
Merge pull request #384 from joeloewi7178/renovate/retrofit
joeloewi7178 Mar 19, 2024
877a3fe
Merge pull request #382 from joeloewi7178/renovate/androidgradleplugin
joeloewi7178 Mar 19, 2024
15dc11f
Merge pull request #383 from joeloewi7178/renovate/androidtools
joeloewi7178 Mar 19, 2024
41ccd52
mod: use retrofit-bom
joeloewi7178 Mar 20, 2024
c08fe5f
fix(deps): update dependency androidx.compose.compiler:compiler to v1…
renovate[bot] Mar 20, 2024
223d86c
fix(deps): update dependency androidx.compose:compose-bom to v2024.03.00
renovate[bot] Mar 20, 2024
20cb176
Merge pull request #375 from joeloewi7178/renovate/kotlin-monorepo
joeloewi7178 Mar 21, 2024
55ea499
Merge pull request #376 from joeloewi7178/renovate/kspplugin
joeloewi7178 Mar 21, 2024
35a8b76
Merge pull request #385 from joeloewi7178/renovate/androidxcomposecom…
joeloewi7178 Mar 21, 2024
e07893d
Merge pull request #386 from joeloewi7178/renovate/androidxcomposebom
joeloewi7178 Mar 21, 2024
bd3319f
mod: log message to crashlytics
joeloewi7178 Mar 21, 2024
cd22de4
fix(deps): update dependency com.google.firebase:firebase-bom to v32.8.0
renovate[bot] Mar 21, 2024
8708596
Merge pull request #387 from joeloewi7178/renovate/firebasebom
joeloewi7178 Mar 22, 2024
fba3a41
chore(deps): update dependency gradle to v8.7
renovate[bot] Mar 22, 2024
1b700f1
fix(deps): update protobuf to v4.26.1
renovate[bot] Mar 27, 2024
53ba2ae
Merge pull request #388 from joeloewi7178/renovate/gradle-8.x
joeloewi7178 Mar 28, 2024
e2a4d1f
Merge pull request #389 from joeloewi7178/renovate/protobuf
joeloewi7178 Mar 28, 2024
3bf1ee1
mod: version reference
joeloewi7178 Mar 28, 2024
45eb0dc
fix(deps): update retrofit to v2.11.0
renovate[bot] Mar 28, 2024
3c0c210
chore(deps): update hilt to v2.51.1
renovate[bot] Mar 29, 2024
d924560
fix(deps): update dependency androidx.compose:compose-bom to v2024.04.00
renovate[bot] Apr 3, 2024
c35fede
fix(deps): update dependency nl.marc-apps:tts to v2.6.0
renovate[bot] Apr 6, 2024
699348a
chore(deps): update androidgradleplugin to v8.3.2
renovate[bot] Apr 10, 2024
c89aba1
fix(deps): update dependency com.android.tools:common to v31.3.2
renovate[bot] Apr 10, 2024
9df1688
Merge pull request #396 from joeloewi7178/renovate/androidtools
joeloewi7178 Apr 11, 2024
6c122c5
Merge pull request #395 from joeloewi7178/renovate/androidgradleplugin
joeloewi7178 Apr 11, 2024
55a0c89
Merge pull request #394 from joeloewi7178/renovate/tts
joeloewi7178 Apr 11, 2024
583d6a2
Merge pull request #392 from joeloewi7178/renovate/androidxcomposebom
joeloewi7178 Apr 11, 2024
6db3d2c
Merge pull request #391 from joeloewi7178/renovate/hilt
joeloewi7178 Apr 11, 2024
5babd68
Merge pull request #390 from joeloewi7178/renovate/retrofit
joeloewi7178 Apr 11, 2024
4b699c9
chore(deps): update kspplugin to v1.9.23-1.0.20
renovate[bot] Apr 11, 2024
b2c3f28
Merge pull request #393 from joeloewi7178/renovate/kspplugin
joeloewi7178 Apr 11, 2024
9e17f49
fix(deps): update dependency com.google.firebase:firebase-bom to v32.8.1
renovate[bot] Apr 12, 2024
b89a18e
Merge pull request #397 from joeloewi7178/renovate/firebasebom
joeloewi7178 Apr 12, 2024
fd0fbbf
mod: use generated project accessor
joeloewi7178 Apr 14, 2024
268c4f0
fix(deps): update kotlinxatomicfu to v0.24.0
renovate[bot] Apr 17, 2024
37f95ad
chore(deps): update dependency androidx.baselineprofile to v1.2.4
renovate[bot] Apr 17, 2024
831e1e6
fix(deps): update dependency androidx.benchmark:benchmark-macro-junit…
renovate[bot] Apr 17, 2024
f1430c1
fix(deps): update dependency androidx.compose.compiler:compiler to v1…
renovate[bot] Apr 17, 2024
f63f26e
fix(deps): update dependency androidx.compose:compose-bom to v2024.04.01
renovate[bot] Apr 17, 2024
90a87af
Merge pull request #402 from joeloewi7178/renovate/androidxcomposebom
joeloewi7178 Apr 18, 2024
f92d5ca
Merge pull request #401 from joeloewi7178/renovate/androidxcomposecom…
joeloewi7178 Apr 18, 2024
86f9cf1
Merge pull request #400 from joeloewi7178/renovate/androidxbenchmarkm…
joeloewi7178 Apr 18, 2024
26b492d
Merge pull request #399 from joeloewi7178/renovate/androidxbaselinepr…
joeloewi7178 Apr 18, 2024
8b13684
Merge pull request #398 from joeloewi7178/renovate/kotlinxatomicfu
joeloewi7178 Apr 18, 2024
0283497
fix(deps): update dependency androidx.activity:activity-compose to v1…
renovate[bot] Apr 18, 2024
bfefb0b
fix(deps): update dependency androidx.core:core-ktx to v1.13.0
renovate[bot] Apr 18, 2024
61a9927
Merge pull request #403 from joeloewi7178/renovate/androidxactivity
joeloewi7178 Apr 18, 2024
926a8b4
Merge pull request #404 from joeloewi7178/renovate/androidxcore
joeloewi7178 Apr 18, 2024
297399e
fix(deps): update dependency androidx.datastore:datastore to v1.1.0
renovate[bot] Apr 18, 2024
1668c00
fix(deps): update dependency com.squareup.leakcanary:leakcanary-andro…
renovate[bot] Apr 18, 2024
7d38264
Merge pull request #405 from joeloewi7178/renovate/androidxdatastore
joeloewi7178 Apr 18, 2024
458dcbe
Merge pull request #406 from joeloewi7178/renovate/leakcanaryandroid
joeloewi7178 Apr 18, 2024
2fe74e0
mod: version reference
joeloewi7178 Apr 18, 2024
0afb721
Merge remote-tracking branch 'origin/development' into development
joeloewi7178 Apr 19, 2024
d7f5820
versionCode 60
joeloewi7178 Apr 19, 2024
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/on_push_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/[email protected]

- name: set up JDK 17
uses: actions/setup-java@v4.1.0
uses: actions/setup-java@v4.2.1
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
Expand Down
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {

defaultConfig {
applicationId = "com.joeloewi.croissant"
versionCode = 59
versionCode = 60
versionName = "1.3.0"
targetSdk = 34

Expand Down Expand Up @@ -68,9 +68,9 @@ baselineProfile {
}

dependencies {
implementation(project(":data"))
implementation(project(":domain"))
baselineProfile(project(":baselineprofile"))
implementation(projects.data)
implementation(projects.domain)
baselineProfile(projects.baselineprofile)

implementation(libs.androidx.core.ktx)
implementation(libs.android.material)
Expand Down Expand Up @@ -111,7 +111,6 @@ dependencies {
implementation(libs.accompanist.webview)
implementation(libs.accompanist.pager.indicators)
implementation(libs.accompanist.swiperefresh)
implementation(libs.accompanist.themeadapter.material3)
implementation(libs.accompanist.navigation.material)

//work
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import androidx.compose.material3.rememberSwipeToDismissBoxState
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.snapshotFlow
Expand All @@ -58,19 +58,22 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.scale
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.flowWithLifecycle
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.itemKey
import androidx.work.ExistingWorkPolicy
import androidx.work.WorkInfo
import androidx.work.WorkManager
import androidx.work.WorkQuery
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.google.firebase.Firebase
Expand Down Expand Up @@ -252,12 +255,14 @@ fun AttendanceWithGamesItem(
{ attendance ->
Firebase.analytics.logEvent("instant_attend_click", bundleOf())

val oneTimeWork =
AttendCheckInEventWorker.buildOneTimeWork(attendanceId = attendance.id)
val oneTimeWork = AttendCheckInEventWorker.buildOneTimeWork(
attendanceId = attendance.id,
isInstantAttendance = true
)

WorkManager.getInstance(context).beginUniqueWork(
attendance.oneTimeAttendCheckInEventWorkerName.toString(),
ExistingWorkPolicy.APPEND_OR_REPLACE,
ExistingWorkPolicy.REPLACE,
oneTimeWork
).enqueue()

Expand Down Expand Up @@ -401,14 +406,24 @@ private fun DismissContent(
},
trailingContent = {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
val workerName =
attendanceWithGames().value.attendance.oneTimeAttendCheckInEventWorkerName.toString()
val isRunning by remember(context, workerName) {
val isRunningFlow = remember(context, workerName) {
WorkManager.getInstance(context)
.getWorkInfosForUniqueWorkFlow(workerName)
.map { list -> list.any { it.state == WorkInfo.State.RUNNING } }
.getWorkInfosFlow(
WorkQuery.Builder
.fromUniqueWorkNames(listOf(workerName))
.addStates(listOf(WorkInfo.State.RUNNING))
.build()
)
.catch { }
.map { it.isNotEmpty() }
.flowOn(Dispatchers.IO)
}.collectAsState(initial = false)
}
val isRunning by produceState(initialValue = false) {
isRunningFlow.flowWithLifecycle(lifecycleOwner.lifecycle).collect { value = it }
}

IconButton(
enabled = !isRunning,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ServiceInfo
import android.net.Uri
import android.os.Build
import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
Expand Down Expand Up @@ -216,21 +215,15 @@ class NotificationGenerator(
.setContentTitle(context.getString(R.string.attendance_foreground_notification_title))
.setContentText(context.getString(R.string.wait_for_a_moment))
.setSmallIcon(R.drawable.ic_baseline_bakery_dining_24)
.setForegroundServiceBehavior(Notification.FOREGROUND_SERVICE_IMMEDIATE)
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.build()
.run {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
return@run ForegroundInfo(
notificationId,
this,
ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE
)
}
return@run ForegroundInfo(
ForegroundInfo(
notificationId,
this
this,
ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class AttendCheckInEventWorker @AssistedInject constructor(
private val _firstTriggeredTimestamp by lazy {
inputData.getLong(FIRST_TRIGGERED_TIMESTAMP, Instant.now().toEpochMilli())
}
private val _isInstantAttendance by lazy { inputData.getBoolean(IS_INSTANT_ATTENDANCE, false) }

override suspend fun getForegroundInfo(): ForegroundInfo =
notificationGenerator.createForegroundInfo(_attendanceId.toInt())
Expand Down Expand Up @@ -205,21 +206,41 @@ class AttendCheckInEventWorker @AssistedInject constructor(
is HoYoLABUnsuccessfulResponseException -> {
when (val retCode = HoYoLABRetCode.findByCode(cause.retCode)) {
HoYoLABRetCode.TooManyRequests, HoYoLABRetCode.TooManyRequestsGenshinImpact -> {
//do not make log, not to skip this game when retry

notificationGenerator.createAttendanceRetryScheduledNotification(
nickname = attendanceWithGames.attendance.nickname,
contentText = context.getString(R.string.attendance_retry_too_many_requests_error)
).let { notification ->
notificationGenerator.safeNotify(
UUID.randomUUID().toString(),
game.type.gameId,
notification
)
if (_isInstantAttendance) {
//make log and do not retry if this work was enqueued by clicking instant attendance

addFailureLog(_attendanceId, game.type, cause)

createUnsuccessfulAttendanceNotification(
nickname = attendanceWithGames.attendance.nickname,
hoYoLABGame = game.type,
region = game.region,
hoYoLABUnsuccessfulResponseException = cause
).let { notification ->
notificationGenerator.safeNotify(
UUID.randomUUID().toString(),
game.type.gameId,
notification
)
}

Result.success()
} else {
//do not make log, not to skip this game when retry
notificationGenerator.createAttendanceRetryScheduledNotification(
nickname = attendanceWithGames.attendance.nickname,
contentText = context.getString(R.string.attendance_retry_too_many_requests_error)
).let { notification ->
notificationGenerator.safeNotify(
UUID.randomUUID().toString(),
game.type.gameId,
notification
)
}

//good to retry
Result.retry()
}

//good to retry
Result.retry()
}

else -> {
Expand All @@ -238,11 +259,11 @@ class AttendCheckInEventWorker @AssistedInject constructor(
)
}

if (!listOf(
if (retCode !in listOf(
HoYoLABRetCode.AlreadyCheckedIn,
HoYoLABRetCode.CharacterNotExists,
HoYoLABRetCode.LoginFailed
).contains(retCode)
)
) {
//we don't know which error was occurred
//record this error for monitoring
Expand All @@ -265,34 +286,54 @@ class AttendCheckInEventWorker @AssistedInject constructor(
}

else -> {
//do not make log, not to pass this game when retry
notificationGenerator.createAttendanceRetryScheduledNotification(
nickname = attendanceWithGames.attendance.nickname
).let { notification ->
notificationGenerator.safeNotify(
UUID.randomUUID().toString(),
game.type.gameId,
notification
)
}
if (_isInstantAttendance) {
//make log and do not retry if this work was enqueued by clicking instant attendance
addFailureLog(_attendanceId, game.type, cause)

notificationGenerator.createUnsuccessfulAttendanceNotification(
nickname = attendanceWithGames.attendance.nickname,
hoYoLABGame = game.type,
attendanceId = _attendanceId
).let { notification ->
notificationGenerator.safeNotify(
UUID.randomUUID().toString(),
game.type.gameId,
notification
)
}

//these errors are not hoyolab server's errors, but networks errors, generally
//do retry
Firebase.crashlytics.log("runAttemptCount: $runAttemptCount")
Result.retry()
Result.success()
} else {
//do not make log, not to pass this game when retry
notificationGenerator.createAttendanceRetryScheduledNotification(
nickname = attendanceWithGames.attendance.nickname
).let { notification ->
notificationGenerator.safeNotify(
UUID.randomUUID().toString(),
game.type.gameId,
notification
)
}

//these errors are not hoyolab server's errors, but networks errors, generally
//do retry
Firebase.crashlytics.log("runAttemptCount: $runAttemptCount")
Result.retry()
}
}
}
}
)
}
}.fold(
onSuccess = { results ->
if (results.contains(Result.retry())) {
//do not retry if this work was enqueued by clicking instant attendance
if (results.contains(Result.retry()) && !_isInstantAttendance) {
return@withContext Result.retry()
}

runAttemptCount.takeIf { count -> count > 0 }?.let {
Firebase.crashlytics.log("success after run attempts: $it")
Firebase.crashlytics.log("succeed after run attempts: $it")
}

Result.success()
Expand All @@ -313,18 +354,21 @@ class AttendCheckInEventWorker @AssistedInject constructor(
companion object {
const val ATTENDANCE_ID = "attendanceId"
const val FIRST_TRIGGERED_TIMESTAMP = "triggeredTimestamp"
const val IS_INSTANT_ATTENDANCE = "isInstantAttendance"

fun buildOneTimeWork(
attendanceId: Long,
triggeredTimestamp: Long = Instant.now().toEpochMilli(),
isInstantAttendance: Boolean = false,
constraints: Constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
) = OneTimeWorkRequestBuilder<AttendCheckInEventWorker>()
.setInputData(
workDataOf(
ATTENDANCE_ID to attendanceId,
FIRST_TRIGGERED_TIMESTAMP to triggeredTimestamp
FIRST_TRIGGERED_TIMESTAMP to triggeredTimestamp,
IS_INSTANT_ATTENDANCE to isInstantAttendance
)
)
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class CheckSessionWorker @AssistedInject constructor(
)

runAttemptCount.takeIf { count -> count > 0 }?.let {
Firebase.crashlytics.log("success after run attempts: $it")
Firebase.crashlytics.log("succeed after run attempts: $it")
}

Result.success()
Expand Down
5 changes: 4 additions & 1 deletion data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
}

dependencies {
implementation(project(":domain"))
implementation(projects.domain)

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
Expand All @@ -31,9 +31,12 @@ dependencies {
androidTestImplementation(libs.androidx.test.espresso.core)

//retrofit2
implementation(platform(libs.retrofit.bom))
implementation(libs.retrofit)
implementation(libs.retrofit.converter.moshi)
implementation(libs.retrofit.converter.scalars)
ksp(libs.retrofit.response.type.keeper)

implementation(platform(libs.okhttp3.bom))
implementation(libs.okhttp3.logging.interceptor)
implementation(libs.okhttp3.dnsoverhttps)
Expand Down
19 changes: 1 addition & 18 deletions data/consumer-proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }

-dontwarn okhttp3.internal.platform.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**

# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation

# R8 full mode strips generic signatures from return types if not kept.
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>

# With R8 full mode generic signatures are stripped for classes that are not kept.
-keep,allowobfuscation,allowshrinking class retrofit2.Response
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
Loading