Skip to content

Commit

Permalink
Merge pull request #344 from joeloewi7178/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
joeloewi7178 authored Jan 30, 2024
2 parents 125bd37 + 21a5cea commit f55835e
Show file tree
Hide file tree
Showing 50 changed files with 863 additions and 825 deletions.
7 changes: 4 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {

defaultConfig {
applicationId = "com.joeloewi.croissant"
versionCode = 54
versionName = "1.2.5"
versionCode = 55
versionName = "1.2.6"
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -106,7 +106,6 @@ dependencies {
//accompanist
implementation(libs.accompanist.permissions)
implementation(libs.accompanist.pager)
implementation(libs.accompanist.placeholder)
implementation(libs.accompanist.systemuicontroller)
implementation(libs.accompanist.webview)
implementation(libs.accompanist.pager.indicators)
Expand Down Expand Up @@ -155,4 +154,6 @@ dependencies {

//open source license activity
implementation(libs.gms.play.services.oss.licenses)

implementation(libs.fornewid.placeholder.material3)
}
433 changes: 216 additions & 217 deletions app/src/main/kotlin/com/joeloewi/croissant/MainActivity.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ import android.content.Context
import android.content.Intent
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.work.Constraints
import androidx.work.ExistingWorkPolicy
import androidx.work.NetworkType
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.OutOfQuotaPolicy
import androidx.work.WorkManager
import androidx.work.workDataOf
import com.google.firebase.Firebase
import com.google.firebase.crashlytics.crashlytics
import com.joeloewi.croissant.BuildConfig
Expand Down Expand Up @@ -77,15 +72,9 @@ class AlarmReceiver : BroadcastReceiver() {
val attendanceId = p1.getLongExtra(ATTENDANCE_ID, Long.MIN_VALUE)
val attendanceWithGames = getOneAttendanceUseCase(attendanceId)
val attendance = attendanceWithGames.attendance
val oneTimeWork = OneTimeWorkRequestBuilder<AttendCheckInEventWorker>()
.setInputData(workDataOf(AttendCheckInEventWorker.ATTENDANCE_ID to attendance.id))
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
)
.build()
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 @@ -6,12 +6,8 @@ import android.content.Context
import android.os.PowerManager
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.work.Constraints
import androidx.work.ExistingWorkPolicy
import androidx.work.NetworkType
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import androidx.work.workDataOf
import com.google.firebase.Firebase
import com.google.firebase.crashlytics.crashlytics
import com.joeloewi.croissant.domain.usecase.ResinStatusWidgetUseCase
Expand Down Expand Up @@ -72,16 +68,7 @@ class ResinStatusWidgetProvider : AppWidgetProvider() {
invoke(appWidgetId)
}.mapCatching {
val oneTimeWorkRequest =
OneTimeWorkRequest.Builder(RefreshResinStatusWorker::class.java)
.setInputData(
workDataOf(RefreshResinStatusWorker.APP_WIDGET_ID to appWidgetId)
)
.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
)
.build()
RefreshResinStatusWorker.buildOneTimeWork(appWidgetId = appWidgetId)

workManager.enqueueUniqueWork(
it.resinStatusWidget.id.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,30 @@ sealed class AttendancesDestination {

data object AttendanceDetailScreen : AttendancesDestination() {
const val ATTENDANCE_ID = "attendanceId"
const val FROM_DEEPLINK = "fromDeeplink"

override val arguments: List<Pair<String, (NavArgumentBuilder.() -> Unit)>> = listOf(
ATTENDANCE_ID to {
type = NavType.LongType

},
FROM_DEEPLINK to {
type = NavType.BoolType
defaultValue = false
}
)

override val plainRoute: String = "attendanceDetailScreen"

override val route: String
get() = "${plainRoute}/{${ATTENDANCE_ID}}?${FROM_DEEPLINK}={${FROM_DEEPLINK}}"
get() = "${plainRoute}/{${ATTENDANCE_ID}}"

fun generateRoute(
attendanceId: Long,
fromDeeplink: Boolean = false
) = "${plainRoute}/$attendanceId?${FROM_DEEPLINK}={$fromDeeplink}"
attendanceId: Long
) = "${plainRoute}/$attendanceId"

fun generateDeepLinkUri(
context: Context,
attendanceId: Long,
fromDeeplink: Boolean = true
attendanceId: Long
): Uri = Uri.Builder()
.scheme(context.getString(R.string.deep_link_scheme))
.authority(context.packageName)
.appendEncodedPath(plainRoute)
.appendPath("$attendanceId")
.appendQueryParameter(FROM_DEEPLINK, "$fromDeeplink")
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.NavigateNext
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.Error
import androidx.compose.material.icons.filled.NavigateNext
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Save
import androidx.compose.material.icons.filled.Warning
Expand Down Expand Up @@ -569,8 +569,8 @@ fun LogSummaryRow(
horizontalAlignment = Alignment.CenterHorizontally
) {
Icon(
imageVector = Icons.Default.NavigateNext,
contentDescription = Icons.Default.NavigateNext.name
imageVector = Icons.AutoMirrored.Default.NavigateNext,
contentDescription = Icons.AutoMirrored.Default.NavigateNext.name
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ import androidx.paging.compose.itemContentType
import androidx.paging.compose.itemKey
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.google.accompanist.placeholder.PlaceholderHighlight
import com.google.accompanist.placeholder.fade
import com.google.accompanist.placeholder.placeholder
import com.joeloewi.croissant.R
import com.joeloewi.croissant.domain.common.WorkerExecutionLogState
import com.joeloewi.croissant.domain.entity.relational.WorkerExecutionLogWithState
Expand All @@ -48,6 +45,9 @@ import com.joeloewi.croissant.ui.theme.IconDp
import com.joeloewi.croissant.util.collectAsLazyPagingItemsWithLifecycle
import com.joeloewi.croissant.util.navigationIconButton
import com.joeloewi.croissant.viewmodel.AttendanceLogsDayViewModel
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.foundation.fade
import io.github.fornewid.placeholder.foundation.placeholder
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,18 @@ import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.itemKey
import androidx.work.Constraints
import androidx.work.ExistingWorkPolicy
import androidx.work.NetworkType
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.OutOfQuotaPolicy
import androidx.work.WorkInfo
import androidx.work.WorkManager
import androidx.work.workDataOf
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.google.accompanist.placeholder.PlaceholderHighlight
import com.google.accompanist.placeholder.fade
import com.google.accompanist.placeholder.placeholder
import com.google.firebase.Firebase
import com.google.firebase.analytics.analytics
import com.joeloewi.croissant.R
import com.joeloewi.croissant.domain.entity.Attendance
import com.joeloewi.croissant.domain.entity.relational.AttendanceWithGames
Expand All @@ -98,6 +93,9 @@ import com.joeloewi.croissant.util.isEmpty
import com.joeloewi.croissant.util.requestReview
import com.joeloewi.croissant.viewmodel.AttendancesViewModel
import com.joeloewi.croissant.worker.AttendCheckInEventWorker
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.foundation.fade
import io.github.fornewid.placeholder.foundation.placeholder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
Expand Down Expand Up @@ -258,15 +256,11 @@ fun AttendanceWithGamesItem(
attendanceWithGames = item,
onClickOneTimeAttend = remember {
{ attendance ->
val oneTimeWork = OneTimeWorkRequestBuilder<AttendCheckInEventWorker>()
.setInputData(workDataOf(AttendCheckInEventWorker.ATTENDANCE_ID to attendance.id))
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
.setConstraints(
Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
)
.build()
Firebase.analytics.logEvent("instant_attend_click", bundleOf())

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

WorkManager.getInstance(context).beginUniqueWork(
attendance.oneTimeAttendCheckInEventWorkerName.toString(),
Expand Down Expand Up @@ -398,6 +392,8 @@ private fun DismissContent(
ZonedDateTime.now(ZoneId.of(timezoneId))
.withHour(hourOfDay)
.withMinute(minute)
.withSecond(30)
.withNano(0)
}.format(
dateTimeFormatterPerHourFormat(hourFormat)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.window.DialogProperties
import androidx.core.view.WindowCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature
import com.google.accompanist.web.*
Expand Down Expand Up @@ -156,7 +158,15 @@ fun LoginHoYoLABContent(
Column {
TopAppBar(
navigationIcon = {
IconButton(onClick = onNavigateUp) {
IconButton(onClick = {
with(lifecycleOwner) {
lifecycleScope.launch(CoroutineExceptionHandler { _, _ -> }) {
if (lifecycle.currentState == Lifecycle.State.RESUMED) {
onNavigateUp()
}
}
}
}) {
Icon(
imageVector = Icons.Default.Close,
contentDescription = Icons.Default.Close.name
Expand Down Expand Up @@ -452,7 +462,7 @@ fun LoginHoYoLABContent(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
CircularProgressIndicator()

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.window.DialogProperties
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.google.accompanist.placeholder.PlaceholderHighlight
import com.google.accompanist.placeholder.fade
import com.google.accompanist.placeholder.placeholder
import com.joeloewi.croissant.R
import com.joeloewi.croissant.domain.common.HoYoLABGame
import com.joeloewi.croissant.domain.entity.Attendance
Expand All @@ -71,6 +68,9 @@ import com.joeloewi.croissant.state.StableWrapper
import com.joeloewi.croissant.ui.theme.DefaultDp
import com.joeloewi.croissant.ui.theme.IconDp
import com.joeloewi.croissant.util.gameNameStringResId
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.toImmutableList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.catch
Expand Down
Loading

0 comments on commit f55835e

Please sign in to comment.