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 #377

Merged
merged 45 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
aadc07c
fix(deps): update dependency androidx.compose.compiler:compiler to v1…
renovate[bot] Feb 21, 2024
33bd478
fix(deps): update dependency androidx.compose:compose-bom to v2024.02.01
renovate[bot] Feb 21, 2024
b74cd53
fix(deps): update dependency androidx.hilt:hilt-navigation-compose to…
renovate[bot] Feb 22, 2024
b6f35e5
fix(deps): update dependency androidx.test.uiautomator:uiautomator to…
renovate[bot] Feb 22, 2024
e087a98
fix(deps): update hiltext to v1.2.0
renovate[bot] Feb 22, 2024
bab81a1
Merge pull request #357 from joeloewi7178/renovate/androidxcomposecom…
joeloewi7178 Feb 22, 2024
3bbb5c9
Merge pull request #358 from joeloewi7178/renovate/androidxcomposebom
joeloewi7178 Feb 22, 2024
b0c526a
Merge pull request #359 from joeloewi7178/renovate/androidxhiltnaviga…
joeloewi7178 Feb 22, 2024
ac22e03
Merge pull request #361 from joeloewi7178/renovate/hiltext
joeloewi7178 Feb 22, 2024
9fdd760
Merge pull request #360 from joeloewi7178/renovate/androidxtestuiauto…
joeloewi7178 Feb 22, 2024
a58938e
mod: move context switching in datasource
joeloewi7178 Feb 23, 2024
4d7d16a
fix(deps): update dependency io.coil-kt:coil-bom to v2.6.0
renovate[bot] Feb 23, 2024
23beb87
chore(deps): update actions/setup-java action to v4.1.0
renovate[bot] Feb 28, 2024
4de899f
fix(deps): update dependency com.google.firebase:firebase-bom to v32.7.3
renovate[bot] Feb 28, 2024
9431eac
fix(deps): update dependency nl.marc-apps:tts to v2.5.0
renovate[bot] Feb 28, 2024
b0460a4
Merge pull request #362 from joeloewi7178/renovate/tts
joeloewi7178 Feb 29, 2024
1b73c61
Merge pull request #363 from joeloewi7178/renovate/coil
joeloewi7178 Feb 29, 2024
a3f6541
chore(deps): update hilt to v2.51
renovate[bot] Feb 29, 2024
f2d3fa3
Merge pull request #365 from joeloewi7178/renovate/actions-setup-java…
joeloewi7178 Feb 29, 2024
c7d153c
Merge pull request #366 from joeloewi7178/renovate/firebasebom
joeloewi7178 Feb 29, 2024
af15301
Merge pull request #364 from joeloewi7178/renovate/hilt
joeloewi7178 Feb 29, 2024
e2f1fe5
chore(deps): update kspplugin to v1.9.22-1.0.18
renovate[bot] Feb 29, 2024
b8a29e5
Merge pull request #367 from joeloewi7178/renovate/kspplugin
joeloewi7178 Feb 29, 2024
eabe361
mod: add atomic library
joeloewi7178 Feb 29, 2024
1945a99
chore(deps): update androidgradleplugin to v8.3.0
renovate[bot] Feb 29, 2024
8637706
fix(deps): update dependency com.android.tools:common to v31.3.0
renovate[bot] Feb 29, 2024
96e9931
Merge pull request #368 from joeloewi7178/renovate/androidgradleplugin
joeloewi7178 Mar 4, 2024
ec8b566
Merge pull request #369 from joeloewi7178/renovate/androidtools
joeloewi7178 Mar 4, 2024
8b158fb
fix(deps): update dependency io.github.fornewid:placeholder-material3…
renovate[bot] Mar 4, 2024
478c2af
Merge pull request #370 from joeloewi7178/renovate/fornewidplaceholde…
joeloewi7178 Mar 4, 2024
68673e2
mod: remove value for whether attendance work has been started by cli…
joeloewi7178 Mar 4, 2024
8d7e023
mod: retry when error caused by too many requests
joeloewi7178 Mar 4, 2024
bc26078
fix(deps): update dependency androidx.compose:compose-bom to v2024.02.02
renovate[bot] Mar 6, 2024
152a6eb
chore(deps): update kotlin monorepo to v1.9.23
renovate[bot] Mar 7, 2024
66b2a90
Merge pull request #371 from joeloewi7178/renovate/androidxcomposebom
joeloewi7178 Mar 7, 2024
810b073
mod: handle unknown hoyolab game
joeloewi7178 Mar 7, 2024
9764983
fix(deps): update dependency com.google.firebase:firebase-bom to v32.7.4
renovate[bot] Mar 7, 2024
b3af08a
chore(deps): update kspplugin to v1.9.23-1.0.19
renovate[bot] Mar 8, 2024
e11fc51
Merge pull request #372 from joeloewi7178/renovate/kotlin-monorepo
joeloewi7178 Mar 11, 2024
d4797e8
Merge pull request #373 from joeloewi7178/renovate/firebasebom
joeloewi7178 Mar 11, 2024
1218f09
Merge pull request #374 from joeloewi7178/renovate/kspplugin
joeloewi7178 Mar 11, 2024
d27e7b4
mod: do not run when date is different
joeloewi7178 Mar 11, 2024
f3086c6
mod: query for count log to see executed at least once
joeloewi7178 Mar 11, 2024
402dba4
mod: return retry in onSuccess block
joeloewi7178 Mar 12, 2024
135a22c
versionCode 59
joeloewi7178 Mar 12, 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.0.0
uses: actions/setup-java@v4.1.0
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
Expand Down
9 changes: 6 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ plugins {
alias(libs.plugins.croissant.android.hilt)
alias(libs.plugins.croissant.android.application.firebase)
id("kotlin-parcelize")
id("com.google.android.gms.oss-licenses-plugin")
id(libs.plugins.gms.oss.licenses.plugin.get().pluginId)
alias(libs.plugins.androidx.baselineprofile)
id(libs.plugins.kotlinx.atomicfu.get().pluginId)
}

kotlin {
Expand All @@ -20,8 +21,8 @@ android {

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

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -156,4 +157,6 @@ dependencies {
implementation(libs.gms.play.services.oss.licenses)

implementation(libs.fornewid.placeholder.material3)

implementation(libs.kotlinx.atomicfu)
}
28 changes: 16 additions & 12 deletions app/src/main/kotlin/com/joeloewi/croissant/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ import androidx.core.content.ContextCompat
import androidx.core.content.getSystemService
import androidx.core.os.bundleOf
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavGraph.Companion.findStartDestination
Expand Down Expand Up @@ -105,10 +104,8 @@ import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

Expand All @@ -124,15 +121,22 @@ class MainActivity : AppCompatActivity() {
enableEdgeToEdge()

lifecycleScope.launch(CoroutineExceptionHandler { _, _ -> }) {
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
_mainActivityViewModel.darkThemeEnabled.onEach { darkThemeEnabled ->
if (darkThemeEnabled) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
_mainActivityViewModel.darkThemeEnabled.flowWithLifecycle(lifecycle)
.flowOn(Dispatchers.IO).collect {
when (it) {
is LCE.Content -> {
if (it.content) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}
}

else -> {

}
}
}.collect()
}
}
}

lifecycleScope.launch(Dispatchers.IO + CoroutineExceptionHandler { _, _ -> }) {
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/kotlin/com/joeloewi/croissant/di/EntryPoints.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package com.joeloewi.croissant.di

import android.content.Context
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.RunnableScheduler
import coil.ImageLoader
import com.joeloewi.croissant.data.di.DefaultDispatcherExecutor
import com.joeloewi.croissant.util.NotificationGenerator
Expand All @@ -37,7 +36,6 @@ interface InitializerEntryPoint {

@DefaultDispatcherExecutor
fun executor(): Executor
fun runnableScheduler(): RunnableScheduler
fun notificationGenerator(): NotificationGenerator
}

Expand Down
7 changes: 0 additions & 7 deletions app/src/main/kotlin/com/joeloewi/croissant/di/UtilModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.joeloewi.croissant.di
import android.content.Context
import android.os.Build
import android.text.format.DateFormat
import androidx.work.RunnableScheduler
import androidx.work.WorkManager
import coil.ImageLoader
import coil.decode.GifDecoder
Expand All @@ -18,7 +17,6 @@ import com.joeloewi.croissant.util.AlarmScheduler
import com.joeloewi.croissant.util.NotificationGenerator
import com.joeloewi.croissant.util.TextToSpeechFactory
import com.joeloewi.croissant.util.impl.AlarmSchedulerImpl
import com.joeloewi.croissant.util.impl.RunnableSchedulerImpl
import dagger.Binds
import dagger.Module
import dagger.Provides
Expand Down Expand Up @@ -88,11 +86,6 @@ object UtilModule {
@Module
@InstallIn(SingletonComponent::class)
abstract class UtilModuleForBind {
@Singleton
@Binds
abstract fun bindRunnableScheduler(
runnableSchedulerImpl: RunnableSchedulerImpl
): RunnableScheduler

@Singleton
@Binds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ class WorkManagerInitializer : Initializer<WorkManager> {
val initializerEntryPoint: InitializerEntryPoint by context.entryPoints()
val hiltWorkerFactory = initializerEntryPoint.hiltWorkerFactory()
val executor = initializerEntryPoint.executor()
val runnableScheduler = initializerEntryPoint.runnableScheduler()

WorkManager.initialize(
context,
Configuration.Builder()
.setWorkerFactory(hiltWorkerFactory)
.setExecutor(executor)
.setTaskExecutor(executor)
.setRunnableScheduler(runnableScheduler)
.build()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ class AlarmReceiver : BroadcastReceiver() {
val attendanceId = p1.getLongExtra(ATTENDANCE_ID, Long.MIN_VALUE)
val attendanceWithGames = getOneAttendanceUseCase(attendanceId)
val attendance = attendanceWithGames.attendance
val oneTimeWork = AttendCheckInEventWorker.buildOneTimeWork(
attendanceId = attendance.id
)
val oneTimeWork =
AttendCheckInEventWorker.buildOneTimeWork(attendanceId = attendance.id)

workManager.beginUniqueWork(
attendance.oneTimeAttendCheckInEventWorkerName.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,8 @@ fun AttendanceWithGamesItem(
{ attendance ->
Firebase.analytics.logEvent("instant_attend_click", bundleOf())

val oneTimeWork = AttendCheckInEventWorker.buildOneTimeWork(
attendanceId = attendance.id
)
val oneTimeWork =
AttendCheckInEventWorker.buildOneTimeWork(attendanceId = attendance.id)

WorkManager.getInstance(context).beginUniqueWork(
attendance.oneTimeAttendCheckInEventWorkerName.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,41 @@ import android.os.Build
import android.os.Message
import android.view.View
import android.view.ViewGroup
import android.webkit.*
import androidx.compose.foundation.layout.*
import android.webkit.ConsoleMessage
import android.webkit.CookieManager
import android.webkit.SslErrorHandler
import android.webkit.WebChromeClient
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebSettings
import android.webkit.WebStorage
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.*
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand All @@ -42,7 +69,12 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature
import com.google.accompanist.web.*
import com.google.accompanist.web.AccompanistWebChromeClient
import com.google.accompanist.web.AccompanistWebViewClient
import com.google.accompanist.web.LoadingState
import com.google.accompanist.web.WebView
import com.google.accompanist.web.rememberWebViewNavigator
import com.google.accompanist.web.rememberWebViewState
import com.joeloewi.croissant.BuildConfig
import com.joeloewi.croissant.R
import com.joeloewi.croissant.state.ILCE
Expand Down Expand Up @@ -212,19 +244,25 @@ fun LoginHoYoLABContent(
}
},
title = {
Column {
Column(
modifier = Modifier
.fillMaxWidth()
.animateContentSize()
) {
Text(
text = webViewState.pageTitle ?: "Title",
style = MaterialTheme.typography.titleMedium,
overflow = TextOverflow.Ellipsis,
maxLines = 1
)
Text(
text = webViewState.lastLoadedUrl ?: "",
style = MaterialTheme.typography.bodyMedium,
overflow = TextOverflow.Ellipsis,
maxLines = 1
)
if (!webViewState.lastLoadedUrl.isNullOrEmpty()) {
Text(
text = webViewState.lastLoadedUrl ?: "",
style = MaterialTheme.typography.bodyMedium,
overflow = TextOverflow.Ellipsis,
maxLines = 1
)
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.text.ClickableText
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Error
import androidx.compose.material.icons.filled.ExpandLess
import androidx.compose.material.icons.filled.ExpandMore
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -47,17 +43,21 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.contentColorFor
import androidx.compose.material3.pulltorefresh.PullToRefreshContainer
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.snapshotFlow
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -85,6 +85,9 @@ import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.foundation.fade
import io.github.fornewid.placeholder.foundation.placeholder
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flowOn

@Composable
fun RedemptionCodesScreen(
Expand All @@ -102,7 +105,7 @@ fun RedemptionCodesScreen(

@OptIn(
ExperimentalMaterial3Api::class,
ExperimentalMaterialApi::class, ExperimentalFoundationApi::class
ExperimentalFoundationApi::class
)
@Composable
private fun RedemptionCodesContent(
Expand All @@ -111,10 +114,33 @@ private fun RedemptionCodesContent(
onRefresh: () -> Unit
) {
val snackbarHostState = remember { SnackbarHostState() }
val pullRefreshState = rememberPullRefreshState(
refreshing = hoYoLABGameRedemptionCodesState().isLoading,
onRefresh = onRefresh
)
val pullToRefreshState = rememberPullToRefreshState()

LaunchedEffect(Unit) {
snapshotFlow { pullToRefreshState.isRefreshing }.flowOn(Dispatchers.IO).catch { }
.collect { isRefreshing ->
if (isRefreshing) {
onRefresh()
}
}
}

LaunchedEffect(pullToRefreshState) {
snapshotFlow { hoYoLABGameRedemptionCodesState() }.flowOn(Dispatchers.IO).catch { }
.collect {
when (it) {
LCE.Loading -> {

}

else -> {
if (pullToRefreshState.isRefreshing) {
pullToRefreshState.endRefresh()
}
}
}
}
}

Scaffold(
snackbarHost = {
Expand All @@ -133,7 +159,7 @@ private fun RedemptionCodesContent(
modifier = Modifier
.fillMaxSize()
.padding(innerPadding)
.pullRefresh(pullRefreshState)
.nestedScroll(pullToRefreshState.nestedScrollConnection)
) {
LazyColumn(
modifier = Modifier
Expand Down Expand Up @@ -212,12 +238,9 @@ private fun RedemptionCodesContent(
}
}

PullRefreshIndicator(
refreshing = hoYoLABGameRedemptionCodesState().isLoading,
state = pullRefreshState,
PullToRefreshContainer(
modifier = Modifier.align(Alignment.TopCenter),
backgroundColor = MaterialTheme.colorScheme.surface,
contentColor = contentColorFor(backgroundColor = MaterialTheme.colorScheme.surface)
state = pullToRefreshState
)
}
}
Expand Down
Loading