Skip to content

Commit

Permalink
refactor: Improve MediaStoreReceiver and dependencies
Browse files Browse the repository at this point in the history
- Improved the MediaStoreReceiver to be more efficient and cleaner:
    - Refactored code for better readability and organization.
    - Simplified logic for building selection queries and arguments.
    - Added support for filtering by album.
- Updated dependencies:
    - Updated Firebase Bom version to 33.6.0.
    - Removed unnecessary dependencies: Lyricfier, Compose UI Utilities, Hilt, Okhttp3 Datasource.
    - Added LeakCanary for debug builds.
    - Replaced Hilt with Koin for dependency injection.
  • Loading branch information
BobbyESP committed Nov 29, 2024
1 parent e4f46f8 commit df90eb2
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 258 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ dependencies {
implementation(libs.compose.tooling.preview)
debugImplementation(libs.compose.tooling)
debugImplementation(libs.compose.test.manifest)

debugImplementation(libs.leakcanary)
}

class RoomSchemaArgProvider(
Expand Down
2 changes: 1 addition & 1 deletion app/mediaplayer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
implementation(libs.core.appcompat)
implementation(libs.androidx.legacy.support.v4) // Needed MediaSessionCompat.Token

//DI (Dependency Injection - Hilt)
//DI (Dependency Injection - Koin)
implementation(libs.bundles.koin)

//Media3
Expand Down
109 changes: 50 additions & 59 deletions app/ui/src/main/java/com/bobbyesp/ui/common/pages/ErrorPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.WarningAmber
import androidx.compose.material.icons.twotone.BugReport
import androidx.compose.material3.Button
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.darkColorScheme
Expand Down Expand Up @@ -130,64 +128,57 @@ private fun SharedTransitionScope.MinimizedErrorPage(
onCardClicked: () -> Unit,
onRetry: () -> Unit,
) {
OutlinedCard(
modifier = Modifier,
colors = CardDefaults.outlinedCardColors(
containerColor = MaterialTheme.colorScheme.errorContainer,
),
shape = MaterialTheme.shapes.small
Column(
modifier = modifier
.padding(8.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Column(
modifier = modifier
.padding(8.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Icon(
modifier = Modifier.size(48.dp),
imageVector = Icons.Rounded.WarningAmber,
contentDescription = stringResource(id = R.string.error),
)
Text(
text = stringResource(id = R.string.unknown_error_title),
style = MaterialTheme.typography.titleLarge.copy(
color = MaterialTheme.colorScheme.onBackground
),
fontWeight = FontWeight.SemiBold,
)
PrimaryStacktraceCard(
modifier = Modifier
.sharedBounds(
boundsTransform = DefaultBoundsTransform,
enter = fadeIn(
tween(
durationMillis = DURATION_ENTER,
delayMillis = DURATION_EXIT_SHORT,
easing = EmphasizedDecelerateEasing
)
),
exit = fadeOut(
tween(
durationMillis = DURATION_EXIT_SHORT,
easing = EmphasizedAccelerateEasing
)
),
sharedContentState = rememberSharedContentState(key = "stacktraceCardBounds"),
animatedVisibilityScope = animatedVisibilityScope,
placeHolderSize = SharedTransitionScope.PlaceHolderSize.animatedSize,
)
.padding(horizontal = 12.dp, vertical = 8.dp)
.fillMaxWidth(),
errorType = throwable::class.simpleName
?: stringResource(id = R.string.unknown_error_title),
methodFailed = throwable.localizedMessage
?: stringResource(id = R.string.unknown_error_title),
line = throwable.stackTrace.firstOrNull()?.lineNumber ?: 0,
onClick = onCardClicked
)
Button(onClick = onRetry) {
Text(text = stringResource(id = R.string.retry))
}
Icon(
modifier = Modifier.size(48.dp),
imageVector = Icons.Rounded.WarningAmber,
contentDescription = stringResource(id = R.string.error),
tint = MaterialTheme.colorScheme.error
)
Text(
text = stringResource(id = R.string.unknown_error_title),
style = MaterialTheme.typography.titleLarge.copy(
color = MaterialTheme.colorScheme.onBackground
),
fontWeight = FontWeight.SemiBold,
)
PrimaryStacktraceCard(
modifier = Modifier
.sharedBounds(
boundsTransform = DefaultBoundsTransform,
enter = fadeIn(
tween(
durationMillis = DURATION_ENTER,
delayMillis = DURATION_EXIT_SHORT,
easing = EmphasizedDecelerateEasing
)
),
exit = fadeOut(
tween(
durationMillis = DURATION_EXIT_SHORT,
easing = EmphasizedAccelerateEasing
)
),
sharedContentState = rememberSharedContentState(key = "stacktraceCardBounds"),
animatedVisibilityScope = animatedVisibilityScope,
placeHolderSize = SharedTransitionScope.PlaceHolderSize.animatedSize,
)
.padding(horizontal = 12.dp, vertical = 8.dp)
.fillMaxWidth(),
errorType = throwable::class.simpleName
?: stringResource(id = R.string.unknown_error_title),
methodFailed = throwable.localizedMessage
?: stringResource(id = R.string.unknown_error_title),
line = throwable.stackTrace.firstOrNull()?.lineNumber ?: 0,
onClick = onCardClicked
)
Button(onClick = onRetry) {
Text(text = stringResource(id = R.string.retry))
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions app/utilities/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ dependencies {
implementation(libs.kotlinx.serialization.json)
implementation(libs.mmkv)
implementation(libs.bundles.compose)
implementation(libs.compose.ui.utilities)
implementation(libs.paging.compose)
implementation(libs.paging.runtime)
implementation(libs.coil)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.bundles.coroutines)
//Accompanist libraries
implementation(libs.bundles.accompanist)

androidTestImplementation(platform(libs.compose.bom))
Expand Down
Loading

0 comments on commit df90eb2

Please sign in to comment.