From 6f6c403437e648e2eb97c04b4d78344476644f09 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Sun, 14 Dec 2025 00:05:44 +0100 Subject: [PATCH] fix: green issue close #158 --- .../flutter_application_1/MainActivity.kt | 12 +++++++++ lib/screens/settings/settings_screen.dart | 26 +++++++++++++------ lib/services/keyboard_shortcuts_service.dart | 7 +++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/android/app/src/main/kotlin/com/example/flutter_application_1/MainActivity.kt b/android/app/src/main/kotlin/com/example/flutter_application_1/MainActivity.kt index 70a7b545..857a5482 100644 --- a/android/app/src/main/kotlin/com/example/flutter_application_1/MainActivity.kt +++ b/android/app/src/main/kotlin/com/example/flutter_application_1/MainActivity.kt @@ -1,10 +1,22 @@ package com.edde746.plezy +import android.os.Build +import android.os.Bundle import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.engine.FlutterEngine import com.edde746.plezy.mpv.MpvPlayerPlugin class MainActivity : FlutterActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + // Disable Android's default focus highlight ring that appears when using + // D-pad navigation so the Flutter UI can render its own focus state. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + window.decorView.defaultFocusHighlightEnabled = false + } + } + override fun configureFlutterEngine(flutterEngine: FlutterEngine) { super.configureFlutterEngine(flutterEngine) flutterEngine.plugins.add(MpvPlayerPlugin()) diff --git a/lib/screens/settings/settings_screen.dart b/lib/screens/settings/settings_screen.dart index d50fdcdc..cb4f01eb 100644 --- a/lib/screens/settings/settings_screen.dart +++ b/lib/screens/settings/settings_screen.dart @@ -31,7 +31,9 @@ class SettingsScreen extends StatefulWidget { class _SettingsScreenState extends State { late settings.SettingsService _settingsService; - late KeyboardShortcutsService _keyboardService; + KeyboardShortcutsService? _keyboardService; + late final bool _keyboardShortcutsSupported = + KeyboardShortcutsService.isPlatformSupported(); bool _isLoading = true; bool _enableDebugLogging = false; @@ -59,7 +61,9 @@ class _SettingsScreenState extends State { Future _loadSettings() async { _settingsService = await settings.SettingsService.getInstance(); - _keyboardService = await KeyboardShortcutsService.getInstance(); + if (_keyboardShortcutsSupported) { + _keyboardService = await KeyboardShortcutsService.getInstance(); + } setState(() { _enableDebugLogging = _settingsService.getEnableDebugLogging(); @@ -99,8 +103,10 @@ class _SettingsScreenState extends State { const SizedBox(height: 24), _buildDownloadsSection(), const SizedBox(height: 24), - _buildKeyboardShortcutsSection(), - const SizedBox(height: 24), + if (_keyboardShortcutsSupported) ...[ + _buildKeyboardShortcutsSection(), + const SizedBox(height: 24), + ], _buildAdvancedSection(), const SizedBox(height: 24), if (UpdateService.isUpdateCheckEnabled) ...[ @@ -531,6 +537,8 @@ class _SettingsScreenState extends State { } Widget _buildKeyboardShortcutsSection() { + if (_keyboardService == null) return const SizedBox.shrink(); + return Card( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -854,7 +862,7 @@ class _SettingsScreenState extends State { _settingsService.setSeekTimeSmall(parsed); }); // Reload keyboard shortcuts service to use new settings - await _keyboardService.refreshFromStorage(); + await _keyboardService?.refreshFromStorage(); if (dialogContext.mounted) { Navigator.pop(dialogContext); } @@ -922,7 +930,7 @@ class _SettingsScreenState extends State { _settingsService.setSeekTimeLarge(parsed); }); // Reload keyboard shortcuts service to use new settings - await _keyboardService.refreshFromStorage(); + await _keyboardService?.refreshFromStorage(); if (dialogContext.mounted) { Navigator.pop(dialogContext); } @@ -1073,11 +1081,13 @@ class _SettingsScreenState extends State { } void _showKeyboardShortcutsDialog() { + if (_keyboardService == null) return; + Navigator.push( context, MaterialPageRoute( builder: (context) => - _KeyboardShortcutsScreen(keyboardService: _keyboardService), + _KeyboardShortcutsScreen(keyboardService: _keyboardService!), ), ); } @@ -1131,7 +1141,7 @@ class _SettingsScreenState extends State { final navigator = Navigator.of(context); final messenger = ScaffoldMessenger.of(context); await _settingsService.resetAllSettings(); - await _keyboardService.resetToDefaults(); + await _keyboardService?.resetToDefaults(); if (mounted) { navigator.pop(); messenger.showSnackBar( diff --git a/lib/services/keyboard_shortcuts_service.dart b/lib/services/keyboard_shortcuts_service.dart index b2a6403b..af45687d 100644 --- a/lib/services/keyboard_shortcuts_service.dart +++ b/lib/services/keyboard_shortcuts_service.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:hotkey_manager/hotkey_manager.dart'; @@ -24,6 +26,11 @@ class KeyboardShortcutsService { return _instance!; } + /// Keyboard shortcut customization is only supported on desktop platforms. + static bool isPlatformSupported() { + return Platform.isWindows || Platform.isLinux || Platform.isMacOS; + } + Future _init() async { _settingsService = await SettingsService.getInstance(); // Ensure settings service is fully initialized before loading data