From 85f0bb839ac7469af8e2db3a47a96657e8b70960 Mon Sep 17 00:00:00 2001 From: Mikhail Kulesh Date: Fri, 31 Jan 2025 00:01:32 +0100 Subject: [PATCH] #336 Present the exact display of the AVR LCD: implemented --- integration_test/onpc_test_utils.dart | 11 ++- integration_test/sim_device_display.dart | 97 ++++++++++++++++++++++++ lib/config/CfgAppSettings.dart | 4 +- lib/config/CfgTabSettings.dart | 4 +- lib/constants/Strings.dart | 8 ++ lib/iscp/State.dart | 8 +- lib/iscp/StateManager.dart | 11 ++- lib/iscp/messages/DeviceDisplayMsg.dart | 47 ++++++++++++ lib/iscp/messages/JacketArtMsg.dart | 17 +---- lib/iscp/messages/MessageFactory.dart | 7 +- lib/iscp/state/ReceiverInformation.dart | 18 ++++- lib/main.dart | 9 ++- lib/utils/Convert.dart | 15 +++- lib/views/AppTabView.dart | 6 +- lib/views/DeviceDisplayView.dart | 72 ++++++++++++++++++ lib/widgets/PositionedTapDetector.dart | 2 +- res/strings.xml | 3 +- res/strings_de.xml | 3 +- res/strings_fr.xml | 3 +- res/strings_pl.xml | 3 +- res/strings_ru.xml | 3 +- 21 files changed, 321 insertions(+), 30 deletions(-) create mode 100644 integration_test/sim_device_display.dart create mode 100644 lib/iscp/messages/DeviceDisplayMsg.dart create mode 100644 lib/views/DeviceDisplayView.dart diff --git a/integration_test/onpc_test_utils.dart b/integration_test/onpc_test_utils.dart index d9d8b502..f06407d1 100644 --- a/integration_test/onpc_test_utils.dart +++ b/integration_test/onpc_test_utils.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2024 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -19,6 +19,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:onpc/constants/Dimens.dart'; import 'package:onpc/constants/Version.dart'; +import 'package:onpc/iscp/StateManager.dart'; +import 'package:onpc/main.dart' as app; import 'package:onpc/utils/Logging.dart'; import 'package:onpc/utils/Pair.dart'; import 'package:onpc/utils/Platform.dart'; @@ -50,6 +52,13 @@ class OnpcTestUtils { OnpcTestUtils(this.tester); + StateManager getStateManager() { + final Finder fab = find.byType(app.MusicControllerApp); + expect(fab, findsOneWidget); + final app.MusicControllerApp mainWidget = fab.evaluate().first.widget as app.MusicControllerApp; + return mainWidget.viewContext.stateManager; + } + Future connect(String device, String searchFor) async { await stepDelayMs(); if (find.textContaining(searchFor).evaluate().isEmpty) { diff --git a/integration_test/sim_device_display.dart b/integration_test/sim_device_display.dart new file mode 100644 index 00000000..f40a39d2 --- /dev/null +++ b/integration_test/sim_device_display.dart @@ -0,0 +1,97 @@ +/* + * Enhanced Music Controller + * Copyright (C) 2019-2025 by Mikhail Kulesh + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. You should have received a copy of the GNU General + * Public License along with this program. + */ + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:onpc/iscp/EISCPMessage.dart'; +import 'package:onpc/iscp/StateManager.dart'; +import 'package:onpc/main.dart' as app; + +import 'onpc_test_utils.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('Simulation of the device display', (tester) async { + final OnpcTestUtils tu = OnpcTestUtils(tester); + app.main(); + + await tu.stepDelayMs(); + await tu.openTab("RC"); + + final List messages = [ + "4368726F6D6563617320372F3130", + "20436F6E6E656374696E672E2E2E", + "1B4368726F6D6563617374206275", + "4368726F6D656361737420627569", + "68726F6D6563617374206275696C", + "726F6D6563617374206275696C74", + "6F6D6563617374206275696C742D", + "6D6563617374206275696C742D69", + "1A416E67656C2028666561742E20", + "6563617374206275696C742D696E", + "63617374206275696C742D696E20", + "617374206275696C742D696E2020", + "7374206275696C742D696E202020", + "74206275696C742D696E20202020", + "206275696C742D696E2020202020", + "6275696C742D696E202020202020", + "75696C742D696E20202020202020", + "696C742D696E2020202020202020", + "6C742D696E202020202020202020", + "742D696E20202020202020202020", + "2D696E2020202020202020202020", + "696E202020202020202020202020", + "6E20202020202020202020202020", + "566F6C756D652020202D34352E30", + "5456206541524320202D34352E30", + "53797374656D2053657475702020", + "4D43414343202020202020202020", + "4E6574776F726B20202020202020", + "496E2F4F75742041737369676E20", + "537065616B657220202020202020", + "417564696F2041646A7573742020", + "536F757263652020202020202020", + "4861726477617265202020202020", + "4D697363656C6C616E656F757320", + "5456204F75742F4F534420202020", + "48444D4920496E70757420202020", + "566964656F20496E707574202020", + "4469676974616C20417564696F20", + "416E616C6F6720417564696F2020", + "496E70757420536B697020202020", + "546F6E6520202020202020202020", + "4C6576656C202020202020202020", + "4F74686572202020202020202020", + "566F6C756D652020202D34342E35", + "5456206541524320202D34342E35", + "566F6C756D652020202D34342E30", + "566F6C756D652020202D34332E35", + "566F6C756D652020202D34332E30", + "566F6C756D652020202D34322E35", + "5456206541524320202D34322E35", + "5043202020202020202D34322E35", + "476F6F676C654361732D34322E35", + "5456202020202020202D34322E35", + "425420415544494F202D34322E35" + ]; + + final StateManager sm = tu.getStateManager(); + for(String element in messages) { + final EISCPMessage raw = EISCPMessage.outputCat("s", "FLD", element); + sm.injectIscpMessage(raw); + await tu.stepDelayMs(delay: 501); + } + }); +} diff --git a/lib/config/CfgAppSettings.dart b/lib/config/CfgAppSettings.dart index d8ed2a12..c1538b0d 100644 --- a/lib/config/CfgAppSettings.dart +++ b/lib/config/CfgAppSettings.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2024 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -441,6 +441,7 @@ class CfgAppSettings extends CfgModule ); _tabSettings.add(CfgTabSettings(this, AppTabs.RC, controlsPortrait: [ + AppControl.DEVICE_DISPLAY, AppControl.SETUP_OP_CMD, AppControl.DIVIDER1, AppControl.SETUP_NAV_CMD, @@ -448,6 +449,7 @@ class CfgAppSettings extends CfgModule AppControl.LISTENING_MODE_SWITCH ], controlsLandscapeLeft: [ + AppControl.DEVICE_DISPLAY, AppControl.SETUP_OP_CMD, AppControl.DIVIDER1, AppControl.LISTENING_MODE_SWITCH diff --git a/lib/config/CfgTabSettings.dart b/lib/config/CfgTabSettings.dart index 5fef52e7..aaad323b 100644 --- a/lib/config/CfgTabSettings.dart +++ b/lib/config/CfgTabSettings.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2023 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -49,6 +49,7 @@ enum AppControl RI_CD_PLAYER, RI_MD_PLAYER, RI_TAPE_DECK, + DEVICE_DISPLAY } enum AppControlGroup @@ -86,6 +87,7 @@ class CfgTabSettings EnumItem.code(AppControl.RI_CD_PLAYER, "RIC", descrList: Strings.l_app_control_ri_cd_player), EnumItem.code(AppControl.RI_MD_PLAYER, "RIM", descrList: Strings.l_app_control_ri_md_player), EnumItem.code(AppControl.RI_TAPE_DECK, "RIT", descrList: Strings.l_app_control_ri_tape_deck), + EnumItem.code(AppControl.DEVICE_DISPLAY, "DDP", descrList: Strings.l_app_control_device_display), ]); static final String TAB_SETTINGS = "tab_settings"; diff --git a/lib/constants/Strings.dart b/lib/constants/Strings.dart index e928834d..9ec91661 100644 --- a/lib/constants/Strings.dart +++ b/lib/constants/Strings.dart @@ -1173,6 +1173,14 @@ Enjoy!"""]; /*pl*/ "Tape Deck (RI)"]; static String get app_control_ri_tape_deck => l_app_control_ri_tape_deck[_language]; + static const List l_app_control_device_display = [ + /*en*/ "Device display", + /*ru*/ "Дисплей устройства", + /*de*/ "Gerätedisplay", + /*fr*/ "Affichage de l\'appareil", + /*pl*/ "Wyświetlacz urządzenia"]; + static String get app_control_device_display => l_app_control_device_display[_language]; + static const List l_tv_display_mode = [ /*en*/ "Display mode on device", /*ru*/ "Режим отображения на дисплее устройства", diff --git a/lib/iscp/State.dart b/lib/iscp/State.dart index 188939a7..544dfbb7 100644 --- a/lib/iscp/State.dart +++ b/lib/iscp/State.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2024 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -63,6 +63,7 @@ import "messages/PlayStatusMsg.dart"; import "messages/PowerStatusMsg.dart"; import "messages/PresetCommandMsg.dart"; import "messages/RadioStationNameMsg.dart"; +import "messages/DeviceDisplayMsg.dart"; import "messages/ReceiverInformationMsg.dart"; import "messages/ServiceType.dart"; import "messages/SleepSetCommandMsg.dart"; @@ -283,6 +284,11 @@ class State with ProtoTypeMix return _isChange(GoogleCastVersionMsg.CODE, _receiverInformation.processGoogleCastVersion(msg)); } + else if (msg is DeviceDisplayMsg) + { + return _isChange(DeviceDisplayMsg.CODE, + _receiverInformation.processDeviceDisplay(msg)); + } // Device settings if (msg is DimmerLevelMsg) diff --git a/lib/iscp/StateManager.dart b/lib/iscp/StateManager.dart index a67a6e7c..349923db 100644 --- a/lib/iscp/StateManager.dart +++ b/lib/iscp/StateManager.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2024 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -798,6 +798,15 @@ class StateManager } } + void injectIscpMessage(EISCPMessage raw) + { + Logging.info(this, "Injecting ISCP message: " + raw.toString()); + if (_messageChannel.getProtoType == ProtoType.ISCP) + { + _onNewEISCPMessage(raw, _messageChannel); + } + } + void sendQueries(final List queries) => _messageChannel.sendQueries(queries); diff --git a/lib/iscp/messages/DeviceDisplayMsg.dart b/lib/iscp/messages/DeviceDisplayMsg.dart new file mode 100644 index 00000000..37fa2d8d --- /dev/null +++ b/lib/iscp/messages/DeviceDisplayMsg.dart @@ -0,0 +1,47 @@ +/* + * Enhanced Music Controller + * Copyright (C) 2019-2025 by Mikhail Kulesh + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. You should have received a copy of the GNU General + * Public License along with this program. + */ + +import "dart:convert"; + +import "../../utils/Convert.dart"; +import "../EISCPMessage.dart"; +import "../ISCPMessage.dart"; + +/* + * FL Display Information Command + */ +class DeviceDisplayMsg extends ISCPMessage +{ + static const String CODE = "FLD"; + + late String _value; + + DeviceDisplayMsg(EISCPMessage raw) : super(CODE, raw) + { + final List s1 = Convert.convertRaw(getData); + _value = utf8.decode(s1, allowMalformed: true); + } + + String get getValue => _value; + + @override + String toString() + => super.toString() + "[VALUE=\"" + _value + "\"]"; + + @override + bool hasImpactOnMediaList() + { + return false; + } +} \ No newline at end of file diff --git a/lib/iscp/messages/JacketArtMsg.dart b/lib/iscp/messages/JacketArtMsg.dart index bbefd1c2..4d6b1a94 100644 --- a/lib/iscp/messages/JacketArtMsg.dart +++ b/lib/iscp/messages/JacketArtMsg.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2023 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -16,6 +16,7 @@ import "dart:typed_data"; import "package:flutter/widgets.dart"; +import "../../utils/Convert.dart"; import "../../utils/UrlLoader.dart"; import "../DcpHeosMessage.dart"; import "../EISCPMessage.dart"; @@ -95,7 +96,7 @@ class JacketArtMsg extends ISCPMessage break; case ImageType.BMP: case ImageType.JPEG: - rawData = convertRaw(getData.substring(2)); + rawData = Convert.convertRaw(getData.substring(2)); break; case ImageType.NO_IMAGE: // nothing to do; @@ -130,18 +131,6 @@ class JacketArtMsg extends ISCPMessage + "]"; } - List convertRaw(String str) - { - final int size = (str.length / 2).floor(); - final List bytes = List.generate(size, (i) - { - final int j1 = 2 * i; - final int j2 = 2 * i + 1; - return (j1 < str.length && j2 < str.length) ? ISCPMessage.nonNullInteger(str.substring(j1, j2 + 1), 16, 0) : 0; - }); - return bytes; - } - Future loadFromUrl() { if (url == null) diff --git a/lib/iscp/messages/MessageFactory.dart b/lib/iscp/messages/MessageFactory.dart index 9855431b..9bf88754 100644 --- a/lib/iscp/messages/MessageFactory.dart +++ b/lib/iscp/messages/MessageFactory.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2024 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -53,6 +53,7 @@ import "PowerStatusMsg.dart"; import "PresetCommandMsg.dart"; import "PresetMemoryMsg.dart"; import "PrivacyPolicyStatusMsg.dart"; +import "DeviceDisplayMsg.dart"; import "ReceiverInformationMsg.dart"; import "SleepSetCommandMsg.dart"; import "SpeakerACommandMsg.dart"; @@ -215,6 +216,10 @@ class MessageFactory case PrivacyPolicyStatusMsg.CODE: return PrivacyPolicyStatusMsg(raw); + // Receiver display + case DeviceDisplayMsg.CODE: + return DeviceDisplayMsg(raw); + default: throw Exception("No factory method for message " + raw.getCode); } diff --git a/lib/iscp/state/ReceiverInformation.dart b/lib/iscp/state/ReceiverInformation.dart index d25b0a88..9483634c 100644 --- a/lib/iscp/state/ReceiverInformation.dart +++ b/lib/iscp/state/ReceiverInformation.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2024 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -30,6 +30,7 @@ import "../messages/GoogleCastVersionMsg.dart"; import "../messages/InputSelectorMsg.dart"; import "../messages/ListeningModeMsg.dart"; import "../messages/PowerStatusMsg.dart"; +import "../messages/DeviceDisplayMsg.dart"; import "../messages/ReceiverInformationMsg.dart"; import "../messages/SubwooferLevelCommandMsg.dart"; import "../messages/ToneCommandMsg.dart"; @@ -103,6 +104,13 @@ class ReceiverInformation String get googleCastVersion => _googleCastVersion; + // FL Display Information, from ReceiverDisplayMsg + static final String _DEFAULT_DEVICE_DISPLAY = ""; + String _deviceDisplayValue = _DEFAULT_DEVICE_DISPLAY; + + String get deviceDisplayValue + => _deviceDisplayValue; + // Default tone control static final ToneControl DEFAULT_BASS_CONTROL = ToneControl(ToneCommandMsg.BASS_KEY, -10, 10, 2); static final ToneControl DEFAULT_TREBLE_CONTROL = ToneControl(ToneCommandMsg.TREBLE_KEY, -10, 10, 2); @@ -150,6 +158,7 @@ class ReceiverInformation _powerStatus = PowerStatus.NONE; _firmwareStatus = FirmwareUpdateMsg.ValueEnum.defValue; _googleCastVersion = Strings.dashed_string; + _deviceDisplayValue = _DEFAULT_DEVICE_DISPLAY; } void createDefaultReceiverInfo(ProtoType protoType) @@ -264,6 +273,13 @@ class ReceiverInformation return changed; } + bool processDeviceDisplay(DeviceDisplayMsg msg) + { + final bool changed = _deviceDisplayValue != msg.getValue; + _deviceDisplayValue = msg.getValue; + return changed; + } + String _getProperty(final String prop) { final String? m = _deviceProperties[prop]; diff --git a/lib/main.dart b/lib/main.dart index 66a4db73..56337503 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2023 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -22,6 +22,7 @@ import "package:flutter/material.dart"; import "package:flutter/rendering.dart"; import "package:flutter/scheduler.dart" show timeDilation; import "package:flutter/services.dart"; +import "package:google_fonts/google_fonts.dart"; import "package:shared_preferences/shared_preferences.dart"; import "config/CfgAppSettings.dart"; @@ -71,6 +72,9 @@ void main() async HttpOverrides.global = OncpHttpOverrides(); } + // we do not want the GoogleFonts library to make any HTTP requests for fonts + GoogleFonts.config.allowRuntimeFetching = false; + // Will slow down animations by this factor timeDilation = 1.0; @@ -117,6 +121,9 @@ class MusicControllerApp extends StatefulWidget final WindowManagerWrapper _windowManager; final ViewContext _viewContext; + ViewContext get viewContext + => _viewContext; + MusicControllerApp(this._windowManager, this._viewContext, {Key? key}) : super(key: key); @override diff --git a/lib/utils/Convert.dart b/lib/utils/Convert.dart index edf1ba54..8d86f4af 100644 --- a/lib/utils/Convert.dart +++ b/lib/utils/Convert.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2024 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -15,6 +15,7 @@ import "dart:ui"; import "../iscp/ConnectionIf.dart"; +import "../iscp/ISCPMessage.dart"; class Convert { @@ -31,4 +32,16 @@ class Convert static ColorFilter toColorFilter(final Color c) => ColorFilter.mode(c, BlendMode.srcIn); + + static List convertRaw(String str) + { + final int size = (str.length / 2).floor(); + final List bytes = List.generate(size, (i) + { + final int j1 = 2 * i; + final int j2 = 2 * i + 1; + return (j1 < str.length && j2 < str.length) ? ISCPMessage.nonNullInteger(str.substring(j1, j2 + 1), 16, 0) : 0; + }); + return bytes; + } } \ No newline at end of file diff --git a/lib/views/AppTabView.dart b/lib/views/AppTabView.dart index cf53eefc..01b840e7 100644 --- a/lib/views/AppTabView.dart +++ b/lib/views/AppTabView.dart @@ -1,6 +1,6 @@ /* * Enhanced Music Controller - * Copyright (C) 2019-2023 by Mikhail Kulesh + * Copyright (C) 2019-2025 by Mikhail Kulesh * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the License, @@ -18,6 +18,7 @@ import "package:flutter/material.dart"; import "../config/CfgTabSettings.dart"; import "../utils/Logging.dart"; import "../widgets/CustomDivider.dart"; +import "DeviceDisplayView.dart"; import "DeviceInfoView.dart"; import "DeviceSettingsView.dart"; import "InputSelectorView.dart"; @@ -262,6 +263,9 @@ class AppTabView extends UpdatableView case AppControl.RI_TAPE_DECK: return UpdatableWidget(key: key, child: RiTapeDeckControlView(viewContext)); + + case AppControl.DEVICE_DISPLAY: + return UpdatableWidget(key: key, child: DeviceDisplayView(viewContext)); } } } \ No newline at end of file diff --git a/lib/views/DeviceDisplayView.dart b/lib/views/DeviceDisplayView.dart new file mode 100644 index 00000000..da08b2a6 --- /dev/null +++ b/lib/views/DeviceDisplayView.dart @@ -0,0 +1,72 @@ +/* + * Enhanced Music Controller + * Copyright (C) 2019-2025 by Mikhail Kulesh + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. You should have received a copy of the GNU General + * Public License along with this program. + */ + +import "package:flutter/material.dart"; +import "package:google_fonts/google_fonts.dart"; + +import "../constants/Dimens.dart"; +import "../iscp/messages/DeviceDisplayMsg.dart"; +import "../utils/Logging.dart"; +import "UpdatableView.dart"; + +class DeviceDisplayView extends UpdatableView +{ + static const List UPDATE_TRIGGERS = [ + DeviceDisplayMsg.CODE + ]; + + DeviceDisplayView(final ViewContext viewContext) : super(viewContext, UPDATE_TRIGGERS); + + @override + Widget createView(BuildContext context, VoidCallback updateCallback) + { + Logging.logRebuild(this); + + if (state.receiverInformation.deviceDisplayValue.isEmpty) + { + return SizedBox.shrink(); + } + + final ThemeData td = Theme.of(context); + + TextStyle textStyle = td.textTheme.titleMedium!; + try + { + textStyle = GoogleFonts.getFont('DotGothic16', + fontSize: ActivityDimens.titleFontSize, + letterSpacing: 3.0, + color: td.iconTheme.color); + } + catch (ex) + { + Logging.info(this, ex.toString()); + } + + final Widget value = Container( + padding: DialogDimens.rowPadding, + margin: DialogDimens.rowPadding, + decoration: BoxDecoration( + border: Border.all(color: td.disabledColor) + ), + alignment: Alignment.center, + child: Text(state.receiverInformation.deviceDisplayValue, style: textStyle), + ); + + return Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + children: [ Expanded(child: value, flex: 1) ] + ); + } +} \ No newline at end of file diff --git a/lib/widgets/PositionedTapDetector.dart b/lib/widgets/PositionedTapDetector.dart index d84d2596..81ad1a88 100644 --- a/lib/widgets/PositionedTapDetector.dart +++ b/lib/widgets/PositionedTapDetector.dart @@ -218,7 +218,7 @@ class TapPosition Offset? relative; @override - bool operator ==(dynamic other) + bool operator ==(Object other) { if (other is! TapPosition) return false; final TapPosition typedOther = other; diff --git a/res/strings.xml b/res/strings.xml index b12988e6..63677110 100644 --- a/res/strings.xml +++ b/res/strings.xml @@ -1,6 +1,6 @@ Display mode on device diff --git a/res/strings_de.xml b/res/strings_de.xml index 64c79de3..ef0d900a 100644 --- a/res/strings_de.xml +++ b/res/strings_de.xml @@ -1,6 +1,6 @@ Anzeigemodus am Gerät diff --git a/res/strings_fr.xml b/res/strings_fr.xml index c107eeb5..3f3c0c19 100644 --- a/res/strings_fr.xml +++ b/res/strings_fr.xml @@ -1,6 +1,6 @@ Mode affichage sur le dispositif diff --git a/res/strings_pl.xml b/res/strings_pl.xml index 40fca801..87dc7c9e 100644 --- a/res/strings_pl.xml +++ b/res/strings_pl.xml @@ -1,6 +1,6 @@ Tryb wyświetlania na urządzeniu diff --git a/res/strings_ru.xml b/res/strings_ru.xml index 6a8c167c..f36e7eaf 100644 --- a/res/strings_ru.xml +++ b/res/strings_ru.xml @@ -1,6 +1,6 @@ Режим отображения на дисплее устройства