fixed UI mode switch in viewer for Android <10

This commit is contained in:
Thibault Deckers 2021-12-22 11:24:57 +09:00
parent 0dc22744d3
commit 876fe26247
4 changed files with 21 additions and 4 deletions

View file

@ -36,6 +36,7 @@ class DeviceHandler(private val context: Context) : MethodCallHandler {
"canRenderGoogleMaps" to (sdkInt >= Build.VERSION_CODES.KITKAT_WATCH),
"hasFilePicker" to (sdkInt >= Build.VERSION_CODES.KITKAT),
"showPinShortcutFeedback" to (sdkInt >= Build.VERSION_CODES.O),
"supportEdgeToEdgeUIMode" to (sdkInt >= Build.VERSION_CODES.Q),
)
)
}

View file

@ -6,7 +6,7 @@ final Device device = Device._private();
class Device {
late final String _userAgent;
late final bool _canGrantDirectoryAccess, _canPinShortcut, _canPrint, _canRenderFlagEmojis, _canRenderGoogleMaps;
late final bool _hasFilePicker, _showPinShortcutFeedback;
late final bool _hasFilePicker, _showPinShortcutFeedback, _supportEdgeToEdgeUIMode;
String get userAgent => _userAgent;
@ -20,11 +20,12 @@ class Device {
bool get canRenderGoogleMaps => _canRenderGoogleMaps;
// TODO TLAD toggle settings > import/export, about > bug report > save
bool get hasFilePicker => _hasFilePicker;
bool get showPinShortcutFeedback => _showPinShortcutFeedback;
bool get supportEdgeToEdgeUIMode => _supportEdgeToEdgeUIMode;
Device._private();
Future<void> init() async {
@ -39,5 +40,6 @@ class Device {
_canRenderGoogleMaps = capabilities['canRenderGoogleMaps'] ?? false;
_hasFilePicker = capabilities['hasFilePicker'] ?? false;
_showPinShortcutFeedback = capabilities['showPinShortcutFeedback'] ?? false;
_supportEdgeToEdgeUIMode = capabilities['supportEdgeToEdgeUIMode'] ?? false;
}
}

View file

@ -1,5 +1,6 @@
import 'dart:math';
import 'package:aves/model/device.dart';
import 'package:aves/model/entry.dart';
import 'package:aves/model/filters/filters.dart';
import 'package:aves/model/highlight.dart';
@ -538,7 +539,13 @@ class _EntryViewerStackState extends State<EntryViewerStack> with FeedbackMixin,
// system UI
static void _showSystemUI() => SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
static void _showSystemUI() {
if (device.supportEdgeToEdgeUIMode) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
} else {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
}
}
static void _hideSystemUI() => SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);

View file

@ -1,5 +1,6 @@
import 'dart:math';
import 'package:aves/model/device.dart';
import 'package:aves/model/entry.dart';
import 'package:aves/model/entry_images.dart';
import 'package:aves/model/panorama.dart';
@ -148,7 +149,13 @@ class _PanoramaPageState extends State<PanoramaPage> {
// system UI
static void _showSystemUI() => SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
static void _showSystemUI() {
if (device.supportEdgeToEdgeUIMode) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
} else {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
}
}
static void _hideSystemUI() => SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);