Skip to content

An open-source cross-platform alternative to AirDrop

fix: navigation bar color on Android 9 and earlier (#656)

Tien Do Nam60269618511a
diff --git a/assets/CHANGELOG.md b/assets/CHANGELOG.md
index 26b46969..894b4a81 100644
--- a/assets/CHANGELOG.md
+++ b/assets/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 1.11.1 (2023-09-)
+
+- fix(android): navigation bar color on Android 9 and earlier (@Tienisto)
+- fix(android): add `requestLegacyExternalStorage` again (that was removed in 1.11.0) (@Tienisto)
+- fix(linux): do not use zenity dependency anymore for file picker (@Tienisto)
+
## 1.11.0 (2023-08-28)
- feat: optionally enable HTTPS (encryption) when share via link (@Tienisto)
diff --git a/lib/provider/device_info_provider.dart b/lib/provider/device_info_provider.dart
index 0bc0774f..861ea5dd 100644
--- a/lib/provider/device_info_provider.dart
+++ b/lib/provider/device_info_provider.dart
@@ -19,6 +19,7 @@ final deviceInfoProvider = ViewProvider<DeviceInfoResult>((ref) {
return DeviceInfoResult(
deviceType: settings.deviceType ?? rawInfo.deviceType,
deviceModel: settings.deviceModel ?? rawInfo.deviceModel,
+ androidSdkInt: rawInfo.androidSdkInt,
);
});
diff --git a/lib/theme.dart b/lib/theme.dart
index 90bdc8e6..35d8dea3 100644
--- a/lib/theme.dart
+++ b/lib/theme.dart
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:localsend_app/gen/strings.g.dart';
+import 'package:localsend_app/provider/device_info_provider.dart';
import 'package:localsend_app/util/native/platform_check.dart';
+import 'package:riverpie_flutter/riverpie_flutter.dart';
final _borderRadius = BorderRadius.circular(5);
@@ -82,15 +84,27 @@ Future<void> updateSystemOverlayStyle(BuildContext context) async {
}
Future<void> updateSystemOverlayStyleWithBrightness(Brightness brightness) async {
- final style = SystemUiOverlayStyle(
- statusBarIconBrightness: brightness == Brightness.light ? Brightness.dark : Brightness.light, // android
- statusBarBrightness: brightness, // iOS
- systemNavigationBarColor: Colors.transparent,
- statusBarColor: Colors.transparent,
- );
+ if (checkPlatform([TargetPlatform.android])) {
+ // See https://github.com/flutter/flutter/issues/90098
+ final darkMode = brightness == Brightness.dark;
+ final androidSdkInt = RiverpieScope.defaultRef.read(deviceInfoProvider).androidSdkInt ?? 0;
+ final bool edgeToEdge = androidSdkInt >= 29;
+
+ SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); // ignore: unawaited_futures
- await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
- SystemChrome.setSystemUIOverlayStyle(style);
+ SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
+ statusBarColor: Colors.transparent,
+ statusBarIconBrightness: brightness == Brightness.light ? Brightness.dark : Brightness.light,
+ systemNavigationBarColor: edgeToEdge ? Colors.transparent : (darkMode ? Colors.black : Colors.white),
+ systemNavigationBarContrastEnforced: false,
+ systemNavigationBarIconBrightness: darkMode ? Brightness.light : Brightness.dark,
+ ));
+ } else {
+ SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
+ statusBarBrightness: brightness, // iOS
+ statusBarColor: Colors.transparent, // Not relevant to this issue
+ ));
+ }
}
extension ThemeDataExt on ThemeData {
diff --git a/lib/util/native/device_info_helper.dart b/lib/util/native/device_info_helper.dart
index a5d00373..9987575c 100644
--- a/lib/util/native/device_info_helper.dart
+++ b/lib/util/native/device_info_helper.dart
@@ -8,9 +8,14 @@ class DeviceInfoResult {
final DeviceType deviceType;
final String? deviceModel;
+ // Used to properly set Edge-to-Edge mode on Android
+ // See https://github.com/flutter/flutter/issues/90098
+ final int? androidSdkInt;
+
DeviceInfoResult({
required this.deviceType,
required this.deviceModel,
+ required this.androidSdkInt,
});
}
@@ -18,6 +23,7 @@ Future<DeviceInfoResult> getDeviceInfo() async {
final plugin = DeviceInfoPlugin();
final DeviceType deviceType;
final String? deviceModel;
+ int? androidSdkInt;
if (kIsWeb) {
deviceType = DeviceType.web;
@@ -41,6 +47,7 @@ Future<DeviceInfoResult> getDeviceInfo() async {
case TargetPlatform.android:
final deviceInfo = await plugin.androidInfo;
deviceModel = deviceInfo.brand.toCase(CaseStyle.pascal);
+ androidSdkInt = deviceInfo.version.sdkInt;
break;
case TargetPlatform.iOS:
final deviceInfo = await plugin.iosInfo;
@@ -64,6 +71,7 @@ Future<DeviceInfoResult> getDeviceInfo() async {
return DeviceInfoResult(
deviceType: deviceType,
deviceModel: deviceModel,
+ androidSdkInt: androidSdkInt,
);
}