From a0a0d43116f8c6e868a5df94175838a7e3f3ec08 Mon Sep 17 00:00:00 2001 From: cogwheel0 <172976095+cogwheel0@users.noreply.github.com> Date: Mon, 20 Oct 2025 23:56:40 +0530 Subject: [PATCH] refactor: Update MainActivity for edge-to-edge display support - Implemented modern edge-to-edge display handling for Android 15+ in MainActivity.kt. - Removed deprecated SystemUiMode.edgeToEdge configuration from main.dart, as edge-to-edge is now managed natively. - Ensured backward compatibility by maintaining the previous edge-to-edge display settings for lower Android versions. --- .../main/kotlin/app/cogwheel/conduit/MainActivity.kt | 11 ++++++++--- lib/main.dart | 10 +++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/android/app/src/main/kotlin/app/cogwheel/conduit/MainActivity.kt b/android/app/src/main/kotlin/app/cogwheel/conduit/MainActivity.kt index 5675718..f187378 100644 --- a/android/app/src/main/kotlin/app/cogwheel/conduit/MainActivity.kt +++ b/android/app/src/main/kotlin/app/cogwheel/conduit/MainActivity.kt @@ -10,10 +10,15 @@ class MainActivity : FlutterActivity() { private lateinit var backgroundStreamingHandler: BackgroundStreamingHandler override fun onCreate(savedInstanceState: Bundle?) { - // Ensure content draws behind system bars (backwards compatible helper) - WindowCompat.setDecorFitsSystemWindows(window, false) - super.onCreate(savedInstanceState) + + // Modern edge-to-edge implementation for Android 15+ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { + window.decorView.setOnApplyWindowInsetsListener(null) + } + + // Enable edge-to-edge display (backwards compatible) + WindowCompat.setDecorFitsSystemWindows(window, false) } override fun configureFlutterEngine(flutterEngine: FlutterEngine) { diff --git a/lib/main.dart b/lib/main.dart index 1fce419..c813c90 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:developer' as developer; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'core/widgets/error_boundary.dart'; @@ -56,12 +55,9 @@ void main() { _startupTimeline!.start('app_startup'); _startupTimeline!.instant('bindings_initialized'); - // Defer edge-to-edge mode to post-frame to avoid impacting first paint - WidgetsBinding.instance.addPostFrameCallback((_) { - // ignore: discarded_futures - SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); - _startupTimeline?.instant('edge_to_edge_enabled'); - }); + // Edge-to-edge is now handled natively in MainActivity.kt for Android 15+ + // No need for SystemUiMode.edgeToEdge which is deprecated + _startupTimeline?.instant('edge_to_edge_configured'); const secureStorage = FlutterSecureStorage( aOptions: AndroidOptions(