diff --git a/CHANGELOG.md b/CHANGELOG.md index 615ed74..19e0b0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to Fern are listed here. Versions follow the Android `versionName`. +## Unreleased + +**UI** +* Tabs and sub-screens slide in the direction of travel; Home, Details and More cards fade and lift in one after another +* Live chip has a pulsing dot, the refresh icon spins on tap, and the first load shows placeholder cards instead of plain text +* CPU/RAM gauges count up with the arc and turn amber at 75% and red at 90%; storage and battery bars warn the same way (battery stays neutral while charging) +* Active apps rows animate when the list changes; the selected nav icon bounces slightly; the low-memory banner fades in +* Dark mode no longer flashes white at launch, and the Android 12+ splash screen uses the app background + ## 1.12.0 **Security** diff --git a/app/src/main/java/com/endroid/fern/ui/FernApp.kt b/app/src/main/java/com/endroid/fern/ui/FernApp.kt index a7f6457..1f06d60 100644 --- a/app/src/main/java/com/endroid/fern/ui/FernApp.kt +++ b/app/src/main/java/com/endroid/fern/ui/FernApp.kt @@ -2,6 +2,17 @@ package com.endroid.fern.ui import androidx.activity.compose.BackHandler import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.FastOutSlowInEasing +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.RepeatMode +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.infiniteRepeatable +import androidx.compose.animation.core.rememberInfiniteTransition +import androidx.compose.animation.slideInHorizontally +import androidx.compose.animation.slideOutHorizontally +import androidx.compose.ui.draw.rotate +import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.draw.clip import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.CenterAlignedTopAppBar @@ -339,28 +350,28 @@ fun FernApp( NavigationBarItem( selected = tab == Tab.Home, onClick = { selectTab(Tab.Home) }, - icon = { Icon(Icons.Default.Home, contentDescription = "Home dashboard") }, + icon = { NavIcon(tab == Tab.Home, Icons.Default.Home, "Home dashboard") }, label = { Text("Home", style = MaterialTheme.typography.labelMedium) }, alwaysShowLabel = true ) NavigationBarItem( selected = tab == Tab.Details, onClick = { selectTab(Tab.Details) }, - icon = { Icon(Icons.Default.Memory, contentDescription = "Hardware details") }, + icon = { NavIcon(tab == Tab.Details, Icons.Default.Memory, "Hardware details") }, label = { Text("Details", style = MaterialTheme.typography.labelMedium) }, alwaysShowLabel = true ) NavigationBarItem( selected = tab == Tab.ActiveApps, onClick = { selectTab(Tab.ActiveApps) }, - icon = { Icon(Icons.Default.Apps, contentDescription = "Active apps list") }, + icon = { NavIcon(tab == Tab.ActiveApps, Icons.Default.Apps, "Active apps list") }, label = { Text("Apps", style = MaterialTheme.typography.labelMedium) }, alwaysShowLabel = true ) NavigationBarItem( selected = tab == Tab.More, onClick = { selectTab(Tab.More) }, - icon = { Icon(Icons.Default.MoreHoriz, contentDescription = "More options") }, + icon = { NavIcon(tab == Tab.More, Icons.Default.MoreHoriz, "More options") }, label = { Text("More", style = MaterialTheme.typography.labelMedium) }, alwaysShowLabel = true ) @@ -372,7 +383,18 @@ fun FernApp( tab == Tab.More && moreSub != MoreSub.None -> "more/${moreSub.name}" else -> tab.name }, - transitionSpec = { fadeIn(tween(180)) togetherWith fadeOut(tween(120)) }, + transitionSpec = { + // Slide in the direction of travel: deeper / further-right tabs come from the right. + val forward = navOrder(targetState) >= navOrder(initialState) + (fadeIn(tween(240, delayMillis = 60)) + + slideInHorizontally(tween(280, easing = FastOutSlowInEasing)) { w -> + if (forward) w / 12 else -w / 12 + }) togetherWith + (fadeOut(tween(110)) + + slideOutHorizontally(tween(220, easing = FastOutSlowInEasing)) { w -> + if (forward) -w / 12 else w / 12 + }) + }, modifier = Modifier.padding(padding).fillMaxSize(), label = "tab" ) { key -> @@ -431,6 +453,111 @@ fun FernApp( } } +@Composable +private fun NavIcon(selected: Boolean, icon: ImageVector, description: String) { + val sc by animateFloatAsState( + if (selected) 1.14f else 1f, + animationSpec = androidx.compose.animation.core.spring( + dampingRatio = androidx.compose.animation.core.Spring.DampingRatioMediumBouncy, + stiffness = androidx.compose.animation.core.Spring.StiffnessMedium + ), + label = "navIcon" + ) + Icon( + icon, + contentDescription = description, + modifier = Modifier.graphicsLayer { scaleX = sc; scaleY = sc } + ) +} + +private fun navOrder(key: String): Int = when { + key.startsWith("more/") && key != "more/None" -> 31 + key == "Home" -> 0 + key == "Details" -> 10 + key == "ActiveApps" -> 20 + else -> 30 +} + +/** Fades and lifts its content in, staggered by [index], each time the screen opens. */ +@Composable +private fun Reveal(index: Int, content: @Composable () -> Unit) { + var shown by remember { mutableStateOf(false) } + LaunchedEffect(Unit) { + delay(index * 55L) + shown = true + } + val p by animateFloatAsState( + if (shown) 1f else 0f, + animationSpec = tween(420, easing = FastOutSlowInEasing), + label = "reveal" + ) + Box( + modifier = Modifier + .fillMaxWidth() + .graphicsLayer { + alpha = p + translationY = (1f - p) * 28.dp.toPx() + } + ) { content() } +} + +@Composable +private fun PulseDot(color: Color) { + val t = rememberInfiniteTransition(label = "pulse") + val a by t.animateFloat( + 0.35f, 1f, + infiniteRepeatable(tween(900, easing = FastOutSlowInEasing), RepeatMode.Reverse), + label = "pulseAlpha" + ) + Box( + modifier = Modifier + .size(7.dp) + .graphicsLayer { + alpha = a + scaleX = 0.8f + 0.2f * a + scaleY = 0.8f + 0.2f * a + } + .background(color, CircleShape) + ) +} + +/** Placeholder cards shown while the first reading is in flight. */ +@Composable +private fun LoadingSkeleton() { + val t = rememberInfiniteTransition(label = "skeleton") + val a by t.animateFloat( + 0.35f, 0.8f, + infiniteRepeatable(tween(850, easing = LinearEasing), RepeatMode.Reverse), + label = "skeletonAlpha" + ) + val c = MaterialTheme.colorScheme.surfaceContainerHigh.copy(alpha = a) + Column(verticalArrangement = Arrangement.spacedBy(14.dp)) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + repeat(2) { + Box( + Modifier + .weight(1f) + .height(190.dp) + .clip(RoundedCornerShape(28.dp)) + .background(c) + ) + } + } + repeat(3) { + Box( + Modifier + .fillMaxWidth() + .height(86.dp) + .clip(RoundedCornerShape(28.dp)) + .background(c) + ) + } + } +} + @Composable private fun HomeContent( s: SystemSnapshot?, @@ -501,12 +628,16 @@ private fun HomeContent( ) .padding(horizontal = 10.dp, vertical = 3.dp) ) { - Text( - "Live", - style = MaterialTheme.typography.labelMedium, - color = MaterialTheme.colorScheme.primary, - fontWeight = FontWeight.SemiBold - ) + Row(verticalAlignment = Alignment.CenterVertically) { + PulseDot(MaterialTheme.colorScheme.primary) + Spacer(modifier = Modifier.size(6.dp)) + Text( + "Live", + style = MaterialTheme.typography.labelMedium, + color = MaterialTheme.colorScheme.primary, + fontWeight = FontWeight.SemiBold + ) + } } if (thermal != null) { Text( @@ -530,22 +661,30 @@ private fun HomeContent( } } val haptic = LocalHapticFeedback.current + var spin by remember { mutableIntStateOf(0) } + val spinDeg by animateFloatAsState( + spin * 360f, + animationSpec = tween(600, easing = FastOutSlowInEasing), + label = "refreshSpin" + ) IconButton(onClick = { if (haptics) haptic.performHapticFeedback(HapticFeedbackType.LongPress) + spin++ onRefreshNow() }) { Icon( Icons.Default.Refresh, contentDescription = "Refresh now", - tint = MaterialTheme.colorScheme.primary + tint = MaterialTheme.colorScheme.primary, + modifier = Modifier.rotate(spinDeg) ) } } if (s == null) { - Text("Reading sensors…") + LoadingSkeleton() return } - if (s.lowMemory) { + if (s.lowMemory) Reveal(0) { Card( colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer), shape = MaterialTheme.shapes.large, @@ -559,6 +698,7 @@ private fun HomeContent( ) } } + Reveal(0) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp) @@ -572,6 +712,7 @@ private fun HomeContent( Modifier.weight(1f) ) } + } s.batteryPowerMw?.let { mw -> val watts = kotlin.math.abs(mw) / 1000f Text( @@ -584,6 +725,7 @@ private fun HomeContent( color = MaterialTheme.colorScheme.onSurfaceVariant ) } + Reveal(1) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp) @@ -602,18 +744,25 @@ private fun HomeContent( Modifier.weight(1f) ) } + } + Reveal(2) { ThermalBar( tempC = s.batteryTempC, thermalLabel = s.thermalLabel, advancedTempC = advancedSnapshot.maxTempC, advancedEnabled = advancedMode && elevatedStatus.backend != ElevatedBackend.None ) + } + Reveal(3) { Bar( Icons.Default.Folder, "Storage", s.storagePercent, - String.format("%.1f / %.1f GB", s.storageUsedGb, s.storageTotalGb) + String.format("%.1f / %.1f GB", s.storageUsedGb, s.storageTotalGb), + warn = 1 ) + } + Reveal(4) { Bar( if (s.batteryCharging) Icons.Default.BatteryChargingFull else Icons.Default.BatteryFull, "Battery", @@ -622,8 +771,11 @@ private fun HomeContent( append("${s.batteryPercent}%") if (s.batteryCharging) append(" · charging") s.batteryTempC?.let { append(String.format(" · %.1f°C", it)) } - } + }, + warn = if (s.batteryCharging) 0 else 2 ) + } + Reveal(5) { Card( colors = CardDefaults.cardColors( containerColor = MaterialTheme.colorScheme.surfaceContainerLow @@ -670,6 +822,7 @@ private fun HomeContent( ) } } + } } } @@ -712,7 +865,7 @@ private fun DetailsContent(s: SystemSnapshot?, peakCpu: Float, peakRam: Float, p PeakChip("Peak net", peakNetLabel, Modifier.weight(1f)) } - DetailSection(icon = Icons.Default.Memory, title = "Processor") { + DetailSection(icon = Icons.Default.Memory, title = "Processor", index = 1) { SpecRow("Cores", "${s.cpuCores}") SpecRow("Chip", s.cpuHardware) SpecRow("Board", s.cpuBoard) @@ -747,7 +900,7 @@ private fun DetailsContent(s: SystemSnapshot?, peakCpu: Float, peakRam: Float, p } } - DetailSection(icon = Icons.Default.Folder, title = "Memory & storage") { + DetailSection(icon = Icons.Default.Folder, title = "Memory & storage", index = 2) { SpecRow("RAM used", formatMb(s.ramUsedMb)) SpecRow("RAM free", formatMb(s.freeRamMb)) SpecRow("RAM total", formatMb(s.ramTotalMb)) @@ -760,7 +913,7 @@ private fun DetailsContent(s: SystemSnapshot?, peakCpu: Float, peakRam: Float, p } } - DetailSection(icon = Icons.Default.BatteryFull, title = "Power") { + DetailSection(icon = Icons.Default.BatteryFull, title = "Power", index = 3) { SpecRow("Level", "${s.batteryPercent}%") SpecRow("Status", if (s.batteryCharging) "Charging" else "Discharging") SpecRow("Health", s.batteryHealth.ifBlank { "—" }) @@ -772,7 +925,7 @@ private fun DetailsContent(s: SystemSnapshot?, peakCpu: Float, peakRam: Float, p } } - DetailSection(icon = Icons.Default.PhoneAndroid, title = "Display & device") { + DetailSection(icon = Icons.Default.PhoneAndroid, title = "Display & device", index = 4) { SpecRow("Resolution", "${s.displayWidthPx} × ${s.displayHeightPx}") SpecRow("Density", "${s.displayDensityDpi} dpi · ${String.format("%.1f", s.displayDensityDpi / 160f)}×") SpecRow("Refresh", String.format("%.0f Hz", s.displayRefreshHz)) @@ -899,8 +1052,10 @@ private fun PeakChip(label: String, value: String, modifier: Modifier = Modifier private fun DetailSection( icon: ImageVector, title: String, + index: Int = 0, content: @Composable () -> Unit ) { + Reveal(index) { Card( colors = CardDefaults.cardColors( containerColor = MaterialTheme.colorScheme.surfaceContainerLow @@ -932,6 +1087,7 @@ private fun DetailSection( content() } } + } } @Composable @@ -1609,6 +1765,7 @@ private fun MoreContent(onOpen: (MoreSub) -> Unit) { style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant ) + Reveal(0) { Card( colors = CardDefaults.cardColors( containerColor = MaterialTheme.colorScheme.surfaceContainerLow @@ -1670,6 +1827,7 @@ private fun MoreContent(onOpen: (MoreSub) -> Unit) { } } } + } Spacer(modifier = Modifier.height(8.dp)) Text( "Fern v${BuildConfig.VERSION_NAME}", @@ -2065,6 +2223,7 @@ private fun ActiveAppsContent( items(displayApps, key = { it.packageName }) { app -> val rss = lookupLong(rssByPackage, app.packageName) val cpuPct = lookupFloat(cpuByPackage, app.packageName) + Box(Modifier.animateItem()) { ActiveAppRow( app = app, rssKb = if (advancedMode && elevated) rss else null, @@ -2085,6 +2244,7 @@ private fun ActiveAppsContent( } } ) + } } item { Text( @@ -2522,7 +2682,13 @@ private fun Gauge( label = "g" ) val track = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.55f) - val arc = MaterialTheme.colorScheme.primary + val cs = MaterialTheme.colorScheme + val arcTarget = when { + percent >= 90f -> cs.error + percent >= 75f -> Color(0xFFE6A817) + else -> cs.primary + } + val arc by animateColorAsState(arcTarget, animationSpec = tween(500), label = "gaugeColor") Card( colors = CardDefaults.cardColors( containerColor = MaterialTheme.colorScheme.surfaceContainerLow @@ -2561,7 +2727,7 @@ private fun Gauge( ) } Text( - String.format("%.0f%%", percent.coerceIn(0f, 100f)), + String.format("%.0f%%", a * 100f), style = MaterialTheme.typography.displaySmall, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onSurface @@ -2699,7 +2865,16 @@ private fun ThermalBar( } @Composable -private fun Bar(icon: ImageVector, title: String, percent: Float, detail: String) { +private fun Bar(icon: ImageVector, title: String, percent: Float, detail: String, warn: Int = 0) { + // warn: 0 = neutral, 1 = high values are bad (storage), 2 = low values are bad (battery) + val cs = MaterialTheme.colorScheme + val amber = Color(0xFFE6A817) + val tintTarget = when (warn) { + 1 -> when { percent >= 95f -> cs.error; percent >= 85f -> amber; else -> cs.primary } + 2 -> when { percent <= 10f -> cs.error; percent <= 20f -> amber; else -> cs.primary } + else -> cs.primary + } + val tint by animateColorAsState(tintTarget, animationSpec = tween(500), label = "barColor") val a by animateFloatAsState( (percent / 100f).coerceIn(0f, 1f), animationSpec = tween(900, easing = androidx.compose.animation.core.FastOutSlowInEasing), @@ -2720,7 +2895,7 @@ private fun Bar(icon: ImageVector, title: String, percent: Float, detail: String verticalArrangement = Arrangement.spacedBy(8.dp) ) { Row(verticalAlignment = Alignment.CenterVertically) { - Icon(icon, contentDescription = "Decorative", tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(18.dp)) + Icon(icon, contentDescription = "Decorative", tint = tint, modifier = Modifier.size(18.dp)) Spacer(modifier = Modifier.size(8.dp)) Text(title, style = MaterialTheme.typography.titleSmall) } @@ -2730,7 +2905,7 @@ private fun Bar(icon: ImageVector, title: String, percent: Float, detail: String .fillMaxWidth() .height(7.dp) .clip(RoundedCornerShape(4.dp)), - color = MaterialTheme.colorScheme.primary, + color = tint, trackColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.55f), strokeCap = StrokeCap.Round ) diff --git a/app/src/main/res/values-night-v31/themes.xml b/app/src/main/res/values-night-v31/themes.xml new file mode 100644 index 0000000..2c02d5d --- /dev/null +++ b/app/src/main/res/values-night-v31/themes.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml new file mode 100644 index 0000000..eedf692 --- /dev/null +++ b/app/src/main/res/values-night/colors.xml @@ -0,0 +1,4 @@ + + + #080B09 + diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..b2c3bc6 --- /dev/null +++ b/app/src/main/res/values-night/themes.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/values-v31/themes.xml b/app/src/main/res/values-v31/themes.xml new file mode 100644 index 0000000..880a7f2 --- /dev/null +++ b/app/src/main/res/values-v31/themes.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f42ada6..c2d9e73 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,4 +1,5 @@ #FFFFFF + #F6FBF4 diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 6212b1b..1df3d99 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,4 +1,6 @@ -