diff --git a/app/src/main/java/cc/skysparkle/fogwave/MainActivity.kt b/app/src/main/java/cc/skysparkle/fogwave/MainActivity.kt index 97c4366..72deba6 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/MainActivity.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/MainActivity.kt @@ -11,11 +11,13 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.ui.Modifier import cc.skysparkle.fogwave.ui.screens.HomeScreen +import cc.skysparkle.fogwave.ui.theme.AppThemeState import cc.skysparkle.fogwave.ui.theme.FogwaveTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + AppThemeState.load(this) enableEdgeToEdge( statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT), navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT) diff --git a/app/src/main/java/cc/skysparkle/fogwave/ui/components/AboutPanel.kt b/app/src/main/java/cc/skysparkle/fogwave/ui/components/AboutPanel.kt index ba92ad1..5f6be60 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/ui/components/AboutPanel.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/ui/components/AboutPanel.kt @@ -1,40 +1,52 @@ package cc.skysparkle.fogwave.ui.components import androidx.annotation.DrawableRes +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.animateColorAsState import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.selection.selectable +import androidx.compose.foundation.selection.toggleable import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Switch +import androidx.compose.material3.SwitchDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import cc.skysparkle.fogwave.BuildConfig import cc.skysparkle.fogwave.R +import cc.skysparkle.fogwave.ui.theme.AppStyle +import cc.skysparkle.fogwave.ui.theme.AppThemeState +import cc.skysparkle.fogwave.ui.theme.GeoColors import cc.skysparkle.fogwave.ui.theme.LocalGeoColors private const val REPOSITORY_URL = "https://git.skysparkle.cc/kalarina/Fogwave" @@ -48,92 +60,47 @@ fun AboutPanel(modifier: Modifier = Modifier) { Column( modifier = modifier .fillMaxWidth() - .padding(horizontal = 20.dp, vertical = 12.dp), - verticalArrangement = Arrangement.spacedBy(16.dp) + .padding(horizontal = 20.dp, vertical = 8.dp), + verticalArrangement = Arrangement.spacedBy(10.dp) ) { - Column( - modifier = Modifier - .fillMaxWidth() - .shadow(4.dp, RoundedCornerShape(24.dp)) - .clip(RoundedCornerShape(24.dp)) - .background(LocalGeoColors.current.surfaceContainer) - .border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(24.dp)) - .padding(20.dp), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.spacedBy(10.dp) - ) { - Box( - modifier = Modifier - .size(64.dp) - .clip(RoundedCornerShape(20.dp)), - contentAlignment = Alignment.Center - ) { - AppIcon( - resId = R.drawable.ic_fogwave_logo, - contentDescription = stringResource(R.string.fogwave_logo_content_desc), - size = 52.dp - ) - } + AppHeader() - Text( - text = stringResource(R.string.app_name), - style = MaterialTheme.typography.titleLarge.copy( - fontWeight = FontWeight.ExtraBold, - fontSize = 22.sp, - letterSpacing = (-0.5).sp, - color = LocalGeoColors.current.deepPurple - ) - ) - - // Comes straight from versionName in app/build.gradle.kts, so it can never drift. - Text( - text = stringResource(R.string.about_version, BuildConfig.VERSION_NAME), - style = MaterialTheme.typography.labelMedium.copy( - fontWeight = FontWeight.SemiBold, - color = LocalGeoColors.current.primary - ), - modifier = Modifier.testTag("about_version") - ) - - Text( - text = stringResource(R.string.about_description), - style = MaterialTheme.typography.bodyMedium.copy( - fontSize = 13.5.sp, - lineHeight = 20.sp, - color = LocalGeoColors.current.onSurfaceVariant, - textAlign = TextAlign.Center - ), - modifier = Modifier.padding(top = 4.dp) - ) + SectionLabel(stringResource(R.string.about_appearance)) + GroupCard { + StylePicker() + CardDivider() + StationFogRow() } - AboutLinkCard( - iconRes = R.drawable.ic_repo, - iconTint = null, - title = stringResource(R.string.about_my_repository), - subtitle = REPOSITORY_URL.removePrefix("https://git.skysparkle.cc/"), - trailingIconRes = R.drawable.ic_open_in_new, - onClick = { context.openUrl(REPOSITORY_URL) }, - modifier = Modifier.testTag("github_repo_card") - ) - - AboutLinkCard( - iconRes = R.drawable.ic_privacy, - title = stringResource(R.string.privacy_title), - subtitle = stringResource(R.string.privacy_subtitle), - trailingIconRes = R.drawable.ic_open_in_new, - onClick = { context.openUrl(PRIVACY_POLICY_URL) }, - modifier = Modifier.testTag("privacy_card") - ) - - AboutLinkCard( - iconRes = R.drawable.ic_copyright, - title = stringResource(R.string.licenses_title), - subtitle = stringResource(R.string.licenses_subtitle), - trailingIconRes = R.drawable.ic_chevron_right, - onClick = { showLicenses = true }, - modifier = Modifier.testTag("licenses_card") - ) + SectionLabel(stringResource(R.string.about_more)) + GroupCard { + LinkRow( + iconRes = R.drawable.ic_mc_code, + title = stringResource(R.string.about_my_repository), + subtitle = REPOSITORY_URL.removePrefix("https://"), + external = true, + onClick = { context.openUrl(REPOSITORY_URL) }, + modifier = Modifier.testTag("github_repo_card") + ) + CardDivider() + LinkRow( + iconRes = R.drawable.ic_mc_shield, + title = stringResource(R.string.privacy_title), + subtitle = stringResource(R.string.privacy_subtitle), + external = true, + onClick = { context.openUrl(PRIVACY_POLICY_URL) }, + modifier = Modifier.testTag("privacy_card") + ) + CardDivider() + LinkRow( + iconRes = R.drawable.ic_mc_copyright, + title = stringResource(R.string.licenses_title), + subtitle = stringResource(R.string.licenses_subtitle), + external = false, + onClick = { showLicenses = true }, + modifier = Modifier.testTag("licenses_card") + ) + } } if (showLicenses) { @@ -141,86 +108,324 @@ fun AboutPanel(modifier: Modifier = Modifier) { } } +/** Logo, name and version in one row, the description underneath. */ @Composable -private fun AboutLinkCard( - @DrawableRes iconRes: Int, - title: String, - subtitle: String, - @DrawableRes trailingIconRes: Int, - onClick: () -> Unit, - modifier: Modifier = Modifier, - iconTint: Color? = LocalGeoColors.current.deepPurple -) { - val opensBrowser = trailingIconRes == R.drawable.ic_open_in_new - Row( - modifier = modifier - .fillMaxWidth() - .shadow(4.dp, RoundedCornerShape(20.dp)) - .clip(RoundedCornerShape(20.dp)) - .background(LocalGeoColors.current.surfaceContainer) - .border(1.2.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(20.dp)) - .clickable( - onClickLabel = if (opensBrowser) stringResource(R.string.about_open_in_browser) else null, - role = Role.Button, - onClick = onClick - ) - .padding(16.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(14.dp) - ) { - Box( - modifier = Modifier - .size(48.dp) - .clip(RoundedCornerShape(14.dp)) - .background(LocalGeoColors.current.primaryContainer) - .border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(14.dp)), - contentAlignment = Alignment.Center +private fun AppHeader() { + val colors = LocalGeoColors.current + GroupCard(contentPadding = 16.dp) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(14.dp) ) { - AppIcon( - resId = iconRes, - tint = iconTint ?: Color.Unspecified, - size = if (iconTint == null) 32.dp else 26.dp - ) - } - - Column(modifier = Modifier.weight(1f)) { - Text( - text = title, - style = MaterialTheme.typography.titleSmall.copy( - fontWeight = FontWeight.Bold, - fontSize = 15.sp, - color = LocalGeoColors.current.deepPurple - ) - ) - Text( - text = subtitle, - style = MaterialTheme.typography.bodySmall.copy( - fontSize = 12.sp, - color = LocalGeoColors.current.primary - ) - ) - } - - if (opensBrowser) { Box( modifier = Modifier - .size(36.dp) - .clip(CircleShape) - .background(LocalGeoColors.current.primaryContainer), + .size(52.dp) + .clip(RoundedCornerShape(16.dp)) + .background(colors.primaryContainer), contentAlignment = Alignment.Center ) { AppIcon( - resId = trailingIconRes, - tint = LocalGeoColors.current.deepPurple, - size = 18.dp + resId = R.drawable.ic_fogwave_logo, + contentDescription = stringResource(R.string.fogwave_logo_content_desc), + size = 40.dp ) } - } else { - AppIcon( - resId = trailingIconRes, - tint = LocalGeoColors.current.onSurfaceVariant, - size = 18.dp + Column(verticalArrangement = Arrangement.spacedBy(4.dp)) { + Text( + text = stringResource(R.string.app_name), + style = MaterialTheme.typography.titleLarge.copy( + fontWeight = FontWeight.ExtraBold, + fontSize = 21.sp, + letterSpacing = (-0.4).sp, + color = colors.deepPurple + ) + ) + // Comes straight from versionName in app/build.gradle.kts, so it can never drift. + Text( + text = stringResource(R.string.about_version, BuildConfig.VERSION_NAME), + style = MaterialTheme.typography.labelSmall.copy( + fontWeight = FontWeight.Bold, + fontSize = 11.sp, + color = colors.primary + ), + modifier = Modifier + .clip(CircleShape) + .background(colors.primaryContainer) + .padding(horizontal = 9.dp, vertical = 3.dp) + .testTag("about_version") + ) + } + } + Text( + text = stringResource(R.string.about_description), + style = MaterialTheme.typography.bodySmall.copy( + fontSize = 13.sp, + lineHeight = 19.sp, + color = colors.onSurfaceVariant + ), + modifier = Modifier.padding(top = 12.dp) + ) + } +} + +@Composable +private fun StylePicker() { + val context = LocalContext.current + val colors = LocalGeoColors.current + val selected = AppThemeState.style + val styles = remember { AppStyle.available } + + Column(modifier = Modifier.padding(16.dp)) { + RowHeader(iconRes = R.drawable.ic_mc_palette, title = stringResource(R.string.app_style_title)) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(top = 14.dp), + horizontalArrangement = Arrangement.spacedBy(4.dp) + ) { + styles.forEach { style -> + StyleSwatch( + style = style, + preview = remember(style) { AppThemeState.colorsFor(context, style) }, + selected = style == selected, + onClick = { AppThemeState.select(context, style) }, + modifier = Modifier.weight(1f) + ) + } + } + AnimatedVisibility(visible = selected == AppStyle.DEVICE) { + Text( + text = stringResource(R.string.app_style_device_hint), + style = MaterialTheme.typography.bodySmall.copy( + fontSize = 12.sp, + lineHeight = 17.sp, + color = colors.onSurfaceVariant + ), + modifier = Modifier.padding(top = 12.dp) ) } } } + +@Composable +private fun StyleSwatch( + style: AppStyle, + preview: GeoColors, + selected: Boolean, + onClick: () -> Unit, + modifier: Modifier = Modifier +) { + val colors = LocalGeoColors.current + val ring by animateColorAsState(if (selected) colors.deepPurple else Color.Transparent, label = "swatch_ring") + + Column( + modifier = modifier + .clip(RoundedCornerShape(14.dp)) + .selectable(selected = selected, role = Role.RadioButton, onClick = onClick) + .padding(vertical = 6.dp) + .testTag("style_${style.name.lowercase()}"), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(6.dp) + ) { + // The outer ring shows the selection; inside, the style's accent over its background + Box( + modifier = Modifier + .size(42.dp) + .border(2.dp, ring, CircleShape) + .padding(4.dp) + .clip(CircleShape) + .background(preview.surfaceContainerHigh), + contentAlignment = Alignment.Center + ) { + Box( + modifier = Modifier + .size(24.dp) + .clip(CircleShape) + .background(preview.accentLavender), + contentAlignment = Alignment.Center + ) { + if (selected) { + AppIcon(resId = R.drawable.ic_mc_check, tint = preview.onAccentLavender, size = 15.dp) + } + } + } + Text( + text = stringResource(style.titleRes), + style = MaterialTheme.typography.labelSmall.copy( + fontSize = 11.sp, + fontWeight = if (selected) FontWeight.Bold else FontWeight.Medium, + color = if (selected) colors.deepPurple else colors.onSurfaceVariant + ), + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + } +} + +@Composable +private fun StationFogRow() { + val context = LocalContext.current + val colors = LocalGeoColors.current + val checked = AppThemeState.stationFog + + Row( + modifier = Modifier + .fillMaxWidth() + .toggleable( + value = checked, + role = Role.Switch, + onValueChange = { AppThemeState.setStationFog(context, it) } + ) + .padding(16.dp) + .testTag("station_fog_toggle"), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + RowIcon(R.drawable.ic_mc_fog) + Column(modifier = Modifier.weight(1f)) { + RowTitle(stringResource(R.string.station_fog_title)) + RowSubtitle(stringResource(R.string.station_fog_subtitle), maxLines = 3) + } + // The row handles the tap, so the switch itself only shows the state + Switch( + checked = checked, + onCheckedChange = null, + colors = SwitchDefaults.colors( + checkedThumbColor = colors.onAccentLavender, + checkedTrackColor = colors.accentLavender, + checkedBorderColor = colors.accentLavender, + uncheckedThumbColor = colors.onSurfaceVariant, + uncheckedTrackColor = colors.surfaceContainerHigh, + uncheckedBorderColor = colors.outline + ) + ) + } +} + +@Composable +private fun LinkRow( + @DrawableRes iconRes: Int, + title: String, + subtitle: String, + external: Boolean, + onClick: () -> Unit, + modifier: Modifier = Modifier +) { + Row( + modifier = modifier + .fillMaxWidth() + .clickable( + onClickLabel = if (external) stringResource(R.string.about_open_in_browser) else null, + role = Role.Button, + onClick = onClick + ) + .padding(horizontal = 16.dp, vertical = 13.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + RowIcon(iconRes) + Column(modifier = Modifier.weight(1f)) { + RowTitle(title) + RowSubtitle(subtitle) + } + AppIcon( + resId = if (external) R.drawable.ic_mc_external else R.drawable.ic_mc_right, + tint = LocalGeoColors.current.onSurfaceVariant, + size = 18.dp + ) + } +} + +@Composable +private fun RowHeader(@DrawableRes iconRes: Int, title: String) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + RowIcon(iconRes) + RowTitle(title) + } +} + +@Composable +private fun RowIcon(@DrawableRes iconRes: Int) { + Box( + modifier = Modifier + .size(36.dp) + .clip(RoundedCornerShape(11.dp)) + .background(LocalGeoColors.current.primaryContainer), + contentAlignment = Alignment.Center + ) { + AppIcon(resId = iconRes, tint = LocalGeoColors.current.primary, size = 20.dp) + } +} + +@Composable +private fun RowTitle(text: String) { + Text( + text = text, + style = MaterialTheme.typography.titleSmall.copy( + fontWeight = FontWeight.Bold, + fontSize = 14.5.sp, + color = LocalGeoColors.current.deepPurple + ), + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) +} + +@Composable +private fun RowSubtitle(text: String, maxLines: Int = 1) { + Text( + text = text, + style = MaterialTheme.typography.bodySmall.copy( + fontSize = 12.sp, + lineHeight = 16.sp, + color = LocalGeoColors.current.onSurfaceVariant + ), + maxLines = maxLines, + overflow = TextOverflow.Ellipsis + ) +} + +@Composable +private fun SectionLabel(text: String) { + Text( + text = text.uppercase(), + style = MaterialTheme.typography.labelSmall.copy( + fontWeight = FontWeight.Bold, + fontSize = 11.sp, + letterSpacing = 1.2.sp, + color = LocalGeoColors.current.onSurfaceVariant + ), + modifier = Modifier.padding(start = 6.dp, top = 8.dp) + ) +} + +/** Rows grouped on one rounded card, like a settings list. */ +@Composable +private fun GroupCard( + contentPadding: Dp = 0.dp, + content: @Composable ColumnScope.() -> Unit +) { + Column( + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(22.dp)) + .background(LocalGeoColors.current.surfaceContainer) + .border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(22.dp)) + .padding(contentPadding), + content = content + ) +} + +@Composable +private fun CardDivider() { + Box( + modifier = Modifier + .fillMaxWidth() + .padding(start = 64.dp) + .height(1.dp) + .background(LocalGeoColors.current.outlineVariant) + ) +} diff --git a/app/src/main/java/cc/skysparkle/fogwave/ui/components/NowPlayingSheet.kt b/app/src/main/java/cc/skysparkle/fogwave/ui/components/NowPlayingSheet.kt index a9a7374..3ceb41c 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/ui/components/NowPlayingSheet.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/ui/components/NowPlayingSheet.kt @@ -77,6 +77,7 @@ import cc.skysparkle.fogwave.data.model.ExtraPlayerTab import cc.skysparkle.fogwave.data.model.RadioStation import cc.skysparkle.fogwave.player.AudioEffectsState import cc.skysparkle.fogwave.player.PlayerState +import cc.skysparkle.fogwave.ui.theme.AppThemeState import cc.skysparkle.fogwave.ui.theme.LocalGeoColors import kotlin.math.roundToInt @@ -120,7 +121,7 @@ fun NowPlayingSheet( ) } val accent by animateColorAsState( - targetValue = rememberStationArt(station).accentOr(colors.accentLavender), + targetValue = rememberStationArt(station).takeIf { AppThemeState.stationFog }.accentOr(colors.accentLavender), animationSpec = tween(700), label = "page_accent" ) diff --git a/app/src/main/java/cc/skysparkle/fogwave/ui/components/StationDisc.kt b/app/src/main/java/cc/skysparkle/fogwave/ui/components/StationDisc.kt index 7b0474b..3353d2a 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/ui/components/StationDisc.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/ui/components/StationDisc.kt @@ -32,6 +32,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import cc.skysparkle.fogwave.data.model.RadioStation +import cc.skysparkle.fogwave.ui.theme.AppThemeState import cc.skysparkle.fogwave.ui.theme.LocalGeoColors import kotlin.math.cos import kotlin.math.min @@ -56,7 +57,7 @@ fun StationDisc( val colors = LocalGeoColors.current val art = rememberStationArt(station) val accent by animateColorAsState( - targetValue = art.accentOr(colors.primary), + targetValue = art.takeIf { AppThemeState.stationFog }.accentOr(colors.primary), animationSpec = tween(600), label = "disc_accent" ) diff --git a/app/src/main/java/cc/skysparkle/fogwave/ui/screens/HomeScreen.kt b/app/src/main/java/cc/skysparkle/fogwave/ui/screens/HomeScreen.kt index e86ad76..1b4e25f 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/ui/screens/HomeScreen.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/ui/screens/HomeScreen.kt @@ -73,6 +73,7 @@ import cc.skysparkle.fogwave.ui.components.TopBrandBar import cc.skysparkle.fogwave.ui.components.accentOr import cc.skysparkle.fogwave.ui.components.rememberStationArt import cc.skysparkle.fogwave.ui.components.stationDescription +import cc.skysparkle.fogwave.ui.theme.AppThemeState import cc.skysparkle.fogwave.ui.theme.LocalGeoColors import cc.skysparkle.fogwave.ui.viewmodel.RadioViewModel @@ -116,7 +117,10 @@ fun HomeScreen( val radioListState = rememberLazyListState() val accent by animateColorAsState( - targetValue = uiState.currentStation?.let { rememberStationArt(it) }.accentOr(LocalGeoColors.current.accentLavender), + // The style's colour unless the user asked for each station's own + targetValue = uiState.currentStation?.let { rememberStationArt(it) } + .takeIf { AppThemeState.stationFog } + .accentOr(LocalGeoColors.current.accentLavender), animationSpec = tween(700), label = "home_accent" ) diff --git a/app/src/main/java/cc/skysparkle/fogwave/ui/theme/AppStyle.kt b/app/src/main/java/cc/skysparkle/fogwave/ui/theme/AppStyle.kt new file mode 100644 index 0000000..e2345a4 --- /dev/null +++ b/app/src/main/java/cc/skysparkle/fogwave/ui/theme/AppStyle.kt @@ -0,0 +1,126 @@ +package cc.skysparkle.fogwave.ui.theme + +import android.content.Context +import android.os.Build +import androidx.annotation.StringRes +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.lerp +import cc.skysparkle.fogwave.R + +/** Colour styles, the same set as in Matewave. Every style is dark. */ +enum class AppStyle(@param:StringRes val titleRes: Int) { + FOGWAVE(R.string.app_style_fogwave), + LAVENDER(R.string.app_style_lavender), + PEACH(R.string.app_style_peach), + MINT(R.string.app_style_mint), + SKY(R.string.app_style_sky), + DEVICE(R.string.app_style_device); + + companion object { + /** Wallpaper colours exist from Android 12. */ + val deviceSupported: Boolean get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S + + val available: List get() = entries.filter { it != DEVICE || deviceSupported } + } +} + +/** The selected style, kept in compose state so every screen recolours at once. */ +object AppThemeState { + private const val PREFS = "app_theme" + private const val KEY_STYLE = "style" + private const val KEY_STATION_FOG = "station_fog" + + var style by mutableStateOf(AppStyle.FOGWAVE) + private set + + var colors by mutableStateOf(DarkGeoColors) + private set + + /** Fog and the disc ring take the playing station's colour instead of the style's. */ + var stationFog by mutableStateOf(false) + private set + + /** Reads the saved settings; call before the first frame. */ + fun load(context: Context) { + val prefs = prefs(context) + val saved = prefs.getString(KEY_STYLE, null) + stationFog = prefs.getBoolean(KEY_STATION_FOG, false) + apply(context, AppStyle.entries.firstOrNull { it.name == saved } ?: AppStyle.FOGWAVE) + } + + fun select(context: Context, style: AppStyle) { + prefs(context).edit().putString(KEY_STYLE, style.name).apply() + apply(context, style) + } + + fun setStationFog(context: Context, enabled: Boolean) { + prefs(context).edit().putBoolean(KEY_STATION_FOG, enabled).apply() + stationFog = enabled + } + + /** Colours of a style, also used for the previews in the picker. */ + fun colorsFor(context: Context, style: AppStyle): GeoColors = when (style) { + AppStyle.FOGWAVE -> DarkGeoColors + AppStyle.LAVENDER -> styleColors(Color(0xFFC8B6FF), Color(0xFF1E1630), Color(0xFF0F0E14), Color(0xFF1A1822), Color(0xFF25222F)) + AppStyle.PEACH -> styleColors(Color(0xFFFFB59E), Color(0xFF2A1710), Color(0xFF12100E), Color(0xFF1D1A17), Color(0xFF28231F)) + AppStyle.MINT -> styleColors(Color(0xFF9EE7C8), Color(0xFF0F231B), Color(0xFF0D110F), Color(0xFF171C1A), Color(0xFF202724)) + AppStyle.SKY -> styleColors(Color(0xFFA5CBFF), Color(0xFF0F1A2A), Color(0xFF0D1014), Color(0xFF171B21), Color(0xFF20252D)) + AppStyle.DEVICE -> deviceColors(context) + } + + private fun apply(context: Context, requested: AppStyle) { + val style = if (requested == AppStyle.DEVICE && !AppStyle.deviceSupported) AppStyle.FOGWAVE else requested + this.style = style + colors = colorsFor(context, style) + } + + private fun deviceColors(context: Context): GeoColors { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return DarkGeoColors + val scheme = dynamicDarkColorScheme(context) + return styleColors( + accent = scheme.primary, + onAccent = scheme.onPrimary, + background = scheme.background, + surface1 = scheme.surfaceContainer, + surface2 = scheme.surfaceContainerHigh + ) + } + + private fun prefs(context: Context) = + context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE) +} + +/** + * Builds the full set from a style's few colours. Pastel styles use their accent for buttons too, + * with dark text on top, like in Matewave. The live dot and the favourite heart keep their own red. + */ +private fun styleColors( + accent: Color, + onAccent: Color, + background: Color, + surface1: Color, + surface2: Color +): GeoColors = DarkGeoColors.copy( + background = background, + surface = background, + surfaceContainer = surface1, + surfaceContainerHigh = surface2, + onSurfaceVariant = lerp(Color(0xFF9AA0AA), accent, 0.12f), + outline = lerp(surface2, Color.White, 0.3f), + outlineVariant = lerp(surface2, Color.White, 0.06f), + primary = accent, + onPrimary = onAccent, + primaryContainer = lerp(background, accent, 0.22f), + onPrimaryContainer = lerp(accent, Color.White, 0.75f), + secondary = lerp(accent, Color.White, 0.4f), + onSecondary = onAccent, + secondaryContainer = lerp(surface2, accent, 0.18f), + onSecondaryContainer = lerp(accent, Color.White, 0.75f), + accentLavender = accent, + onAccentLavender = onAccent, + deepPurple = lerp(Color.White, accent, 0.06f) +) diff --git a/app/src/main/java/cc/skysparkle/fogwave/ui/theme/Theme.kt b/app/src/main/java/cc/skysparkle/fogwave/ui/theme/Theme.kt index c4d6d00..0aeef9c 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/ui/theme/Theme.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/ui/theme/Theme.kt @@ -1,33 +1,36 @@ package cc.skysparkle.fogwave.ui.theme +import androidx.compose.material3.ColorScheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.remember -private val DarkColorScheme = with(DarkGeoColors) { - darkColorScheme( - primary = primary, - onPrimary = onPrimary, - primaryContainer = primaryContainer, - onPrimaryContainer = onPrimaryContainer, - secondary = secondary, - onSecondary = onSecondary, - secondaryContainer = secondaryContainer, - onSecondaryContainer = onSecondaryContainer, - background = background, - onBackground = onBackground, - surface = surface, - onSurface = onSurface, - surfaceVariant = outlineVariant, - onSurfaceVariant = onSurfaceVariant, - outline = outline - ) -} +private fun GeoColors.toColorScheme(): ColorScheme = darkColorScheme( + primary = primary, + onPrimary = onPrimary, + primaryContainer = primaryContainer, + onPrimaryContainer = onPrimaryContainer, + secondary = secondary, + onSecondary = onSecondary, + secondaryContainer = secondaryContainer, + onSecondaryContainer = onSecondaryContainer, + background = background, + onBackground = onBackground, + surface = surface, + onSurface = onSurface, + surfaceVariant = outlineVariant, + onSurfaceVariant = onSurfaceVariant, + outline = outline +) +/** Always dark; the colours follow the style picked in About (see [AppThemeState]). */ @Composable fun FogwaveTheme(content: @Composable () -> Unit) { - CompositionLocalProvider(LocalGeoColors provides DarkGeoColors) { - MaterialTheme(colorScheme = DarkColorScheme, typography = Typography, content = content) + val colors = AppThemeState.colors + val scheme = remember(colors) { colors.toColorScheme() } + CompositionLocalProvider(LocalGeoColors provides colors) { + MaterialTheme(colorScheme = scheme, typography = Typography, content = content) } } diff --git a/app/src/main/res/drawable-nodpi/ic_chevron_right.webp b/app/src/main/res/drawable-nodpi/ic_chevron_right.webp deleted file mode 100644 index 8129ee5..0000000 Binary files a/app/src/main/res/drawable-nodpi/ic_chevron_right.webp and /dev/null differ diff --git a/app/src/main/res/drawable-nodpi/ic_copyright.webp b/app/src/main/res/drawable-nodpi/ic_copyright.webp deleted file mode 100644 index d548462..0000000 Binary files a/app/src/main/res/drawable-nodpi/ic_copyright.webp and /dev/null differ diff --git a/app/src/main/res/drawable-nodpi/ic_privacy.webp b/app/src/main/res/drawable-nodpi/ic_privacy.webp deleted file mode 100644 index 8a3d575..0000000 Binary files a/app/src/main/res/drawable-nodpi/ic_privacy.webp and /dev/null differ diff --git a/app/src/main/res/drawable-nodpi/ic_repo.webp b/app/src/main/res/drawable-nodpi/ic_repo.webp deleted file mode 100644 index 384c3b9..0000000 Binary files a/app/src/main/res/drawable-nodpi/ic_repo.webp and /dev/null differ diff --git a/app/src/main/res/drawable/ic_mc_check.xml b/app/src/main/res/drawable/ic_mc_check.xml new file mode 100644 index 0000000..063f774 --- /dev/null +++ b/app/src/main/res/drawable/ic_mc_check.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_mc_code.xml b/app/src/main/res/drawable/ic_mc_code.xml new file mode 100644 index 0000000..d847a4b --- /dev/null +++ b/app/src/main/res/drawable/ic_mc_code.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_mc_copyright.xml b/app/src/main/res/drawable/ic_mc_copyright.xml new file mode 100644 index 0000000..7281240 --- /dev/null +++ b/app/src/main/res/drawable/ic_mc_copyright.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_mc_external.xml b/app/src/main/res/drawable/ic_mc_external.xml new file mode 100644 index 0000000..498380d --- /dev/null +++ b/app/src/main/res/drawable/ic_mc_external.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_mc_fog.xml b/app/src/main/res/drawable/ic_mc_fog.xml new file mode 100644 index 0000000..73f9006 --- /dev/null +++ b/app/src/main/res/drawable/ic_mc_fog.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_mc_palette.xml b/app/src/main/res/drawable/ic_mc_palette.xml new file mode 100644 index 0000000..60fe82b --- /dev/null +++ b/app/src/main/res/drawable/ic_mc_palette.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_mc_right.xml b/app/src/main/res/drawable/ic_mc_right.xml new file mode 100644 index 0000000..e1ecfc3 --- /dev/null +++ b/app/src/main/res/drawable/ic_mc_right.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_mc_shield.xml b/app/src/main/res/drawable/ic_mc_shield.xml new file mode 100644 index 0000000..7e8b220 --- /dev/null +++ b/app/src/main/res/drawable/ic_mc_shield.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 7df3710..229bb24 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -114,4 +114,15 @@ Teilen Ich höre %1$s mit Fogwave Ich höre „%1$s“ auf %2$s mit Fogwave + Darstellung + Mehr + App-Farben + Lavendel + Pfirsich + Minze + Himmel + Gerät + Die Farben kommen aus deinem Hintergrundbild (Material You) und ändern sich mit ihm. + Nebel in Senderfarbe + Der Nebel und der Ring um das Cover nehmen die Farbe des laufenden Senders an diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 3dcc237..46461c1 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -113,4 +113,15 @@ 共有 Fogwaveで%1$sを聴いています Fogwaveで%2$sの「%1$s」を聴いています + 外観 + その他 + アプリの色 + ラベンダー + ピーチ + ミント + スカイ + 端末 + 色は壁紙から取得され(Material You)、壁紙に合わせて変わります。 + 局の色の霧 + 霧とディスクの周りのリングが再生中の局の色になります diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index e97df3a..224ef11 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -116,4 +116,15 @@ Bendrinti Klausausi %1$s per Fogwave Klausausi „%1$s“ per %2$s su Fogwave + Išvaizda + Daugiau + Programėlės spalvos + Levanda + Persikas + Mėta + Dangus + Fonas + Spalvos paimamos iš ekrano fono („Material You“) ir keičiasi kartu su juo. + Rūkas stoties spalva + Rūkas ir žiedas aplink diską nusidažo grojančios stoties spalva diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index bbffd93..af4547e 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -116,4 +116,15 @@ Поделиться Слушаю %1$s в Fogwave Слушаю «%1$s» на %2$s в Fogwave + Оформление + Ещё + Цвета приложения + Лаванда + Персик + Мята + Небо + Обои + Цвета берутся из обоев (Material You) и меняются вместе с ними. + Туман в цвете станции + Туман и кольцо вокруг диска окрашиваются в цвет играющей станции diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 00bd85c..b2b6521 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -113,4 +113,15 @@ 分享 我正在用 Fogwave 收听 %1$s 我正在用 Fogwave 收听 %2$s 的“%1$s” + 外观 + 更多 + 应用配色 + 薰衣草 + 蜜桃 + 薄荷 + 天空 + 设备 + 颜色取自壁纸(Material You),并随壁纸变化。 + 电台颜色的雾 + 雾和唱片周围的圆环会变成正在播放电台的颜色 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0a824b3..f1db258 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -114,4 +114,16 @@ Share I\'m listening to %1$s on Fogwave I\'m listening to “%1$s” on %2$s with Fogwave + Appearance + More + App colors + Fogwave + Lavender + Peach + Mint + Sky + Device + Colors are taken from your wallpaper (Material You) and change with it. + Fog in station color + The fog and the ring around the disc take the color of the playing station