diff --git a/CHANGELOG.md b/CHANGELOG.md index 705f6bf..88d0f15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,19 @@ upload needs a **higher `versionCode`** than every previous upload. ## [Unreleased] +### Fixed + +- **Play Console no longer reports deprecated edge-to-edge APIs.** The release build contained + `Window.setStatusBarColor`, `Window.setNavigationBarColor` and + `LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES`, all of which Android 15 deprecates for apps + targeting SDK 35+. They came from `ComponentActivity.enableEdgeToEdge()` (androidx.activity + 1.13.0), whose per-API-level implementations still set the status/navigation bar scrims and use + the deprecated cutout mode on API 28/29. `ui/theme/EdgeToEdge` now performs the same setup with + current APIs only: `WindowCompat.setDecorFitsSystemWindows`, navigation-bar contrast off, cutout + mode `always` on API 30+, and light/dark bar icons following the system night mode. `MainActivity` + calls it instead of `enableEdgeToEdge()`; the theme still supplies the transparent bars below + API 35, and the existing inset handling in `ScannerScreen` is unchanged. + ## [1.0.1] — 2026-10-13 · versionCode 2 ### Fixed diff --git a/app/src/main/java/de/softwareapp_hb/fotodup/finder/MainActivity.kt b/app/src/main/java/de/softwareapp_hb/fotodup/finder/MainActivity.kt index 4c3900f..bf7178f 100644 --- a/app/src/main/java/de/softwareapp_hb/fotodup/finder/MainActivity.kt +++ b/app/src/main/java/de/softwareapp_hb/fotodup/finder/MainActivity.kt @@ -3,18 +3,20 @@ package de.softwareapp_hb.fotodup.finder import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.ui.Modifier import de.softwareapp_hb.fotodup.finder.ui.scanner.ScannerScreen import de.softwareapp_hb.fotodup.finder.ui.theme.FotoDupTheme +import de.softwareapp_hb.fotodup.finder.ui.theme.applyEdgeToEdge class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { - enableEdgeToEdge() super.onCreate(savedInstanceState) + // AndroidX's enableEdgeToEdge() would do this too, but it still uses APIs that are + // deprecated on Android 15; see applyEdgeToEdge() for the details. + applyEdgeToEdge() setContent { FotoDupTheme { Surface( diff --git a/app/src/main/java/de/softwareapp_hb/fotodup/finder/ui/theme/EdgeToEdge.kt b/app/src/main/java/de/softwareapp_hb/fotodup/finder/ui/theme/EdgeToEdge.kt new file mode 100644 index 0000000..b1d0c17 --- /dev/null +++ b/app/src/main/java/de/softwareapp_hb/fotodup/finder/ui/theme/EdgeToEdge.kt @@ -0,0 +1,55 @@ +package de.softwareapp_hb.fotodup.finder.ui.theme + +import android.app.Activity +import android.content.res.Configuration +import android.os.Build +import android.view.WindowManager +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsControllerCompat + +/** + * Draws the activity edge-to-edge using only window APIs that are still current on Android 15. + * + * `ComponentActivity.enableEdgeToEdge()` (androidx.activity 1.13.0) still calls + * `Window.setStatusBarColor()` and `Window.setNavigationBarColor()` in its API 21/26/29 + * implementations, and it sets `LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES` on API 28/29. All + * three are deprecated for apps targeting SDK 35 and therefore appear in Play Console as + * "Your app uses deprecated APIs or parameters for edge-to-edge". + * + * The window itself is already transparent because of the theme, so the colour-scrim half of + * `enableEdgeToEdge()` is unnecessary. What remains is letting the window lay out behind the + * system bars, keeping the navigation-bar scrim off, and choosing light or dark bar icons for + * the current theme. + * + * Call this from `Activity.onCreate()`, after `super.onCreate()` and before setting content. + */ +fun Activity.applyEdgeToEdge() { + // Lay out behind the status and navigation bars instead of letting the decor view inset + // them. On API 35+ this is a no-op: the platform already enforces edge-to-edge there. + WindowCompat.setDecorFitsSystemWindows(window, false) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + // The navigation bar is transparent (see the theme), and without this Android 10+ draws + // its own translucent contrast scrim over the gesture/button area. + window.isNavigationBarContrastEnforced = false + } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + // Allow the app to draw into the display cutout on every edge. API 28/29 would need the + // now-deprecated SHORT_EDGES mode for that, so those versions keep the platform default + // instead; Android 15 ignores the mode because edge-to-edge is mandatory there. + window.attributes = window.attributes.apply { + layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS + } + } + + val darkTheme = (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == + Configuration.UI_MODE_NIGHT_YES + WindowInsetsControllerCompat(window, window.decorView).apply { + // Dark icons on a light background and light icons on a dark one — the same system + // night-mode flag that drives FotoDupTheme. + isAppearanceLightStatusBars = !darkTheme + isAppearanceLightNavigationBars = !darkTheme + } +}