fix: android 15 warnings
This commit is contained in:
@@ -28,12 +28,14 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
// Align with modern Android Gradle Plugin requirements
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = JavaVersion.VERSION_11.toString()
|
// Generate JVM bytecode targeting Java 17
|
||||||
|
jvmTarget = JavaVersion.VERSION_17.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|||||||
@@ -10,23 +10,8 @@ class MainActivity : FlutterActivity() {
|
|||||||
private lateinit var backgroundStreamingHandler: BackgroundStreamingHandler
|
private lateinit var backgroundStreamingHandler: BackgroundStreamingHandler
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
// Enable edge-to-edge display for Android 15+ compatibility
|
// Ensure content draws behind system bars (backwards compatible helper)
|
||||||
// This ensures proper handling of system bars and insets
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
|
||||||
// For Android 15+ (API 35), try to use enableEdgeToEdge if available
|
|
||||||
try {
|
|
||||||
// Use reflection to call EdgeToEdge.enable() for forward compatibility
|
|
||||||
val edgeToEdgeClass = Class.forName("androidx.activity.EdgeToEdge")
|
|
||||||
val enableMethod = edgeToEdgeClass.getMethod("enable", android.app.Activity::class.java)
|
|
||||||
enableMethod.invoke(null, this)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
// Fallback to WindowCompat if EdgeToEdge is not available
|
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// For older versions, use WindowCompat for backward compatibility
|
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
<!-- Android 15+ edge-to-edge configuration -->
|
<!-- Android 15+ edge-to-edge configuration -->
|
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||||
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
|
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
<!-- Do not set status/navigation bar colors on API 35+ -->
|
||||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
||||||
<item name="android:enforceNavigationBarContrast">false</item>
|
<item name="android:enforceNavigationBarContrast">false</item>
|
||||||
<item name="android:enforceStatusBarContrast">false</item>
|
<item name="android:enforceStatusBarContrast">false</item>
|
||||||
</style>
|
</style>
|
||||||
@@ -25,8 +24,7 @@
|
|||||||
<item name="android:windowBackground">?android:colorBackground</item>
|
<item name="android:windowBackground">?android:colorBackground</item>
|
||||||
<!-- Android 15+ edge-to-edge configuration -->
|
<!-- Android 15+ edge-to-edge configuration -->
|
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
<!-- Do not set status/navigation bar colors on API 35+ -->
|
||||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
|
||||||
<item name="android:enforceNavigationBarContrast">false</item>
|
<item name="android:enforceNavigationBarContrast">false</item>
|
||||||
<item name="android:enforceStatusBarContrast">false</item>
|
<item name="android:enforceStatusBarContrast">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -326,25 +326,21 @@ class PlatformService {
|
|||||||
statusBarIconBrightness: isDarkContent
|
statusBarIconBrightness: isDarkContent
|
||||||
? Brightness.dark
|
? Brightness.dark
|
||||||
: Brightness.light,
|
: Brightness.light,
|
||||||
|
// iOS: it's safe to pass a color; leave behavior unchanged
|
||||||
statusBarColor: backgroundColor,
|
statusBarColor: backgroundColor,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// For Android 15+, use edge-to-edge approach
|
// Android: Avoid passing any bar colors to prevent invoking
|
||||||
// Avoid deprecated setStatusBarColor, setNavigationBarColor, setNavigationBarDividerColor
|
// deprecated Window.setStatusBarColor / setNavigationBarColor / setNavigationBarDividerColor
|
||||||
|
// on Android 15+. Only control icon brightness; colors come from theme + EdgeToEdge.
|
||||||
SystemChrome.setSystemUIOverlayStyle(
|
SystemChrome.setSystemUIOverlayStyle(
|
||||||
SystemUiOverlayStyle(
|
SystemUiOverlayStyle(
|
||||||
// Only set icon brightness for edge-to-edge compatibility
|
statusBarIconBrightness:
|
||||||
statusBarIconBrightness: isDarkContent
|
isDarkContent ? Brightness.dark : Brightness.light,
|
||||||
? Brightness.dark
|
systemNavigationBarIconBrightness:
|
||||||
: Brightness.light,
|
isDarkContent ? Brightness.dark : Brightness.light,
|
||||||
systemNavigationBarIconBrightness: isDarkContent
|
// Do NOT set status/navigation bar colors on Android.
|
||||||
? Brightness.dark
|
|
||||||
: Brightness.light,
|
|
||||||
// Use transparent colors for proper edge-to-edge display
|
|
||||||
statusBarColor: Colors.transparent,
|
|
||||||
systemNavigationBarColor: Colors.transparent,
|
|
||||||
systemNavigationBarDividerColor: Colors.transparent,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'core/services/navigation_service.dart';
|
import 'core/services/navigation_service.dart';
|
||||||
import 'core/widgets/error_boundary.dart';
|
import 'core/widgets/error_boundary.dart';
|
||||||
@@ -23,6 +24,10 @@ import 'core/services/share_receiver_service.dart';
|
|||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
// Enable edge-to-edge globally (back-compat on pre-Android 15)
|
||||||
|
// Pairs with Activity's EdgeToEdge.enable and our SafeArea usage.
|
||||||
|
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
|
||||||
final sharedPrefs = await SharedPreferences.getInstance();
|
final sharedPrefs = await SharedPreferences.getInstance();
|
||||||
const secureStorage = FlutterSecureStorage();
|
const secureStorage = FlutterSecureStorage();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user