fix: Moved from always setting highest refresh rate to highest available

This commit is contained in:
Anton Stubenbord
2023-02-10 16:44:15 +01:00
parent cc343b2b63
commit 3fe8c34994

View File

@@ -140,10 +140,6 @@ void main() async {
appSettingsCubit.stream.listen((event) => languageHeaderInterceptor appSettingsCubit.stream.listen((event) => languageHeaderInterceptor
.preferredLocaleSubtag = event.preferredLocaleSubtag); .preferredLocaleSubtag = event.preferredLocaleSubtag);
// Temporary Fix: Can be removed if the flutter engine implements the fix itself
// Activate the highest availabe refresh rate on the device
await FlutterDisplayMode.setHighRefreshRate();
runApp( runApp(
MultiProvider( MultiProvider(
providers: [ providers: [
@@ -201,6 +197,21 @@ void main() async {
); );
} }
Future<void> setOptimalDisplayMode() async {
final List<DisplayMode> supported = await FlutterDisplayMode.supported;
final DisplayMode active = await FlutterDisplayMode.active;
final List<DisplayMode> sameResolution = supported
.where((m) => m.width == active.width && m.height == active.height)
.toList()
..sort((a, b) => b.refreshRate.compareTo(a.refreshRate));
final DisplayMode mostOptimalMode =
sameResolution.isNotEmpty ? sameResolution.first : active;
await FlutterDisplayMode.setPreferredMode(mostOptimalMode);
}
class PaperlessMobileEntrypoint extends StatefulWidget { class PaperlessMobileEntrypoint extends StatefulWidget {
const PaperlessMobileEntrypoint({ const PaperlessMobileEntrypoint({
Key? key, Key? key,
@@ -282,11 +293,15 @@ class _AuthenticationWrapperState extends State<AuthenticationWrapper> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
// Temporary Fix: Can be removed if the flutter engine implements the fix itself
// Activate the highest supported refresh rate on the device
setOptimalDisplayMode();
initializeDateFormatting(); initializeDateFormatting();
// For sharing files coming from outside the app while the app is still opened // For sharing files coming from outside the app while the app is still opened
ReceiveSharingIntent.getMediaStream() ReceiveSharingIntent.getMediaStream()
.listen(ShareIntentQueue.instance.addAll); .listen(ShareIntentQueue.instance.addAll);
// For sharing files coming from outside the app while the app is closed // For sharing files coming from outside the app while the app is closed
// TODO: This does not work currently, app does not have permission to access the shared file
ReceiveSharingIntent.getInitialMedia() ReceiveSharingIntent.getInitialMedia()
.then(ShareIntentQueue.instance.addAll); .then(ShareIntentQueue.instance.addAll);
} }